@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | } |
5 | 5 | |
6 | 6 | class FrmField { |
7 | - static $use_cache = true; |
|
7 | + static $use_cache = true; |
|
8 | 8 | static $transient_size = 200; |
9 | 9 | |
10 | 10 | public static function field_selection() { |
@@ -51,39 +51,39 @@ discard block |
||
51 | 51 | )); |
52 | 52 | } |
53 | 53 | |
54 | - public static function create( $values, $return = true ) { |
|
55 | - global $wpdb, $frm_duplicate_ids; |
|
54 | + public static function create( $values, $return = true ) { |
|
55 | + global $wpdb, $frm_duplicate_ids; |
|
56 | 56 | |
57 | - $new_values = array(); |
|
58 | - $key = isset($values['field_key']) ? $values['field_key'] : $values['name']; |
|
57 | + $new_values = array(); |
|
58 | + $key = isset($values['field_key']) ? $values['field_key'] : $values['name']; |
|
59 | 59 | $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
60 | 60 | |
61 | 61 | foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) { |
62 | 62 | $new_values[ $col ] = $values[ $col ]; |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | - $new_values['options'] = $values['options']; |
|
65 | + $new_values['options'] = $values['options']; |
|
66 | 66 | |
67 | - $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null; |
|
68 | - $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0; |
|
69 | - $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null; |
|
70 | - $new_values['field_options'] = $values['field_options']; |
|
71 | - $new_values['created_at'] = current_time('mysql', 1); |
|
67 | + $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null; |
|
68 | + $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0; |
|
69 | + $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null; |
|
70 | + $new_values['field_options'] = $values['field_options']; |
|
71 | + $new_values['created_at'] = current_time('mysql', 1); |
|
72 | 72 | |
73 | 73 | if ( isset( $values['id'] ) ) { |
74 | 74 | $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key']; |
75 | - $new_values = apply_filters('frm_duplicated_field', $new_values); |
|
76 | - } |
|
75 | + $new_values = apply_filters('frm_duplicated_field', $new_values); |
|
76 | + } |
|
77 | 77 | |
78 | 78 | foreach ( $new_values as $k => $v ) { |
79 | - if ( is_array( $v ) ) { |
|
79 | + if ( is_array( $v ) ) { |
|
80 | 80 | $new_values[ $k ] = serialize( $v ); |
81 | 81 | } |
82 | - unset( $k, $v ); |
|
83 | - } |
|
82 | + unset( $k, $v ); |
|
83 | + } |
|
84 | 84 | |
85 | - //if(isset($values['id']) and is_numeric($values['id'])) |
|
86 | - // $new_values['id'] = $values['id']; |
|
85 | + //if(isset($values['id']) and is_numeric($values['id'])) |
|
86 | + // $new_values['id'] = $values['id']; |
|
87 | 87 | |
88 | 88 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values ); |
89 | 89 | $new_id = 0; |
@@ -104,22 +104,22 @@ discard block |
||
104 | 104 | } else { |
105 | 105 | return false; |
106 | 106 | } |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | - public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) { |
|
110 | - global $frm_duplicate_ids; |
|
109 | + public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) { |
|
110 | + global $frm_duplicate_ids; |
|
111 | 111 | |
112 | 112 | $where = array( array( 'or' => 1, 'fi.form_id' => $old_form_id, 'fr.parent_form_id' => $old_form_id ) ); |
113 | 113 | $fields = self::getAll( $where, 'field_order', '', $blog_id ); |
114 | 114 | |
115 | - foreach ( (array) $fields as $field ) { |
|
116 | - $new_key = ($copy_keys) ? $field->field_key : ''; |
|
117 | - if ( $copy_keys && substr($field->field_key, -1) == 2 ) { |
|
118 | - $new_key = rtrim($new_key, 2); |
|
119 | - } |
|
115 | + foreach ( (array) $fields as $field ) { |
|
116 | + $new_key = ($copy_keys) ? $field->field_key : ''; |
|
117 | + if ( $copy_keys && substr($field->field_key, -1) == 2 ) { |
|
118 | + $new_key = rtrim($new_key, 2); |
|
119 | + } |
|
120 | 120 | |
121 | - $values = array(); |
|
122 | - FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key ); |
|
121 | + $values = array(); |
|
122 | + FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key ); |
|
123 | 123 | |
124 | 124 | // If this is a repeating section, create new form |
125 | 125 | if ( self::is_repeating_field( $field ) ) { |
@@ -138,16 +138,16 @@ discard block |
||
138 | 138 | $values['form_id'] = $new_repeat_form_id; |
139 | 139 | } |
140 | 140 | |
141 | - $values = apply_filters('frm_duplicated_field', $values); |
|
142 | - $new_id = self::create($values); |
|
143 | - $frm_duplicate_ids[ $field->id ] = $new_id; |
|
144 | - $frm_duplicate_ids[ $field->field_key ] = $new_id; |
|
145 | - unset($field); |
|
146 | - } |
|
147 | - } |
|
141 | + $values = apply_filters('frm_duplicated_field', $values); |
|
142 | + $new_id = self::create($values); |
|
143 | + $frm_duplicate_ids[ $field->id ] = $new_id; |
|
144 | + $frm_duplicate_ids[ $field->field_key ] = $new_id; |
|
145 | + unset($field); |
|
146 | + } |
|
147 | + } |
|
148 | 148 | |
149 | 149 | public static function update( $id, $values ) { |
150 | - global $wpdb; |
|
150 | + global $wpdb; |
|
151 | 151 | |
152 | 152 | $id = absint( $id ); |
153 | 153 | |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | $values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id ); |
156 | 156 | } |
157 | 157 | |
158 | - if ( isset($values['required']) ) { |
|
159 | - $values['required'] = (int) $values['required']; |
|
160 | - } |
|
158 | + if ( isset($values['required']) ) { |
|
159 | + $values['required'] = (int) $values['required']; |
|
160 | + } |
|
161 | 161 | |
162 | 162 | self::preserve_format_option_backslashes( $values ); |
163 | 163 | |
@@ -174,41 +174,41 @@ discard block |
||
174 | 174 | |
175 | 175 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) ); |
176 | 176 | |
177 | - $form_id = 0; |
|
177 | + $form_id = 0; |
|
178 | 178 | if ( isset( $values['form_id'] ) ) { |
179 | - $form_id = absint( $values['form_id'] ); |
|
179 | + $form_id = absint( $values['form_id'] ); |
|
180 | 180 | } else { |
181 | - $field = self::getOne($id); |
|
182 | - if ( $field ) { |
|
183 | - $form_id = $field->form_id; |
|
184 | - } |
|
185 | - unset($field); |
|
186 | - } |
|
187 | - unset($values); |
|
181 | + $field = self::getOne($id); |
|
182 | + if ( $field ) { |
|
183 | + $form_id = $field->form_id; |
|
184 | + } |
|
185 | + unset($field); |
|
186 | + } |
|
187 | + unset($values); |
|
188 | 188 | |
189 | 189 | if ( $query_results ) { |
190 | - wp_cache_delete( $id, 'frm_field' ); |
|
191 | - if ( $form_id ) { |
|
192 | - self::delete_form_transient( $form_id ); |
|
193 | - } |
|
194 | - } |
|
190 | + wp_cache_delete( $id, 'frm_field' ); |
|
191 | + if ( $form_id ) { |
|
192 | + self::delete_form_transient( $form_id ); |
|
193 | + } |
|
194 | + } |
|
195 | 195 | |
196 | - return $query_results; |
|
197 | - } |
|
196 | + return $query_results; |
|
197 | + } |
|
198 | 198 | |
199 | 199 | /** |
200 | - * Keep backslashes in the phone format option |
|
201 | - * |
|
202 | - * @since 2.0.8 |
|
203 | - * @param $values array - pass by reference |
|
204 | - */ |
|
200 | + * Keep backslashes in the phone format option |
|
201 | + * |
|
202 | + * @since 2.0.8 |
|
203 | + * @param $values array - pass by reference |
|
204 | + */ |
|
205 | 205 | private static function preserve_format_option_backslashes( &$values ) { |
206 | 206 | if ( isset( $values['field_options']['format'] ) ) { |
207 | 207 | $values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] ); |
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
211 | - public static function destroy( $id ) { |
|
211 | + public static function destroy( $id ) { |
|
212 | 212 | global $wpdb; |
213 | 213 | |
214 | 214 | do_action( 'frm_before_destroy_field', $id ); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $id ) ); |
225 | 225 | return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) ); |
226 | - } |
|
226 | + } |
|
227 | 227 | |
228 | 228 | public static function delete_form_transient( $form_id ) { |
229 | 229 | $form_id = absint( $form_id ); |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | |
238 | 238 | FrmAppHelper::cache_delete_group( 'frm_field' ); |
239 | 239 | |
240 | - $form = FrmForm::getOne($form_id); |
|
241 | - if ( $form && $form->parent_form_id ) { |
|
242 | - self::delete_form_transient( $form->parent_form_id ); |
|
243 | - } |
|
244 | - } |
|
240 | + $form = FrmForm::getOne($form_id); |
|
241 | + if ( $form && $form->parent_form_id ) { |
|
242 | + self::delete_form_transient( $form->parent_form_id ); |
|
243 | + } |
|
244 | + } |
|
245 | 245 | |
246 | 246 | /** |
247 | 247 | * If $field is numeric, get the field object |
@@ -257,131 +257,131 @@ discard block |
||
257 | 257 | return; |
258 | 258 | } |
259 | 259 | |
260 | - global $wpdb; |
|
260 | + global $wpdb; |
|
261 | 261 | |
262 | - $where = is_numeric($id) ? 'id=%d' : 'field_key=%s'; |
|
262 | + $where = is_numeric($id) ? 'id=%d' : 'field_key=%s'; |
|
263 | 263 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); |
264 | 264 | |
265 | - $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
|
265 | + $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
|
266 | 266 | |
267 | - if ( empty($results) ) { |
|
268 | - return $results; |
|
269 | - } |
|
267 | + if ( empty($results) ) { |
|
268 | + return $results; |
|
269 | + } |
|
270 | 270 | |
271 | - if ( is_numeric($id) ) { |
|
271 | + if ( is_numeric($id) ) { |
|
272 | 272 | FrmAppHelper::set_cache( $results->field_key, $results, 'frm_field' ); |
273 | - } else if ( $results ) { |
|
273 | + } else if ( $results ) { |
|
274 | 274 | FrmAppHelper::set_cache( $results->id, $results, 'frm_field' ); |
275 | - } |
|
275 | + } |
|
276 | 276 | |
277 | 277 | self::prepare_options( $results ); |
278 | 278 | |
279 | - return stripslashes_deep($results); |
|
280 | - } |
|
279 | + return stripslashes_deep($results); |
|
280 | + } |
|
281 | 281 | |
282 | - /** |
|
283 | - * Get the field type by key or id |
|
284 | - * @param int|string The field id or key |
|
282 | + /** |
|
283 | + * Get the field type by key or id |
|
284 | + * @param int|string The field id or key |
|
285 | 285 | * @param mixed $col The name of the column in the fields database table |
286 | - */ |
|
287 | - public static function &get_type( $id, $col = 'type' ) { |
|
288 | - $field = FrmAppHelper::check_cache( $id, 'frm_field' ); |
|
289 | - if ( $field ) { |
|
290 | - $type = $field->{$col}; |
|
291 | - } else { |
|
292 | - $type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col ); |
|
293 | - } |
|
294 | - |
|
295 | - return $type; |
|
296 | - } |
|
286 | + */ |
|
287 | + public static function &get_type( $id, $col = 'type' ) { |
|
288 | + $field = FrmAppHelper::check_cache( $id, 'frm_field' ); |
|
289 | + if ( $field ) { |
|
290 | + $type = $field->{$col}; |
|
291 | + } else { |
|
292 | + $type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col ); |
|
293 | + } |
|
294 | + |
|
295 | + return $type; |
|
296 | + } |
|
297 | 297 | |
298 | 298 | public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) { |
299 | - if ( ! $form_id ) { |
|
300 | - return array(); |
|
301 | - } |
|
299 | + if ( ! $form_id ) { |
|
300 | + return array(); |
|
301 | + } |
|
302 | 302 | |
303 | 303 | $results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_sub, 'inc_repeat' => $inc_sub ) ); |
304 | 304 | if ( ! empty( $results ) ) { |
305 | - $fields = array(); |
|
306 | - $count = 0; |
|
307 | - foreach ( $results as $result ) { |
|
308 | - if ( $type != $result->type ) { |
|
309 | - continue; |
|
310 | - } |
|
305 | + $fields = array(); |
|
306 | + $count = 0; |
|
307 | + foreach ( $results as $result ) { |
|
308 | + if ( $type != $result->type ) { |
|
309 | + continue; |
|
310 | + } |
|
311 | 311 | |
312 | 312 | $fields[ $result->id ] = $result; |
313 | - $count++; |
|
314 | - if ( $limit == 1 ) { |
|
315 | - $fields = $result; |
|
316 | - break; |
|
317 | - } |
|
313 | + $count++; |
|
314 | + if ( $limit == 1 ) { |
|
315 | + $fields = $result; |
|
316 | + break; |
|
317 | + } |
|
318 | 318 | |
319 | - if ( ! empty($limit) && $count >= $limit ) { |
|
320 | - break; |
|
321 | - } |
|
319 | + if ( ! empty($limit) && $count >= $limit ) { |
|
320 | + break; |
|
321 | + } |
|
322 | 322 | |
323 | - unset($result); |
|
324 | - } |
|
325 | - return stripslashes_deep($fields); |
|
326 | - } |
|
323 | + unset($result); |
|
324 | + } |
|
325 | + return stripslashes_deep($fields); |
|
326 | + } |
|
327 | 327 | |
328 | - self::$use_cache = false; |
|
328 | + self::$use_cache = false; |
|
329 | 329 | |
330 | 330 | $where = array( 'fi.form_id' => (int) $form_id, 'fi.type' => $type ); |
331 | 331 | self::maybe_include_repeating_fields( $inc_sub, $where ); |
332 | 332 | $results = self::getAll( $where, 'field_order', $limit ); |
333 | - self::$use_cache = true; |
|
334 | - self::include_sub_fields($results, $inc_sub, $type); |
|
333 | + self::$use_cache = true; |
|
334 | + self::include_sub_fields($results, $inc_sub, $type); |
|
335 | 335 | |
336 | - return $results; |
|
337 | - } |
|
336 | + return $results; |
|
337 | + } |
|
338 | 338 | |
339 | 339 | public static function get_all_for_form( $form_id, $limit = '', $inc_embed = 'exclude', $inc_repeat = 'include' ) { |
340 | - if ( ! (int) $form_id ) { |
|
341 | - return array(); |
|
342 | - } |
|
340 | + if ( ! (int) $form_id ) { |
|
341 | + return array(); |
|
342 | + } |
|
343 | 343 | |
344 | 344 | $results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) ); |
345 | 345 | if ( ! empty( $results ) ) { |
346 | - if ( empty($limit) ) { |
|
346 | + if ( empty($limit) ) { |
|
347 | 347 | return $results; |
348 | - } |
|
348 | + } |
|
349 | 349 | |
350 | - $fields = array(); |
|
351 | - $count = 0; |
|
352 | - foreach ( $results as $result ) { |
|
350 | + $fields = array(); |
|
351 | + $count = 0; |
|
352 | + foreach ( $results as $result ) { |
|
353 | 353 | $fields[ $result->id ] = $result; |
354 | - if ( ! empty($limit) && $count >= $limit ) { |
|
355 | - break; |
|
356 | - } |
|
357 | - } |
|
354 | + if ( ! empty($limit) && $count >= $limit ) { |
|
355 | + break; |
|
356 | + } |
|
357 | + } |
|
358 | 358 | |
359 | 359 | return $fields; |
360 | - } |
|
360 | + } |
|
361 | 361 | |
362 | - self::$use_cache = false; |
|
362 | + self::$use_cache = false; |
|
363 | 363 | |
364 | 364 | $where = array( 'fi.form_id' => absint( $form_id ) ); |
365 | 365 | self::maybe_include_repeating_fields( $inc_repeat, $where ); |
366 | 366 | $results = self::getAll( $where, 'field_order', $limit ); |
367 | 367 | |
368 | - self::$use_cache = true; |
|
368 | + self::$use_cache = true; |
|
369 | 369 | |
370 | 370 | self::include_sub_fields( $results, $inc_embed, 'all' ); |
371 | 371 | |
372 | - if ( empty($limit) ) { |
|
372 | + if ( empty($limit) ) { |
|
373 | 373 | self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) ); |
374 | - } |
|
374 | + } |
|
375 | 375 | |
376 | 376 | return $results; |
377 | - } |
|
377 | + } |
|
378 | 378 | |
379 | 379 | /** |
380 | - * If repeating fields should be included, adjust $where accordingly |
|
381 | - * |
|
382 | - * @param string $inc_repeat |
|
383 | - * @param array $where - pass by reference |
|
384 | - */ |
|
380 | + * If repeating fields should be included, adjust $where accordingly |
|
381 | + * |
|
382 | + * @param string $inc_repeat |
|
383 | + * @param array $where - pass by reference |
|
384 | + */ |
|
385 | 385 | private static function maybe_include_repeating_fields( $inc_repeat, &$where ) { |
386 | 386 | if ( $inc_repeat == 'include' ) { |
387 | 387 | $form_id = $where['fi.form_id']; |
@@ -392,77 +392,77 @@ discard block |
||
392 | 392 | |
393 | 393 | public static function include_sub_fields( &$results, $inc_embed, $type = 'all' ) { |
394 | 394 | if ( 'include' != $inc_embed || empty( $results ) ) { |
395 | - return; |
|
396 | - } |
|
395 | + return; |
|
396 | + } |
|
397 | 397 | |
398 | - $form_fields = $results; |
|
398 | + $form_fields = $results; |
|
399 | 399 | $index_offset = 1; |
400 | - foreach ( $form_fields as $k => $field ) { |
|
401 | - if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) { |
|
402 | - continue; |
|
403 | - } |
|
404 | - |
|
405 | - if ( $type == 'all' ) { |
|
406 | - $sub_fields = self::get_all_for_form( $field->field_options['form_select'] ); |
|
407 | - } else { |
|
408 | - $sub_fields = self::get_all_types_in_form($field->form_id, $type); |
|
409 | - } |
|
410 | - |
|
411 | - if ( ! empty($sub_fields) ) { |
|
400 | + foreach ( $form_fields as $k => $field ) { |
|
401 | + if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) { |
|
402 | + continue; |
|
403 | + } |
|
404 | + |
|
405 | + if ( $type == 'all' ) { |
|
406 | + $sub_fields = self::get_all_for_form( $field->field_options['form_select'] ); |
|
407 | + } else { |
|
408 | + $sub_fields = self::get_all_types_in_form($field->form_id, $type); |
|
409 | + } |
|
410 | + |
|
411 | + if ( ! empty($sub_fields) ) { |
|
412 | 412 | $index = $k + $index_offset; |
413 | 413 | $index_offset += count( $sub_fields ); |
414 | 414 | array_splice($results, $index, 0, $sub_fields); |
415 | - } |
|
416 | - unset($field, $sub_fields); |
|
417 | - } |
|
418 | - } |
|
415 | + } |
|
416 | + unset($field, $sub_fields); |
|
417 | + } |
|
418 | + } |
|
419 | 419 | |
420 | 420 | public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) { |
421 | 421 | $cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id; |
422 | - if ( self::$use_cache ) { |
|
423 | - // make sure old cache doesn't get saved as a transient |
|
424 | - $results = wp_cache_get($cache_key, 'frm_field'); |
|
425 | - if ( false !== $results ) { |
|
426 | - return stripslashes_deep($results); |
|
427 | - } |
|
428 | - } |
|
429 | - |
|
430 | - global $wpdb; |
|
431 | - |
|
432 | - if ( $blog_id && is_multisite() ) { |
|
433 | - global $wpmuBaseTablePrefix; |
|
434 | - if ( $wpmuBaseTablePrefix ) { |
|
422 | + if ( self::$use_cache ) { |
|
423 | + // make sure old cache doesn't get saved as a transient |
|
424 | + $results = wp_cache_get($cache_key, 'frm_field'); |
|
425 | + if ( false !== $results ) { |
|
426 | + return stripslashes_deep($results); |
|
427 | + } |
|
428 | + } |
|
429 | + |
|
430 | + global $wpdb; |
|
431 | + |
|
432 | + if ( $blog_id && is_multisite() ) { |
|
433 | + global $wpmuBaseTablePrefix; |
|
434 | + if ( $wpmuBaseTablePrefix ) { |
|
435 | 435 | $prefix = $wpmuBaseTablePrefix . $blog_id . '_'; |
436 | - } else { |
|
437 | - $prefix = $wpdb->get_blog_prefix( $blog_id ); |
|
438 | - } |
|
436 | + } else { |
|
437 | + $prefix = $wpdb->get_blog_prefix( $blog_id ); |
|
438 | + } |
|
439 | 439 | |
440 | 440 | $table_name = $prefix . 'frm_fields'; |
441 | 441 | $form_table_name = $prefix . 'frm_forms'; |
442 | 442 | } else { |
443 | 443 | $table_name = $wpdb->prefix . 'frm_fields'; |
444 | 444 | $form_table_name = $wpdb->prefix . 'frm_forms'; |
445 | - } |
|
445 | + } |
|
446 | 446 | |
447 | 447 | if ( ! empty( $order_by ) && strpos( $order_by, 'ORDER BY' ) === false ) { |
448 | 448 | $order_by = ' ORDER BY ' . $order_by; |
449 | 449 | } |
450 | 450 | |
451 | - $limit = FrmAppHelper::esc_limit($limit); |
|
451 | + $limit = FrmAppHelper::esc_limit($limit); |
|
452 | 452 | |
453 | - $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; |
|
454 | - $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results'; |
|
453 | + $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; |
|
454 | + $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results'; |
|
455 | 455 | |
456 | - if ( is_array($where) ) { |
|
457 | - $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type ); |
|
456 | + if ( is_array($where) ) { |
|
457 | + $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type ); |
|
458 | 458 | } else { |
459 | 459 | // if the query is not an array, then it has already been prepared |
460 | - $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
460 | + $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
461 | 461 | |
462 | 462 | $function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results'; |
463 | 463 | $results = $wpdb->$function_name( $query ); |
464 | - } |
|
465 | - unset( $where ); |
|
464 | + } |
|
465 | + unset( $where ); |
|
466 | 466 | |
467 | 467 | self::format_field_results( $results ); |
468 | 468 | |
@@ -561,21 +561,21 @@ discard block |
||
561 | 561 | |
562 | 562 | public static function getIds( $where = '', $order_by = '', $limit = '' ) { |
563 | 563 | _deprecated_function( __FUNCTION__, '2.0' ); |
564 | - global $wpdb; |
|
565 | - if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) { |
|
564 | + global $wpdb; |
|
565 | + if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) { |
|
566 | 566 | $order_by = ' ORDER BY ' . $order_by; |
567 | - } |
|
567 | + } |
|
568 | 568 | |
569 | 569 | $query = 'SELECT fi.id FROM ' . $wpdb->prefix . 'frm_fields fi ' . |
570 | 570 | 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON fi.form_id=fr.id' . |
571 | 571 | FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
572 | 572 | |
573 | - $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col'; |
|
573 | + $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col'; |
|
574 | 574 | $cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit; |
575 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method); |
|
575 | + $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method); |
|
576 | 576 | |
577 | - return $results; |
|
578 | - } |
|
577 | + return $results; |
|
578 | + } |
|
579 | 579 | |
580 | 580 | public static function is_no_save_field( $type ) { |
581 | 581 | return in_array( $type, self::no_save_fields() ); |
@@ -718,8 +718,8 @@ discard block |
||
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
721 | - * @since 2.0.09 |
|
722 | - */ |
|
721 | + * @since 2.0.09 |
|
722 | + */ |
|
723 | 723 | public static function is_repeating_field( $field ) { |
724 | 724 | if ( is_array( $field ) ) { |
725 | 725 | $is_repeating_field = ( 'divider' == $field['type'] ); |
@@ -729,14 +729,14 @@ discard block |
||
729 | 729 | return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) ); |
730 | 730 | } |
731 | 731 | |
732 | - /** |
|
733 | - * @param string $key |
|
734 | - * @return int field id |
|
735 | - */ |
|
732 | + /** |
|
733 | + * @param string $key |
|
734 | + * @return int field id |
|
735 | + */ |
|
736 | 736 | public static function get_id_by_key( $key ) { |
737 | - $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) ); |
|
738 | - return $id; |
|
739 | - } |
|
737 | + $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) ); |
|
738 | + return $id; |
|
739 | + } |
|
740 | 740 | |
741 | 741 | /** |
742 | 742 | * @param string $id |
@@ -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 | |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | static $transient_size = 200; |
9 | 9 | |
10 | 10 | public static function field_selection() { |
11 | - $fields = apply_filters('frm_available_fields', array( |
|
11 | + $fields = apply_filters( 'frm_available_fields', array( |
|
12 | 12 | 'text' => __( 'Single Line Text', 'formidable' ), |
13 | 13 | 'textarea' => __( 'Paragraph Text', 'formidable' ), |
14 | 14 | 'checkbox' => __( 'Checkboxes', 'formidable' ), |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | 'email' => __( 'Email Address', 'formidable' ), |
18 | 18 | 'url' => __( 'Website/URL', 'formidable' ), |
19 | 19 | 'captcha' => __( 'reCAPTCHA', 'formidable' ), |
20 | - )); |
|
20 | + ) ); |
|
21 | 21 | |
22 | 22 | return $fields; |
23 | 23 | } |
24 | 24 | |
25 | 25 | public static function pro_field_selection() { |
26 | - return apply_filters('frm_pro_available_fields', array( |
|
26 | + return apply_filters( 'frm_pro_available_fields', array( |
|
27 | 27 | 'end_divider' => array( |
28 | 28 | 'name' => __( 'End Section', 'formidable' ), |
29 | 29 | 'switch_from' => 'divider', |
@@ -48,36 +48,36 @@ discard block |
||
48 | 48 | 'tag' => __( 'Tags', 'formidable' ), |
49 | 49 | 'credit_card' => __( 'Credit Card', 'formidable' ), |
50 | 50 | 'address' => __( 'Address', 'formidable' ), |
51 | - )); |
|
51 | + ) ); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public static function create( $values, $return = true ) { |
55 | 55 | global $wpdb, $frm_duplicate_ids; |
56 | 56 | |
57 | 57 | $new_values = array(); |
58 | - $key = isset($values['field_key']) ? $values['field_key'] : $values['name']; |
|
58 | + $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name']; |
|
59 | 59 | $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
60 | 60 | |
61 | 61 | foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) { |
62 | - $new_values[ $col ] = $values[ $col ]; |
|
62 | + $new_values[$col] = $values[$col]; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | $new_values['options'] = $values['options']; |
66 | 66 | |
67 | - $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null; |
|
68 | - $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0; |
|
69 | - $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null; |
|
67 | + $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null; |
|
68 | + $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0; |
|
69 | + $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null; |
|
70 | 70 | $new_values['field_options'] = $values['field_options']; |
71 | - $new_values['created_at'] = current_time('mysql', 1); |
|
71 | + $new_values['created_at'] = current_time( 'mysql', 1 ); |
|
72 | 72 | |
73 | 73 | if ( isset( $values['id'] ) ) { |
74 | - $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key']; |
|
75 | - $new_values = apply_filters('frm_duplicated_field', $new_values); |
|
74 | + $frm_duplicate_ids[$values['field_key']] = $new_values['field_key']; |
|
75 | + $new_values = apply_filters( 'frm_duplicated_field', $new_values ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | foreach ( $new_values as $k => $v ) { |
79 | 79 | if ( is_array( $v ) ) { |
80 | - $new_values[ $k ] = serialize( $v ); |
|
80 | + $new_values[$k] = serialize( $v ); |
|
81 | 81 | } |
82 | 82 | unset( $k, $v ); |
83 | 83 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | if ( $query_results ) { |
100 | 100 | if ( isset( $values['id'] ) ) { |
101 | - $frm_duplicate_ids[ $values['id'] ] = $new_id; |
|
101 | + $frm_duplicate_ids[$values['id']] = $new_id; |
|
102 | 102 | } |
103 | 103 | return $new_id; |
104 | 104 | } else { |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | $fields = self::getAll( $where, 'field_order', '', $blog_id ); |
114 | 114 | |
115 | 115 | foreach ( (array) $fields as $field ) { |
116 | - $new_key = ($copy_keys) ? $field->field_key : ''; |
|
117 | - if ( $copy_keys && substr($field->field_key, -1) == 2 ) { |
|
118 | - $new_key = rtrim($new_key, 2); |
|
116 | + $new_key = ( $copy_keys ) ? $field->field_key : ''; |
|
117 | + if ( $copy_keys && substr( $field->field_key, -1 ) == 2 ) { |
|
118 | + $new_key = rtrim( $new_key, 2 ); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $values = array(); |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | $values['form_id'] = $new_repeat_form_id; |
139 | 139 | } |
140 | 140 | |
141 | - $values = apply_filters('frm_duplicated_field', $values); |
|
142 | - $new_id = self::create($values); |
|
143 | - $frm_duplicate_ids[ $field->id ] = $new_id; |
|
144 | - $frm_duplicate_ids[ $field->field_key ] = $new_id; |
|
145 | - unset($field); |
|
141 | + $values = apply_filters( 'frm_duplicated_field', $values ); |
|
142 | + $new_id = self::create( $values ); |
|
143 | + $frm_duplicate_ids[$field->id] = $new_id; |
|
144 | + $frm_duplicate_ids[$field->field_key] = $new_id; |
|
145 | + unset( $field ); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id ); |
156 | 156 | } |
157 | 157 | |
158 | - if ( isset($values['required']) ) { |
|
158 | + if ( isset( $values['required'] ) ) { |
|
159 | 159 | $values['required'] = (int) $values['required']; |
160 | 160 | } |
161 | 161 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | |
168 | 168 | // serialize array values |
169 | 169 | foreach ( array( 'default_value', 'field_options', 'options' ) as $opt ) { |
170 | - if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) { |
|
171 | - $values[ $opt ] = serialize( $values[ $opt ] ); |
|
170 | + if ( isset( $values[$opt] ) && is_array( $values[$opt] ) ) { |
|
171 | + $values[$opt] = serialize( $values[$opt] ); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | if ( isset( $values['form_id'] ) ) { |
179 | 179 | $form_id = absint( $values['form_id'] ); |
180 | 180 | } else { |
181 | - $field = self::getOne($id); |
|
181 | + $field = self::getOne( $id ); |
|
182 | 182 | if ( $field ) { |
183 | 183 | $form_id = $field->form_id; |
184 | 184 | } |
185 | - unset($field); |
|
185 | + unset( $field ); |
|
186 | 186 | } |
187 | - unset($values); |
|
187 | + unset( $values ); |
|
188 | 188 | |
189 | 189 | if ( $query_results ) { |
190 | 190 | wp_cache_delete( $id, 'frm_field' ); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | FrmAppHelper::cache_delete_group( 'frm_field' ); |
239 | 239 | |
240 | - $form = FrmForm::getOne($form_id); |
|
240 | + $form = FrmForm::getOne( $form_id ); |
|
241 | 241 | if ( $form && $form->parent_form_id ) { |
242 | 242 | self::delete_form_transient( $form->parent_form_id ); |
243 | 243 | } |
@@ -259,16 +259,16 @@ discard block |
||
259 | 259 | |
260 | 260 | global $wpdb; |
261 | 261 | |
262 | - $where = is_numeric($id) ? 'id=%d' : 'field_key=%s'; |
|
262 | + $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s'; |
|
263 | 263 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); |
264 | 264 | |
265 | 265 | $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
266 | 266 | |
267 | - if ( empty($results) ) { |
|
267 | + if ( empty( $results ) ) { |
|
268 | 268 | return $results; |
269 | 269 | } |
270 | 270 | |
271 | - if ( is_numeric($id) ) { |
|
271 | + if ( is_numeric( $id ) ) { |
|
272 | 272 | FrmAppHelper::set_cache( $results->field_key, $results, 'frm_field' ); |
273 | 273 | } else if ( $results ) { |
274 | 274 | FrmAppHelper::set_cache( $results->id, $results, 'frm_field' ); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | self::prepare_options( $results ); |
278 | 278 | |
279 | - return stripslashes_deep($results); |
|
279 | + return stripslashes_deep( $results ); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -309,20 +309,20 @@ discard block |
||
309 | 309 | continue; |
310 | 310 | } |
311 | 311 | |
312 | - $fields[ $result->id ] = $result; |
|
313 | - $count++; |
|
312 | + $fields[$result->id] = $result; |
|
313 | + $count ++; |
|
314 | 314 | if ( $limit == 1 ) { |
315 | 315 | $fields = $result; |
316 | 316 | break; |
317 | 317 | } |
318 | 318 | |
319 | - if ( ! empty($limit) && $count >= $limit ) { |
|
319 | + if ( ! empty( $limit ) && $count >= $limit ) { |
|
320 | 320 | break; |
321 | 321 | } |
322 | 322 | |
323 | - unset($result); |
|
323 | + unset( $result ); |
|
324 | 324 | } |
325 | - return stripslashes_deep($fields); |
|
325 | + return stripslashes_deep( $fields ); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | self::$use_cache = false; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | self::maybe_include_repeating_fields( $inc_sub, $where ); |
332 | 332 | $results = self::getAll( $where, 'field_order', $limit ); |
333 | 333 | self::$use_cache = true; |
334 | - self::include_sub_fields($results, $inc_sub, $type); |
|
334 | + self::include_sub_fields( $results, $inc_sub, $type ); |
|
335 | 335 | |
336 | 336 | return $results; |
337 | 337 | } |
@@ -343,15 +343,15 @@ discard block |
||
343 | 343 | |
344 | 344 | $results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) ); |
345 | 345 | if ( ! empty( $results ) ) { |
346 | - if ( empty($limit) ) { |
|
346 | + if ( empty( $limit ) ) { |
|
347 | 347 | return $results; |
348 | 348 | } |
349 | 349 | |
350 | 350 | $fields = array(); |
351 | 351 | $count = 0; |
352 | 352 | foreach ( $results as $result ) { |
353 | - $fields[ $result->id ] = $result; |
|
354 | - if ( ! empty($limit) && $count >= $limit ) { |
|
353 | + $fields[$result->id] = $result; |
|
354 | + if ( ! empty( $limit ) && $count >= $limit ) { |
|
355 | 355 | break; |
356 | 356 | } |
357 | 357 | } |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | |
370 | 370 | self::include_sub_fields( $results, $inc_embed, 'all' ); |
371 | 371 | |
372 | - if ( empty($limit) ) { |
|
372 | + if ( empty( $limit ) ) { |
|
373 | 373 | self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) ); |
374 | 374 | } |
375 | 375 | |
@@ -398,22 +398,22 @@ discard block |
||
398 | 398 | $form_fields = $results; |
399 | 399 | $index_offset = 1; |
400 | 400 | foreach ( $form_fields as $k => $field ) { |
401 | - if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) { |
|
401 | + if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) { |
|
402 | 402 | continue; |
403 | 403 | } |
404 | 404 | |
405 | 405 | if ( $type == 'all' ) { |
406 | 406 | $sub_fields = self::get_all_for_form( $field->field_options['form_select'] ); |
407 | 407 | } else { |
408 | - $sub_fields = self::get_all_types_in_form($field->form_id, $type); |
|
408 | + $sub_fields = self::get_all_types_in_form( $field->form_id, $type ); |
|
409 | 409 | } |
410 | 410 | |
411 | - if ( ! empty($sub_fields) ) { |
|
411 | + if ( ! empty( $sub_fields ) ) { |
|
412 | 412 | $index = $k + $index_offset; |
413 | 413 | $index_offset += count( $sub_fields ); |
414 | - array_splice($results, $index, 0, $sub_fields); |
|
414 | + array_splice( $results, $index, 0, $sub_fields ); |
|
415 | 415 | } |
416 | - unset($field, $sub_fields); |
|
416 | + unset( $field, $sub_fields ); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
@@ -421,9 +421,9 @@ discard block |
||
421 | 421 | $cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id; |
422 | 422 | if ( self::$use_cache ) { |
423 | 423 | // make sure old cache doesn't get saved as a transient |
424 | - $results = wp_cache_get($cache_key, 'frm_field'); |
|
424 | + $results = wp_cache_get( $cache_key, 'frm_field' ); |
|
425 | 425 | if ( false !== $results ) { |
426 | - return stripslashes_deep($results); |
|
426 | + return stripslashes_deep( $results ); |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
@@ -448,16 +448,16 @@ discard block |
||
448 | 448 | $order_by = ' ORDER BY ' . $order_by; |
449 | 449 | } |
450 | 450 | |
451 | - $limit = FrmAppHelper::esc_limit($limit); |
|
451 | + $limit = FrmAppHelper::esc_limit( $limit ); |
|
452 | 452 | |
453 | 453 | $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; |
454 | 454 | $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results'; |
455 | 455 | |
456 | - if ( is_array($where) ) { |
|
456 | + if ( is_array( $where ) ) { |
|
457 | 457 | $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type ); |
458 | 458 | } else { |
459 | 459 | // if the query is not an array, then it has already been prepared |
460 | - $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
460 | + $query .= FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
461 | 461 | |
462 | 462 | $function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results'; |
463 | 463 | $results = $wpdb->$function_name( $query ); |
@@ -480,9 +480,9 @@ discard block |
||
480 | 480 | FrmAppHelper::set_cache( $result->id, $result, 'frm_field' ); |
481 | 481 | FrmAppHelper::set_cache( $result->field_key, $result, 'frm_field' ); |
482 | 482 | |
483 | - $results[ $r_key ]->field_options = maybe_unserialize( $result->field_options ); |
|
484 | - $results[ $r_key ]->options = maybe_unserialize( $result->options ); |
|
485 | - $results[ $r_key ]->default_value = maybe_unserialize( $result->default_value ); |
|
483 | + $results[$r_key]->field_options = maybe_unserialize( $result->field_options ); |
|
484 | + $results[$r_key]->options = maybe_unserialize( $result->options ); |
|
485 | + $results[$r_key]->default_value = maybe_unserialize( $result->default_value ); |
|
486 | 486 | |
487 | 487 | unset( $r_key, $result ); |
488 | 488 | } |
@@ -501,8 +501,8 @@ discard block |
||
501 | 501 | private static function prepare_options( &$results ) { |
502 | 502 | $results->field_options = maybe_unserialize( $results->field_options ); |
503 | 503 | |
504 | - $results->options = maybe_unserialize($results->options); |
|
505 | - $results->default_value = maybe_unserialize($results->default_value); |
|
504 | + $results->options = maybe_unserialize( $results->options ); |
|
505 | + $results->default_value = maybe_unserialize( $results->default_value ); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | |
530 | 530 | if ( count( $next_fields ) >= self::$transient_size ) { |
531 | 531 | // if this transient is full, check for another |
532 | - $next++; |
|
532 | + $next ++; |
|
533 | 533 | self::get_next_transient( $fields, $base_name, $next ); |
534 | 534 | } |
535 | 535 | } |
@@ -555,14 +555,14 @@ discard block |
||
555 | 555 | return; |
556 | 556 | } |
557 | 557 | |
558 | - $next++; |
|
558 | + $next ++; |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | |
562 | 562 | public static function getIds( $where = '', $order_by = '', $limit = '' ) { |
563 | 563 | _deprecated_function( __FUNCTION__, '2.0' ); |
564 | 564 | global $wpdb; |
565 | - if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) { |
|
565 | + if ( ! empty( $order_by ) && ! strpos( $order_by, 'ORDER BY' ) !== false ) { |
|
566 | 566 | $order_by = ' ORDER BY ' . $order_by; |
567 | 567 | } |
568 | 568 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col'; |
574 | 574 | $cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit; |
575 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method); |
|
575 | + $results = FrmAppHelper::check_cache( $cache_key, 'frm_field', $query, $method ); |
|
576 | 576 | |
577 | 577 | return $results; |
578 | 578 | } |
@@ -603,8 +603,8 @@ discard block |
||
603 | 603 | $is_multi_value_field = ( |
604 | 604 | $field['type'] == 'checkbox' || |
605 | 605 | $field['type'] == 'address' || |
606 | - ( $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) || |
|
607 | - ( $field['type'] == 'lookup' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) || |
|
606 | + ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) || |
|
607 | + ( $field['type'] == 'lookup' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) || |
|
608 | 608 | self::is_multiple_select( $field ) |
609 | 609 | ); |
610 | 610 | |
@@ -629,9 +629,9 @@ discard block |
||
629 | 629 | */ |
630 | 630 | public static function is_multiple_select( $field ) { |
631 | 631 | if ( is_array( $field ) ) { |
632 | - return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select') ) ); |
|
632 | + return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select' ) ) ); |
|
633 | 633 | } else { |
634 | - return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset($field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select') ) ); |
|
634 | + return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset( $field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select' ) ) ); |
|
635 | 635 | } |
636 | 636 | } |
637 | 637 | |
@@ -678,23 +678,23 @@ discard block |
||
678 | 678 | } |
679 | 679 | |
680 | 680 | public static function is_option_true_in_array( $field, $option ) { |
681 | - return isset( $field[ $option ] ) && $field[ $option ]; |
|
681 | + return isset( $field[$option] ) && $field[$option]; |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | public static function is_option_true_in_object( $field, $option ) { |
685 | - return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ]; |
|
685 | + return isset( $field->field_options[$option] ) && $field->field_options[$option]; |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | public static function is_option_empty_in_array( $field, $option ) { |
689 | - return ! isset( $field[ $option ] ) || empty( $field[ $option ] ); |
|
689 | + return ! isset( $field[$option] ) || empty( $field[$option] ); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | public static function is_option_empty_in_object( $field, $option ) { |
693 | - return ! isset( $field->field_options[ $option ] ) || empty( $field->field_options[ $option ] ); |
|
693 | + return ! isset( $field->field_options[$option] ) || empty( $field->field_options[$option] ); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | public static function is_option_value_in_object( $field, $option ) { |
697 | - return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != ''; |
|
697 | + return isset( $field->field_options[$option] ) && $field->field_options[$option] != ''; |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -710,11 +710,11 @@ discard block |
||
710 | 710 | } |
711 | 711 | |
712 | 712 | public static function get_option_in_array( $field, $option ) { |
713 | - return $field[ $option ]; |
|
713 | + return $field[$option]; |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | public static function get_option_in_object( $field, $option ) { |
717 | - return isset( $field->field_options[ $option ] ) ? $field->field_options[ $option ] : ''; |
|
717 | + return isset( $field->field_options[$option] ) ? $field->field_options[$option] : ''; |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |