NF_Display_Preview

Class NF_Display_Preview.

Defined (1)

The class is defined in the following location(s).

/includes/Display/Preview.php  
  1. final class NF_Display_Preview 
  2. protected $form_id = ''; 
  3.  
  4. public function __construct() 
  5. if ( ! isset( $_GET['nf_preview_form'] ) ) return; 
  6.  
  7. $this->_form_id = $_GET['nf_preview_form']; 
  8.  
  9. add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) ); 
  10.  
  11. add_filter('the_title', array( $this, 'the_title' ) ); 
  12. remove_filter( 'the_content', 'wpautop' ); 
  13. remove_filter( 'the_excerpt', 'wpautop' ); 
  14. add_filter('the_content', array( $this, 'the_content' ), 9001 ); 
  15. add_filter('get_the_excerpt', array( $this, 'the_content' ) ); 
  16. add_filter('template_include', array( $this, 'template_include' ) ); 
  17. add_filter('post_thumbnail_html', array( $this, 'post_thumbnail_html' ) ); 
  18.  
  19. public function pre_get_posts( $query ) 
  20. $query->set( 'posts_per_page', 1 ); 
  21.  
  22. /** 
  23. * @return string 
  24. */ 
  25. function the_title( $title ) 
  26. if( ! in_the_loop() ) return $title; 
  27.  
  28. $form_title = Ninja_Forms()->form( $this->_form_id )->get()->get_setting( 'title' ); 
  29.  
  30. return $form_title . " " . __( 'Preview', 'ninja-forms' ); 
  31.  
  32. /** 
  33. * @return string 
  34. */ 
  35. function the_content() 
  36. if ( ! is_user_logged_in() ) return __( 'You must be logged in to preview a form.', 'ninja-forms' ); 
  37.  
  38. return do_shortcode( "[nf_preview id='{$this->_form_id}']" ); 
  39.  
  40. /** 
  41. * @return string 
  42. */ 
  43. function template_include() 
  44. return locate_template( array( 'page.php', 'single.php', 'index.php' ) ); 
  45.  
  46. function post_thumbnail_html() { 
  47. return ''; 
  48.  
  49. } // END CLASS NF_Display_Preview