WC_Shortcode_Products::parse_attributes()protectedWC 3.2.0

Parse 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_attributes( $attributes );
$attributes(array) (required)
Shortcode attributes.

Changelog

Since 3.2.0 Introduced.

WC_Shortcode_Products::parse_attributes() code WC 8.7.0

protected function parse_attributes( $attributes ) {
	$attributes = $this->parse_legacy_attributes( $attributes );

	$attributes = shortcode_atts(
		array(
			'limit'          => '-1',      // Results limit.
			'columns'        => '',        // Number of columns.
			'rows'           => '',        // Number of rows. If defined, limit will be ignored.
			'orderby'        => '',        // menu_order, title, date, rand, price, popularity, rating, or id.
			'order'          => '',        // ASC or DESC.
			'ids'            => '',        // Comma separated IDs.
			'skus'           => '',        // Comma separated SKUs.
			'category'       => '',        // Comma separated category slugs or ids.
			'cat_operator'   => 'IN',      // Operator to compare categories. Possible values are 'IN', 'NOT IN', 'AND'.
			'attribute'      => '',        // Single attribute slug.
			'terms'          => '',        // Comma separated term slugs or ids.
			'terms_operator' => 'IN',      // Operator to compare terms. Possible values are 'IN', 'NOT IN', 'AND'.
			'tag'            => '',        // Comma separated tag slugs.
			'tag_operator'   => 'IN',      // Operator to compare tags. Possible values are 'IN', 'NOT IN', 'AND'.
			'visibility'     => 'visible', // Product visibility setting. Possible values are 'visible', 'catalog', 'search', 'hidden'.
			'class'          => '',        // HTML class.
			'page'           => 1,         // Page for pagination.
			'paginate'       => false,     // Should results be paginated.
			'cache'          => true,      // Should shortcode output be cached.
		),
		$attributes,
		$this->type
	);

	if ( ! absint( $attributes['columns'] ) ) {
		$attributes['columns'] = wc_get_default_products_per_row();
	}

	return $attributes;
}