Advertisement
geminilabs

[site-reviews] set the assigned_posts value for all shortcodes from an URL parameter

Oct 4th, 2023 (edited)
890
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. /**
  2.  * Set the assigned_posts value from an URL parameter (?assigned_post=)
  3.  *
  4.  * Example URL:
  5.  * https://domain.com?assigned_post=4
  6.  *
  7.  * Example Shortcode Usage:
  8.  * [site_reviews assigned_posts="post_id"]
  9.  * [site_reviews_form assigned_posts="post_id"]
  10.  * [site_reviews_summary assigned_posts="post_id"]
  11.  *
  12.  * @return int
  13.  */
  14. add_filter('site-reviews/assigned_posts/post_id', function (int $postId) {
  15.     if ($overridePostId = filter_input(INPUT_GET, 'assigned_post', FILTER_VALIDATE_INT)) {
  16.         return $overridePostId;
  17.     }
  18.     return $postId;
  19. });
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement