Sanitize ids later

This commit is contained in:
Mike Jolley 2016-10-17 17:04:24 +01:00
parent f42d853453
commit 6bf077a367
1 changed files with 4 additions and 4 deletions

View File

@ -765,7 +765,7 @@ function wc_get_related_products( $product_id, $limit = 5, $exclude_ids = array(
global $wpdb; global $wpdb;
$product_id = absint( $product_id ); $product_id = absint( $product_id );
$exclude_ids = array_map( 'absint', array_merge( array( 0, $product_id ), $exclude_ids ) ); $exclude_ids = array_merge( array( 0, $product_id ), $exclude_ids );
$transient_name = 'wc_related_' . $product_id; $transient_name = 'wc_related_' . $product_id;
$related_posts = get_transient( $transient_name ); $related_posts = get_transient( $transient_name );
$limit = $limit > 0 ? $limit : 5; $limit = $limit > 0 ? $limit : 5;
@ -834,9 +834,9 @@ function wc_get_related_products_query( $cats_array, $tags_array, $exclude_ids,
global $wpdb; global $wpdb;
// Arrays to string. // Arrays to string.
$exclude_ids = implode( ',', $exclude_ids ); $exclude_ids = implode( ',', array_map( 'absint', $exclude_ids ) );
$cats_array = implode( ',', $cats_array ); $cats_array = implode( ',', array_map( 'absint', $cats_array ) );
$tags_array = implode( ',', $tags_array ); $tags_array = implode( ',', array_map( 'absint', $tags_array ) );
$limit = absint( $limit ); $limit = absint( $limit );
$query = array(); $query = array();