Merge pull request #19344 from woocommerce/update/widgets-phpcs
Fixed includes/widgets PHPCS violations
This commit is contained in:
commit
0f7568b68f
|
@ -1,19 +1,17 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shopping Cart Widget.
|
||||
*
|
||||
* Displays shopping cart widget.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 2.3.0
|
||||
* @extends WC_Widget
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Widget cart class.
|
||||
*/
|
||||
class WC_Widget_Cart extends WC_Widget {
|
||||
|
||||
|
@ -22,7 +20,7 @@ class WC_Widget_Cart extends WC_Widget {
|
|||
*/
|
||||
public function __construct() {
|
||||
$this->widget_cssclass = 'woocommerce widget_shopping_cart';
|
||||
$this->widget_description = __( "Display the customer shopping cart.", 'woocommerce' );
|
||||
$this->widget_description = __( 'Display the customer shopping cart.', 'woocommerce' );
|
||||
$this->widget_id = 'woocommerce_widget_cart';
|
||||
$this->widget_name = __( 'Cart', 'woocommerce' );
|
||||
$this->settings = array(
|
||||
|
@ -46,8 +44,8 @@ class WC_Widget_Cart extends WC_Widget {
|
|||
*
|
||||
* @see WP_Widget
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
* @param array $args Arguments.
|
||||
* @param array $instance Widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
if ( apply_filters( 'woocommerce_widget_cart_is_hidden', is_cart() || is_checkout() ) ) {
|
||||
|
@ -62,7 +60,7 @@ class WC_Widget_Cart extends WC_Widget {
|
|||
echo '<div class="hide_cart_widget_if_empty">';
|
||||
}
|
||||
|
||||
// Insert cart widget placeholder - code in woocommerce.js will update this on page load
|
||||
// Insert cart widget placeholder - code in woocommerce.js will update this on page load.
|
||||
echo '<div class="widget_shopping_cart_content"></div>';
|
||||
|
||||
if ( $hide_if_empty ) {
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Layered Navigation Filters Widget.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 2.3.0
|
||||
* @extends WC_Widget
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Widget layered nav filters.
|
||||
*/
|
||||
class WC_Widget_Layered_Nav_Filters extends WC_Widget {
|
||||
|
||||
|
@ -38,8 +36,8 @@ class WC_Widget_Layered_Nav_Filters extends WC_Widget {
|
|||
* Output widget.
|
||||
*
|
||||
* @see WP_Widget
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
* @param array $args Arguments.
|
||||
* @param array $instance Widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
if ( ! is_shop() && ! is_product_taxonomy() ) {
|
||||
|
@ -47,9 +45,9 @@ class WC_Widget_Layered_Nav_Filters extends WC_Widget {
|
|||
}
|
||||
|
||||
$_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes();
|
||||
$min_price = isset( $_GET['min_price'] ) ? wc_clean( $_GET['min_price'] ) : 0;
|
||||
$max_price = isset( $_GET['max_price'] ) ? wc_clean( $_GET['max_price'] ) : 0;
|
||||
$rating_filter = isset( $_GET['rating_filter'] ) ? array_filter( array_map( 'absint', explode( ',', $_GET['rating_filter'] ) ) ) : array();
|
||||
$min_price = isset( $_GET['min_price'] ) ? wc_clean( wp_unslash( $_GET['min_price'] ) ) : 0; // WPCS: input var ok, CSRF ok.
|
||||
$max_price = isset( $_GET['max_price'] ) ? wc_clean( wp_unslash( $_GET['max_price'] ) ) : 0; // WPCS: input var ok, CSRF ok.
|
||||
$rating_filter = isset( $_GET['rating_filter'] ) ? array_filter( array_map( 'absint', explode( ',', wp_unslash( $_GET['rating_filter'] ) ) ) ) : array(); // WPCS: sanitization ok, input var ok, CSRF ok.
|
||||
$base_link = $this->get_current_page_url();
|
||||
|
||||
if ( 0 < count( $_chosen_attributes ) || 0 < $min_price || 0 < $max_price || ! empty( $rating_filter ) ) {
|
||||
|
@ -58,22 +56,23 @@ class WC_Widget_Layered_Nav_Filters extends WC_Widget {
|
|||
|
||||
echo '<ul>';
|
||||
|
||||
// Attributes
|
||||
// Attributes.
|
||||
if ( ! empty( $_chosen_attributes ) ) {
|
||||
foreach ( $_chosen_attributes as $taxonomy => $data ) {
|
||||
foreach ( $data['terms'] as $term_slug ) {
|
||||
if ( ! $term = get_term_by( 'slug', $term_slug, $taxonomy ) ) {
|
||||
$term = get_term_by( 'slug', $term_slug, $taxonomy );
|
||||
if ( ! $term ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filter_name = 'filter_' . sanitize_title( str_replace( 'pa_', '', $taxonomy ) );
|
||||
$current_filter = isset( $_GET[ $filter_name ] ) ? explode( ',', wc_clean( $_GET[ $filter_name ] ) ) : array();
|
||||
$current_filter = isset( $_GET[ $filter_name ] ) ? explode( ',', wc_clean( wp_unslash( $_GET[ $filter_name ] ) ) ) : array(); // WPCS: input var ok, CSRF ok.
|
||||
$current_filter = array_map( 'sanitize_title', $current_filter );
|
||||
$new_filter = array_diff( $current_filter, array( $term_slug ) );
|
||||
|
||||
$link = remove_query_arg( array( 'add-to-cart', $filter_name ), $base_link );
|
||||
|
||||
if ( sizeof( $new_filter ) > 0 ) {
|
||||
if ( count( $new_filter ) > 0 ) {
|
||||
$link = add_query_arg( $filter_name, implode( ',', $new_filter ), $link );
|
||||
}
|
||||
|
||||
|
@ -84,18 +83,22 @@ class WC_Widget_Layered_Nav_Filters extends WC_Widget {
|
|||
|
||||
if ( $min_price ) {
|
||||
$link = remove_query_arg( 'min_price', $base_link );
|
||||
echo '<li class="chosen"><a rel="nofollow" aria-label="' . esc_attr__( 'Remove filter', 'woocommerce' ) . '" href="' . esc_url( $link ) . '">' . sprintf( __( 'Min %s', 'woocommerce' ), wc_price( $min_price ) ) . '</a></li>';
|
||||
/* translators: %s: minimum price */
|
||||
echo '<li class="chosen"><a rel="nofollow" aria-label="' . esc_attr__( 'Remove filter', 'woocommerce' ) . '" href="' . esc_url( $link ) . '">' . sprintf( __( 'Min %s', 'woocommerce' ), wc_price( $min_price ) ) . '</a></li>'; // WPCS: XSS ok.
|
||||
}
|
||||
|
||||
if ( $max_price ) {
|
||||
$link = remove_query_arg( 'max_price', $base_link );
|
||||
echo '<li class="chosen"><a rel="nofollow" aria-label="' . esc_attr__( 'Remove filter', 'woocommerce' ) . '" href="' . esc_url( $link ) . '">' . sprintf( __( 'Max %s', 'woocommerce' ), wc_price( $max_price ) ) . '</a></li>';
|
||||
/* translators: %s: maximum price */
|
||||
echo '<li class="chosen"><a rel="nofollow" aria-label="' . esc_attr__( 'Remove filter', 'woocommerce' ) . '" href="' . esc_url( $link ) . '">' . sprintf( __( 'Max %s', 'woocommerce' ), wc_price( $max_price ) ) . '</a></li>'; // WPCS: XSS ok.
|
||||
}
|
||||
|
||||
if ( ! empty( $rating_filter ) ) {
|
||||
foreach ( $rating_filter as $rating ) {
|
||||
$link_ratings = implode( ',', array_diff( $rating_filter, array( $rating ) ) );
|
||||
$link = $link_ratings ? add_query_arg( 'rating_filter', $link_ratings ) : remove_query_arg( 'rating_filter', $base_link );
|
||||
|
||||
/* translators: %s: rating */
|
||||
echo '<li class="chosen"><a rel="nofollow" aria-label="' . esc_attr__( 'Remove filter', 'woocommerce' ) . '" href="' . esc_url( $link ) . '">' . sprintf( esc_html__( 'Rated %s out of 5', 'woocommerce' ), esc_html( $rating ) ) . '</a></li>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,20 +3,13 @@
|
|||
* Layered nav widget
|
||||
*
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 2.6.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Layered Navigation Widget.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 2.6.0
|
||||
* @extends WC_Widget
|
||||
* Widget layered nav class.
|
||||
*/
|
||||
class WC_Widget_Layered_Nav extends WC_Widget {
|
||||
|
||||
|
@ -133,16 +126,16 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
$orderby = wc_attribute_orderby( $taxonomy );
|
||||
|
||||
switch ( $orderby ) {
|
||||
case 'name' :
|
||||
case 'name':
|
||||
$get_terms_args['orderby'] = 'name';
|
||||
$get_terms_args['menu_order'] = false;
|
||||
break;
|
||||
case 'id' :
|
||||
case 'id':
|
||||
$get_terms_args['orderby'] = 'id';
|
||||
$get_terms_args['order'] = 'ASC';
|
||||
$get_terms_args['menu_order'] = false;
|
||||
break;
|
||||
case 'menu_order' :
|
||||
case 'menu_order':
|
||||
$get_terms_args['menu_order'] = 'ASC';
|
||||
break;
|
||||
}
|
||||
|
@ -154,10 +147,10 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
}
|
||||
|
||||
switch ( $orderby ) {
|
||||
case 'name_num' :
|
||||
case 'name_num':
|
||||
usort( $terms, '_wc_get_product_terms_name_num_usort_callback' );
|
||||
break;
|
||||
case 'parent' :
|
||||
case 'parent':
|
||||
usort( $terms, '_wc_get_product_terms_parent_usort_callback' );
|
||||
break;
|
||||
}
|
||||
|
@ -232,6 +225,8 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
$_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes();
|
||||
$taxonomy_filter_name = str_replace( 'pa_', '', $taxonomy );
|
||||
$taxonomy_label = wc_attribute_label( $taxonomy );
|
||||
|
||||
/* translators: %s: taxonomy name */
|
||||
$any_label = apply_filters( 'woocommerce_layered_nav_any_label', sprintf( __( 'Any %s', 'woocommerce' ), $taxonomy_label ), $taxonomy_label, $taxonomy );
|
||||
$multiple = 'or' === $query_type;
|
||||
$current_values = isset( $_chosen_attributes[ $taxonomy ]['terms'] ) ? $_chosen_attributes[ $taxonomy ]['terms'] : array();
|
||||
|
@ -254,7 +249,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
}
|
||||
|
||||
// Get count based on current view.
|
||||
$option_is_set = in_array( $term->slug, $current_values );
|
||||
$option_is_set = in_array( $term->slug, $current_values, true );
|
||||
$count = isset( $term_counts[ $term->term_id ] ) ? $term_counts[ $term->term_id ] : 0;
|
||||
|
||||
// Only show options with count > 0.
|
||||
|
@ -281,7 +276,8 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
echo wc_query_string_form_fields( null, array( 'filter_' . $taxonomy_filter_name, 'query_type_' . $taxonomy_filter_name ), '', true ); // @codingStandardsIgnoreLine
|
||||
echo '</form>';
|
||||
|
||||
wc_enqueue_js( "
|
||||
wc_enqueue_js(
|
||||
"
|
||||
// Update value on change.
|
||||
jQuery( '.dropdown_layered_nav_" . esc_js( $taxonomy_filter_name ) . "' ).change( function() {
|
||||
var slug = jQuery( this ).val();
|
||||
|
@ -310,7 +306,8 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
};
|
||||
wc_layered_nav_select();
|
||||
}
|
||||
" );
|
||||
"
|
||||
);
|
||||
}
|
||||
|
||||
return $found;
|
||||
|
@ -361,7 +358,8 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
. $tax_query_sql['where'] . $meta_query_sql['where'] .
|
||||
'AND terms.term_id IN (' . implode( ',', array_map( 'absint', $term_ids ) ) . ')';
|
||||
|
||||
if ( $search = WC_Query::get_main_search_query_sql() ) {
|
||||
$search = WC_Query::get_main_search_query_sql();
|
||||
if ( $search ) {
|
||||
$query['where'] .= ' AND ' . $search;
|
||||
}
|
||||
|
||||
|
@ -401,7 +399,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
|
||||
foreach ( $terms as $term ) {
|
||||
$current_values = isset( $_chosen_attributes[ $taxonomy ]['terms'] ) ? $_chosen_attributes[ $taxonomy ]['terms'] : array();
|
||||
$option_is_set = in_array( $term->slug, $current_values );
|
||||
$option_is_set = in_array( $term->slug, $current_values, true );
|
||||
$count = isset( $term_counts[ $term->term_id ] ) ? $term_counts[ $term->term_id ] : 0;
|
||||
|
||||
// Skip the term for the current archive.
|
||||
|
@ -417,10 +415,10 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
}
|
||||
|
||||
$filter_name = 'filter_' . sanitize_title( str_replace( 'pa_', '', $taxonomy ) );
|
||||
$current_filter = isset( $_GET[ $filter_name ] ) ? explode( ',', wc_clean( wp_unslash( $_GET[ $filter_name ] ) ) ) : array();
|
||||
$current_filter = isset( $_GET[ $filter_name ] ) ? explode( ',', wc_clean( wp_unslash( $_GET[ $filter_name ] ) ) ) : array(); // WPCS: input var ok, CSRF ok.
|
||||
$current_filter = array_map( 'sanitize_title', $current_filter );
|
||||
|
||||
if ( ! in_array( $term->slug, $current_filter ) ) {
|
||||
if ( ! in_array( $term->slug, $current_filter, true ) ) {
|
||||
$current_filter[] = $term->slug;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Price Filter Widget and related functions.
|
||||
*
|
||||
* Generates a range slider to filter products by price.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 2.3.0
|
||||
* @extends WC_Widget
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Widget price filter class.
|
||||
*/
|
||||
class WC_Widget_Price_Filter extends WC_Widget {
|
||||
|
||||
|
@ -36,13 +34,15 @@ class WC_Widget_Price_Filter extends WC_Widget {
|
|||
wp_register_script( 'accounting', WC()->plugin_url() . '/assets/js/accounting/accounting' . $suffix . '.js', array( 'jquery' ), '0.4.2' );
|
||||
wp_register_script( 'wc-jquery-ui-touchpunch', WC()->plugin_url() . '/assets/js/jquery-ui-touch-punch/jquery-ui-touch-punch' . $suffix . '.js', array( 'jquery-ui-slider' ), WC_VERSION, true );
|
||||
wp_register_script( 'wc-price-slider', WC()->plugin_url() . '/assets/js/frontend/price-slider' . $suffix . '.js', array( 'jquery-ui-slider', 'wc-jquery-ui-touchpunch', 'accounting' ), WC_VERSION, true );
|
||||
wp_localize_script( 'wc-price-slider', 'woocommerce_price_slider_params', array(
|
||||
wp_localize_script(
|
||||
'wc-price-slider', 'woocommerce_price_slider_params', array(
|
||||
'currency_format_num_decimals' => 0,
|
||||
'currency_format_symbol' => get_woocommerce_currency_symbol(),
|
||||
'currency_format_decimal_sep' => esc_attr( wc_get_price_decimal_separator() ),
|
||||
'currency_format_thousand_sep' => esc_attr( wc_get_price_thousand_separator() ),
|
||||
'currency_format' => esc_attr( str_replace( array( '%1$s', '%2$s' ), array( '%s', '%v' ), get_woocommerce_price_format() ) ),
|
||||
) );
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_customize_preview() ) {
|
||||
wp_enqueue_script( 'wc-price-slider' );
|
||||
|
@ -56,8 +56,8 @@ class WC_Widget_Price_Filter extends WC_Widget {
|
|||
*
|
||||
* @see WP_Widget
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
* @param array $args Arguments.
|
||||
* @param array $instance Widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
global $wp;
|
||||
|
@ -89,8 +89,8 @@ class WC_Widget_Price_Filter extends WC_Widget {
|
|||
$form_action = preg_replace( '%\/page/[0-9]+%', '', home_url( trailingslashit( $wp->request ) ) );
|
||||
}
|
||||
|
||||
$min_price = isset( $_GET['min_price'] ) ? esc_attr( $_GET['min_price'] ) : apply_filters( 'woocommerce_price_filter_widget_min_amount', $min );
|
||||
$max_price = isset( $_GET['max_price'] ) ? esc_attr( $_GET['max_price'] ) : apply_filters( 'woocommerce_price_filter_widget_max_amount', $max );
|
||||
$min_price = isset( $_GET['min_price'] ) ? wc_clean( wp_unslash( $_GET['min_price'] ) ) : apply_filters( 'woocommerce_price_filter_widget_min_amount', $min ); // WPCS: input var ok, CSRF ok.
|
||||
$max_price = isset( $_GET['max_price'] ) ? wc_clean( wp_unslash( $_GET['max_price'] ) ) : apply_filters( 'woocommerce_price_filter_widget_max_amount', $max ); // WPCS: input var ok, CSRF ok.
|
||||
|
||||
echo '<form method="get" action="' . esc_url( $form_action ) . '">
|
||||
<div class="price_slider_wrapper">
|
||||
|
@ -106,13 +106,14 @@ class WC_Widget_Price_Filter extends WC_Widget {
|
|||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>';
|
||||
</form>'; // WPCS: XSS ok.
|
||||
|
||||
$this->widget_end( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filtered min price for current products.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get_filtered_price() {
|
||||
|
@ -150,10 +151,11 @@ class WC_Widget_Price_Filter extends WC_Widget {
|
|||
AND price_meta.meta_value > '' ";
|
||||
$sql .= $tax_query_sql['where'] . $meta_query_sql['where'];
|
||||
|
||||
if ( $search = WC_Query::get_main_search_query_sql() ) {
|
||||
$search = WC_Query::get_main_search_query_sql();
|
||||
if ( $search ) {
|
||||
$sql .= ' AND ' . $search;
|
||||
}
|
||||
|
||||
return $wpdb->get_row( $sql );
|
||||
return $wpdb->get_row( $sql ); // WPCS: unprepared SQL ok.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,11 @@
|
|||
/**
|
||||
* Product Categories Widget
|
||||
*
|
||||
* @author Automattic
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 2.3.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Product categories widget class.
|
||||
|
@ -136,10 +132,14 @@ class WC_Widget_Product_Categories extends WC_Widget {
|
|||
$this->cat_ancestors = get_ancestors( $this->current_cat->term_id, 'product_cat' );
|
||||
|
||||
} elseif ( is_singular( 'product' ) ) {
|
||||
$terms = wc_get_product_terms( $post->ID, 'product_cat', apply_filters( 'woocommerce_product_categories_widget_product_terms_args', array(
|
||||
$terms = wc_get_product_terms(
|
||||
$post->ID, 'product_cat', apply_filters(
|
||||
'woocommerce_product_categories_widget_product_terms_args', array(
|
||||
'orderby' => 'parent',
|
||||
'order' => 'DESC',
|
||||
) ) );
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ( $terms ) {
|
||||
$main_term = apply_filters( 'woocommerce_product_categories_widget_main_term', $terms[0], $terms );
|
||||
|
@ -176,7 +176,8 @@ class WC_Widget_Product_Categories extends WC_Widget {
|
|||
// Gather siblings of ancestors.
|
||||
if ( $this->cat_ancestors ) {
|
||||
foreach ( $this->cat_ancestors as $ancestor ) {
|
||||
$include = array_merge( $include, get_terms(
|
||||
$include = array_merge(
|
||||
$include, get_terms(
|
||||
'product_cat',
|
||||
array(
|
||||
'fields' => 'ids',
|
||||
|
@ -184,7 +185,8 @@ class WC_Widget_Product_Categories extends WC_Widget {
|
|||
'hierarchical' => false,
|
||||
'hide_empty' => false,
|
||||
)
|
||||
) );
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -198,7 +200,7 @@ class WC_Widget_Product_Categories extends WC_Widget {
|
|||
'hide_empty' => false,
|
||||
)
|
||||
);
|
||||
} // End if().
|
||||
}
|
||||
|
||||
$list_args['include'] = implode( ',', $include );
|
||||
$dropdown_args['include'] = $list_args['include'];
|
||||
|
@ -213,19 +215,26 @@ class WC_Widget_Product_Categories extends WC_Widget {
|
|||
$list_args['depth'] = 1;
|
||||
$list_args['child_of'] = 0;
|
||||
$list_args['hierarchical'] = 1;
|
||||
} // End if().
|
||||
}
|
||||
|
||||
$this->widget_start( $args, $instance );
|
||||
|
||||
if ( $dropdown ) {
|
||||
wc_product_dropdown_categories( apply_filters( 'woocommerce_product_categories_widget_dropdown_args', wp_parse_args( $dropdown_args, array(
|
||||
wc_product_dropdown_categories(
|
||||
apply_filters(
|
||||
'woocommerce_product_categories_widget_dropdown_args', wp_parse_args(
|
||||
$dropdown_args, array(
|
||||
'show_count' => $count,
|
||||
'hierarchical' => $hierarchical,
|
||||
'show_uncategorized' => 0,
|
||||
'orderby' => $orderby,
|
||||
'selected' => $this->current_cat ? $this->current_cat->slug : '',
|
||||
) ) ) );
|
||||
wc_enqueue_js( "
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
wc_enqueue_js(
|
||||
"
|
||||
jQuery( '.dropdown_product_cat' ).change( function() {
|
||||
if ( jQuery(this).val() != '' ) {
|
||||
var this_page = '';
|
||||
|
@ -238,11 +247,12 @@ class WC_Widget_Product_Categories extends WC_Widget {
|
|||
location.href = this_page;
|
||||
}
|
||||
});
|
||||
" );
|
||||
"
|
||||
);
|
||||
} else {
|
||||
include_once( WC()->plugin_path() . '/includes/walkers/class-product-cat-list-walker.php' );
|
||||
include_once WC()->plugin_path() . '/includes/walkers/class-product-cat-list-walker.php';
|
||||
|
||||
$list_args['walker'] = new WC_Product_Cat_List_Walker;
|
||||
$list_args['walker'] = new WC_Product_Cat_List_Walker();
|
||||
$list_args['title_li'] = '';
|
||||
$list_args['pad_counts'] = 1;
|
||||
$list_args['show_option_none'] = __( 'No product categories exist.', 'woocommerce' );
|
||||
|
@ -255,7 +265,7 @@ class WC_Widget_Product_Categories extends WC_Widget {
|
|||
wp_list_categories( apply_filters( 'woocommerce_product_categories_widget_args', $list_args ) );
|
||||
|
||||
echo '</ul>';
|
||||
} // End if().
|
||||
}
|
||||
|
||||
$this->widget_end( $args );
|
||||
}
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Product Search Widget.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 2.3.0
|
||||
* @extends WC_Widget
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Widget product search class.
|
||||
*/
|
||||
class WC_Widget_Product_Search extends WC_Widget {
|
||||
|
||||
|
@ -39,8 +37,8 @@ class WC_Widget_Product_Search extends WC_Widget {
|
|||
*
|
||||
* @see WP_Widget
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
* @param array $args Arguments.
|
||||
* @param array $instance Widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
$this->widget_start( $args, $instance );
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* Tag Cloud Widget.
|
||||
*
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 3.4.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tag Cloud Widget.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 2.3.0
|
||||
* @extends WC_Widget
|
||||
* Widget product tag cloud
|
||||
*/
|
||||
class WC_Widget_Product_Tag_Cloud extends WC_Widget {
|
||||
|
||||
|
@ -39,11 +39,11 @@ class WC_Widget_Product_Tag_Cloud extends WC_Widget {
|
|||
*
|
||||
* @see WP_Widget
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
* @param array $args Arguments.
|
||||
* @param array $instance Widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
$current_taxonomy = $this->_get_current_taxonomy( $instance );
|
||||
$current_taxonomy = $this->get_current_taxonomy( $instance );
|
||||
|
||||
if ( empty( $instance['title'] ) ) {
|
||||
$taxonomy = get_taxonomy( $current_taxonomy );
|
||||
|
@ -54,10 +54,14 @@ class WC_Widget_Product_Tag_Cloud extends WC_Widget {
|
|||
|
||||
echo '<div class="tagcloud">';
|
||||
|
||||
wp_tag_cloud( apply_filters( 'woocommerce_product_tag_cloud_widget_args', array(
|
||||
wp_tag_cloud(
|
||||
apply_filters(
|
||||
'woocommerce_product_tag_cloud_widget_args', array(
|
||||
'taxonomy' => $current_taxonomy,
|
||||
'topic_count_text_callback' => array( $this, '_topic_count_text' ),
|
||||
) ) );
|
||||
'topic_count_text_callback' => array( $this, 'topic_count_text' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
echo '</div>';
|
||||
|
||||
|
@ -67,22 +71,50 @@ class WC_Widget_Product_Tag_Cloud extends WC_Widget {
|
|||
/**
|
||||
* Return the taxonomy being displayed.
|
||||
*
|
||||
* @param object $instance
|
||||
* @param object $instance Widget instance.
|
||||
* @return string
|
||||
*/
|
||||
public function _get_current_taxonomy( $instance ) {
|
||||
public function get_current_taxonomy( $instance ) {
|
||||
return 'product_tag';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns topic count text.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @param int $count
|
||||
* @since 3.4.0
|
||||
* @param int $count Count text.
|
||||
* @return string
|
||||
*/
|
||||
public function _topic_count_text( $count ) {
|
||||
public function topic_count_text( $count ) {
|
||||
/* translators: %s: product count */
|
||||
return sprintf( _n( '%s product', '%s products', $count, 'woocommerce' ), number_format_i18n( $count ) );
|
||||
}
|
||||
|
||||
// Ignore whole block to avoid warnings about PSR2.Methods.MethodDeclaration.Underscore violation.
|
||||
// @codingStandardsIgnoreStart
|
||||
/**
|
||||
* Return the taxonomy being displayed.
|
||||
*
|
||||
* @deprecated 3.4.0
|
||||
* @param object $instance Widget instance.
|
||||
* @return string
|
||||
*/
|
||||
public function _get_current_taxonomy( $instance ) {
|
||||
wc_deprecated_function( '_get_current_taxonomy', '3.4.0', 'WC_Widget_Product_Tag_Cloud->get_current_taxonomy' );
|
||||
return $this->get_current_taxonomy( $instance );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns topic count text.
|
||||
*
|
||||
* @deprecated 3.4.0
|
||||
* @since 2.6.0
|
||||
* @param int $count Count text.
|
||||
* @return string
|
||||
*/
|
||||
public function _topic_count_text( $count ) {
|
||||
wc_deprecated_function( '_topic_count_text', '3.4.0', 'WC_Widget_Product_Tag_Cloud->topic_count_text' );
|
||||
return $this->topic_count_text( $count );
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* List products. One widget to rule them all.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 3.3.0
|
||||
* @extends WC_Widget
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Widget products.
|
||||
*/
|
||||
class WC_Widget_Products extends WC_Widget {
|
||||
|
||||
|
@ -84,8 +82,9 @@ class WC_Widget_Products extends WC_Widget {
|
|||
|
||||
/**
|
||||
* Query the products and return them.
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
*
|
||||
* @param array $args Arguments.
|
||||
* @param array $instance Widget instance.
|
||||
* @return WP_Query
|
||||
*/
|
||||
public function get_products( $args, $instance ) {
|
||||
|
@ -105,7 +104,7 @@ class WC_Widget_Products extends WC_Widget {
|
|||
'tax_query' => array(
|
||||
'relation' => 'AND',
|
||||
),
|
||||
);
|
||||
); // WPCS: slow query ok.
|
||||
|
||||
if ( empty( $instance['show_hidden'] ) ) {
|
||||
$query_args['tax_query'][] = array(
|
||||
|
@ -134,18 +133,18 @@ class WC_Widget_Products extends WC_Widget {
|
|||
'terms' => $product_visibility_term_ids['outofstock'],
|
||||
'operator' => 'NOT IN',
|
||||
),
|
||||
);
|
||||
); // WPCS: slow query ok.
|
||||
}
|
||||
|
||||
switch ( $show ) {
|
||||
case 'featured' :
|
||||
case 'featured':
|
||||
$query_args['tax_query'][] = array(
|
||||
'taxonomy' => 'product_visibility',
|
||||
'field' => 'term_taxonomy_id',
|
||||
'terms' => $product_visibility_term_ids['featured'],
|
||||
);
|
||||
break;
|
||||
case 'onsale' :
|
||||
case 'onsale':
|
||||
$product_ids_on_sale = wc_get_product_ids_on_sale();
|
||||
$product_ids_on_sale[] = 0;
|
||||
$query_args['post__in'] = $product_ids_on_sale;
|
||||
|
@ -153,18 +152,18 @@ class WC_Widget_Products extends WC_Widget {
|
|||
}
|
||||
|
||||
switch ( $orderby ) {
|
||||
case 'price' :
|
||||
$query_args['meta_key'] = '_price';
|
||||
case 'price':
|
||||
$query_args['meta_key'] = '_price'; // WPCS: slow query ok.
|
||||
$query_args['orderby'] = 'meta_value_num';
|
||||
break;
|
||||
case 'rand' :
|
||||
case 'rand':
|
||||
$query_args['orderby'] = 'rand';
|
||||
break;
|
||||
case 'sales' :
|
||||
$query_args['meta_key'] = 'total_sales';
|
||||
case 'sales':
|
||||
$query_args['meta_key'] = 'total_sales'; // WPCS: slow query ok.
|
||||
$query_args['orderby'] = 'meta_value_num';
|
||||
break;
|
||||
default :
|
||||
default:
|
||||
$query_args['orderby'] = 'date';
|
||||
}
|
||||
|
||||
|
@ -176,8 +175,8 @@ class WC_Widget_Products extends WC_Widget {
|
|||
*
|
||||
* @see WP_Widget
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
* @param array $args Arguments.
|
||||
* @param array $instance Widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
if ( $this->get_cached_widget( $args ) ) {
|
||||
|
@ -186,7 +185,8 @@ class WC_Widget_Products extends WC_Widget {
|
|||
|
||||
ob_start();
|
||||
|
||||
if ( ( $products = $this->get_products( $args, $instance ) ) && $products->have_posts() ) {
|
||||
$products = $this->get_products( $args, $instance );
|
||||
if ( $products && $products->have_posts() ) {
|
||||
$this->widget_start( $args, $instance );
|
||||
|
||||
echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' ) );
|
||||
|
@ -208,6 +208,6 @@ class WC_Widget_Products extends WC_Widget {
|
|||
|
||||
wp_reset_postdata();
|
||||
|
||||
echo $this->cache_widget( $args, ob_get_clean() );
|
||||
echo $this->cache_widget( $args, ob_get_clean() ); // WPCS: XSS ok.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rating Filter Widget and related functions.
|
||||
*
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 2.6.0
|
||||
* @extends WC_Widget
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Widget rating filter class.
|
||||
*/
|
||||
class WC_Widget_Rating_Filter extends WC_Widget {
|
||||
|
||||
|
@ -36,7 +33,8 @@ class WC_Widget_Rating_Filter extends WC_Widget {
|
|||
|
||||
/**
|
||||
* Count products after other filters have occurred by adjusting the main query.
|
||||
* @param int $rating
|
||||
*
|
||||
* @param int $rating Rating.
|
||||
* @return int
|
||||
*/
|
||||
protected function get_filtered_product_count( $rating ) {
|
||||
|
@ -73,20 +71,20 @@ class WC_Widget_Rating_Filter extends WC_Widget {
|
|||
$sql .= " WHERE {$wpdb->posts}.post_type = 'product' AND {$wpdb->posts}.post_status = 'publish' ";
|
||||
$sql .= $tax_query_sql['where'] . $meta_query_sql['where'];
|
||||
|
||||
if ( $search = WC_Query::get_main_search_query_sql() ) {
|
||||
$search = WC_Query::get_main_search_query_sql();
|
||||
if ( $search ) {
|
||||
$sql .= ' AND ' . $search;
|
||||
}
|
||||
|
||||
return absint( $wpdb->get_var( $sql ) );
|
||||
return absint( $wpdb->get_var( $sql ) ); // WPCS: unprepared SQL ok.
|
||||
}
|
||||
|
||||
/**
|
||||
* widget function.
|
||||
* Widget function.
|
||||
*
|
||||
* @see WP_Widget
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
* @param array $args Arguments.
|
||||
* @param array $instance Widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
if ( ! is_shop() && ! is_product_taxonomy() ) {
|
||||
|
@ -100,7 +98,7 @@ class WC_Widget_Rating_Filter extends WC_Widget {
|
|||
ob_start();
|
||||
|
||||
$found = false;
|
||||
$rating_filter = isset( $_GET['rating_filter'] ) ? array_filter( array_map( 'absint', explode( ',', $_GET['rating_filter'] ) ) ) : array();
|
||||
$rating_filter = isset( $_GET['rating_filter'] ) ? array_filter( array_map( 'absint', explode( ',', wp_unslash( $_GET['rating_filter'] ) ) ) ) : array(); // WPCS: input var ok, CSRF ok, sanitization ok.
|
||||
|
||||
$this->widget_start( $args, $instance );
|
||||
|
||||
|
@ -114,18 +112,18 @@ class WC_Widget_Rating_Filter extends WC_Widget {
|
|||
$found = true;
|
||||
$link = $this->get_current_page_url();
|
||||
|
||||
if ( in_array( $rating, $rating_filter ) ) {
|
||||
if ( in_array( $rating, $rating_filter, true ) ) {
|
||||
$link_ratings = implode( ',', array_diff( $rating_filter, array( $rating ) ) );
|
||||
} else {
|
||||
$link_ratings = implode( ',', array_merge( $rating_filter, array( $rating ) ) );
|
||||
}
|
||||
|
||||
$class = in_array( $rating, $rating_filter ) ? 'wc-layered-nav-rating chosen' : 'wc-layered-nav-rating';
|
||||
$class = in_array( $rating, $rating_filter, true ) ? 'wc-layered-nav-rating chosen' : 'wc-layered-nav-rating';
|
||||
$link = apply_filters( 'woocommerce_rating_filter_link', $link_ratings ? add_query_arg( 'rating_filter', $link_ratings ) : remove_query_arg( 'rating_filter' ) );
|
||||
$rating_html = wc_get_star_rating_html( $rating );
|
||||
$count_html = esc_html( apply_filters( 'woocommerce_rating_filter_count', "({$count})", $count, $rating ) );
|
||||
|
||||
printf( '<li class="%s"><a href="%s"><span class="star-rating">%s</span> %s</a></li>', esc_attr( $class ), esc_url( $link ), $rating_html, $count_html );
|
||||
printf( '<li class="%s"><a href="%s"><span class="star-rating">%s</span> %s</a></li>', esc_attr( $class ), esc_url( $link ), $rating_html, $count_html ); // WPCS: XSS ok.
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
|
@ -135,7 +133,7 @@ class WC_Widget_Rating_Filter extends WC_Widget {
|
|||
if ( ! $found ) {
|
||||
ob_end_clean();
|
||||
} else {
|
||||
echo ob_get_clean();
|
||||
echo ob_get_clean(); // WPCS: XSS ok.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recent Reviews Widget.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 2.3.0
|
||||
* @extends WC_Widget
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Widget recent reviews class.
|
||||
*/
|
||||
class WC_Widget_Recent_Reviews extends WC_Widget {
|
||||
|
||||
|
@ -46,9 +44,8 @@ class WC_Widget_Recent_Reviews extends WC_Widget {
|
|||
* Output widget.
|
||||
*
|
||||
* @see WP_Widget
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
* @param array $args Arguments.
|
||||
* @param array $instance Widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
global $comments, $comment;
|
||||
|
@ -60,7 +57,15 @@ class WC_Widget_Recent_Reviews extends WC_Widget {
|
|||
ob_start();
|
||||
|
||||
$number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std'];
|
||||
$comments = get_comments( array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish', 'post_type' => 'product', 'parent' => 0 ) );
|
||||
$comments = get_comments(
|
||||
array(
|
||||
'number' => $number,
|
||||
'status' => 'approve',
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'product',
|
||||
'parent' => 0,
|
||||
)
|
||||
); // WPCS: override ok.
|
||||
|
||||
if ( $comments ) {
|
||||
$this->widget_start( $args, $instance );
|
||||
|
@ -77,12 +82,12 @@ class WC_Widget_Recent_Reviews extends WC_Widget {
|
|||
|
||||
echo '<li><a href="' . esc_url( get_comment_link( $comment->comment_ID ) ) . '">';
|
||||
|
||||
echo $_product->get_image() . wp_kses_post( $_product->get_name() ) . '</a>';
|
||||
echo $_product->get_image() . wp_kses_post( $_product->get_name() ) . '</a>'; // WPCS: XSS ok.
|
||||
|
||||
echo $rating_html;
|
||||
echo $rating_html; // WPCS: XSS ok.
|
||||
|
||||
/* translators: %s: review author */
|
||||
echo '<span class="reviewer">' . sprintf( esc_html__( 'by %s', 'woocommerce' ), get_comment_author() ) . '</span>';
|
||||
echo '<span class="reviewer">' . sprintf( esc_html__( 'by %s', 'woocommerce' ), get_comment_author() ) . '</span>'; // WPCS: XSS ok.
|
||||
|
||||
echo '</li>';
|
||||
}
|
||||
|
@ -94,7 +99,7 @@ class WC_Widget_Recent_Reviews extends WC_Widget {
|
|||
|
||||
$content = ob_get_clean();
|
||||
|
||||
echo $content;
|
||||
echo $content; // WPCS: XSS ok.
|
||||
|
||||
$this->cache_widget( $args, $content );
|
||||
}
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recent Products Widget.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 3.3.0
|
||||
* @extends WC_Widget
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Widget recently viewed.
|
||||
*/
|
||||
class WC_Widget_Recently_Viewed extends WC_Widget {
|
||||
|
||||
|
@ -46,13 +44,11 @@ class WC_Widget_Recently_Viewed extends WC_Widget {
|
|||
* Output widget.
|
||||
*
|
||||
* @see WP_Widget
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
* @param array $args Arguments.
|
||||
* @param array $instance Widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
|
||||
$viewed_products = ! empty( $_COOKIE['woocommerce_recently_viewed'] ) ? (array) explode( '|', $_COOKIE['woocommerce_recently_viewed'] ) : array();
|
||||
$viewed_products = ! empty( $_COOKIE['woocommerce_recently_viewed'] ) ? (array) explode( '|', wp_unslash( $_COOKIE['woocommerce_recently_viewed'] ) ) : array(); // @codingStandardsIgnoreLine
|
||||
$viewed_products = array_reverse( array_filter( array_map( 'absint', $viewed_products ) ) );
|
||||
|
||||
if ( empty( $viewed_products ) ) {
|
||||
|
@ -80,7 +76,7 @@ class WC_Widget_Recently_Viewed extends WC_Widget {
|
|||
'terms' => 'outofstock',
|
||||
'operator' => 'NOT IN',
|
||||
),
|
||||
);
|
||||
); // WPCS: slow query ok.
|
||||
}
|
||||
|
||||
$r = new WP_Query( apply_filters( 'woocommerce_recently_viewed_products_widget_query_args', $query_args ) );
|
||||
|
@ -109,6 +105,6 @@ class WC_Widget_Recently_Viewed extends WC_Widget {
|
|||
|
||||
$content = ob_get_clean();
|
||||
|
||||
echo $content;
|
||||
echo $content; // WPCS: XSS ok.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Top Rated Products Widget.
|
||||
* Gets and displays top rated products in an unordered list.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Widgets
|
||||
* @package WooCommerce/Widgets
|
||||
* @version 3.3.0
|
||||
* @extends WC_Widget
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Widget top rated products class.
|
||||
*/
|
||||
class WC_Widget_Top_Rated_Products extends WC_Widget {
|
||||
|
||||
|
@ -47,9 +45,8 @@ class WC_Widget_Top_Rated_Products extends WC_Widget {
|
|||
* Output widget.
|
||||
*
|
||||
* @see WP_Widget
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
* @param array $args Arguments.
|
||||
* @param array $instance Widget instance.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
|
||||
|
@ -71,7 +68,7 @@ class WC_Widget_Top_Rated_Products extends WC_Widget {
|
|||
'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 );
|
||||
|
||||
|
@ -100,7 +97,7 @@ class WC_Widget_Top_Rated_Products extends WC_Widget {
|
|||
|
||||
$content = ob_get_clean();
|
||||
|
||||
echo $content;
|
||||
echo $content; // WPCS: XSS ok.
|
||||
|
||||
$this->cache_widget( $args, $content );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue