NF_Actions_SuccessMessage

Class NF_Action_SuccessMessage.

Defined (1)

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

/includes/Actions/SuccessMessage.php  
  1. final class NF_Actions_SuccessMessage extends NF_Abstracts_Action 
  2. /** 
  3. * @var string 
  4. */ 
  5. protected $_name = 'successmessage'; 
  6.  
  7. /** 
  8. * @var array 
  9. */ 
  10. protected $_tags = array(); 
  11.  
  12. /** 
  13. * @var string 
  14. */ 
  15. protected $_timing = 'late'; 
  16.  
  17. /** 
  18. * @var int 
  19. */ 
  20. protected $_priority = 10; 
  21.  
  22. /** 
  23. * Constructor 
  24. */ 
  25. public function __construct() 
  26. parent::__construct(); 
  27.  
  28. $this->_nicename = __( 'Success Message', 'ninja-forms' ); 
  29.  
  30. $settings = Ninja_Forms::config( 'ActionSuccessMessageSettings' ); 
  31.  
  32. $this->_settings = array_merge( $this->_settings, $settings ); 
  33.  
  34. add_action( 'nf_before_import_form', array( $this, 'import_form_action_success_message' ), 11 ); 
  35.  
  36. /** 
  37. * PUBLIC METHODS 
  38. */ 
  39.  
  40. public function save( $action_settings ) 
  41.  
  42.  
  43. public function process( $action_settings, $form_id, $data ) 
  44. if( isset( $action_settings[ 'success_msg' ] ) ) { 
  45.  
  46. if( ! isset( $data[ 'actions' ] ) || ! isset( $data[ 'actions' ][ 'success_message' ] ) ) { 
  47. $data[ 'actions' ][ 'success_message' ] = ''; 
  48.  
  49. ob_start(); 
  50. do_shortcode( $action_settings['success_msg'] ); 
  51. $ob = ob_get_clean(); 
  52.  
  53. if( $ob ) { 
  54. $data[ 'debug' ][ 'console' ][] = sprintf( __( 'Shortcodes should return and not echo, see: %s', 'ninja-forms' ), 'https://codex.wordpress.org/Shortcode_API#Output' ); 
  55. $data['actions']['success_message'] .= $action_settings['success_msg']; 
  56. } else { 
  57. $data['actions']['success_message'] .= do_shortcode( $action_settings['success_msg'] ); 
  58.  
  59. return $data; 
  60.  
  61. public function import_form_action_success_message( $import ) 
  62. if( ! isset( $import[ 'actions' ] ) ) return $import; 
  63.  
  64. foreach( $import[ 'actions' ] as &$action ) { 
  65.  
  66. if( 'success_message' == $action[ 'type' ] ) { 
  67.  
  68. $action[ 'type' ] = 'successmessage'; 
  69.  
  70. return $import;