Advertisement
geminilabs

[site-reviews] Customise the rendered HTML of the review

Aug 6th, 2019
302
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Customise the rendered HTML of the review.
  3.  * In this example, we are modifying the review response HTML.
  4.  * Paste this in your active theme's functions.php file.
  5.  *
  6.  * @param array $fields
  7.  * @param \GeminiLabs\SiteReviews\Review $review
  8.  * @return void
  9.  */
  10. add_filter( 'site-reviews/review/build/after', function( $fields, $review ) {
  11.     if( !empty( $review->response )) {
  12.         // Here we are only changing the response heading:
  13.         $customHtml = '<h3>We Said:</h3>';
  14.         $fields['response'] = preg_replace( '(<p><strong>Response(.+)</strong></p>)', $customHtml, $fields['response'] );
  15.     }
  16.     return $fields;
  17. }, 10, 2 );
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement