Advertisement
geminilabs

Untitled

Nov 11th, 2020 (edited)
995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. /**
  2.  * 1. This enables full debug-level logging of Site Reviews
  3.  */
  4. add_filter('site-reviews/console/level', '__return_zero', 1);
  5.  
  6. /**
  7.  * 2. This flushes the WordPress cache
  8.  * @see https://developer.wordpress.org/reference/functions/wp_cache_flush/
  9.  */
  10. add_action('init', function () {
  11.   wp_cache_flush();
  12. });
  13.  
  14. /**
  15.  * 3. Here we log the database query that Site Reviews uses to get the review ids
  16.  */
  17. add_filter('site-reviews/database/sql/query-review-ids', function ($statement) {
  18.   glsr_log()->once('info', 'sql/query-review-ids', $statement);
  19.   return $statement;
  20. });
  21.  
  22. /**
  23.  * 4. Finally, here we query the first 10 reviews and then log the details to the console.
  24.  */
  25. add_action('wp_footer', function () {
  26.   $reviews = glsr_get_reviews(['status' => 'all']); // This function is documented on the Site Reviews Help page
  27.   // loop through the reviews that were found
  28.   foreach ($reviews as $review) {
  29.       $review->meta();   // load the review meta
  30.       $review->custom(); // load any custom review fields
  31.       glsr_log($review); // finally, log the review details to the console
  32.   }
  33. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement