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