From 594eedeca1a2155cb34a17b57622cd8a7e5d4e6c Mon Sep 17 00:00:00 2001 From: Matt Harrison Date: Wed, 20 Oct 2021 22:33:11 -0400 Subject: [PATCH 1/3] Add Product Reviews filter for `review` comment type. Creates the filter option for the WordPress Comments page to filter to product reviews. Closes #29920 --- .../woocommerce/includes/class-wc-comments.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/woocommerce/includes/class-wc-comments.php b/plugins/woocommerce/includes/class-wc-comments.php index f83c30b2b8f..b378ecd8760 100644 --- a/plugins/woocommerce/includes/class-wc-comments.php +++ b/plugins/woocommerce/includes/class-wc-comments.php @@ -46,6 +46,9 @@ class WC_Comments { // Support avatars for `review` comment type. add_filter( 'get_avatar_comment_types', array( __CLASS__, 'add_avatar_for_review_comment_type' ) ); + // Add Product Reviews filter for `review` comment type. + add_filter( 'admin_comment_types_dropdown', array( __CLASS__, 'add_review_comment_fitler' ) ); + // Review of verified purchase. add_action( 'comment_post', array( __CLASS__, 'add_comment_purchase_verification' ) ); @@ -293,6 +296,18 @@ class WC_Comments { return array_merge( $comment_types, array( 'review' ) ); } + /** + * Add Product Reviews filter for `review` comment type. + * + * @since 5.9 + * @param array $comment_types Array of comment type labels keyed by their name. + * @return array + */ + public static function add_review_comment_fitler( $comment_types ) { + $comment_types['review'] = __( 'Product Reviews', 'woocommerce' ); + return $comment_types; + } + /** * Determine if a review is from a verified owner at submission. * From 55503c6bd6acaeb527fdeb9b9969a4f3810afc89 Mon Sep 17 00:00:00 2001 From: barryhughes <3594411+barryhughes@users.noreply.github.com> Date: Tue, 9 Nov 2021 16:01:27 -0800 Subject: [PATCH 2/3] Fix hook/callback name, add type hints. --- plugins/woocommerce/includes/class-wc-comments.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/woocommerce/includes/class-wc-comments.php b/plugins/woocommerce/includes/class-wc-comments.php index b378ecd8760..b57c8ae8984 100644 --- a/plugins/woocommerce/includes/class-wc-comments.php +++ b/plugins/woocommerce/includes/class-wc-comments.php @@ -47,7 +47,7 @@ class WC_Comments { add_filter( 'get_avatar_comment_types', array( __CLASS__, 'add_avatar_for_review_comment_type' ) ); // Add Product Reviews filter for `review` comment type. - add_filter( 'admin_comment_types_dropdown', array( __CLASS__, 'add_review_comment_fitler' ) ); + add_filter( 'admin_comment_types_dropdown', array( __CLASS__, 'add_review_comment_filter' ) ); // Review of verified purchase. add_action( 'comment_post', array( __CLASS__, 'add_comment_purchase_verification' ) ); @@ -299,11 +299,13 @@ class WC_Comments { /** * Add Product Reviews filter for `review` comment type. * - * @since 5.9 + * @since 6.0.0 + * * @param array $comment_types Array of comment type labels keyed by their name. + * * @return array */ - public static function add_review_comment_fitler( $comment_types ) { + public static function add_review_comment_filter( array $comment_types ): array { $comment_types['review'] = __( 'Product Reviews', 'woocommerce' ); return $comment_types; } From 13f598a0b16800412709a306e313b4be4b51fa54 Mon Sep 17 00:00:00 2001 From: barryhughes <3594411+barryhughes@users.noreply.github.com> Date: Tue, 9 Nov 2021 16:02:38 -0800 Subject: [PATCH 3/3] Whitespace. --- plugins/woocommerce/includes/class-wc-comments.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/woocommerce/includes/class-wc-comments.php b/plugins/woocommerce/includes/class-wc-comments.php index b57c8ae8984..4d3ae407269 100644 --- a/plugins/woocommerce/includes/class-wc-comments.php +++ b/plugins/woocommerce/includes/class-wc-comments.php @@ -301,7 +301,7 @@ class WC_Comments { * * @since 6.0.0 * - * @param array $comment_types Array of comment type labels keyed by their name. + * @param array $comment_types Array of comment type labels keyed by their name. * * @return array */