Advertisement
geminilabs

[site-reviews] customise the response title

Oct 9th, 2019
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. /**
  2.  * Customises the response title
  3.  * REQUIRES SITE REVIEWS >= v4.0.6
  4.  * Paste this in your active theme's functions.php file
  5.  *
  6.  * @param string $responseHtml The response HTML
  7.  * @param string $value The raw response value
  8.  * @param string $review The review the response belongs to
  9.  * @return string
  10.  */
  11. add_filter('site-reviews/review/build/response', function($responseHtml, $value, $review) {
  12.     if (is_numeric($review->assigned_to)) {
  13.  
  14.         // Get the title of the assigned page
  15.         $responseFrom = get_post($review->assigned_to)->post_name;
  16.  
  17.         // OR, get the page author display name
  18.         // $responseFrom = get_the_author($review->assigned_to);
  19.  
  20.         // OR, get the name of the manager saved to the page in a Custom Field
  21.         // $responseFrom = get_post_meta($review->assigned_to, 'assigned_manager_name', true);
  22.  
  23.         if (!empty($responseFrom)) {
  24.             $search = 'Response from '.get_bloginfo('name');
  25.             $replace = 'Response from '.$responseFrom;
  26.             $responseHtml = str_replace($search, $replace, $responseHtml);      
  27.         }
  28.     }
  29.     return $responseHtml;
  30. }, 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement