From 1b370bb64a17b44a07db1bc98587776b55a5f8e2 Mon Sep 17 00:00:00 2001 From: Jeff Stieler Date: Fri, 9 Oct 2015 10:22:56 -0600 Subject: [PATCH] Helper method to retrieve review verification status from comment meta, generating it on the fly for existing reviews. --- includes/wc-user-functions.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/includes/wc-user-functions.php b/includes/wc-user-functions.php index 120454a6ca8..5089137dae7 100644 --- a/includes/wc-user-functions.php +++ b/includes/wc-user-functions.php @@ -548,3 +548,19 @@ function wc_reset_order_customer_id_on_deleted_user( $user_id ) { } add_action( 'deleted_user', 'wc_reset_order_customer_id_on_deleted_user' ); + +/** + * Get review verification status. + * @param int $comment_id + * @return bool + */ +function wc_review_is_from_verified_owner( $comment_id ) { + $verified = get_comment_meta( $comment_id, 'verified', true ); + + // If no "verified" meta is present, generate it (if this is a product review). + if ( '' === $verified ) { + $verified = WC_Comments::add_comment_purchase_verification( $comment_id ); + } + + return (bool) $verified; +}