ensure parameter datatype for array_slice (#38529)

* ensure parameter datatype for array_slice

* add phpdocs to existing filters

* fix spacing

---------

Co-authored-by: Ron Rennick <ronald.rennick@automattic.com>
This commit is contained in:
Ron Rennick 2023-05-31 15:18:57 -03:00 committed by GitHub
parent a5e36377f9
commit ba57d8da29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
ensure parameter datatype for array_slice

View File

@ -2113,7 +2113,13 @@ if ( ! function_exists( 'woocommerce_upsell_display' ) ) {
$orderby = apply_filters( 'woocommerce_upsells_orderby', isset( $args['orderby'] ) ? $args['orderby'] : $orderby );
$order = apply_filters( 'woocommerce_upsells_order', isset( $args['order'] ) ? $args['order'] : $order );
$limit = apply_filters( 'woocommerce_upsells_total', isset( $args['posts_per_page'] ) ? $args['posts_per_page'] : $limit );
/**
* Filter the number of upsell products should on the product page.
*
* @param int $limit number of upsell products.
* @since 3.0.0
*/
$limit = intval( apply_filters( 'woocommerce_upsells_total', $args['posts_per_page'] ?? $limit ) );
// Get visible upsells then sort them at random, then limit result set.
$upsells = wc_products_array_orderby( array_filter( array_map( 'wc_get_product', $product->get_upsell_ids() ), 'wc_products_array_filter_visible' ), $orderby, $order );
@ -2193,7 +2199,13 @@ if ( ! function_exists( 'woocommerce_cross_sell_display' ) ) {
$orderby = apply_filters( 'woocommerce_cross_sells_orderby', $orderby );
$order = apply_filters( 'woocommerce_cross_sells_order', $order );
$cross_sells = wc_products_array_orderby( $cross_sells, $orderby, $order );
$limit = apply_filters( 'woocommerce_cross_sells_total', $limit );
/**
* Filter the number of cross sell products should on the product page.
*
* @param int $limit number of cross sell products.
* @since 3.0.0
*/
$limit = intval( apply_filters( 'woocommerce_cross_sells_total', $limit ) );
$cross_sells = $limit > 0 ? array_slice( $cross_sells, 0, $limit ) : $cross_sells;
wc_get_template(