Advertisement
geminilabs

test review assignment to product

Nov 16th, 2020 (edited)
1,474
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. add_filter('site-reviews/review/wrap', function ($context, $review) {
  2.     $firstAssignedPostId = array_shift($review->assigned_posts);
  3.     if (!empty($firstAssignedPostId)) {
  4.         glsr_log([
  5.             'assigned_post_type' => get_post_type($firstAssignedPostId),
  6.             'product_id' => $firstAssignedPostId,
  7.             'product_featured_image' => get_the_post_thumbnail($firstAssignedPostId, 'site-reviews-avatar'),
  8.         ]);
  9.         $context['avatar'] = get_the_post_thumbnail($firstAssignedPostId, 'site-reviews-avatar');
  10.     } else {
  11.         glsr_log(sprintf('The review with an ID of %s is not assigned to a product', $review->ID));
  12.     }
  13.     return $context;
  14. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement