Advertisement
arie_cristianD

render review berore post content

Dec 18th, 2024 (edited)
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. add_action(
  2.     'init',
  3.     function () {
  4.         if ( ! is_admin() && class_exists( 'JNews_Review_Frontend' ) ) {
  5.             remove_filter( 'the_content', array( JNews_Review_Frontend::getInstance(), 'review_content' ), 10 );
  6.         }
  7.     }
  8. );
  9. add_filter( 'the_content', 'add_review_before_post' );
  10.  
  11. function add_review_before_post( $content ) {
  12.     if ( class_exists( 'JNews_Review_Frontend' ) && jnews_get_metabox_value( 'jnews_review.enable_review', false ) ) {
  13.         // if split post, we need to leave the post to it should be
  14.         $split_post = jnews_get_metabox_value( 'jnews_post_split.enable_post_split', false );
  15.  
  16.         if ( $split_post ) {
  17.             return $content;
  18.         }
  19.  
  20.         // check multipage
  21.         global $page, $numpages, $multipage;
  22.  
  23.         if ( $multipage ) {
  24.             if ( $page === $numpages ) {
  25.                 return JNews_Review_Frontend::getInstance()->post_review() . $content;
  26.             }
  27.         } else {
  28.             return JNews_Review_Frontend::getInstance()->post_review() . $content;
  29.         }
  30.     }
  31.  
  32.     return $content;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement