Remove numbered arguments from queries
This commit is contained in:
parent
fcbdd35223
commit
c5cba283ed
|
@ -2075,13 +2075,13 @@ class WC_AJAX {
|
|||
$nextid = isset( $_POST['nextid'] ) ? $_POST['nextid'] : false;
|
||||
$new_pos = array(); // store new positions for ajax
|
||||
|
||||
$siblings = $wpdb->get_results( $wpdb->prepare('
|
||||
SELECT ID, menu_order FROM %1$s AS posts
|
||||
WHERE posts.post_type = \'product\'
|
||||
AND posts.post_status IN ( \'publish\', \'pending\', \'draft\', \'future\', \'private\' )
|
||||
AND posts.ID NOT IN (%2$d)
|
||||
$siblings = $wpdb->get_results( $wpdb->prepare( "
|
||||
SELECT ID, menu_order FROM {$wpdb->posts} AS posts
|
||||
WHERE posts.post_type = 'product'
|
||||
AND posts.post_status IN ( 'publish', 'pending', 'draft', 'future', 'private' )
|
||||
AND posts.ID NOT IN (%d)
|
||||
ORDER BY posts.menu_order ASC, posts.ID DESC
|
||||
', $wpdb->posts, $post->ID) );
|
||||
", $post->ID ) );
|
||||
|
||||
$menu_order = 0;
|
||||
|
||||
|
|
|
@ -861,17 +861,17 @@ class WC_Query {
|
|||
$min_class = $min - WC_Tax::get_tax_total( WC_Tax::calc_inclusive_tax( $min, $tax_rates ) );
|
||||
$max_class = $max - WC_Tax::get_tax_total( WC_Tax::calc_inclusive_tax( $max, $tax_rates ) );
|
||||
|
||||
$matched_products_query = apply_filters( 'woocommerce_price_filter_results', $wpdb->get_results( $wpdb->prepare( '
|
||||
SELECT DISTINCT ID, post_parent, post_type FROM %1$s
|
||||
INNER JOIN %2$s pm1 ON ID = pm1.post_id
|
||||
INNER JOIN %2$s pm2 ON ID = pm2.post_id
|
||||
WHERE post_type IN ( "product", "product_variation" )
|
||||
AND post_status = "publish"
|
||||
AND pm1.meta_key IN ("' . implode( '","', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price' ) ) ) . '")
|
||||
AND pm1.meta_value BETWEEN %3$d AND %4$d
|
||||
AND pm2.meta_key = "_tax_class"
|
||||
AND pm2.meta_value = "%5$s"
|
||||
', $wpdb->posts, $wpdb->postmeta, $min_class, $max_class, sanitize_title( $tax_class ) ), OBJECT_K ), $min_class, $max_class );
|
||||
$matched_products_query = apply_filters( 'woocommerce_price_filter_results', $wpdb->get_results( $wpdb->prepare( "
|
||||
SELECT DISTINCT ID, post_parent, post_type FROM {$wpdb->posts}
|
||||
INNER JOIN {$wpdb->postmeta} pm1 ON ID = pm1.post_id
|
||||
INNER JOIN {$wpdb->postmeta} pm2 ON ID = pm2.post_id
|
||||
WHERE post_type IN ( 'product', 'product_variation' )
|
||||
AND post_status = 'publish'
|
||||
AND pm1.meta_key IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price' ) ) ) ) . "')
|
||||
AND pm1.meta_value BETWEEN %d AND %d
|
||||
AND pm2.meta_key = '_tax_class'
|
||||
AND pm2.meta_value = %s
|
||||
", $min_class, $max_class, sanitize_title( $tax_class ) ), OBJECT_K ), $min_class, $max_class );
|
||||
|
||||
if ( $matched_products_query ) {
|
||||
foreach ( $matched_products_query as $product ) {
|
||||
|
@ -885,14 +885,14 @@ class WC_Query {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
$matched_products_query = apply_filters( 'woocommerce_price_filter_results', $wpdb->get_results( $wpdb->prepare( '
|
||||
SELECT DISTINCT ID, post_parent, post_type FROM %1$s
|
||||
INNER JOIN %2$s pm1 ON ID = post_id
|
||||
WHERE post_type IN ( "product", "product_variation" )
|
||||
AND post_status = "publish"
|
||||
AND pm1.meta_key IN ("' . implode( '","', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price' ) ) ) . '")
|
||||
AND pm1.meta_value BETWEEN %3$d AND %4$d
|
||||
', $wpdb->posts, $wpdb->postmeta, $min, $max, $tax_class ), OBJECT_K ), $min, $max );
|
||||
$matched_products_query = apply_filters( 'woocommerce_price_filter_results', $wpdb->get_results( $wpdb->prepare( "
|
||||
SELECT DISTINCT ID, post_parent, post_type FROM {$wpdb->posts}
|
||||
INNER JOIN {$wpdb->postmeta} pm1 ON ID = pm1.post_id
|
||||
WHERE post_type IN ( 'product', 'product_variation' )
|
||||
AND post_status = 'publish'
|
||||
AND pm1.meta_key IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price' ) ) ) ) . "')
|
||||
AND pm1.meta_value BETWEEN %d AND %d
|
||||
", $min, $max ), OBJECT_K ), $min, $max );
|
||||
|
||||
if ( $matched_products_query ) {
|
||||
foreach ( $matched_products_query as $product ) {
|
||||
|
|
|
@ -96,55 +96,47 @@ class WC_Widget_Price_Filter extends WC_Widget {
|
|||
}
|
||||
|
||||
if ( 0 === sizeof( WC()->query->layered_nav_product_ids ) ) {
|
||||
$min = floor( $wpdb->get_var(
|
||||
$wpdb->prepare('
|
||||
SELECT min(meta_value + 0)
|
||||
FROM %1$s
|
||||
LEFT JOIN %2$s ON %1$s.ID = %2$s.post_id
|
||||
WHERE meta_key IN ("' . implode( '","', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price', '_min_variation_price' ) ) ) . '")
|
||||
AND meta_value != ""
|
||||
', $wpdb->posts, $wpdb->postmeta )
|
||||
) );
|
||||
$max = ceil( $wpdb->get_var(
|
||||
$wpdb->prepare('
|
||||
SELECT max(meta_value + 0)
|
||||
FROM %1$s
|
||||
LEFT JOIN %2$s ON %1$s.ID = %2$s.post_id
|
||||
WHERE meta_key IN ("' . implode( '","', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price' ) ) ) . '")
|
||||
', $wpdb->posts, $wpdb->postmeta, '_price' )
|
||||
) );
|
||||
$min = floor( $wpdb->get_var( "
|
||||
SELECT min(meta_value + 0)
|
||||
FROM {$wpdb->posts} as posts
|
||||
LEFT JOIN {$wpdb->postmeta} as postmeta ON posts.ID = postmeta.post_id
|
||||
WHERE meta_key IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price', '_min_variation_price' ) ) ) ) . "')
|
||||
AND meta_value != ''
|
||||
" ) );
|
||||
$max = ceil( $wpdb->get_var( "
|
||||
SELECT max(meta_value + 0)
|
||||
FROM {$wpdb->posts} as posts
|
||||
LEFT JOIN {$wpdb->postmeta} as postmeta ON posts.ID = postmeta.post_id
|
||||
WHERE meta_key IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price' ) ) ) ) . "')
|
||||
" ) );
|
||||
} else {
|
||||
$min = floor( $wpdb->get_var(
|
||||
$wpdb->prepare('
|
||||
SELECT min(meta_value + 0)
|
||||
FROM %1$s
|
||||
LEFT JOIN %2$s ON %1$s.ID = %2$s.post_id
|
||||
WHERE meta_key IN ("' . implode( '","', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price', '_min_variation_price' ) ) ) . '")
|
||||
AND meta_value != ""
|
||||
AND (
|
||||
%1$s.ID IN (' . implode( ',', array_map( 'absint', WC()->query->layered_nav_product_ids ) ) . ')
|
||||
OR (
|
||||
%1$s.post_parent IN (' . implode( ',', array_map( 'absint', WC()->query->layered_nav_product_ids ) ) . ')
|
||||
AND %1$s.post_parent != 0
|
||||
)
|
||||
$min = floor( $wpdb->get_var( "
|
||||
SELECT min(meta_value + 0)
|
||||
FROM {$wpdb->posts} as posts
|
||||
LEFT JOIN {$wpdb->postmeta} as postmeta ON posts.ID = postmeta.post_id
|
||||
WHERE meta_key IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price', '_min_variation_price' ) ) ) ) . "')
|
||||
AND meta_value != ''
|
||||
AND (
|
||||
posts.ID IN (" . implode( ',', array_map( 'absint', WC()->query->layered_nav_product_ids ) ) . ")
|
||||
OR (
|
||||
posts.post_parent IN (" . implode( ',', array_map( 'absint', WC()->query->layered_nav_product_ids ) ) . ")
|
||||
AND posts.post_parent != 0
|
||||
)
|
||||
', $wpdb->posts, $wpdb->postmeta
|
||||
) ) );
|
||||
$max = ceil( $wpdb->get_var(
|
||||
$wpdb->prepare('
|
||||
SELECT max(meta_value + 0)
|
||||
FROM %1$s
|
||||
LEFT JOIN %2$s ON %1$s.ID = %2$s.post_id
|
||||
WHERE meta_key IN ("' . implode( '","', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price' ) ) ) . '")
|
||||
AND (
|
||||
%1$s.ID IN (' . implode( ',', array_map( 'absint', WC()->query->layered_nav_product_ids ) ) . ')
|
||||
OR (
|
||||
%1$s.post_parent IN (' . implode( ',', array_map( 'absint', WC()->query->layered_nav_product_ids ) ) . ')
|
||||
AND %1$s.post_parent != 0
|
||||
)
|
||||
)
|
||||
" ) );
|
||||
$max = ceil( $wpdb->get_var( "
|
||||
SELECT max(meta_value + 0)
|
||||
FROM {$wpdb->posts} as posts
|
||||
LEFT JOIN {$wpdb->postmeta} as postmeta ON posts.ID = postmeta.post_id
|
||||
WHERE meta_key IN ('" . implode( "','", array_map( 'esc_sql', apply_filters( 'woocommerce_price_filter_meta_keys', array( '_price' ) ) ) ) . "')
|
||||
AND (
|
||||
posts.ID IN (" . implode( ',', array_map( 'absint', WC()->query->layered_nav_product_ids ) ) . ")
|
||||
OR (
|
||||
posts.post_parent IN (" . implode( ',', array_map( 'absint', WC()->query->layered_nav_product_ids ) ) . ")
|
||||
AND posts.post_parent != 0
|
||||
)
|
||||
', $wpdb->posts, $wpdb->postmeta
|
||||
) ) );
|
||||
)
|
||||
" ) );
|
||||
}
|
||||
|
||||
if ( $min == $max ) {
|
||||
|
|
Loading…
Reference in New Issue