diff --git a/includes/class-wc-shortcodes.php b/includes/class-wc-shortcodes.php index 3871abeab41..54ea4efb54e 100644 --- a/includes/class-wc-shortcodes.php +++ b/includes/class-wc-shortcodes.php @@ -188,7 +188,7 @@ class WC_Shortcodes { 'order' => 'ASC', 'category' => '', 'operator' => 'IN', - ), $atts ); + ), (array) $atts ); $shortcode = new WC_Shortcode_Products( $atts, 'product_category' ); @@ -274,29 +274,18 @@ class WC_Shortcodes { * @return string */ public static function recent_products( $atts ) { - $atts = shortcode_atts( array( + $atts = array_merge( array( 'per_page' => '12', 'columns' => '4', 'orderby' => 'date', - 'order' => 'desc', - 'category' => '', // Slugs - 'operator' => 'IN', // Possible values are 'IN', 'NOT IN', 'AND'. - ), $atts, 'recent_products' ); + 'order' => 'DESC', + 'category' => '', + 'operator' => 'IN', + ), (array) $atts ); - $query_args = array( - 'post_type' => 'product', - 'post_status' => 'publish', - 'ignore_sticky_posts' => 1, - 'posts_per_page' => $atts['per_page'], - 'orderby' => $atts['orderby'], - 'order' => $atts['order'], - 'meta_query' => WC()->query->get_meta_query(), - 'tax_query' => WC()->query->get_tax_query(), - ); + $shortcode = new WC_Shortcode_Products( $atts, 'recent_products' ); - $query_args = self::_maybe_add_category_args( $query_args, $atts['category'], $atts['operator'] ); - - return self::product_loop( $query_args, $atts, 'recent_products' ); + return $shortcode->get_content(); } /** @@ -306,7 +295,7 @@ class WC_Shortcodes { * @return string */ public static function products( $atts ) { - $shortcode = new WC_Shortcode_Products( $atts ); + $shortcode = new WC_Shortcode_Products( (array) $atts ); return $shortcode->get_content(); }