Add back category filtering which somehow was removed
This commit is contained in:
parent
bdcc8a28f9
commit
cd3d61bf98
|
@ -299,22 +299,29 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
|
|||
* Render any custom filters and search inputs for the list table.
|
||||
*/
|
||||
protected function render_filters() {
|
||||
$current_category_slug = isset( $_REQUEST['product_cat'] ) ? wc_clean( wp_unslash( $_REQUEST['product_cat'] ) ) : false; // WPCS: input var ok, sanitization ok.
|
||||
$current_product_type = isset( $_REQUEST['product_type'] ) ? wc_clean( wp_unslash( $_REQUEST['product_type'] ) ) : false; // WPCS: input var ok, sanitization ok.
|
||||
// @codingStandardsIgnoreStart
|
||||
$current_category = $current_category_slug ? get_term_by( 'slug', $current_category_slug, 'product_cat' ): false;
|
||||
// @codingStandardsIgnoreEnd
|
||||
?>
|
||||
<select class="wc-category-search" name="product_cat" data-placeholder="<?php esc_attr_e( 'Filter by category', 'woocommerce' ); ?>" data-allow_clear="true">
|
||||
<?php if ( $current_category_slug && $current_category ) : ?>
|
||||
<option value="<?php echo esc_attr( $current_category_slug ); ?>" selected="selected"><?php echo esc_html( $current_category->name ); ?><option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<?php
|
||||
// Category Filtering.
|
||||
$categories_count = (int) wp_count_terms( 'product_cat' );
|
||||
|
||||
$terms = get_terms( 'product_type' );
|
||||
$output = '<select name="product_type" id="dropdown_product_type">';
|
||||
$output .= '<option value="">' . __( 'Filter by product type', 'woocommerce' ) . '</option>';
|
||||
if ( $categories_count <= apply_filters( 'woocommerce_product_category_filter_threshold', 100 ) ) {
|
||||
wc_product_dropdown_categories( array(
|
||||
'option_select_text' => __( 'Filter by category', 'woocommerce' ),
|
||||
) );
|
||||
} else {
|
||||
$current_category_slug = isset( $_GET['product_cat'] ) ? wc_clean( wp_unslash( $_GET['product_cat'] ) ) : false; // WPCS: input var ok, CSRF ok.
|
||||
$current_category = $current_category_slug ? get_term_by( 'slug', $current_category_slug, 'product_cat' ) : false;
|
||||
?>
|
||||
<select class="wc-category-search" name="product_cat" data-placeholder="<?php esc_attr_e( 'Filter by category', 'woocommerce' ); ?>" data-allow_clear="true">
|
||||
<?php if ( $current_category_slug && $current_category ) : ?>
|
||||
<option value="<?php echo esc_attr( $current_category_slug ); ?>" selected="selected"><?php echo esc_html( $current_category->name ); ?><option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Product type filtering.
|
||||
$current_product_type = isset( $_REQUEST['product_type'] ) ? wc_clean( wp_unslash( $_REQUEST['product_type'] ) ) : false; // WPCS: input var ok, sanitization ok.
|
||||
$terms = get_terms( 'product_type' );
|
||||
$output = '<select name="product_type" id="dropdown_product_type"><option value="">' . __( 'Filter by product type', 'woocommerce' ) . '</option>';
|
||||
|
||||
foreach ( $terms as $term ) {
|
||||
$output .= '<option value="' . sanitize_title( $term->name ) . '" ';
|
||||
|
|
Loading…
Reference in New Issue