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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
<?php function ninja_forms_edit_field($field_id){ global $wpdb, $ninja_forms_fields;
do_action( 'ninja_forms_edit_field_before_li', $field_id ); do_action( 'ninja_forms_edit_field_li', $field_id ); do_action( 'ninja_forms_edit_field_after_li', $field_id );
}
function ninja_forms_edit_field_el_output($field_id, $type, $label = '', $name = '', $value = '', $width = 'wide', $options = '', $class = '', $desc = '', $label_class = '' ){ global $ninja_forms_fields, $nf_rte_editors;
$field_row = ninja_forms_get_field_by_id($field_id); $field_type = $field_row['type']; $reg_field = $ninja_forms_fields[$field_type];
$class = 'code ninja-forms-'.$field_type.'-'.$name.' '.$class; $id = 'ninja_forms_field_'.$field_id.'_'.$name; if ( strpos( $name, '[' ) !== false ) { str_replace( ']', '', $name ); $name = explode( '[', $name ); if ( is_array ( $name ) ) { $tmp_name = 'ninja_forms_field_'.$field_id; foreach ( $name as $n ) { $tmp_name .= '['.$n.']'; } $name = $tmp_name; } else { $name = 'ninja_forms_field_'.$field_id.'['.$name.']'; } } else { $name = 'ninja_forms_field_'.$field_id.'['.$name.']'; }
?> <div class="description description-<?php echo $width;?> <?php echo $type;?>" id="<?php echo $name;?>_p"> <?php if($type != 'rte'){ $value = ninja_forms_esc_html_deep( $value ); ?> <span class="field-option"> <?php } if($type != 'checkbox' AND $type != 'desc'){ ?> <label for="<?php echo $id;?>" id="<?php echo $id;?>_label" class="<?php echo $label_class;?>"> <?php _e( $label , 'ninja-forms'); ?></label><br/> <?php } switch($type){ case 'text': ?> <input type="text" class="<?php echo $class;?>" name="<?php echo $name;?>" id="<?php echo $id;?>" value="<?php echo $value;?>" /> <?php break; case 'number': ?> <input type="number" class="<?php echo $class;?>" name="<?php echo $name;?>" id="<?php echo $id;?>" value="<?php echo $value;?>" /> <?php break; case 'checkbox': ?> <label for="<?php echo $id;?>" id="<?php echo $id;?>_label"> <input type="hidden" value="0" name="<?php echo $name;?>"> <input type="checkbox" value="1" name="<?php echo $name;?>" id="<?php echo $id;?>" class="<?php echo $class;?>" <?php checked($value, 1);?>> <?php _e( $label , 'ninja-forms'); ?> </label> <?php break; case 'select': ?> <select id="<?php echo $id;?>" name="<?php echo $name;?>" class="<?php echo $class;?>"> <?php if(is_array($options) AND !empty($options)){ foreach($options as $opt){ ?> <option value="<?php echo $opt['value'];?>" <?php selected($opt['value'], $value); ?> ><?php _e( $opt['name'], 'ninja-forms'); ?></option> <?php } } ?> </select> <?php break; case 'multi': ?> <select multiple="multiple" id="<?php echo $id;?>" name="<?php echo $name;?>" class="<?php echo $class;?>"> <?php if(is_array($options) AND !empty($options)){ foreach($options as $opt){ ?> <option value="<?php echo $opt['value'];?>" <?php selected($opt['value'], $value); ?> ><?php _e( $opt['name'], 'ninja-forms'); ?></option> <?php } } ?> </select> <?php break; case 'textarea': ?> <textarea id="<?php echo $id;?>" name="<?php echo $name;?>" class="<?php echo $class;?>" rows="3" cols="20" ><?php echo $value;?></textarea> <?php break; case 'hidden': ?> <input type="hidden" name="<?php echo $name;?>" value="<?php echo $value;?>"> <?php break; case 'desc': ?> <span class="desc"><label for="<?php echo $id;?>" id="<?php echo $id;?>_label"><?php _e($label, 'ninja-forms'); ?></label></span> <?php break; case 'rte': $editor_id = str_replace( '[', '_', $name ); $editor_id = str_replace( ']', '', $editor_id ); $plugin_settings = nf_get_settings(); if ( !isset( $plugin_settings['version_2_2_25_rte_fix'] ) OR $plugin_settings['version_2_2_25_rte_fix'] == '' ) { $value = html_entity_decode( $value ); $plugin_settings['version_2_2_25_rte_fix'] = 1; update_option( 'ninja_forms_settings', $plugin_settings ); }
$args = apply_filters( 'ninja_forms_edit_field_rte', array( 'textarea_name' => $name ) ); wp_editor( $value, $editor_id, $args );
// If we're using ajax, add this editor ID to our global var so that we can instantiate it on the front-end. if ( isset ( $_POST['action'] ) && $_POST['action'] == 'ninja_forms_new_field' ) $nf_rte_editors[] = $editor_id;
break; }
if($desc != ''){ ?> <span class="description"> <?php _e($desc, 'ninja-forms'); ?> </span> <?php } if($type != 'rte'){ ?> </span> <?php } ?> </div> <?php }
|