Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Example usage: [is_verified_owner][site_reviews_form][/is_verified_owner]
- *
- * @param array $atts
- * @param string $content
- * @return string
- */
- add_shortcode('is_verified_owner', function ($atts, $content = '') {
- global $product;
- if (!function_exists('wc_customer_bought_product') || empty($product)) {
- return do_shortcode($content);
- }
- $isVerifiedOwner = wc_customer_bought_product('', get_current_user_id(), $product->get_id());
- return $isVerifiedOwner || 'no' === get_option('woocommerce_review_rating_verification_required')
- ? do_shortcode($content)
- : esc_html__('Only logged in customers who have purchased this product may leave a review.', 'site-reviews-woocommerce');
- }, 10, 2);
Add Comment
Please, Sign In to add comment