diff --git a/src/BlockTypes/ProductCollection.php b/src/BlockTypes/ProductCollection.php index 3b7a1922cb0..45056369897 100644 --- a/src/BlockTypes/ProductCollection.php +++ b/src/BlockTypes/ProductCollection.php @@ -401,6 +401,7 @@ function( $acc, $query ) { */ if ( ! empty( $merged_query['post__in'] ) && + is_array( $merged_query['post__in'] ) && count( $merged_query['post__in'] ) > count( array_unique( $merged_query['post__in'] ) ) ) { $merged_query['post__in'] = array_unique( diff --git a/src/BlockTypes/ProductQuery.php b/src/BlockTypes/ProductQuery.php index be61ea4d509..d82f9583c28 100644 --- a/src/BlockTypes/ProductQuery.php +++ b/src/BlockTypes/ProductQuery.php @@ -298,6 +298,7 @@ function( $acc, $query ) { */ if ( ! empty( $merged_query['post__in'] ) && + is_array( $merged_query['post__in'] ) && count( $merged_query['post__in'] ) > count( array_unique( $merged_query['post__in'] ) ) ) { $merged_query['post__in'] = array_unique( diff --git a/src/StoreApi/Schemas/V1/ProductReviewSchema.php b/src/StoreApi/Schemas/V1/ProductReviewSchema.php index 75932239a77..29d62b55d42 100644 --- a/src/StoreApi/Schemas/V1/ProductReviewSchema.php +++ b/src/StoreApi/Schemas/V1/ProductReviewSchema.php @@ -159,9 +159,8 @@ public function get_properties() { * @return array */ public function get_item_response( $review ) { - $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; - $rating = get_comment_meta( $review->comment_ID, 'rating', true ) === '' ? null : (int) get_comment_meta( $review->comment_ID, 'rating', true ); - $data = [ + $rating = get_comment_meta( $review->comment_ID, 'rating', true ) === '' ? null : (int) get_comment_meta( $review->comment_ID, 'rating', true ); + return [ 'id' => (int) $review->comment_ID, 'date_created' => wc_rest_prepare_date_response( $review->comment_date ), 'formatted_date_created' => get_comment_date( 'F j, Y', $review->comment_ID ), @@ -171,16 +170,10 @@ public function get_item_response( $review ) { 'product_permalink' => get_permalink( (int) $review->comment_post_ID ), 'product_image' => $this->image_attachment_schema->get_item_response( get_post_thumbnail_id( (int) $review->comment_post_ID ) ), 'reviewer' => $review->comment_author, - 'review' => $review->comment_content, + 'review' => wp_autop( $review->comment_content ), 'rating' => $rating, 'verified' => wc_review_is_from_verified_owner( $review->comment_ID ), 'reviewer_avatar_urls' => rest_get_avatar_urls( $review->comment_author_email ), ]; - - if ( 'view' === $context ) { - $data['review'] = wpautop( $data['review'] ); - } - - return $data; } } diff --git a/src/Templates/SingleProductTemplateCompatibility.php b/src/Templates/SingleProductTemplateCompatibility.php index 56e92808cd7..aa84c3dc4f5 100644 --- a/src/Templates/SingleProductTemplateCompatibility.php +++ b/src/Templates/SingleProductTemplateCompatibility.php @@ -425,7 +425,7 @@ private static function has_single_product_template_blocks( $parsed_blocks ) { private static function group_blocks( $parsed_blocks ) { return array_reduce( $parsed_blocks, - function( $carry, $block ) { + function( array $carry, array $block ) { if ( 'core/template-part' === $block['blockName'] ) { $carry[] = array( $block ); return $carry; diff --git a/templates/notices/error.php b/templates/notices/error.php index 436430d3c65..2518cfa380e 100644 --- a/templates/notices/error.php +++ b/templates/notices/error.php @@ -19,7 +19,7 @@ exit; } -if ( ! $notices ) { +if ( empty( $notices ) || ! is_array( $notices ) ) { return; }