WC_Shortcode_Products::parse_legacy_attributes()protectedWC 3.2.0

Parse legacy attributes.

Method of the class: WC_Shortcode_Products{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->parse_legacy_attributes( $attributes );
$attributes(array) (required)
Attributes.

Changelog

Since 3.2.0 Introduced.

WC_Shortcode_Products::parse_legacy_attributes() code WC 8.7.0

protected function parse_legacy_attributes( $attributes ) {
	$mapping = array(
		'per_page' => 'limit',
		'operator' => 'cat_operator',
		'filter'   => 'terms',
	);

	foreach ( $mapping as $old => $new ) {
		if ( isset( $attributes[ $old ] ) ) {
			$attributes[ $new ] = $attributes[ $old ];
			unset( $attributes[ $old ] );
		}
	}

	return $attributes;
}