Add `woocommerce_top_rated_widget_args` filter for WC_Widget_Top_Rated_Products widget

This commit is contained in:
Sergey Ratushnuy 2019-12-26 11:51:34 +02:00
parent 93e0a91faa
commit e3ac006420
1 changed files with 12 additions and 10 deletions

View File

@ -58,16 +58,18 @@ class WC_Widget_Top_Rated_Products extends WC_Widget {
$number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std'];
$query_args = array(
'posts_per_page' => $number,
'no_found_rows' => 1,
'post_status' => 'publish',
'post_type' => 'product',
'meta_key' => '_wc_average_rating',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'meta_query' => WC()->query->get_meta_query(),
'tax_query' => WC()->query->get_tax_query(),
$query_args = apply_filters( 'woocommerce_top_rated_widget_args',
array(
'posts_per_page' => $number,
'no_found_rows' => 1,
'post_status' => 'publish',
'post_type' => 'product',
'meta_key' => '_wc_average_rating',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'meta_query' => WC()->query->get_meta_query(),
'tax_query' => WC()->query->get_tax_query(),
)
); // WPCS: slow query ok.
$r = new WP_Query( $query_args );