/deprecated/classes/notification-success-message.php

  1. <?php if ( ! defined( 'ABSPATH' ) ) exit; 
  2. /** 
  3. * Class for our success message notification type. 
  4. * 
  5. * @package Ninja Forms 
  6. * @subpackage Classes/Notifications 
  7. * @copyright Copyright (c) 2014, WPNINJAS 
  8. * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License 
  9. * @since 2.8 
  10. */ 
  11.  
  12. class NF_Notification_Success_Message extends NF_Notification_Base_Type 
  13.  
  14. /** 
  15. * Get things rolling 
  16. */ 
  17. function __construct() { 
  18. $this->name = __( 'Success Message', 'ninja-forms' ); 
  19.  
  20. /** 
  21. * Output our edit screen 
  22. *  
  23. * @access public 
  24. * @since 2.8 
  25. * @return void 
  26. */ 
  27. public function edit_screen( $id = '' ) { 
  28. $settings = array( 
  29. 'textarea_name' => 'settings[success_msg]',  
  30. ); 
  31. $loc_opts = apply_filters( 'nf_success_message_locations',  
  32. array( 
  33. array( 'action' => 'ninja_forms_display_before_fields', 'name' => __( 'Before Form', 'ninja-forms' ) ),  
  34. array( 'action' => 'ninja_forms_display_after_fields', 'name' => __( 'After Form', 'ninja-forms' ) ),  
  35. ); 
  36. ?> 
  37. <!-- <tr> 
  38. <th scope="row"><label for="success_message_loc"><?php _e( 'Location', 'ninja-forms' ); ?></label></th> 
  39. <td> 
  40. <select name="settings[success_message_loc]"> 
  41. <?php 
  42. foreach ( $loc_opts as $opt ) { 
  43. ?> 
  44. <option value="<?php echo $opt['action'];?>" <?php selected( nf_get_object_meta_value( $id, 'success_message_loc' ), $opt['action'] ); ?>><?php echo $opt['name'];?></option> 
  45. <?php 
  46. ?> 
  47. </select> 
  48. </td> 
  49. </tr> --> 
  50. <tr> 
  51. <th scope="row"><label for="success_msg"><?php _e( 'Message', 'ninja-forms' ); ?></label></th> 
  52. <td> 
  53. <?php wp_editor( nf_get_object_meta_value( $id, 'success_msg' ), 'success_msg', $settings ); ?> 
  54. </td> 
  55. </tr> 
  56.  
  57. <?php 
  58.  
  59. /** 
  60. * Process our Success Message notification 
  61. *  
  62. * @access public 
  63. * @since 2.8 
  64. * @return void 
  65. */ 
  66. public function process( $id ) { 
  67. global $ninja_forms_processing; 
  68.  
  69. // We need to get our name setting so that we can use it to create a unique success message ID. 
  70. $name = Ninja_Forms()->notification( $id )->get_setting( 'name' ); 
  71. // If our name is empty, we need to generate a random string. 
  72. if ( empty ( $name ) ) { 
  73. $name = ninja_forms_random_string( 4 ); 
  74. $success_msg = apply_filters( 'nf_success_msg', Ninja_Forms()->notification( $id )->get_setting( 'success_msg' ), $id ); 
  75. $success_msg = do_shortcode( wpautop( $success_msg ) ); 
  76. $success_msg = nf_parse_fields_shortcode( $success_msg ); 
  77. $ninja_forms_processing->add_success_msg( 'success_msg-' . $name, $success_msg ); 
  78.  
  79. return new NF_Notification_Success_Message(); 
.