Helper method to retrieve review verification status from comment meta, generating it on the fly for existing reviews.

This commit is contained in:
Jeff Stieler 2015-10-09 10:22:56 -06:00
parent e9bfa2553c
commit 1b370bb64a
1 changed files with 16 additions and 0 deletions

View File

@ -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;
}