diff --git a/includes/admin/list-tables/class-wc-admin-list-table-products.php b/includes/admin/list-tables/class-wc-admin-list-table-products.php index 00974742408..a89627b8631 100644 --- a/includes/admin/list-tables/class-wc-admin-list-table-products.php +++ b/includes/admin/list-tables/class-wc-admin-list-table-products.php @@ -287,6 +287,27 @@ 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() { + $filters = apply_filters( 'woocommerce_products_admin_list_table_filters', array( + 'product_category' => array( $this, 'render_products_category_filter' ), + 'product_type' => array( $this, 'render_products_type_filter' ), + 'stock_status' => array( $this, 'render_products_stock_status_filter' ), + ) ); + + ob_start(); + foreach ( $filters as $filter_callback ) { + call_user_func( $filter_callback ); + } + $output = ob_get_clean(); + + echo apply_filters( 'woocommerce_product_filters', $output ); // WPCS: XSS ok. + } + + /** + * Render the product category filter for the list table. + * + * @since 3.5.0 + */ + protected function render_products_category_filter() { $categories_count = (int) wp_count_terms( 'product_cat' ); if ( $categories_count <= apply_filters( 'woocommerce_product_category_filter_threshold', 100 ) ) { @@ -307,7 +328,14 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table { '; @@ -351,18 +379,25 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table { } $output .= ''; + echo $output; + } + /** + * Render the stock status filter for the list table. + * + * @since 3.5.0 + */ + public function render_products_stock_status_filter() { $current_stock_status = isset( $_REQUEST['stock_status'] ) ? wc_clean( wp_unslash( $_REQUEST['stock_status'] ) ) : false; // WPCS: input var ok, sanitization ok. $stock_statuses = wc_get_product_stock_status_options(); - $output .= ''; foreach ( $stock_statuses as $status => $label ) { $output .= ''; } $output .= ''; - - echo apply_filters( 'woocommerce_product_filters', $output ); // WPCS: XSS ok. + echo $output; } /**