Merge pull request #21954 from willgorham/fix/21793
Fix hardcoded db table name [Fixes #21793]
This commit is contained in:
commit
0ddfbbe1ac
|
@ -289,11 +289,14 @@ 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' ),
|
||||
) );
|
||||
$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 ) {
|
||||
|
@ -389,18 +392,24 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
|
|||
protected function query_filters( $query_vars ) {
|
||||
if ( isset( $query_vars['orderby'] ) ) {
|
||||
if ( 'price' === $query_vars['orderby'] ) {
|
||||
$query_vars = array_merge( $query_vars, array(
|
||||
// phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
|
||||
'meta_key' => '_price',
|
||||
'orderby' => 'meta_value_num',
|
||||
) );
|
||||
$query_vars = array_merge(
|
||||
$query_vars,
|
||||
array(
|
||||
// phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
|
||||
'meta_key' => '_price',
|
||||
'orderby' => 'meta_value_num',
|
||||
)
|
||||
);
|
||||
}
|
||||
if ( 'sku' === $query_vars['orderby'] ) {
|
||||
$query_vars = array_merge( $query_vars, array(
|
||||
// phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
|
||||
'meta_key' => '_sku',
|
||||
'orderby' => 'meta_value',
|
||||
) );
|
||||
$query_vars = array_merge(
|
||||
$query_vars,
|
||||
array(
|
||||
// phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
|
||||
'meta_key' => '_sku',
|
||||
'orderby' => 'meta_value',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -511,8 +520,8 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table {
|
|||
if ( isset( $_GET['product_shipping_class'] ) && '0' !== $_GET['product_shipping_class'] ) { // WPCS: input var ok.
|
||||
$replaced_where = str_replace( ".post_type = 'product'", ".post_type = 'product_variation'", $pieces['where'] );
|
||||
$pieces['where'] .= " OR {$wpdb->posts}.ID in (
|
||||
SELECT {$wpdb->posts}.post_parent FROM
|
||||
wp_posts LEFT JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)
|
||||
SELECT {$wpdb->posts}.post_parent FROM
|
||||
{$wpdb->posts} LEFT JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)
|
||||
WHERE 1=1 $replaced_where
|
||||
)";
|
||||
return $pieces;
|
||||
|
|
Loading…
Reference in New Issue