NF_Display_Shortcodes

The Ninja Forms NF Display Shortcodes class.

Defined (1)

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

/includes/Display/Shortcodes.php  
  1. final class NF_Display_Shortcodes 
  2. public function __construct() 
  3. add_shortcode( 'nf_preview', array( $this, 'display_form_preview' ) ); 
  4. add_shortcode( 'ninja_form', array( $this, 'display_form_front_end' ) ); 
  5. add_shortcode( 'ninja_forms', array( $this, 'display_form_front_end' ) ); 
  6. add_shortcode( 'ninja_forms_display_form', array( $this, 'display_form_front_end' ) ); 
  7.  
  8. public function display_form_preview( $atts = array() ) 
  9. if( ! isset( $atts[ 'id' ] ) ) return $this->display_no_id(); 
  10.  
  11. ob_start(); 
  12. Ninja_Forms()->display( $atts['id'], TRUE ); 
  13. return ob_get_clean(); 
  14.  
  15. public function display_form_front_end( $atts = array() ) 
  16. if( ! isset( $atts[ 'id' ] ) ) return $this->display_no_id(); 
  17.  
  18. ob_start(); 
  19. Ninja_Forms()->display( $atts['id'] ); 
  20. return ob_get_clean(); 
  21.  
  22. /** 
  23. * TODO: Extract output to template files. 
  24. * @return string 
  25. */ 
  26. private function display_no_id() 
  27. $output = __( 'Notice: Ninja Forms shortcode used without specifying a form.', 'ninja-forms' ); 
  28.  
  29. // TODO: Maybe support filterable permissions. 
  30. if( ! current_user_can( 'manage_options' ) ) return "<!-- $output -->"; 
  31.  
  32. // TODO: Log error for support reference. 
  33. // TODO: Maybe display notice if not logged in. 
  34. trigger_error( __( 'Ninja Forms shortcode used without specifying a form.', 'ninja-forms' ) ); 
  35.  
  36. return "<div style='border: 3px solid red; padding: 1em; margin: 1em auto;'>$output</div>";