@@ -2,132 +2,132 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmFieldsController { |
4 | 4 | |
5 | - public static function load_field() { |
|
6 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
5 | + public static function load_field() { |
|
6 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
7 | 7 | |
8 | - $fields = $_POST['field']; |
|
9 | - if ( empty( $fields ) ) { |
|
10 | - wp_die(); |
|
11 | - } |
|
8 | + $fields = $_POST['field']; |
|
9 | + if ( empty( $fields ) ) { |
|
10 | + wp_die(); |
|
11 | + } |
|
12 | 12 | |
13 | - $_GET['page'] = 'formidable'; |
|
14 | - $fields = stripslashes_deep( $fields ); |
|
13 | + $_GET['page'] = 'formidable'; |
|
14 | + $fields = stripslashes_deep( $fields ); |
|
15 | 15 | |
16 | - $ajax = true; |
|
16 | + $ajax = true; |
|
17 | 17 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
18 | - $path = FrmAppHelper::plugin_path(); |
|
19 | - $field_html = array(); |
|
20 | - |
|
21 | - foreach ( $fields as $field ) { |
|
22 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
23 | - $field = json_decode( $field, true ); |
|
24 | - if ( ! isset( $field['id'] ) ) { |
|
25 | - // this field may have already been loaded |
|
26 | - continue; |
|
27 | - } |
|
18 | + $path = FrmAppHelper::plugin_path(); |
|
19 | + $field_html = array(); |
|
20 | + |
|
21 | + foreach ( $fields as $field ) { |
|
22 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
23 | + $field = json_decode( $field, true ); |
|
24 | + if ( ! isset( $field['id'] ) ) { |
|
25 | + // this field may have already been loaded |
|
26 | + continue; |
|
27 | + } |
|
28 | 28 | |
29 | - $field_id = absint( $field['id'] ); |
|
29 | + $field_id = absint( $field['id'] ); |
|
30 | 30 | |
31 | - if ( ! isset( $field['value'] ) ) { |
|
32 | - $field['value'] = ''; |
|
33 | - } |
|
31 | + if ( ! isset( $field['value'] ) ) { |
|
32 | + $field['value'] = ''; |
|
33 | + } |
|
34 | 34 | |
35 | - $field_name = 'item_meta['. $field_id .']'; |
|
36 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
35 | + $field_name = 'item_meta['. $field_id .']'; |
|
36 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
37 | 37 | |
38 | - ob_start(); |
|
39 | - include($path .'/classes/views/frm-forms/add_field.php'); |
|
40 | - $field_html[ $field_id ] = ob_get_contents(); |
|
41 | - ob_end_clean(); |
|
42 | - } |
|
38 | + ob_start(); |
|
39 | + include($path .'/classes/views/frm-forms/add_field.php'); |
|
40 | + $field_html[ $field_id ] = ob_get_contents(); |
|
41 | + ob_end_clean(); |
|
42 | + } |
|
43 | 43 | |
44 | - unset($path); |
|
44 | + unset($path); |
|
45 | 45 | |
46 | - echo json_encode($field_html); |
|
46 | + echo json_encode($field_html); |
|
47 | 47 | |
48 | - wp_die(); |
|
49 | - } |
|
48 | + wp_die(); |
|
49 | + } |
|
50 | 50 | |
51 | - public static function create() { |
|
52 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
51 | + public static function create() { |
|
52 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
53 | 53 | |
54 | 54 | $field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' ); |
55 | 55 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
56 | 56 | |
57 | - $field = self::include_new_field($field_type, $form_id); |
|
57 | + $field = self::include_new_field($field_type, $form_id); |
|
58 | 58 | |
59 | - // this hook will allow for multiple fields to be added at once |
|
60 | - do_action('frm_after_field_created', $field, $form_id); |
|
59 | + // this hook will allow for multiple fields to be added at once |
|
60 | + do_action('frm_after_field_created', $field, $form_id); |
|
61 | 61 | |
62 | - wp_die(); |
|
63 | - } |
|
62 | + wp_die(); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @param integer $form_id |
|
67 | - */ |
|
65 | + /** |
|
66 | + * @param integer $form_id |
|
67 | + */ |
|
68 | 68 | public static function include_new_field( $field_type, $form_id ) { |
69 | - $values = array(); |
|
70 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
71 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
72 | - } |
|
69 | + $values = array(); |
|
70 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
71 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
72 | + } |
|
73 | 73 | |
74 | - $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
75 | - $field_id = FrmField::create( $field_values ); |
|
74 | + $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
75 | + $field_id = FrmField::create( $field_values ); |
|
76 | 76 | |
77 | - if ( ! $field_id ) { |
|
78 | - return false; |
|
79 | - } |
|
77 | + if ( ! $field_id ) { |
|
78 | + return false; |
|
79 | + } |
|
80 | 80 | |
81 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
81 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
82 | 82 | |
83 | - return $field; |
|
84 | - } |
|
83 | + return $field; |
|
84 | + } |
|
85 | 85 | |
86 | - public static function update_form_id() { |
|
87 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
86 | + public static function update_form_id() { |
|
87 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
88 | 88 | |
89 | 89 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
90 | 90 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
91 | 91 | |
92 | - if ( ! $field_id || ! $form_id ) { |
|
93 | - wp_die(); |
|
94 | - } |
|
92 | + if ( ! $field_id || ! $form_id ) { |
|
93 | + wp_die(); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | $updated = FrmField::update( $field_id, compact( 'form_id' ) ); |
97 | 97 | echo absint( $updated ); |
98 | 98 | |
99 | - wp_die(); |
|
100 | - } |
|
99 | + wp_die(); |
|
100 | + } |
|
101 | 101 | |
102 | 102 | public static function edit_name( $field = 'name', $id = '' ) { |
103 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
103 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
104 | 104 | |
105 | - if ( empty($field) ) { |
|
106 | - $field = 'name'; |
|
107 | - } |
|
105 | + if ( empty($field) ) { |
|
106 | + $field = 'name'; |
|
107 | + } |
|
108 | 108 | |
109 | - if ( empty($id) ) { |
|
109 | + if ( empty($id) ) { |
|
110 | 110 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
111 | 111 | $id = str_replace( 'field_label_', '', $id ); |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | 114 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
115 | 115 | $value = trim( $value ); |
116 | - if ( trim(strip_tags($value)) == '' ) { |
|
117 | - // set blank value if there is no content |
|
118 | - $value = ''; |
|
119 | - } |
|
116 | + if ( trim(strip_tags($value)) == '' ) { |
|
117 | + // set blank value if there is no content |
|
118 | + $value = ''; |
|
119 | + } |
|
120 | 120 | |
121 | 121 | FrmField::update( $id, array( $field => $value ) ); |
122 | 122 | |
123 | 123 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
124 | 124 | |
125 | 125 | echo stripslashes( wp_kses_post( $value ) ); |
126 | - wp_die(); |
|
127 | - } |
|
126 | + wp_die(); |
|
127 | + } |
|
128 | 128 | |
129 | - public static function update_ajax_option() { |
|
130 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
129 | + public static function update_ajax_option() { |
|
130 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
131 | 131 | |
132 | 132 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
133 | 133 | if ( ! $field_id ) { |
@@ -137,151 +137,151 @@ discard block |
||
137 | 137 | $field = FrmField::getOne( $field_id ); |
138 | 138 | |
139 | 139 | foreach ( array( 'clear_on_focus', 'separate_value', 'default_blank' ) as $val ) { |
140 | - if ( isset($_POST[ $val ]) ) { |
|
140 | + if ( isset($_POST[ $val ]) ) { |
|
141 | 141 | // all three of these options are boolean |
142 | 142 | $new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' ); |
143 | 143 | |
144 | - if ( $val == 'separate_value' ) { |
|
144 | + if ( $val == 'separate_value' ) { |
|
145 | 145 | $new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1; |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - $field->field_options[ $val ] = $new_val; |
|
149 | - unset($new_val); |
|
150 | - } |
|
151 | - unset($val); |
|
152 | - } |
|
148 | + $field->field_options[ $val ] = $new_val; |
|
149 | + unset($new_val); |
|
150 | + } |
|
151 | + unset($val); |
|
152 | + } |
|
153 | 153 | |
154 | - FrmField::update( $field_id, array( |
|
155 | - 'field_options' => $field->field_options, |
|
154 | + FrmField::update( $field_id, array( |
|
155 | + 'field_options' => $field->field_options, |
|
156 | 156 | 'form_id' => $field->form_id, |
157 | - ) ); |
|
158 | - wp_die(); |
|
159 | - } |
|
157 | + ) ); |
|
158 | + wp_die(); |
|
159 | + } |
|
160 | 160 | |
161 | - public static function duplicate() { |
|
162 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
161 | + public static function duplicate() { |
|
162 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
163 | 163 | |
164 | - global $wpdb; |
|
164 | + global $wpdb; |
|
165 | 165 | |
166 | 166 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
167 | 167 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
168 | 168 | |
169 | 169 | $copy_field = FrmField::getOne( $field_id ); |
170 | - if ( ! $copy_field ) { |
|
171 | - wp_die(); |
|
172 | - } |
|
170 | + if ( ! $copy_field ) { |
|
171 | + wp_die(); |
|
172 | + } |
|
173 | 173 | |
174 | - do_action('frm_duplicate_field', $copy_field, $form_id); |
|
175 | - do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
174 | + do_action('frm_duplicate_field', $copy_field, $form_id); |
|
175 | + do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
176 | 176 | |
177 | - $values = array( 'id' => $form_id ); |
|
178 | - FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
177 | + $values = array( 'id' => $form_id ); |
|
178 | + FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
179 | 179 | |
180 | 180 | $field_count = FrmDb::get_count( $wpdb->prefix .'frm_fields fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
181 | 181 | |
182 | - $values['field_order'] = $field_count + 1; |
|
182 | + $values['field_order'] = $field_count + 1; |
|
183 | 183 | |
184 | - if ( ! $field_id = FrmField::create($values) ) { |
|
185 | - wp_die(); |
|
186 | - } |
|
184 | + if ( ! $field_id = FrmField::create($values) ) { |
|
185 | + wp_die(); |
|
186 | + } |
|
187 | 187 | |
188 | - self::include_single_field($field_id, $values); |
|
188 | + self::include_single_field($field_id, $values); |
|
189 | 189 | |
190 | - wp_die(); |
|
191 | - } |
|
190 | + wp_die(); |
|
191 | + } |
|
192 | 192 | |
193 | - /** |
|
194 | - * Load a single field in the form builder along with all needed variables |
|
195 | - */ |
|
196 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
197 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
198 | - $field_name = 'item_meta['. $field_id .']'; |
|
199 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
200 | - $id = $form_id ? $form_id : $field['form_id']; |
|
201 | - if ( $field['type'] == 'html' ) { |
|
202 | - $field['stop_filter'] = true; |
|
203 | - } |
|
193 | + /** |
|
194 | + * Load a single field in the form builder along with all needed variables |
|
195 | + */ |
|
196 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
197 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
198 | + $field_name = 'item_meta['. $field_id .']'; |
|
199 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
200 | + $id = $form_id ? $form_id : $field['form_id']; |
|
201 | + if ( $field['type'] == 'html' ) { |
|
202 | + $field['stop_filter'] = true; |
|
203 | + } |
|
204 | 204 | |
205 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
205 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
206 | 206 | |
207 | - return $field; |
|
208 | - } |
|
207 | + return $field; |
|
208 | + } |
|
209 | 209 | |
210 | - public static function destroy() { |
|
211 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
210 | + public static function destroy() { |
|
211 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
212 | 212 | |
213 | 213 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
214 | 214 | FrmField::destroy( $field_id ); |
215 | - wp_die(); |
|
216 | - } |
|
215 | + wp_die(); |
|
216 | + } |
|
217 | 217 | |
218 | - /* Field Options */ |
|
218 | + /* Field Options */ |
|
219 | 219 | |
220 | - //Add Single Option or Other Option |
|
221 | - public static function add_option() { |
|
222 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
220 | + //Add Single Option or Other Option |
|
221 | + public static function add_option() { |
|
222 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
223 | 223 | |
224 | 224 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
225 | 225 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
226 | 226 | |
227 | - //Get the field |
|
228 | - $field = FrmField::getOne($id); |
|
227 | + //Get the field |
|
228 | + $field = FrmField::getOne($id); |
|
229 | 229 | |
230 | 230 | if ( ! empty( $field->options ) ) { |
231 | 231 | $keys = array_keys( $field->options ); |
232 | - $last = str_replace( 'other_', '', end( $keys ) ); |
|
233 | - } else { |
|
234 | - $last = 0; |
|
235 | - } |
|
236 | - $opt_key = $last + 1; |
|
232 | + $last = str_replace( 'other_', '', end( $keys ) ); |
|
233 | + } else { |
|
234 | + $last = 0; |
|
235 | + } |
|
236 | + $opt_key = $last + 1; |
|
237 | 237 | |
238 | - if ( 'other' == $opt_type ) { |
|
238 | + if ( 'other' == $opt_type ) { |
|
239 | 239 | $opt = esc_html__( 'Other', 'formidable' ); |
240 | - $other_val = ''; |
|
241 | - $opt_key = 'other_' . $opt_key; |
|
242 | - |
|
243 | - //Update value of "other" in DB |
|
244 | - $field_options = maybe_unserialize( $field->field_options ); |
|
245 | - $field_options['other'] = 1; |
|
246 | - FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
247 | - } else { |
|
240 | + $other_val = ''; |
|
241 | + $opt_key = 'other_' . $opt_key; |
|
242 | + |
|
243 | + //Update value of "other" in DB |
|
244 | + $field_options = maybe_unserialize( $field->field_options ); |
|
245 | + $field_options['other'] = 1; |
|
246 | + FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
247 | + } else { |
|
248 | 248 | $first_opt = reset( $field->options ); |
249 | 249 | $next_opt = count( $field->options ); |
250 | - if ( $first_opt != '' ) { |
|
251 | - $next_opt++; |
|
252 | - } |
|
253 | - $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
254 | - unset($next_opt); |
|
255 | - } |
|
256 | - $field_val = $opt; |
|
250 | + if ( $first_opt != '' ) { |
|
251 | + $next_opt++; |
|
252 | + } |
|
253 | + $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
254 | + unset($next_opt); |
|
255 | + } |
|
256 | + $field_val = $opt; |
|
257 | 257 | $field->options[ $opt_key ] = $opt; |
258 | 258 | |
259 | - //Update options in DB |
|
259 | + //Update options in DB |
|
260 | 260 | FrmField::update( $id, array( 'options' => $field->options ) ); |
261 | 261 | |
262 | - $field_data = $field; |
|
263 | - $field = array( |
|
264 | - 'type' => $field_data->type, |
|
265 | - 'id' => $id, |
|
266 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
267 | - 'form_id' => $field_data->form_id, |
|
268 | - 'field_key' => $field_data->field_key, |
|
269 | - ); |
|
270 | - |
|
271 | - $field_name = 'item_meta['. $id .']'; |
|
272 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
273 | - $checked = ''; |
|
274 | - |
|
275 | - if ( 'other' == $opt_type ) { |
|
276 | - require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
277 | - } else { |
|
278 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
279 | - } |
|
280 | - wp_die(); |
|
281 | - } |
|
282 | - |
|
283 | - public static function edit_option() { |
|
284 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
262 | + $field_data = $field; |
|
263 | + $field = array( |
|
264 | + 'type' => $field_data->type, |
|
265 | + 'id' => $id, |
|
266 | + 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
267 | + 'form_id' => $field_data->form_id, |
|
268 | + 'field_key' => $field_data->field_key, |
|
269 | + ); |
|
270 | + |
|
271 | + $field_name = 'item_meta['. $id .']'; |
|
272 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
273 | + $checked = ''; |
|
274 | + |
|
275 | + if ( 'other' == $opt_type ) { |
|
276 | + require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
277 | + } else { |
|
278 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
279 | + } |
|
280 | + wp_die(); |
|
281 | + } |
|
282 | + |
|
283 | + public static function edit_option() { |
|
284 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
285 | 285 | |
286 | 286 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
287 | 287 | $ids = explode( '-', $element_id ); |
@@ -289,42 +289,42 @@ discard block |
||
289 | 289 | |
290 | 290 | $orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value' ) ); |
291 | 291 | if ( strpos( $element_id, 'key_' ) ) { |
292 | - $new_value = $update_value; |
|
293 | - } else { |
|
294 | - $new_label = $update_value; |
|
295 | - } |
|
292 | + $new_value = $update_value; |
|
293 | + } else { |
|
294 | + $new_label = $update_value; |
|
295 | + } |
|
296 | 296 | |
297 | - $field = FrmField::getOne($id); |
|
298 | - $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
297 | + $field = FrmField::getOne($id); |
|
298 | + $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
299 | 299 | |
300 | - $this_opt_id = end($ids); |
|
300 | + $this_opt_id = end($ids); |
|
301 | 301 | $this_opt = (array) $field->options[ $this_opt_id ]; |
302 | - $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ? true : false ); |
|
302 | + $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ? true : false ); |
|
303 | 303 | |
304 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
305 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
304 | + $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
305 | + $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
306 | 306 | |
307 | - if ( ! isset( $new_label ) ) { |
|
308 | - $new_label = $label; |
|
309 | - } |
|
307 | + if ( ! isset( $new_label ) ) { |
|
308 | + $new_label = $label; |
|
309 | + } |
|
310 | 310 | |
311 | - if ( isset($new_value) || isset($value) ) { |
|
312 | - $update_value = isset($new_value) ? $new_value : $value; |
|
313 | - } |
|
311 | + if ( isset($new_value) || isset($value) ) { |
|
312 | + $update_value = isset($new_value) ? $new_value : $value; |
|
313 | + } |
|
314 | 314 | |
315 | 315 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
316 | 316 | $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
317 | - } else { |
|
317 | + } else { |
|
318 | 318 | $field->options[ $this_opt_id ] = $orig_update_value; |
319 | - } |
|
319 | + } |
|
320 | 320 | |
321 | 321 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
322 | 322 | echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value ); |
323 | - wp_die(); |
|
324 | - } |
|
323 | + wp_die(); |
|
324 | + } |
|
325 | 325 | |
326 | - public static function delete_option() { |
|
327 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
326 | + public static function delete_option() { |
|
327 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
328 | 328 | |
329 | 329 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
330 | 330 | $field = FrmField::getOne( $field_id ); |
@@ -332,339 +332,339 @@ discard block |
||
332 | 332 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
333 | 333 | |
334 | 334 | $options = $field->options; |
335 | - unset( $options[ $opt_key ] ); |
|
336 | - $response = array( 'other' => true ); |
|
335 | + unset( $options[ $opt_key ] ); |
|
336 | + $response = array( 'other' => true ); |
|
337 | 337 | |
338 | - //If the deleted option is an "other" option |
|
338 | + //If the deleted option is an "other" option |
|
339 | 339 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
340 | - //Assume all other options are gone, unless proven otherwise |
|
341 | - $other = false; |
|
340 | + //Assume all other options are gone, unless proven otherwise |
|
341 | + $other = false; |
|
342 | 342 | |
343 | - //Check if all other options are really gone |
|
344 | - foreach ( $options as $o_key => $o_val ) { |
|
345 | - //If there is still an other option in the field, set other to true |
|
343 | + //Check if all other options are really gone |
|
344 | + foreach ( $options as $o_key => $o_val ) { |
|
345 | + //If there is still an other option in the field, set other to true |
|
346 | 346 | if ( FrmFieldsHelper::is_other_opt( $o_key ) ) { |
347 | - $other = true; |
|
348 | - break; |
|
349 | - } |
|
350 | - unset( $o_key, $o_val ); |
|
351 | - } |
|
352 | - |
|
353 | - //If all other options are gone |
|
354 | - if ( false === $other ) { |
|
355 | - $field_options = maybe_unserialize( $field->field_options ); |
|
356 | - $field_options['other'] = 0; |
|
347 | + $other = true; |
|
348 | + break; |
|
349 | + } |
|
350 | + unset( $o_key, $o_val ); |
|
351 | + } |
|
352 | + |
|
353 | + //If all other options are gone |
|
354 | + if ( false === $other ) { |
|
355 | + $field_options = maybe_unserialize( $field->field_options ); |
|
356 | + $field_options['other'] = 0; |
|
357 | 357 | FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
358 | - $response = array( 'other' => false ); |
|
359 | - } |
|
360 | - } |
|
361 | - echo json_encode( $response ); |
|
358 | + $response = array( 'other' => false ); |
|
359 | + } |
|
360 | + } |
|
361 | + echo json_encode( $response ); |
|
362 | 362 | |
363 | 363 | FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) ); |
364 | 364 | |
365 | - wp_die(); |
|
366 | - } |
|
365 | + wp_die(); |
|
366 | + } |
|
367 | 367 | |
368 | - public static function import_choices() { |
|
369 | - if ( ! current_user_can( 'frm_edit_forms' ) ) { |
|
370 | - wp_die(); |
|
371 | - } |
|
368 | + public static function import_choices() { |
|
369 | + if ( ! current_user_can( 'frm_edit_forms' ) ) { |
|
370 | + wp_die(); |
|
371 | + } |
|
372 | 372 | |
373 | 373 | $field_id = absint( $_REQUEST['field_id'] ); |
374 | 374 | |
375 | - global $current_screen, $hook_suffix; |
|
375 | + global $current_screen, $hook_suffix; |
|
376 | 376 | |
377 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
378 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
379 | - $hook_suffix = ''; |
|
380 | - set_current_screen(); |
|
381 | - } |
|
377 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
378 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
379 | + $hook_suffix = ''; |
|
380 | + set_current_screen(); |
|
381 | + } |
|
382 | 382 | |
383 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
384 | - register_admin_color_schemes(); |
|
385 | - } |
|
383 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
384 | + register_admin_color_schemes(); |
|
385 | + } |
|
386 | 386 | |
387 | - $hook_suffix = $admin_body_class = ''; |
|
387 | + $hook_suffix = $admin_body_class = ''; |
|
388 | 388 | |
389 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
390 | - $admin_body_class .= ' folded'; |
|
391 | - } |
|
389 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
390 | + $admin_body_class .= ' folded'; |
|
391 | + } |
|
392 | 392 | |
393 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
394 | - $admin_body_class .= ' admin-bar'; |
|
395 | - } |
|
393 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
394 | + $admin_body_class .= ' admin-bar'; |
|
395 | + } |
|
396 | 396 | |
397 | - if ( is_rtl() ) { |
|
398 | - $admin_body_class .= ' rtl'; |
|
399 | - } |
|
397 | + if ( is_rtl() ) { |
|
398 | + $admin_body_class .= ' rtl'; |
|
399 | + } |
|
400 | 400 | |
401 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
402 | - $prepop = array(); |
|
403 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
401 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
402 | + $prepop = array(); |
|
403 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
404 | 404 | |
405 | - $field = FrmField::getOne($field_id); |
|
405 | + $field = FrmField::getOne($field_id); |
|
406 | 406 | |
407 | - wp_enqueue_script( 'utils' ); |
|
408 | - wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
409 | - FrmAppHelper::load_admin_wide_js(); |
|
407 | + wp_enqueue_script( 'utils' ); |
|
408 | + wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
409 | + FrmAppHelper::load_admin_wide_js(); |
|
410 | 410 | |
411 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
412 | - wp_die(); |
|
413 | - } |
|
411 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
412 | + wp_die(); |
|
413 | + } |
|
414 | 414 | |
415 | - public static function import_options() { |
|
416 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
415 | + public static function import_options() { |
|
416 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
417 | 417 | |
418 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
419 | - return; |
|
420 | - } |
|
418 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
419 | + return; |
|
420 | + } |
|
421 | 421 | |
422 | 422 | $field_id = absint( $_POST['field_id'] ); |
423 | - $field = FrmField::getOne($field_id); |
|
423 | + $field = FrmField::getOne($field_id); |
|
424 | 424 | |
425 | 425 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
426 | - return; |
|
427 | - } |
|
428 | - |
|
429 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
430 | - $opts = stripslashes_deep($_POST['opts']); |
|
431 | - $opts = explode("\n", rtrim($opts, "\n")); |
|
432 | - if ( $field['separate_value'] ) { |
|
433 | - foreach ( $opts as $opt_key => $opt ) { |
|
434 | - if ( strpos($opt, '|') !== false ) { |
|
435 | - $vals = explode('|', $opt); |
|
436 | - if ( $vals[0] != $vals[1] ) { |
|
437 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
438 | - } |
|
439 | - unset($vals); |
|
440 | - } |
|
441 | - unset($opt_key, $opt); |
|
442 | - } |
|
443 | - } |
|
444 | - |
|
445 | - //Keep other options after bulk update |
|
446 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
447 | - $other_array = array(); |
|
448 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
449 | - if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
450 | - $other_array[ $opt_key ] = $opt; |
|
451 | - } |
|
452 | - unset($opt_key, $opt); |
|
453 | - } |
|
454 | - if ( ! empty($other_array) ) { |
|
455 | - $opts = array_merge( $opts, $other_array); |
|
456 | - } |
|
457 | - } |
|
458 | - |
|
459 | - FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
460 | - |
|
461 | - $field['options'] = $opts; |
|
462 | - $field_name = $field['name']; |
|
463 | - |
|
464 | - // Get html_id which will be used in single-option.php |
|
465 | - $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
466 | - |
|
467 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
468 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
469 | - } else { |
|
470 | - FrmFieldsHelper::show_single_option($field); |
|
471 | - } |
|
472 | - |
|
473 | - wp_die(); |
|
474 | - } |
|
475 | - |
|
476 | - public static function update_order() { |
|
477 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
426 | + return; |
|
427 | + } |
|
428 | + |
|
429 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
430 | + $opts = stripslashes_deep($_POST['opts']); |
|
431 | + $opts = explode("\n", rtrim($opts, "\n")); |
|
432 | + if ( $field['separate_value'] ) { |
|
433 | + foreach ( $opts as $opt_key => $opt ) { |
|
434 | + if ( strpos($opt, '|') !== false ) { |
|
435 | + $vals = explode('|', $opt); |
|
436 | + if ( $vals[0] != $vals[1] ) { |
|
437 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
438 | + } |
|
439 | + unset($vals); |
|
440 | + } |
|
441 | + unset($opt_key, $opt); |
|
442 | + } |
|
443 | + } |
|
444 | + |
|
445 | + //Keep other options after bulk update |
|
446 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
447 | + $other_array = array(); |
|
448 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
449 | + if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
450 | + $other_array[ $opt_key ] = $opt; |
|
451 | + } |
|
452 | + unset($opt_key, $opt); |
|
453 | + } |
|
454 | + if ( ! empty($other_array) ) { |
|
455 | + $opts = array_merge( $opts, $other_array); |
|
456 | + } |
|
457 | + } |
|
458 | + |
|
459 | + FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
460 | + |
|
461 | + $field['options'] = $opts; |
|
462 | + $field_name = $field['name']; |
|
463 | + |
|
464 | + // Get html_id which will be used in single-option.php |
|
465 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
466 | + |
|
467 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
468 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
469 | + } else { |
|
470 | + FrmFieldsHelper::show_single_option($field); |
|
471 | + } |
|
472 | + |
|
473 | + wp_die(); |
|
474 | + } |
|
475 | + |
|
476 | + public static function update_order() { |
|
477 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
478 | 478 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
479 | 479 | foreach ( (array) $fields as $position => $item ) { |
480 | 480 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
481 | 481 | } |
482 | - wp_die(); |
|
483 | - } |
|
482 | + wp_die(); |
|
483 | + } |
|
484 | 484 | |
485 | 485 | public static function change_type( $type ) { |
486 | - $type_switch = array( |
|
487 | - 'scale' => 'radio', |
|
488 | - '10radio' => 'radio', |
|
489 | - 'rte' => 'textarea', |
|
490 | - 'website' => 'url', |
|
491 | - ); |
|
492 | - if ( isset( $type_switch[ $type ] ) ) { |
|
493 | - $type = $type_switch[ $type ]; |
|
494 | - } |
|
486 | + $type_switch = array( |
|
487 | + 'scale' => 'radio', |
|
488 | + '10radio' => 'radio', |
|
489 | + 'rte' => 'textarea', |
|
490 | + 'website' => 'url', |
|
491 | + ); |
|
492 | + if ( isset( $type_switch[ $type ] ) ) { |
|
493 | + $type = $type_switch[ $type ]; |
|
494 | + } |
|
495 | 495 | |
496 | 496 | $frm_field_selection = FrmField::field_selection(); |
497 | - $types = array_keys($frm_field_selection); |
|
498 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
499 | - $type = 'text'; |
|
500 | - } |
|
497 | + $types = array_keys($frm_field_selection); |
|
498 | + if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
499 | + $type = 'text'; |
|
500 | + } |
|
501 | 501 | |
502 | - return $type; |
|
503 | - } |
|
502 | + return $type; |
|
503 | + } |
|
504 | 504 | |
505 | 505 | public static function display_field_options( $display ) { |
506 | 506 | switch ( $display['type'] ) { |
507 | - case 'captcha': |
|
508 | - $display['required'] = false; |
|
509 | - $display['invalid'] = true; |
|
510 | - $display['default_blank'] = false; |
|
507 | + case 'captcha': |
|
508 | + $display['required'] = false; |
|
509 | + $display['invalid'] = true; |
|
510 | + $display['default_blank'] = false; |
|
511 | 511 | $display['captcha_size'] = true; |
512 | - break; |
|
513 | - case 'radio': |
|
514 | - $display['default_blank'] = false; |
|
515 | - break; |
|
516 | - case 'text': |
|
517 | - case 'textarea': |
|
518 | - $display['size'] = true; |
|
519 | - $display['clear_on_focus'] = true; |
|
520 | - break; |
|
521 | - case 'select': |
|
522 | - $display['size'] = true; |
|
523 | - break; |
|
524 | - case 'url': |
|
525 | - case 'website': |
|
526 | - case 'email': |
|
527 | - $display['size'] = true; |
|
528 | - $display['clear_on_focus'] = true; |
|
529 | - $display['invalid'] = true; |
|
530 | - } |
|
531 | - |
|
532 | - return $display; |
|
533 | - } |
|
534 | - |
|
535 | - public static function input_html( $field, $echo = true ) { |
|
536 | - $class = array(); //$field['type']; |
|
537 | - self::add_input_classes($field, $class); |
|
538 | - |
|
539 | - $add_html = array(); |
|
540 | - self::add_html_size($field, $add_html); |
|
541 | - self::add_html_length($field, $add_html); |
|
542 | - self::add_html_placeholder($field, $add_html, $class); |
|
512 | + break; |
|
513 | + case 'radio': |
|
514 | + $display['default_blank'] = false; |
|
515 | + break; |
|
516 | + case 'text': |
|
517 | + case 'textarea': |
|
518 | + $display['size'] = true; |
|
519 | + $display['clear_on_focus'] = true; |
|
520 | + break; |
|
521 | + case 'select': |
|
522 | + $display['size'] = true; |
|
523 | + break; |
|
524 | + case 'url': |
|
525 | + case 'website': |
|
526 | + case 'email': |
|
527 | + $display['size'] = true; |
|
528 | + $display['clear_on_focus'] = true; |
|
529 | + $display['invalid'] = true; |
|
530 | + } |
|
531 | + |
|
532 | + return $display; |
|
533 | + } |
|
534 | + |
|
535 | + public static function input_html( $field, $echo = true ) { |
|
536 | + $class = array(); //$field['type']; |
|
537 | + self::add_input_classes($field, $class); |
|
538 | + |
|
539 | + $add_html = array(); |
|
540 | + self::add_html_size($field, $add_html); |
|
541 | + self::add_html_length($field, $add_html); |
|
542 | + self::add_html_placeholder($field, $add_html, $class); |
|
543 | 543 | self::add_validation_messages( $field, $add_html ); |
544 | 544 | |
545 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
545 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
546 | 546 | |
547 | 547 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
548 | 548 | |
549 | - self::add_shortcodes_to_html($field, $add_html); |
|
549 | + self::add_shortcodes_to_html($field, $add_html); |
|
550 | 550 | |
551 | 551 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
552 | 552 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
553 | 553 | |
554 | - if ( $echo ) { |
|
555 | - echo $add_html; |
|
556 | - } |
|
554 | + if ( $echo ) { |
|
555 | + echo $add_html; |
|
556 | + } |
|
557 | 557 | |
558 | - return $add_html; |
|
559 | - } |
|
558 | + return $add_html; |
|
559 | + } |
|
560 | 560 | |
561 | 561 | private static function add_input_classes( $field, array &$class ) { |
562 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
563 | - $class[] = $field['input_class']; |
|
564 | - } |
|
562 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
563 | + $class[] = $field['input_class']; |
|
564 | + } |
|
565 | 565 | |
566 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
567 | - return; |
|
568 | - } |
|
566 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
567 | + return; |
|
568 | + } |
|
569 | 569 | |
570 | - global $frm_vars; |
|
570 | + global $frm_vars; |
|
571 | 571 | if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) { |
572 | - $class[] = 'dyn_default_value'; |
|
573 | - } |
|
572 | + $class[] = 'dyn_default_value'; |
|
573 | + } |
|
574 | 574 | |
575 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
576 | - $class[] = 'auto_width'; |
|
577 | - } |
|
578 | - } |
|
575 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
576 | + $class[] = 'auto_width'; |
|
577 | + } |
|
578 | + } |
|
579 | 579 | |
580 | 580 | private static function add_html_size( $field, array &$add_html ) { |
581 | 581 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) { |
582 | - return; |
|
583 | - } |
|
582 | + return; |
|
583 | + } |
|
584 | 584 | |
585 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
586 | - return; |
|
587 | - } |
|
585 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
586 | + return; |
|
587 | + } |
|
588 | 588 | |
589 | - if ( is_numeric($field['size']) ) { |
|
590 | - $field['size'] .= 'px'; |
|
591 | - } |
|
589 | + if ( is_numeric($field['size']) ) { |
|
590 | + $field['size'] .= 'px'; |
|
591 | + } |
|
592 | 592 | |
593 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
594 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
595 | - $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
593 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
594 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
595 | + $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
596 | 596 | |
597 | - self::add_html_cols($field, $add_html); |
|
598 | - } |
|
597 | + self::add_html_cols($field, $add_html); |
|
598 | + } |
|
599 | 599 | |
600 | 600 | private static function add_html_cols( $field, array &$add_html ) { |
601 | 601 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
602 | - return; |
|
603 | - } |
|
602 | + return; |
|
603 | + } |
|
604 | 604 | |
605 | - // convert to cols for textareas |
|
606 | - $calc = array( |
|
607 | - '' => 9, |
|
608 | - 'px' => 9, |
|
609 | - 'rem' => 0.444, |
|
610 | - 'em' => 0.544, |
|
611 | - ); |
|
605 | + // convert to cols for textareas |
|
606 | + $calc = array( |
|
607 | + '' => 9, |
|
608 | + 'px' => 9, |
|
609 | + 'rem' => 0.444, |
|
610 | + 'em' => 0.544, |
|
611 | + ); |
|
612 | 612 | |
613 | - // include "col" for valid html |
|
614 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
613 | + // include "col" for valid html |
|
614 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
615 | 615 | |
616 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
617 | - return; |
|
618 | - } |
|
616 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
617 | + return; |
|
618 | + } |
|
619 | 619 | |
620 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
620 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
621 | 621 | |
622 | 622 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
623 | - } |
|
623 | + } |
|
624 | 624 | |
625 | 625 | private static function add_html_length( $field, array &$add_html ) { |
626 | - // check for max setting and if this field accepts maxlength |
|
626 | + // check for max setting and if this field accepts maxlength |
|
627 | 627 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) { |
628 | - return; |
|
629 | - } |
|
628 | + return; |
|
629 | + } |
|
630 | 630 | |
631 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
632 | - // don't load on form builder page |
|
633 | - return; |
|
634 | - } |
|
631 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
632 | + // don't load on form builder page |
|
633 | + return; |
|
634 | + } |
|
635 | 635 | |
636 | 636 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
637 | - } |
|
637 | + } |
|
638 | 638 | |
639 | 639 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
640 | 640 | if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) { |
641 | 641 | return; |
642 | 642 | } |
643 | 643 | |
644 | - if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
644 | + if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
645 | 645 | if ( is_array( $field['default_value'] ) ) { |
646 | 646 | $field['default_value'] = json_encode( $field['default_value'] ); |
647 | 647 | } |
648 | 648 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"'; |
649 | - return; |
|
650 | - } |
|
649 | + return; |
|
650 | + } |
|
651 | 651 | |
652 | - $frm_settings = FrmAppHelper::get_settings(); |
|
652 | + $frm_settings = FrmAppHelper::get_settings(); |
|
653 | 653 | |
654 | 654 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
655 | - // use HMTL5 placeholder with js fallback |
|
656 | - $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
657 | - wp_enqueue_script('jquery-placeholder'); |
|
658 | - } else if ( ! $frm_settings->use_html ) { |
|
655 | + // use HMTL5 placeholder with js fallback |
|
656 | + $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
657 | + wp_enqueue_script('jquery-placeholder'); |
|
658 | + } else if ( ! $frm_settings->use_html ) { |
|
659 | 659 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
660 | - $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
661 | - $class[] = 'frm_toggle_default'; |
|
660 | + $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
661 | + $class[] = 'frm_toggle_default'; |
|
662 | 662 | |
663 | - if ( $field['value'] == $field['default_value'] ) { |
|
664 | - $class[] = 'frm_default'; |
|
665 | - } |
|
666 | - } |
|
667 | - } |
|
663 | + if ( $field['value'] == $field['default_value'] ) { |
|
664 | + $class[] = 'frm_default'; |
|
665 | + } |
|
666 | + } |
|
667 | + } |
|
668 | 668 | |
669 | 669 | private static function add_validation_messages( $field, array &$add_html ) { |
670 | 670 | if ( FrmField::is_required( $field ) ) { |
@@ -685,50 +685,50 @@ discard block |
||
685 | 685 | } |
686 | 686 | } |
687 | 687 | |
688 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
689 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
690 | - return; |
|
691 | - } |
|
692 | - |
|
693 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
694 | - if ( 'opt' === $k ) { |
|
695 | - continue; |
|
696 | - } |
|
697 | - |
|
698 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
699 | - $add_html[] = $v; |
|
700 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
701 | - $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
702 | - } else { |
|
688 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
689 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
690 | + return; |
|
691 | + } |
|
692 | + |
|
693 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
694 | + if ( 'opt' === $k ) { |
|
695 | + continue; |
|
696 | + } |
|
697 | + |
|
698 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
699 | + $add_html[] = $v; |
|
700 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
701 | + $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
702 | + } else { |
|
703 | 703 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
704 | - } |
|
705 | - |
|
706 | - unset($k, $v); |
|
707 | - } |
|
708 | - } |
|
709 | - |
|
710 | - public static function check_value( $opt, $opt_key, $field ) { |
|
711 | - if ( is_array( $opt ) ) { |
|
712 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
713 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
714 | - } else { |
|
715 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
716 | - } |
|
717 | - } |
|
718 | - return $opt; |
|
719 | - } |
|
704 | + } |
|
705 | + |
|
706 | + unset($k, $v); |
|
707 | + } |
|
708 | + } |
|
709 | + |
|
710 | + public static function check_value( $opt, $opt_key, $field ) { |
|
711 | + if ( is_array( $opt ) ) { |
|
712 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
713 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
714 | + } else { |
|
715 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
716 | + } |
|
717 | + } |
|
718 | + return $opt; |
|
719 | + } |
|
720 | 720 | |
721 | 721 | public static function check_label( $opt ) { |
722 | - if ( is_array($opt) ) { |
|
723 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
724 | - } |
|
725 | - |
|
726 | - return $opt; |
|
727 | - } |
|
728 | - |
|
729 | - public static function add_conditional_update_msg() { |
|
730 | - echo '<tr><td colspan="2">'; |
|
731 | - FrmAppHelper::update_message( 'calculate and conditionally hide and show fields' ); |
|
732 | - echo '</td></tr>'; |
|
733 | - } |
|
722 | + if ( is_array($opt) ) { |
|
723 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
724 | + } |
|
725 | + |
|
726 | + return $opt; |
|
727 | + } |
|
728 | + |
|
729 | + public static function add_conditional_update_msg() { |
|
730 | + echo '<tr><td colspan="2">'; |
|
731 | + FrmAppHelper::update_message( 'calculate and conditionally hide and show fields' ); |
|
732 | + echo '</td></tr>'; |
|
733 | + } |
|
734 | 734 | } |
@@ -32,18 +32,18 @@ discard block |
||
32 | 32 | $field['value'] = ''; |
33 | 33 | } |
34 | 34 | |
35 | - $field_name = 'item_meta['. $field_id .']'; |
|
36 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
35 | + $field_name = 'item_meta[' . $field_id . ']'; |
|
36 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
37 | 37 | |
38 | 38 | ob_start(); |
39 | - include($path .'/classes/views/frm-forms/add_field.php'); |
|
40 | - $field_html[ $field_id ] = ob_get_contents(); |
|
39 | + include( $path . '/classes/views/frm-forms/add_field.php' ); |
|
40 | + $field_html[$field_id] = ob_get_contents(); |
|
41 | 41 | ob_end_clean(); |
42 | 42 | } |
43 | 43 | |
44 | - unset($path); |
|
44 | + unset( $path ); |
|
45 | 45 | |
46 | - echo json_encode($field_html); |
|
46 | + echo json_encode( $field_html ); |
|
47 | 47 | |
48 | 48 | wp_die(); |
49 | 49 | } |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | $field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' ); |
55 | 55 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
56 | 56 | |
57 | - $field = self::include_new_field($field_type, $form_id); |
|
57 | + $field = self::include_new_field( $field_type, $form_id ); |
|
58 | 58 | |
59 | 59 | // this hook will allow for multiple fields to be added at once |
60 | - do_action('frm_after_field_created', $field, $form_id); |
|
60 | + do_action( 'frm_after_field_created', $field, $form_id ); |
|
61 | 61 | |
62 | 62 | wp_die(); |
63 | 63 | } |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | public static function include_new_field( $field_type, $form_id ) { |
69 | 69 | $values = array(); |
70 | 70 | if ( FrmAppHelper::pro_is_installed() ) { |
71 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
71 | + $values['post_type'] = FrmProFormsHelper::post_type( $form_id ); |
|
72 | 72 | } |
73 | 73 | |
74 | - $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
74 | + $field_values = apply_filters( 'frm_before_field_created', FrmFieldsHelper::setup_new_vars( $field_type, $form_id ) ); |
|
75 | 75 | $field_id = FrmField::create( $field_values ); |
76 | 76 | |
77 | 77 | if ( ! $field_id ) { |
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | |
81 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
81 | + $field = self::include_single_field( $field_id, $values, $form_id ); |
|
82 | 82 | |
83 | 83 | return $field; |
84 | 84 | } |
@@ -102,18 +102,18 @@ discard block |
||
102 | 102 | public static function edit_name( $field = 'name', $id = '' ) { |
103 | 103 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
104 | 104 | |
105 | - if ( empty($field) ) { |
|
105 | + if ( empty( $field ) ) { |
|
106 | 106 | $field = 'name'; |
107 | 107 | } |
108 | 108 | |
109 | - if ( empty($id) ) { |
|
109 | + if ( empty( $id ) ) { |
|
110 | 110 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
111 | 111 | $id = str_replace( 'field_label_', '', $id ); |
112 | 112 | } |
113 | 113 | |
114 | 114 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
115 | 115 | $value = trim( $value ); |
116 | - if ( trim(strip_tags($value)) == '' ) { |
|
116 | + if ( trim( strip_tags( $value ) ) == '' ) { |
|
117 | 117 | // set blank value if there is no content |
118 | 118 | $value = ''; |
119 | 119 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $field = FrmField::getOne( $field_id ); |
138 | 138 | |
139 | 139 | foreach ( array( 'clear_on_focus', 'separate_value', 'default_blank' ) as $val ) { |
140 | - if ( isset($_POST[ $val ]) ) { |
|
140 | + if ( isset( $_POST[$val] ) ) { |
|
141 | 141 | // all three of these options are boolean |
142 | 142 | $new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' ); |
143 | 143 | |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | $new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1; |
146 | 146 | } |
147 | 147 | |
148 | - $field->field_options[ $val ] = $new_val; |
|
149 | - unset($new_val); |
|
148 | + $field->field_options[$val] = $new_val; |
|
149 | + unset( $new_val ); |
|
150 | 150 | } |
151 | - unset($val); |
|
151 | + unset( $val ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | FrmField::update( $field_id, array( |
@@ -171,21 +171,21 @@ discard block |
||
171 | 171 | wp_die(); |
172 | 172 | } |
173 | 173 | |
174 | - do_action('frm_duplicate_field', $copy_field, $form_id); |
|
175 | - do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
174 | + do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
|
175 | + do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
|
176 | 176 | |
177 | 177 | $values = array( 'id' => $form_id ); |
178 | 178 | FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
179 | 179 | |
180 | - $field_count = FrmDb::get_count( $wpdb->prefix .'frm_fields fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
|
180 | + $field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
|
181 | 181 | |
182 | 182 | $values['field_order'] = $field_count + 1; |
183 | 183 | |
184 | - if ( ! $field_id = FrmField::create($values) ) { |
|
184 | + if ( ! $field_id = FrmField::create( $values ) ) { |
|
185 | 185 | wp_die(); |
186 | 186 | } |
187 | 187 | |
188 | - self::include_single_field($field_id, $values); |
|
188 | + self::include_single_field( $field_id, $values ); |
|
189 | 189 | |
190 | 190 | wp_die(); |
191 | 191 | } |
@@ -194,15 +194,15 @@ discard block |
||
194 | 194 | * Load a single field in the form builder along with all needed variables |
195 | 195 | */ |
196 | 196 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
197 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
198 | - $field_name = 'item_meta['. $field_id .']'; |
|
199 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
197 | + $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) ); |
|
198 | + $field_name = 'item_meta[' . $field_id . ']'; |
|
199 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
200 | 200 | $id = $form_id ? $form_id : $field['form_id']; |
201 | 201 | if ( $field['type'] == 'html' ) { |
202 | 202 | $field['stop_filter'] = true; |
203 | 203 | } |
204 | 204 | |
205 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
205 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); |
|
206 | 206 | |
207 | 207 | return $field; |
208 | 208 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
226 | 226 | |
227 | 227 | //Get the field |
228 | - $field = FrmField::getOne($id); |
|
228 | + $field = FrmField::getOne( $id ); |
|
229 | 229 | |
230 | 230 | if ( ! empty( $field->options ) ) { |
231 | 231 | $keys = array_keys( $field->options ); |
@@ -248,13 +248,13 @@ discard block |
||
248 | 248 | $first_opt = reset( $field->options ); |
249 | 249 | $next_opt = count( $field->options ); |
250 | 250 | if ( $first_opt != '' ) { |
251 | - $next_opt++; |
|
251 | + $next_opt ++; |
|
252 | 252 | } |
253 | - $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
254 | - unset($next_opt); |
|
253 | + $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
|
254 | + unset( $next_opt ); |
|
255 | 255 | } |
256 | 256 | $field_val = $opt; |
257 | - $field->options[ $opt_key ] = $opt; |
|
257 | + $field->options[$opt_key] = $opt; |
|
258 | 258 | |
259 | 259 | //Update options in DB |
260 | 260 | FrmField::update( $id, array( 'options' => $field->options ) ); |
@@ -263,19 +263,19 @@ discard block |
||
263 | 263 | $field = array( |
264 | 264 | 'type' => $field_data->type, |
265 | 265 | 'id' => $id, |
266 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
266 | + 'separate_value' => isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0, |
|
267 | 267 | 'form_id' => $field_data->form_id, |
268 | 268 | 'field_key' => $field_data->field_key, |
269 | 269 | ); |
270 | 270 | |
271 | - $field_name = 'item_meta['. $id .']'; |
|
272 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
271 | + $field_name = 'item_meta[' . $id . ']'; |
|
272 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
273 | 273 | $checked = ''; |
274 | 274 | |
275 | 275 | if ( 'other' == $opt_type ) { |
276 | - require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
276 | + require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
|
277 | 277 | } else { |
278 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
278 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
|
279 | 279 | } |
280 | 280 | wp_die(); |
281 | 281 | } |
@@ -294,28 +294,28 @@ discard block |
||
294 | 294 | $new_label = $update_value; |
295 | 295 | } |
296 | 296 | |
297 | - $field = FrmField::getOne($id); |
|
297 | + $field = FrmField::getOne( $id ); |
|
298 | 298 | $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
299 | 299 | |
300 | - $this_opt_id = end($ids); |
|
301 | - $this_opt = (array) $field->options[ $this_opt_id ]; |
|
302 | - $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ? true : false ); |
|
300 | + $this_opt_id = end( $ids ); |
|
301 | + $this_opt = (array) $field->options[$this_opt_id]; |
|
302 | + $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other' ) !== false ? true : false ); |
|
303 | 303 | |
304 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
305 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
304 | + $label = isset( $this_opt['label'] ) ? $this_opt['label'] : reset( $this_opt ); |
|
305 | + $value = isset( $this_opt['value'] ) ? $this_opt['value'] : ''; |
|
306 | 306 | |
307 | 307 | if ( ! isset( $new_label ) ) { |
308 | 308 | $new_label = $label; |
309 | 309 | } |
310 | 310 | |
311 | - if ( isset($new_value) || isset($value) ) { |
|
312 | - $update_value = isset($new_value) ? $new_value : $value; |
|
311 | + if ( isset( $new_value ) || isset( $value ) ) { |
|
312 | + $update_value = isset( $new_value ) ? $new_value : $value; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
316 | - $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
|
316 | + $field->options[$this_opt_id] = array( 'value' => $update_value, 'label' => $new_label ); |
|
317 | 317 | } else { |
318 | - $field->options[ $this_opt_id ] = $orig_update_value; |
|
318 | + $field->options[$this_opt_id] = $orig_update_value; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
333 | 333 | |
334 | 334 | $options = $field->options; |
335 | - unset( $options[ $opt_key ] ); |
|
335 | + unset( $options[$opt_key] ); |
|
336 | 336 | $response = array( 'other' => true ); |
337 | 337 | |
338 | 338 | //If the deleted option is an "other" option |
@@ -400,45 +400,45 @@ discard block |
||
400 | 400 | |
401 | 401 | $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
402 | 402 | $prepop = array(); |
403 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
403 | + FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
|
404 | 404 | |
405 | - $field = FrmField::getOne($field_id); |
|
405 | + $field = FrmField::getOne( $field_id ); |
|
406 | 406 | |
407 | 407 | wp_enqueue_script( 'utils' ); |
408 | - wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
408 | + wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
|
409 | 409 | FrmAppHelper::load_admin_wide_js(); |
410 | 410 | |
411 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
411 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
|
412 | 412 | wp_die(); |
413 | 413 | } |
414 | 414 | |
415 | 415 | public static function import_options() { |
416 | 416 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
417 | 417 | |
418 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
418 | + if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
|
419 | 419 | return; |
420 | 420 | } |
421 | 421 | |
422 | 422 | $field_id = absint( $_POST['field_id'] ); |
423 | - $field = FrmField::getOne($field_id); |
|
423 | + $field = FrmField::getOne( $field_id ); |
|
424 | 424 | |
425 | 425 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
426 | 426 | return; |
427 | 427 | } |
428 | 428 | |
429 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
430 | - $opts = stripslashes_deep($_POST['opts']); |
|
431 | - $opts = explode("\n", rtrim($opts, "\n")); |
|
429 | + $field = FrmFieldsHelper::setup_edit_vars( $field ); |
|
430 | + $opts = stripslashes_deep( $_POST['opts'] ); |
|
431 | + $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
|
432 | 432 | if ( $field['separate_value'] ) { |
433 | 433 | foreach ( $opts as $opt_key => $opt ) { |
434 | - if ( strpos($opt, '|') !== false ) { |
|
435 | - $vals = explode('|', $opt); |
|
434 | + if ( strpos( $opt, '|' ) !== false ) { |
|
435 | + $vals = explode( '|', $opt ); |
|
436 | 436 | if ( $vals[0] != $vals[1] ) { |
437 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
437 | + $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
438 | 438 | } |
439 | - unset($vals); |
|
439 | + unset( $vals ); |
|
440 | 440 | } |
441 | - unset($opt_key, $opt); |
|
441 | + unset( $opt_key, $opt ); |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | |
@@ -447,12 +447,12 @@ discard block |
||
447 | 447 | $other_array = array(); |
448 | 448 | foreach ( $field['options'] as $opt_key => $opt ) { |
449 | 449 | if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
450 | - $other_array[ $opt_key ] = $opt; |
|
450 | + $other_array[$opt_key] = $opt; |
|
451 | 451 | } |
452 | - unset($opt_key, $opt); |
|
452 | + unset( $opt_key, $opt ); |
|
453 | 453 | } |
454 | - if ( ! empty($other_array) ) { |
|
455 | - $opts = array_merge( $opts, $other_array); |
|
454 | + if ( ! empty( $other_array ) ) { |
|
455 | + $opts = array_merge( $opts, $other_array ); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
@@ -465,9 +465,9 @@ discard block |
||
465 | 465 | $html_id = FrmFieldsHelper::get_html_id( $field ); |
466 | 466 | |
467 | 467 | if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
468 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
468 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
|
469 | 469 | } else { |
470 | - FrmFieldsHelper::show_single_option($field); |
|
470 | + FrmFieldsHelper::show_single_option( $field ); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | wp_die(); |
@@ -489,13 +489,13 @@ discard block |
||
489 | 489 | 'rte' => 'textarea', |
490 | 490 | 'website' => 'url', |
491 | 491 | ); |
492 | - if ( isset( $type_switch[ $type ] ) ) { |
|
493 | - $type = $type_switch[ $type ]; |
|
492 | + if ( isset( $type_switch[$type] ) ) { |
|
493 | + $type = $type_switch[$type]; |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | $frm_field_selection = FrmField::field_selection(); |
497 | - $types = array_keys($frm_field_selection); |
|
498 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
497 | + $types = array_keys( $frm_field_selection ); |
|
498 | + if ( ! in_array( $type, $types ) && $type != 'captcha' ) { |
|
499 | 499 | $type = 'text'; |
500 | 500 | } |
501 | 501 | |
@@ -534,19 +534,19 @@ discard block |
||
534 | 534 | |
535 | 535 | public static function input_html( $field, $echo = true ) { |
536 | 536 | $class = array(); //$field['type']; |
537 | - self::add_input_classes($field, $class); |
|
537 | + self::add_input_classes( $field, $class ); |
|
538 | 538 | |
539 | 539 | $add_html = array(); |
540 | - self::add_html_size($field, $add_html); |
|
541 | - self::add_html_length($field, $add_html); |
|
542 | - self::add_html_placeholder($field, $add_html, $class); |
|
540 | + self::add_html_size( $field, $add_html ); |
|
541 | + self::add_html_length( $field, $add_html ); |
|
542 | + self::add_html_placeholder( $field, $add_html, $class ); |
|
543 | 543 | self::add_validation_messages( $field, $add_html ); |
544 | 544 | |
545 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
545 | + $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field ); |
|
546 | 546 | |
547 | 547 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
548 | 548 | |
549 | - self::add_shortcodes_to_html($field, $add_html); |
|
549 | + self::add_shortcodes_to_html( $field, $add_html ); |
|
550 | 550 | |
551 | 551 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
552 | 552 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | } |
560 | 560 | |
561 | 561 | private static function add_input_classes( $field, array &$class ) { |
562 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
562 | + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
|
563 | 563 | $class[] = $field['input_class']; |
564 | 564 | } |
565 | 565 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | $class[] = 'dyn_default_value'; |
573 | 573 | } |
574 | 574 | |
575 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
575 | + if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
|
576 | 576 | $class[] = 'auto_width'; |
577 | 577 | } |
578 | 578 | } |
@@ -582,19 +582,19 @@ discard block |
||
582 | 582 | return; |
583 | 583 | } |
584 | 584 | |
585 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
585 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
586 | 586 | return; |
587 | 587 | } |
588 | 588 | |
589 | - if ( is_numeric($field['size']) ) { |
|
589 | + if ( is_numeric( $field['size'] ) ) { |
|
590 | 590 | $field['size'] .= 'px'; |
591 | 591 | } |
592 | 592 | |
593 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
593 | + $important = apply_filters( 'frm_use_important_width', 1, $field ); |
|
594 | 594 | // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
595 | - $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
595 | + $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
|
596 | 596 | |
597 | - self::add_html_cols($field, $add_html); |
|
597 | + self::add_html_cols( $field, $add_html ); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | private static function add_html_cols( $field, array &$add_html ) { |
@@ -611,13 +611,13 @@ discard block |
||
611 | 611 | ); |
612 | 612 | |
613 | 613 | // include "col" for valid html |
614 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
614 | + $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
|
615 | 615 | |
616 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
616 | + if ( ! isset( $calc[$unit] ) ) { |
|
617 | 617 | return; |
618 | 618 | } |
619 | 619 | |
620 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
620 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit]; |
|
621 | 621 | |
622 | 622 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
623 | 623 | } |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | return; |
629 | 629 | } |
630 | 630 | |
631 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
631 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
632 | 632 | // don't load on form builder page |
633 | 633 | return; |
634 | 634 | } |
@@ -653,11 +653,11 @@ discard block |
||
653 | 653 | |
654 | 654 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
655 | 655 | // use HMTL5 placeholder with js fallback |
656 | - $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
657 | - wp_enqueue_script('jquery-placeholder'); |
|
656 | + $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
|
657 | + wp_enqueue_script( 'jquery-placeholder' ); |
|
658 | 658 | } else if ( ! $frm_settings->use_html ) { |
659 | 659 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
660 | - $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
660 | + $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
|
661 | 661 | $class[] = 'frm_toggle_default'; |
662 | 662 | |
663 | 663 | if ( $field['value'] == $field['default_value'] ) { |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | $format = FrmEntryValidate::phone_format( $field ); |
682 | 682 | $format = substr( $format, 2, -2 ); |
683 | 683 | $key = 'pattern'; |
684 | - $add_html[ $key ] = $key . '="' . esc_attr( $format ) . '"'; |
|
684 | + $add_html[$key] = $key . '="' . esc_attr( $format ) . '"'; |
|
685 | 685 | } |
686 | 686 | } |
687 | 687 | |
@@ -695,15 +695,15 @@ discard block |
||
695 | 695 | continue; |
696 | 696 | } |
697 | 697 | |
698 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
698 | + if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
|
699 | 699 | $add_html[] = $v; |
700 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
701 | - $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
700 | + } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) { |
|
701 | + $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] ); |
|
702 | 702 | } else { |
703 | - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
|
703 | + $add_html[$k] = $k . '="' . esc_attr( $v ) . '"'; |
|
704 | 704 | } |
705 | 705 | |
706 | - unset($k, $v); |
|
706 | + unset( $k, $v ); |
|
707 | 707 | } |
708 | 708 | } |
709 | 709 | |
@@ -719,8 +719,8 @@ discard block |
||
719 | 719 | } |
720 | 720 | |
721 | 721 | public static function check_label( $opt ) { |
722 | - if ( is_array($opt) ) { |
|
723 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
722 | + if ( is_array( $opt ) ) { |
|
723 | + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | return $opt; |
@@ -64,8 +64,8 @@ |
||
64 | 64 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=destroy&id=' . $style->ID ) ); ?>" id="frm_delete_style" class="submitdelete deletion" onclick="return confirm('<?php esc_attr_e( 'Are you sure you want to delete that style?', 'formidable' ) ?>')"><?php _e( 'Delete Style', 'formidable' ) ?></a> |
65 | 65 | <?php } ?> |
66 | 66 | <?php |
67 | - if ( $style->ID ) { |
|
68 | - echo '<span class="howto"><span>.frm_style_'. esc_attr( $style->post_name ) .'</span></span>'; |
|
67 | + if ( $style->ID ) { |
|
68 | + echo '<span class="howto"><span>.frm_style_'. esc_attr( $style->post_name ) .'</span></span>'; |
|
69 | 69 | } ?> |
70 | 70 | <div class="publishing-action"> |
71 | 71 | <input type="button" value="<?php esc_attr_e( 'Reset to Default', 'formidable' ) ?>" class="button-secondary frm_reset_style" /> |
@@ -2,14 +2,14 @@ discard block |
||
2 | 2 | <div class="wrap"> |
3 | 3 | <?php FrmStylesHelper::style_menu(); ?> |
4 | 4 | |
5 | - <?php include(FrmAppHelper::plugin_path() .'/classes/views/shared/errors.php'); ?> |
|
5 | + <?php include( FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php' ); ?> |
|
6 | 6 | |
7 | 7 | <?php do_action( 'frm_style_switcher', $style, $styles ) ?> |
8 | 8 | |
9 | 9 | <form id="frm_styling_form" action="" name="frm_styling_form" method="post"> |
10 | 10 | <input type="hidden" name="ID" value="<?php echo esc_attr( $style->ID ) ?>" /> |
11 | 11 | <input type="hidden" name="frm_action" value="save" /> |
12 | - <textarea name="<?php echo esc_attr( $frm_style->get_field_name('custom_css') ) ?>" class="frm_hidden"><?php echo FrmAppHelper::esc_textarea( $style->post_content['custom_css'] ) ?></textarea> |
|
12 | + <textarea name="<?php echo esc_attr( $frm_style->get_field_name( 'custom_css' ) ) ?>" class="frm_hidden"><?php echo FrmAppHelper::esc_textarea( $style->post_content['custom_css'] ) ?></textarea> |
|
13 | 13 | <?php wp_nonce_field( 'frm_style_nonce', 'frm_style' ); ?> |
14 | 14 | |
15 | 15 | <div id="nav-menus-frame"> |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | <div class="styling_settings"> |
20 | 20 | <input type="hidden" name="style_name" value="frm_style_<?php echo esc_attr( $style->post_name ) ?>" /> |
21 | - <?php FrmStylesController::do_accordion_sections( FrmStylesController::$screen, 'side', compact('style', 'frm_style') ); ?> |
|
21 | + <?php FrmStylesController::do_accordion_sections( FrmStylesController::$screen, 'side', compact( 'style', 'frm_style' ) ); ?> |
|
22 | 22 | </div> |
23 | 23 | |
24 | 24 | </div><!-- /#menu-settings-column --> |
@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | <div class="major-publishing-actions"> |
32 | 32 | <label class="menu-name-label howto open-label" for="menu-name"> |
33 | 33 | <span><?php _e( 'Style Name', 'formidable' ) ?></span> |
34 | - <input id="menu-name" name="<?php echo esc_attr( $frm_style->get_field_name('post_title', '') ); ?>" type="text" class="menu-name regular-text menu-item-textbox" title="<?php esc_attr_e( 'Enter style name here', 'formidable' ) ?>" value="<?php echo esc_attr( $style->post_title ) ?>" /> |
|
34 | + <input id="menu-name" name="<?php echo esc_attr( $frm_style->get_field_name( 'post_title', '' ) ); ?>" type="text" class="menu-name regular-text menu-item-textbox" title="<?php esc_attr_e( 'Enter style name here', 'formidable' ) ?>" value="<?php echo esc_attr( $style->post_title ) ?>" /> |
|
35 | 35 | </label> |
36 | 36 | |
37 | - <input name="prev_menu_order" type="hidden" value="<?php echo esc_attr($style->menu_order) ?>" /> |
|
37 | + <input name="prev_menu_order" type="hidden" value="<?php echo esc_attr( $style->menu_order ) ?>" /> |
|
38 | 38 | <label class="menu-name-label howto open-label default-style-box" for="menu_order"> |
39 | 39 | <span> |
40 | 40 | <?php if ( $style->menu_order ) { ?> |
41 | - <input name="<?php echo esc_attr( $frm_style->get_field_name('menu_order', '') ); ?>" type="hidden" value="1" /> |
|
42 | - <input id="menu_order" disabled="disabled" type="checkbox" value="1" <?php checked($style->menu_order, 1) ?> /> |
|
41 | + <input name="<?php echo esc_attr( $frm_style->get_field_name( 'menu_order', '' ) ); ?>" type="hidden" value="1" /> |
|
42 | + <input id="menu_order" disabled="disabled" type="checkbox" value="1" <?php checked( $style->menu_order, 1 ) ?> /> |
|
43 | 43 | <?php } else { ?> |
44 | - <input id="menu_order" name="<?php echo esc_attr( $frm_style->get_field_name('menu_order', '') ); ?>" type="checkbox" value="1" <?php checked($style->menu_order, 1) ?> /> |
|
44 | + <input id="menu_order" name="<?php echo esc_attr( $frm_style->get_field_name( 'menu_order', '' ) ); ?>" type="checkbox" value="1" <?php checked( $style->menu_order, 1 ) ?> /> |
|
45 | 45 | <?php } ?> |
46 | 46 | <?php _e( 'Make default style', 'formidable' ) ?></span> |
47 | 47 | </label> |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | <div id="post-body"> |
55 | 55 | <div id="post-body-content"> |
56 | 56 | |
57 | - <?php include( dirname(__FILE__) .'/_sample_form.php') ?> |
|
57 | + <?php include( dirname( __FILE__ ) . '/_sample_form.php' ) ?> |
|
58 | 58 | |
59 | 59 | </div><!-- /#post-body-content --> |
60 | 60 | </div><!-- /#post-body --> |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | <?php } ?> |
66 | 66 | <?php |
67 | 67 | if ( $style->ID ) { |
68 | - echo '<span class="howto"><span>.frm_style_'. esc_attr( $style->post_name ) .'</span></span>'; |
|
68 | + echo '<span class="howto"><span>.frm_style_' . esc_attr( $style->post_name ) . '</span></span>'; |
|
69 | 69 | } ?> |
70 | 70 | <div class="publishing-action"> |
71 | 71 | <input type="button" value="<?php esc_attr_e( 'Reset to Default', 'formidable' ) ?>" class="button-secondary frm_reset_style" /> |
@@ -179,7 +179,7 @@ |
||
179 | 179 | * @access public |
180 | 180 | * |
181 | 181 | * @param string $name Property to check if set. |
182 | - * @return bool Whether the property is set. |
|
182 | + * @return boolean|null Whether the property is set. |
|
183 | 183 | */ |
184 | 184 | public function __isset( $name ) { |
185 | 185 | if ( in_array( $name, $this->compat_fields ) ) { |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | protected $modes = array(); |
68 | 68 | |
69 | 69 | /** |
70 | - * |
|
71 | - * @var array |
|
72 | - */ |
|
73 | - protected $params; |
|
70 | + * |
|
71 | + * @var array |
|
72 | + */ |
|
73 | + protected $params; |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Stores the value returned by ->get_column_info() |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | 'single_row_columns' ); |
88 | 88 | |
89 | 89 | /** |
90 | - * Construct the table object |
|
91 | - */ |
|
90 | + * Construct the table object |
|
91 | + */ |
|
92 | 92 | public function __construct( $args ) { |
93 | - $args = wp_parse_args( $args, array( |
|
93 | + $args = wp_parse_args( $args, array( |
|
94 | 94 | 'params' => array(), |
95 | 95 | 'plural' => '', |
96 | 96 | 'singular' => '', |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | 3 | die( 'You are not allowed to call this page directly.' ); |
4 | 4 | } |
5 | 5 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 ); |
106 | 106 | |
107 | - if ( !$args['plural'] ) |
|
107 | + if ( ! $args['plural'] ) |
|
108 | 108 | $args['plural'] = $this->screen->base; |
109 | 109 | |
110 | 110 | $args['plural'] = sanitize_key( $args['plural'] ); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | 'per_page' => 0, |
246 | 246 | ) ); |
247 | 247 | |
248 | - if ( !$args['total_pages'] && $args['per_page'] > 0 ) |
|
248 | + if ( ! $args['total_pages'] && $args['per_page'] > 0 ) |
|
249 | 249 | $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); |
250 | 250 | |
251 | 251 | // Redirect if page number is invalid and headers are not already sent. |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @return bool |
285 | 285 | */ |
286 | 286 | public function has_items() { |
287 | - return !empty( $this->items ); |
|
287 | + return ! empty( $this->items ); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @param string $input_id The search input id |
308 | 308 | */ |
309 | 309 | public function search_box( $text, $input_id ) { |
310 | - if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) |
|
310 | + if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) |
|
311 | 311 | return; |
312 | 312 | |
313 | 313 | $input_id = $input_id . '-search-input'; |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | <p class="search-box"> |
325 | 325 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
326 | 326 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
327 | - <?php submit_button( $text, 'button', '', false, array('id' => 'search-submit') ); ?> |
|
327 | + <?php submit_button( $text, 'button', '', false, array( 'id' => 'search-submit' ) ); ?> |
|
328 | 328 | </p> |
329 | 329 | <?php |
330 | 330 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | |
368 | 368 | echo "<ul class='subsubsub'>\n"; |
369 | 369 | foreach ( $views as $class => $view ) { |
370 | - $views[ $class ] = "\t<li class='$class'>$view"; |
|
370 | + $views[$class] = "\t<li class='$class'>$view"; |
|
371 | 371 | } |
372 | 372 | echo implode( " |</li>\n", $views ) . "</li>\n"; |
373 | 373 | echo "</ul>"; |
@@ -471,12 +471,12 @@ discard block |
||
471 | 471 | $action_count = count( $actions ); |
472 | 472 | $i = 0; |
473 | 473 | |
474 | - if ( !$action_count ) |
|
474 | + if ( ! $action_count ) |
|
475 | 475 | return ''; |
476 | 476 | |
477 | 477 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
478 | 478 | foreach ( $actions as $action => $link ) { |
479 | - ++$i; |
|
479 | + ++ $i; |
|
480 | 480 | ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
481 | 481 | $out .= "<span class='$action'>$link$sep</span>"; |
482 | 482 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | |
533 | 533 | $month_count = count( $months ); |
534 | 534 | |
535 | - if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) |
|
535 | + if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) |
|
536 | 536 | return; |
537 | 537 | |
538 | 538 | $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">‹</span>'; |
749 | 749 | } else { |
750 | 750 | $page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
751 | - esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ), |
|
751 | + esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ), |
|
752 | 752 | __( 'Previous page' ), |
753 | 753 | '‹' |
754 | 754 | ); |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">›</span>'; |
772 | 772 | } else { |
773 | 773 | $page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
774 | - esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ), |
|
774 | + esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ), |
|
775 | 775 | __( 'Next page' ), |
776 | 776 | '›' |
777 | 777 | ); |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | |
835 | 835 | // We need a primary defined so responsive views show something, |
836 | 836 | // so let's fall back to the first non-checkbox column. |
837 | - foreach( $columns as $col => $column_name ) { |
|
837 | + foreach ( $columns as $col => $column_name ) { |
|
838 | 838 | if ( 'cb' === $col ) { |
839 | 839 | continue; |
840 | 840 | } |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | |
861 | 861 | // If the primary column doesn't exist fall back to the |
862 | 862 | // first non-checkbox column. |
863 | - if ( ! isset( $columns[ $default ] ) ) { |
|
863 | + if ( ! isset( $columns[$default] ) ) { |
|
864 | 864 | $default = FrmListHelper::get_default_primary_column_name(); |
865 | 865 | } |
866 | 866 | |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | */ |
875 | 875 | $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); |
876 | 876 | |
877 | - if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { |
|
877 | + if ( empty( $column ) || ! isset( $columns[$column] ) ) { |
|
878 | 878 | $column = $default; |
879 | 879 | } |
880 | 880 | |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | // In 4.3, we added a fourth argument for primary column. |
897 | 897 | $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
898 | 898 | foreach ( $this->_column_headers as $key => $value ) { |
899 | - $column_headers[ $key ] = $value; |
|
899 | + $column_headers[$key] = $value; |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | return $column_headers; |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | continue; |
925 | 925 | |
926 | 926 | $data = (array) $data; |
927 | - if ( !isset( $data[1] ) ) |
|
927 | + if ( ! isset( $data[1] ) ) |
|
928 | 928 | $data[1] = false; |
929 | 929 | |
930 | 930 | $sortable[$id] = $data; |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | static $cb_counter = 1; |
981 | 981 | $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' |
982 | 982 | . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />'; |
983 | - $cb_counter++; |
|
983 | + $cb_counter ++; |
|
984 | 984 | } |
985 | 985 | |
986 | 986 | foreach ( $columns as $column_key => $column_display_name ) { |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
1020 | 1020 | $id = $with_id ? "id='$column_key'" : ''; |
1021 | 1021 | |
1022 | - if ( !empty( $class ) ) |
|
1022 | + if ( ! empty( $class ) ) |
|
1023 | 1023 | $class = "class='" . join( ' ', $class ) . "'"; |
1024 | 1024 | |
1025 | 1025 | echo "<$tag $scope $id $class>$column_display_name</$tag>"; |
@@ -104,8 +104,9 @@ discard block |
||
104 | 104 | |
105 | 105 | add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 ); |
106 | 106 | |
107 | - if ( !$args['plural'] ) |
|
108 | - $args['plural'] = $this->screen->base; |
|
107 | + if ( !$args['plural'] ) { |
|
108 | + $args['plural'] = $this->screen->base; |
|
109 | + } |
|
109 | 110 | |
110 | 111 | $args['plural'] = sanitize_key( $args['plural'] ); |
111 | 112 | $args['singular'] = sanitize_key( $args['singular'] ); |
@@ -245,8 +246,9 @@ discard block |
||
245 | 246 | 'per_page' => 0, |
246 | 247 | ) ); |
247 | 248 | |
248 | - if ( !$args['total_pages'] && $args['per_page'] > 0 ) |
|
249 | - $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); |
|
249 | + if ( !$args['total_pages'] && $args['per_page'] > 0 ) { |
|
250 | + $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); |
|
251 | + } |
|
250 | 252 | |
251 | 253 | // Redirect if page number is invalid and headers are not already sent. |
252 | 254 | if ( ! headers_sent() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) { |
@@ -268,11 +270,13 @@ discard block |
||
268 | 270 | * @return int Number of items that correspond to the given pagination argument. |
269 | 271 | */ |
270 | 272 | public function get_pagination_arg( $key ) { |
271 | - if ( 'page' == $key ) |
|
272 | - return $this->get_pagenum(); |
|
273 | + if ( 'page' == $key ) { |
|
274 | + return $this->get_pagenum(); |
|
275 | + } |
|
273 | 276 | |
274 | - if ( isset( $this->_pagination_args[$key] ) ) |
|
275 | - return $this->_pagination_args[$key]; |
|
277 | + if ( isset( $this->_pagination_args[$key] ) ) { |
|
278 | + return $this->_pagination_args[$key]; |
|
279 | + } |
|
276 | 280 | } |
277 | 281 | |
278 | 282 | /** |
@@ -307,20 +311,25 @@ discard block |
||
307 | 311 | * @param string $input_id The search input id |
308 | 312 | */ |
309 | 313 | public function search_box( $text, $input_id ) { |
310 | - if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) |
|
311 | - return; |
|
314 | + if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) { |
|
315 | + return; |
|
316 | + } |
|
312 | 317 | |
313 | 318 | $input_id = $input_id . '-search-input'; |
314 | 319 | |
315 | - if ( ! empty( $_REQUEST['orderby'] ) ) |
|
316 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
317 | - if ( ! empty( $_REQUEST['order'] ) ) |
|
318 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
319 | - if ( ! empty( $_REQUEST['post_mime_type'] ) ) |
|
320 | - echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
|
321 | - if ( ! empty( $_REQUEST['detached'] ) ) |
|
322 | - echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
|
323 | -?> |
|
320 | + if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
321 | + echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
322 | + } |
|
323 | + if ( ! empty( $_REQUEST['order'] ) ) { |
|
324 | + echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
325 | + } |
|
326 | + if ( ! empty( $_REQUEST['post_mime_type'] ) ) { |
|
327 | + echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
|
328 | + } |
|
329 | + if ( ! empty( $_REQUEST['detached'] ) ) { |
|
330 | + echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
|
331 | + } |
|
332 | + ?> |
|
324 | 333 | <p class="search-box"> |
325 | 334 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
326 | 335 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
@@ -362,8 +371,9 @@ discard block |
||
362 | 371 | */ |
363 | 372 | $views = apply_filters( "views_{$this->screen->id}", $views ); |
364 | 373 | |
365 | - if ( empty( $views ) ) |
|
366 | - return; |
|
374 | + if ( empty( $views ) ) { |
|
375 | + return; |
|
376 | + } |
|
367 | 377 | |
368 | 378 | echo "<ul class='subsubsub'>\n"; |
369 | 379 | foreach ( $views as $class => $view ) { |
@@ -417,8 +427,9 @@ discard block |
||
417 | 427 | $two = '2'; |
418 | 428 | } |
419 | 429 | |
420 | - if ( empty( $this->_actions ) ) |
|
421 | - return; |
|
430 | + if ( empty( $this->_actions ) ) { |
|
431 | + return; |
|
432 | + } |
|
422 | 433 | |
423 | 434 | echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . __( 'Select bulk action' ) . "</label>"; |
424 | 435 | echo "<select name='action$two' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n"; |
@@ -445,14 +456,17 @@ discard block |
||
445 | 456 | * @return string|false The action name or False if no action was selected |
446 | 457 | */ |
447 | 458 | public function current_action() { |
448 | - if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) |
|
449 | - return false; |
|
459 | + if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) { |
|
460 | + return false; |
|
461 | + } |
|
450 | 462 | |
451 | - if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) |
|
452 | - return $_REQUEST['action']; |
|
463 | + if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) { |
|
464 | + return $_REQUEST['action']; |
|
465 | + } |
|
453 | 466 | |
454 | - if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) |
|
455 | - return $_REQUEST['action2']; |
|
467 | + if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) { |
|
468 | + return $_REQUEST['action2']; |
|
469 | + } |
|
456 | 470 | |
457 | 471 | return false; |
458 | 472 | } |
@@ -471,8 +485,9 @@ discard block |
||
471 | 485 | $action_count = count( $actions ); |
472 | 486 | $i = 0; |
473 | 487 | |
474 | - if ( !$action_count ) |
|
475 | - return ''; |
|
488 | + if ( !$action_count ) { |
|
489 | + return ''; |
|
490 | + } |
|
476 | 491 | |
477 | 492 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
478 | 493 | foreach ( $actions as $action => $link ) { |
@@ -532,8 +547,9 @@ discard block |
||
532 | 547 | |
533 | 548 | $month_count = count( $months ); |
534 | 549 | |
535 | - if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) |
|
536 | - return; |
|
550 | + if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) { |
|
551 | + return; |
|
552 | + } |
|
537 | 553 | |
538 | 554 | $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; |
539 | 555 | ?> |
@@ -542,8 +558,9 @@ discard block |
||
542 | 558 | <option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option> |
543 | 559 | <?php |
544 | 560 | foreach ( $months as $arc_row ) { |
545 | - if ( 0 == $arc_row->year ) |
|
546 | - continue; |
|
561 | + if ( 0 == $arc_row->year ) { |
|
562 | + continue; |
|
563 | + } |
|
547 | 564 | |
548 | 565 | $month = zeroise( $arc_row->month, 2 ); |
549 | 566 | $year = $arc_row->year; |
@@ -575,8 +592,9 @@ discard block |
||
575 | 592 | <?php |
576 | 593 | foreach ( $this->modes as $mode => $title ) { |
577 | 594 | $classes = array( 'view-' . $mode ); |
578 | - if ( $current_mode == $mode ) |
|
579 | - $classes[] = 'current'; |
|
595 | + if ( $current_mode == $mode ) { |
|
596 | + $classes[] = 'current'; |
|
597 | + } |
|
580 | 598 | printf( |
581 | 599 | "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n", |
582 | 600 | esc_url( add_query_arg( 'mode', $mode ) ), |
@@ -647,8 +665,9 @@ discard block |
||
647 | 665 | public function get_pagenum() { |
648 | 666 | $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0; |
649 | 667 | |
650 | - if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) |
|
651 | - $pagenum = $this->_pagination_args['total_pages']; |
|
668 | + if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) { |
|
669 | + $pagenum = $this->_pagination_args['total_pages']; |
|
670 | + } |
|
652 | 671 | |
653 | 672 | return max( 1, $pagenum ); |
654 | 673 | } |
@@ -665,8 +684,9 @@ discard block |
||
665 | 684 | */ |
666 | 685 | protected function get_items_per_page( $option, $default = 20 ) { |
667 | 686 | $per_page = (int) get_user_option( $option ); |
668 | - if ( empty( $per_page ) || $per_page < 1 ) |
|
669 | - $per_page = $default; |
|
687 | + if ( empty( $per_page ) || $per_page < 1 ) { |
|
688 | + $per_page = $default; |
|
689 | + } |
|
670 | 690 | |
671 | 691 | /** |
672 | 692 | * Filter the number of items to be displayed on each page of the list table. |
@@ -920,12 +940,14 @@ discard block |
||
920 | 940 | |
921 | 941 | $sortable = array(); |
922 | 942 | foreach ( $_sortable as $id => $data ) { |
923 | - if ( empty( $data ) ) |
|
924 | - continue; |
|
943 | + if ( empty( $data ) ) { |
|
944 | + continue; |
|
945 | + } |
|
925 | 946 | |
926 | 947 | $data = (array) $data; |
927 | - if ( !isset( $data[1] ) ) |
|
928 | - $data[1] = false; |
|
948 | + if ( !isset( $data[1] ) ) { |
|
949 | + $data[1] = false; |
|
950 | + } |
|
929 | 951 | |
930 | 952 | $sortable[$id] = $data; |
931 | 953 | } |
@@ -966,15 +988,17 @@ discard block |
||
966 | 988 | $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
967 | 989 | $current_url = remove_query_arg( 'paged', $current_url ); |
968 | 990 | |
969 | - if ( isset( $_GET['orderby'] ) ) |
|
970 | - $current_orderby = $_GET['orderby']; |
|
971 | - else |
|
972 | - $current_orderby = ''; |
|
991 | + if ( isset( $_GET['orderby'] ) ) { |
|
992 | + $current_orderby = $_GET['orderby']; |
|
993 | + } else { |
|
994 | + $current_orderby = ''; |
|
995 | + } |
|
973 | 996 | |
974 | - if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) |
|
975 | - $current_order = 'desc'; |
|
976 | - else |
|
977 | - $current_order = 'asc'; |
|
997 | + if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { |
|
998 | + $current_order = 'desc'; |
|
999 | + } else { |
|
1000 | + $current_order = 'asc'; |
|
1001 | + } |
|
978 | 1002 | |
979 | 1003 | if ( ! empty( $columns['cb'] ) ) { |
980 | 1004 | static $cb_counter = 1; |
@@ -990,10 +1014,11 @@ discard block |
||
990 | 1014 | $class[] = 'hidden'; |
991 | 1015 | } |
992 | 1016 | |
993 | - if ( 'cb' == $column_key ) |
|
994 | - $class[] = 'check-column'; |
|
995 | - elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) |
|
996 | - $class[] = 'num'; |
|
1017 | + if ( 'cb' == $column_key ) { |
|
1018 | + $class[] = 'check-column'; |
|
1019 | + } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) { |
|
1020 | + $class[] = 'num'; |
|
1021 | + } |
|
997 | 1022 | |
998 | 1023 | if ( $column_key === $primary ) { |
999 | 1024 | $class[] = 'column-primary'; |
@@ -1019,8 +1044,9 @@ discard block |
||
1019 | 1044 | $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
1020 | 1045 | $id = $with_id ? "id='$column_key'" : ''; |
1021 | 1046 | |
1022 | - if ( !empty( $class ) ) |
|
1023 | - $class = "class='" . join( ' ', $class ) . "'"; |
|
1047 | + if ( !empty( $class ) ) { |
|
1048 | + $class = "class='" . join( ' ', $class ) . "'"; |
|
1049 | + } |
|
1024 | 1050 | |
1025 | 1051 | echo "<$tag $scope $id $class>$column_display_name</$tag>"; |
1026 | 1052 | } |
@@ -1082,9 +1108,10 @@ discard block |
||
1082 | 1108 | * @param string $which |
1083 | 1109 | */ |
1084 | 1110 | protected function display_tablenav( $which ) { |
1085 | - if ( 'top' == $which ) |
|
1086 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
1087 | -?> |
|
1111 | + if ( 'top' == $which ) { |
|
1112 | + wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
1113 | + } |
|
1114 | + ?> |
|
1088 | 1115 | <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
1089 | 1116 | |
1090 | 1117 | <div class="alignleft actions bulkactions"> |