@@ -746,6 +746,9 @@ discard block |
||
746 | 746 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
747 | 747 | } |
748 | 748 | |
749 | + /** |
|
750 | + * @param string $function |
|
751 | + */ |
|
749 | 752 | public static function recursive_function_map( $value, $function ) { |
750 | 753 | if ( is_array( $value ) ) { |
751 | 754 | $original_function = $function; |
@@ -1173,6 +1176,9 @@ discard block |
||
1173 | 1176 | return $sub . (($len < $original_len) ? $continue : ''); |
1174 | 1177 | } |
1175 | 1178 | |
1179 | + /** |
|
1180 | + * @param string[] $function_names |
|
1181 | + */ |
|
1176 | 1182 | public static function mb_function( $function_names, $args ) { |
1177 | 1183 | $mb_function_name = $function_names[0]; |
1178 | 1184 | $function_name = $function_names[1]; |
@@ -1206,6 +1212,9 @@ discard block |
||
1206 | 1212 | return $formatted; |
1207 | 1213 | } |
1208 | 1214 | |
1215 | + /** |
|
1216 | + * @param string $time_format |
|
1217 | + */ |
|
1209 | 1218 | private static function add_time_to_date( $time_format, $date ) { |
1210 | 1219 | if ( empty( $time_format ) ) { |
1211 | 1220 | $time_format = get_option('time_format'); |
@@ -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 | |
@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public static function plugin_folder() { |
26 | - return basename(self::plugin_path()); |
|
26 | + return basename( self::plugin_path() ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public static function plugin_path() { |
30 | - return dirname(dirname(dirname(__FILE__))); |
|
30 | + return dirname( dirname( dirname( __FILE__ ) ) ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public static function plugin_url() { |
34 | 34 | //prevously FRM_URL constant |
35 | - return plugins_url( '', self::plugin_path() .'/formidable.php' ); |
|
35 | + return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public static function relative_plugin_url() { |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | * @return string |
55 | 55 | */ |
56 | 56 | public static function site_name() { |
57 | - return get_option('blogname'); |
|
57 | + return get_option( 'blogname' ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public static function make_affiliate_url( $url ) { |
61 | - $affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') ); |
|
61 | + $affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) ); |
|
62 | 62 | $allowed_affiliates = array( 'mojo' ); |
63 | 63 | if ( in_array( strtolower( $affiliate_id ), $allowed_affiliates ) ) { |
64 | 64 | $url .= '?aff=' . $affiliate_id; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public static function get_settings() { |
78 | 78 | global $frm_settings; |
79 | - if ( empty($frm_settings) ) { |
|
79 | + if ( empty( $frm_settings ) ) { |
|
80 | 80 | $frm_settings = new FrmSettings(); |
81 | 81 | } |
82 | 82 | return $frm_settings; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | public static function pro_is_installed() { |
95 | - return apply_filters('frm_pro_installed', false); |
|
95 | + return apply_filters( 'frm_pro_installed', false ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @return boolean |
137 | 137 | */ |
138 | 138 | public static function doing_ajax() { |
139 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
139 | + return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page(); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @return boolean |
157 | 157 | */ |
158 | 158 | public static function is_admin() { |
159 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
159 | + return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @return string |
183 | 183 | */ |
184 | 184 | public static function get_server_value( $value ) { |
185 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
185 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
198 | 198 | 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
199 | 199 | ) as $key ) { |
200 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
200 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
201 | 201 | continue; |
202 | 202 | } |
203 | 203 | |
204 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
205 | - $ip = trim($ip); // just to be safe |
|
204 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
205 | + $ip = trim( $ip ); // just to be safe |
|
206 | 206 | |
207 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
207 | + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
|
208 | 208 | return $ip; |
209 | 209 | } |
210 | 210 | } |
@@ -214,15 +214,15 @@ discard block |
||
214 | 214 | } |
215 | 215 | |
216 | 216 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
217 | - if ( strpos($param, '[') ) { |
|
218 | - $params = explode('[', $param); |
|
217 | + if ( strpos( $param, '[' ) ) { |
|
218 | + $params = explode( '[', $param ); |
|
219 | 219 | $param = $params[0]; |
220 | 220 | } |
221 | 221 | |
222 | 222 | if ( $src == 'get' ) { |
223 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
224 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
225 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
223 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); |
|
224 | + if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { |
|
225 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) ); |
|
226 | 226 | } |
227 | 227 | self::sanitize_value( $sanitize, $value ); |
228 | 228 | } else { |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | |
232 | 232 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
233 | 233 | foreach ( $params as $k => $p ) { |
234 | - if ( ! $k || ! is_array($value) ) { |
|
234 | + if ( ! $k || ! is_array( $value ) ) { |
|
235 | 235 | continue; |
236 | 236 | } |
237 | 237 | |
238 | - $p = trim($p, ']'); |
|
239 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
238 | + $p = trim( $p, ']' ); |
|
239 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
@@ -278,16 +278,16 @@ discard block |
||
278 | 278 | |
279 | 279 | $value = $args['default']; |
280 | 280 | if ( $args['type'] == 'get' ) { |
281 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
282 | - $value = $_GET[ $args['param'] ]; |
|
281 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
282 | + $value = $_GET[$args['param']]; |
|
283 | 283 | } |
284 | 284 | } else if ( $args['type'] == 'post' ) { |
285 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
286 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
285 | + if ( isset( $_POST[$args['param']] ) ) { |
|
286 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
287 | 287 | } |
288 | 288 | } else { |
289 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
290 | - $value = $_REQUEST[ $args['param'] ]; |
|
289 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
290 | + $value = $_REQUEST[$args['param']]; |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | public static function sanitize_request( $sanitize_method, &$values ) { |
324 | 324 | $temp_values = $values; |
325 | 325 | foreach ( $temp_values as $k => $val ) { |
326 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
327 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
326 | + if ( isset( $sanitize_method[$k] ) ) { |
|
327 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | public static function sanitize_array( &$values ) { |
333 | 333 | $temp_values = $values; |
334 | 334 | foreach ( $temp_values as $k => $val ) { |
335 | - $values[ $k ] = wp_kses_post( $val ); |
|
335 | + $values[$k] = wp_kses_post( $val ); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | |
353 | 353 | $allowed_html = array(); |
354 | 354 | foreach ( $allowed as $a ) { |
355 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
355 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | return wp_kses( $value, $allowed_html ); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @since 2.0 |
364 | 364 | */ |
365 | 365 | public static function remove_get_action() { |
366 | - if ( ! isset($_GET) ) { |
|
366 | + if ( ! isset( $_GET ) ) { |
|
367 | 367 | return; |
368 | 368 | } |
369 | 369 | |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | global $wp_query; |
388 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
389 | - $value = $wp_query->query_vars[ $param ]; |
|
388 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
389 | + $value = $wp_query->query_vars[$param]; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | return $value; |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | */ |
398 | 398 | public static function trigger_hook_load( $type, $object = null ) { |
399 | 399 | // only load the form hooks once |
400 | - $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object); |
|
400 | + $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
|
401 | 401 | if ( ! $hooks_loaded ) { |
402 | - do_action('frm_load_'. $type .'_hooks'); |
|
402 | + do_action( 'frm_load_' . $type . '_hooks' ); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -415,16 +415,16 @@ discard block |
||
415 | 415 | * @return mixed $results The cache or query results |
416 | 416 | */ |
417 | 417 | public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
418 | - $results = wp_cache_get($cache_key, $group); |
|
419 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
418 | + $results = wp_cache_get( $cache_key, $group ); |
|
419 | + if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) { |
|
420 | 420 | return $results; |
421 | 421 | } |
422 | 422 | |
423 | 423 | if ( 'get_posts' == $type ) { |
424 | - $results = get_posts($query); |
|
424 | + $results = get_posts( $query ); |
|
425 | 425 | } else { |
426 | 426 | global $wpdb; |
427 | - $results = $wpdb->{$type}($query); |
|
427 | + $results = $wpdb->{$type}( $query ); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | if ( ! self::prevent_caching() ) { |
@@ -448,9 +448,9 @@ discard block |
||
448 | 448 | } |
449 | 449 | |
450 | 450 | // then check the transient |
451 | - $results = get_transient($cache_key); |
|
451 | + $results = get_transient( $cache_key ); |
|
452 | 452 | if ( $results ) { |
453 | - wp_cache_set($cache_key, $results); |
|
453 | + wp_cache_set( $cache_key, $results ); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | return $results; |
@@ -461,8 +461,8 @@ discard block |
||
461 | 461 | * @param string $cache_key |
462 | 462 | */ |
463 | 463 | public static function delete_cache_and_transient( $cache_key ) { |
464 | - delete_transient($cache_key); |
|
465 | - wp_cache_delete($cache_key); |
|
464 | + delete_transient( $cache_key ); |
|
465 | + wp_cache_delete( $cache_key ); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
@@ -476,9 +476,9 @@ discard block |
||
476 | 476 | public static function cache_delete_group( $group ) { |
477 | 477 | global $wp_object_cache; |
478 | 478 | |
479 | - if ( isset( $wp_object_cache->cache[ $group ] ) ) { |
|
480 | - foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { |
|
481 | - wp_cache_delete($k, $group); |
|
479 | + if ( isset( $wp_object_cache->cache[$group] ) ) { |
|
480 | + foreach ( $wp_object_cache->cache[$group] as $k => $v ) { |
|
481 | + wp_cache_delete( $k, $group ); |
|
482 | 482 | } |
483 | 483 | return true; |
484 | 484 | } |
@@ -509,29 +509,29 @@ discard block |
||
509 | 509 | public static function load_scripts( $scripts ) { |
510 | 510 | _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
511 | 511 | foreach ( (array) $scripts as $s ) { |
512 | - wp_enqueue_script($s); |
|
512 | + wp_enqueue_script( $s ); |
|
513 | 513 | } |
514 | 514 | } |
515 | 515 | |
516 | 516 | public static function load_styles( $styles ) { |
517 | 517 | _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
518 | 518 | foreach ( (array) $styles as $s ) { |
519 | - wp_enqueue_style($s); |
|
519 | + wp_enqueue_style( $s ); |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
523 | 523 | public static function get_pages() { |
524 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
524 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
528 | 528 | $pages = self::get_pages(); |
529 | 529 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
530 | 530 | ?> |
531 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
531 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
532 | 532 | <option value=""> </option> |
533 | 533 | <?php foreach ( $pages as $page ) { ?> |
534 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
534 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
535 | 535 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
536 | 536 | </option> |
537 | 537 | <?php } ?> |
@@ -540,26 +540,26 @@ discard block |
||
540 | 540 | } |
541 | 541 | |
542 | 542 | public static function post_edit_link( $post_id ) { |
543 | - $post = get_post($post_id); |
|
543 | + $post = get_post( $post_id ); |
|
544 | 544 | if ( $post ) { |
545 | - return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>'; |
|
545 | + return '<a href="' . esc_url( admin_url( 'post.php' ) . '?post=' . $post_id . '&action=edit' ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
|
546 | 546 | } |
547 | 547 | return ''; |
548 | 548 | } |
549 | 549 | |
550 | 550 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
551 | 551 | ?> |
552 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
|
552 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php |
|
553 | 553 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
554 | 554 | ?> class="frm_multiselect"> |
555 | - <?php self::roles_options($capability); ?> |
|
555 | + <?php self::roles_options( $capability ); ?> |
|
556 | 556 | </select> |
557 | 557 | <?php |
558 | 558 | } |
559 | 559 | |
560 | 560 | public static function roles_options( $capability ) { |
561 | 561 | global $frm_vars; |
562 | - if ( isset($frm_vars['editable_roles']) ) { |
|
562 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
563 | 563 | $editable_roles = $frm_vars['editable_roles']; |
564 | 564 | } else { |
565 | 565 | $editable_roles = get_editable_roles(); |
@@ -567,10 +567,10 @@ discard block |
||
567 | 567 | } |
568 | 568 | |
569 | 569 | foreach ( $editable_roles as $role => $details ) { |
570 | - $name = translate_user_role($details['name'] ); ?> |
|
571 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
570 | + $name = translate_user_role( $details['name'] ); ?> |
|
571 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
572 | 572 | <?php |
573 | - unset($role, $details); |
|
573 | + unset( $role, $details ); |
|
574 | 574 | } |
575 | 575 | } |
576 | 576 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | public static function maybe_add_permissions() { |
627 | 627 | self::force_capability( 'frm_view_entries' ); |
628 | 628 | |
629 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
629 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
630 | 630 | return; |
631 | 631 | } |
632 | 632 | |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | $frm_roles = self::frm_capabilities(); |
636 | 636 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
637 | 637 | $user->add_cap( $frm_role ); |
638 | - unset($frm_role, $frm_role_description); |
|
638 | + unset( $frm_role, $frm_role_description ); |
|
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
@@ -660,12 +660,12 @@ discard block |
||
660 | 660 | * @param string $permission |
661 | 661 | */ |
662 | 662 | public static function permission_check( $permission, $show_message = 'show' ) { |
663 | - $permission_error = self::permission_nonce_error($permission); |
|
663 | + $permission_error = self::permission_nonce_error( $permission ); |
|
664 | 664 | if ( $permission_error !== false ) { |
665 | 665 | if ( 'hide' == $show_message ) { |
666 | 666 | $permission_error = ''; |
667 | 667 | } |
668 | - wp_die($permission_error); |
|
668 | + wp_die( $permission_error ); |
|
669 | 669 | } |
670 | 670 | } |
671 | 671 | |
@@ -682,11 +682,11 @@ discard block |
||
682 | 682 | } |
683 | 683 | |
684 | 684 | $error = false; |
685 | - if ( empty($nonce_name) ) { |
|
685 | + if ( empty( $nonce_name ) ) { |
|
686 | 686 | return $error; |
687 | 687 | } |
688 | 688 | |
689 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
689 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
690 | 690 | $frm_settings = self::get_settings(); |
691 | 691 | $error = $frm_settings->admin_permission; |
692 | 692 | } |
@@ -702,9 +702,9 @@ discard block |
||
702 | 702 | |
703 | 703 | public static function check_selected( $values, $current ) { |
704 | 704 | $values = self::recursive_function_map( $values, 'trim' ); |
705 | - $current = trim($current); |
|
705 | + $current = trim( $current ); |
|
706 | 706 | |
707 | - return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current ); |
|
707 | + return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | /** |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | } else { |
766 | 766 | foreach ( $value as $k => $v ) { |
767 | 767 | if ( ! is_array( $v ) ) { |
768 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
768 | + $value[$k] = call_user_func( $original_function, $v ); |
|
769 | 769 | } |
770 | 770 | } |
771 | 771 | } |
@@ -786,11 +786,11 @@ discard block |
||
786 | 786 | public static function array_flatten( $array, $keys = 'keep' ) { |
787 | 787 | $return = array(); |
788 | 788 | foreach ( $array as $key => $value ) { |
789 | - if ( is_array($value) ) { |
|
789 | + if ( is_array( $value ) ) { |
|
790 | 790 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
791 | 791 | } else { |
792 | 792 | if ( $keys == 'keep' ) { |
793 | - $return[ $key ] = $value; |
|
793 | + $return[$key] = $value; |
|
794 | 794 | } else { |
795 | 795 | $return[] = $value; |
796 | 796 | } |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | } |
801 | 801 | |
802 | 802 | public static function esc_textarea( $text ) { |
803 | - $safe_text = str_replace('"', '"', $text); |
|
803 | + $safe_text = str_replace( '"', '"', $text ); |
|
804 | 804 | $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
805 | 805 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
806 | 806 | } |
@@ -810,8 +810,8 @@ discard block |
||
810 | 810 | * @since 2.0 |
811 | 811 | */ |
812 | 812 | public static function use_wpautop( $content ) { |
813 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
814 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
813 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
814 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
815 | 815 | } |
816 | 816 | return $content; |
817 | 817 | } |
@@ -829,8 +829,8 @@ discard block |
||
829 | 829 | * @return string The base Google APIS url for the current version of jQuery UI |
830 | 830 | */ |
831 | 831 | public static function jquery_ui_base_url() { |
832 | - $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core'); |
|
833 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
832 | + $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' ); |
|
833 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
834 | 834 | return $url; |
835 | 835 | } |
836 | 836 | |
@@ -845,11 +845,11 @@ discard block |
||
845 | 845 | |
846 | 846 | $ver = 0; |
847 | 847 | |
848 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
848 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
849 | 849 | return $ver; |
850 | 850 | } |
851 | 851 | |
852 | - $query = $wp_scripts->registered[ $handle ]; |
|
852 | + $query = $wp_scripts->registered[$handle]; |
|
853 | 853 | if ( is_object( $query ) ) { |
854 | 854 | $ver = $query->ver; |
855 | 855 | } |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | } |
863 | 863 | |
864 | 864 | public static function get_user_id_param( $user_id ) { |
865 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
865 | + if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
|
866 | 866 | return $user_id; |
867 | 867 | } |
868 | 868 | |
@@ -870,29 +870,29 @@ discard block |
||
870 | 870 | $user_ID = get_current_user_id(); |
871 | 871 | $user_id = $user_ID; |
872 | 872 | } else { |
873 | - if ( is_email($user_id) ) { |
|
874 | - $user = get_user_by('email', $user_id); |
|
873 | + if ( is_email( $user_id ) ) { |
|
874 | + $user = get_user_by( 'email', $user_id ); |
|
875 | 875 | } else { |
876 | - $user = get_user_by('login', $user_id); |
|
876 | + $user = get_user_by( 'login', $user_id ); |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | if ( $user ) { |
880 | 880 | $user_id = $user->ID; |
881 | 881 | } |
882 | - unset($user); |
|
882 | + unset( $user ); |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | return $user_id; |
886 | 886 | } |
887 | 887 | |
888 | 888 | public static function get_file_contents( $filename, $atts = array() ) { |
889 | - if ( ! is_file($filename) ) { |
|
889 | + if ( ! is_file( $filename ) ) { |
|
890 | 890 | return false; |
891 | 891 | } |
892 | 892 | |
893 | - extract($atts); |
|
893 | + extract( $atts ); |
|
894 | 894 | ob_start(); |
895 | - include($filename); |
|
895 | + include( $filename ); |
|
896 | 896 | $contents = ob_get_contents(); |
897 | 897 | ob_end_clean(); |
898 | 898 | return $contents; |
@@ -908,28 +908,28 @@ discard block |
||
908 | 908 | $key = ''; |
909 | 909 | |
910 | 910 | if ( ! empty( $name ) ) { |
911 | - $key = sanitize_key($name); |
|
911 | + $key = sanitize_key( $name ); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | if ( empty( $key ) ) { |
915 | - $max_slug_value = pow(36, $num_chars); |
|
915 | + $max_slug_value = pow( 36, $num_chars ); |
|
916 | 916 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
917 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
917 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
918 | 918 | } |
919 | 919 | |
920 | - if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
921 | - $key = $key .'a'; |
|
920 | + if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
921 | + $key = $key . 'a'; |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
925 | 925 | |
926 | - if ( $key_check || is_numeric($key_check) ) { |
|
926 | + if ( $key_check || is_numeric( $key_check ) ) { |
|
927 | 927 | $suffix = 2; |
928 | 928 | do { |
929 | 929 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
930 | 930 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
931 | - $suffix++; |
|
932 | - } while ($key_check || is_numeric($key_check)); |
|
931 | + $suffix ++; |
|
932 | + } while ( $key_check || is_numeric( $key_check ) ); |
|
933 | 933 | $key = $alt_post_name; |
934 | 934 | } |
935 | 935 | return $key; |
@@ -947,32 +947,32 @@ discard block |
||
947 | 947 | |
948 | 948 | global $frm_vars; |
949 | 949 | |
950 | - if ( empty($post_values) ) { |
|
951 | - $post_values = stripslashes_deep($_POST); |
|
950 | + if ( empty( $post_values ) ) { |
|
951 | + $post_values = stripslashes_deep( $_POST ); |
|
952 | 952 | } |
953 | 953 | |
954 | 954 | $values = array( 'id' => $record->id, 'fields' => array() ); |
955 | 955 | |
956 | 956 | foreach ( array( 'name', 'description' ) as $var ) { |
957 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
958 | - $values[ $var ] = self::get_param( $var, $default_val ); |
|
959 | - unset($var, $default_val); |
|
957 | + $default_val = isset( $record->{$var}) ? $record->{$var} : ''; |
|
958 | + $values[$var] = self::get_param( $var, $default_val ); |
|
959 | + unset( $var, $default_val ); |
|
960 | 960 | } |
961 | 961 | |
962 | - $values['description'] = self::use_wpautop($values['description']); |
|
962 | + $values['description'] = self::use_wpautop( $values['description'] ); |
|
963 | 963 | $frm_settings = self::get_settings(); |
964 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
964 | + $is_form_builder = self::is_admin_page( 'formidable' ); |
|
965 | 965 | |
966 | 966 | foreach ( (array) $fields as $field ) { |
967 | 967 | // Make sure to filter default values (for placeholder text), but not on the form builder page |
968 | 968 | if ( ! $is_form_builder ) { |
969 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
969 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
|
970 | 970 | } |
971 | 971 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
972 | - self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
972 | + self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
973 | 973 | } |
974 | 974 | |
975 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
975 | + self::fill_form_opts( $record, $table, $post_values, $values ); |
|
976 | 976 | |
977 | 977 | if ( $table == 'entries' ) { |
978 | 978 | $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
@@ -989,8 +989,8 @@ discard block |
||
989 | 989 | if ( $args['default'] ) { |
990 | 990 | $meta_value = $field->default_value; |
991 | 991 | } else { |
992 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
993 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
992 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
|
993 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
994 | 994 | $field->field_options['custom_field'] = ''; |
995 | 995 | } |
996 | 996 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
@@ -999,8 +999,8 @@ discard block |
||
999 | 999 | } |
1000 | 1000 | } |
1001 | 1001 | |
1002 | - $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type; |
|
1003 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1002 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
1003 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
1004 | 1004 | |
1005 | 1005 | $field_array = array( |
1006 | 1006 | 'id' => $field->id, |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | 'default_value' => $field->default_value, |
1009 | 1009 | 'name' => $field->name, |
1010 | 1010 | 'description' => $field->description, |
1011 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1011 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), |
|
1012 | 1012 | 'options' => $field->options, |
1013 | 1013 | 'required' => $field->required, |
1014 | 1014 | 'field_key' => $field->field_key, |
@@ -1018,38 +1018,38 @@ discard block |
||
1018 | 1018 | ); |
1019 | 1019 | |
1020 | 1020 | $args['field_type'] = $field_type; |
1021 | - self::fill_field_opts($field, $field_array, $args); |
|
1021 | + self::fill_field_opts( $field, $field_array, $args ); |
|
1022 | 1022 | |
1023 | - $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); |
|
1023 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'] ); |
|
1024 | 1024 | |
1025 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1025 | + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
|
1026 | 1026 | $field_array['unique_msg'] = ''; |
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | $field_array = array_merge( $field->field_options, $field_array ); |
1030 | 1030 | |
1031 | - $values['fields'][ $field->id ] = $field_array; |
|
1031 | + $values['fields'][$field->id] = $field_array; |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1035 | 1035 | $post_values = $args['post_values']; |
1036 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1036 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
1037 | 1037 | |
1038 | 1038 | foreach ( $opt_defaults as $opt => $default_opt ) { |
1039 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt .'_'. $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt .'_'. $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
1040 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1041 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1042 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1039 | + $field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt ); |
|
1040 | + if ( $opt == 'blank' && $field_array[$opt] == '' ) { |
|
1041 | + $field_array[$opt] = $args['frm_settings']->blank_msg; |
|
1042 | + } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { |
|
1043 | 1043 | if ( $args['field_type'] == 'captcha' ) { |
1044 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1044 | + $field_array[$opt] = $args['frm_settings']->re_msg; |
|
1045 | 1045 | } else { |
1046 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1046 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1047 | 1047 | } |
1048 | 1048 | } |
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | if ( $field_array['custom_html'] == '' ) { |
1052 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1052 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); |
|
1053 | 1053 | } |
1054 | 1054 | } |
1055 | 1055 | |
@@ -1068,18 +1068,18 @@ discard block |
||
1068 | 1068 | return; |
1069 | 1069 | } |
1070 | 1070 | |
1071 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1071 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
|
1072 | 1072 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1073 | 1073 | |
1074 | - if ( ! is_array($form->options) ) { |
|
1074 | + if ( ! is_array( $form->options ) ) { |
|
1075 | 1075 | return; |
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | foreach ( $form->options as $opt => $value ) { |
1079 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1079 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
1080 | 1080 | } |
1081 | 1081 | |
1082 | - self::fill_form_defaults($post_values, $values); |
|
1082 | + self::fill_form_defaults( $post_values, $values ); |
|
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | /** |
@@ -1089,23 +1089,23 @@ discard block |
||
1089 | 1089 | $form_defaults = FrmFormsHelper::get_default_opts(); |
1090 | 1090 | |
1091 | 1091 | foreach ( $form_defaults as $opt => $default ) { |
1092 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1093 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
1092 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
1093 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | - unset($opt, $defaut); |
|
1096 | + unset( $opt, $defaut ); |
|
1097 | 1097 | } |
1098 | 1098 | |
1099 | - if ( ! isset($values['custom_style']) ) { |
|
1099 | + if ( ! isset( $values['custom_style'] ) ) { |
|
1100 | 1100 | $frm_settings = self::get_settings(); |
1101 | 1101 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1105 | - if ( ! isset( $values[ $h .'_html' ] ) ) { |
|
1106 | - $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1105 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
1106 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
1107 | 1107 | } |
1108 | - unset($h); |
|
1108 | + unset( $h ); |
|
1109 | 1109 | } |
1110 | 1110 | } |
1111 | 1111 | |
@@ -1121,9 +1121,9 @@ discard block |
||
1121 | 1121 | } |
1122 | 1122 | ?> |
1123 | 1123 | <li> |
1124 | - <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
1125 | - <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
|
1126 | - <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
|
1124 | + <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
1125 | + <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['key'] ) ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ) ?>]</a> |
|
1126 | + <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ) ?></a> |
|
1127 | 1127 | </li> |
1128 | 1128 | <?php |
1129 | 1129 | } |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | return ''; |
1152 | 1152 | } else if ( $length <= 10 ) { |
1153 | 1153 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
1154 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
1154 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | $sub = ''; |
@@ -1160,23 +1160,23 @@ discard block |
||
1160 | 1160 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
1161 | 1161 | |
1162 | 1162 | foreach ( $words as $word ) { |
1163 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
1163 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
|
1164 | 1164 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
1165 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
1165 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
1166 | 1166 | break; |
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | $sub .= $part; |
1170 | 1170 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
1171 | 1171 | |
1172 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1172 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
1173 | 1173 | break; |
1174 | 1174 | } |
1175 | 1175 | |
1176 | - unset($total_len, $word); |
|
1176 | + unset( $total_len, $word ); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1179 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | public static function mb_function( $function_names, $args ) { |
@@ -1189,17 +1189,17 @@ discard block |
||
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1192 | - if ( empty($date) ) { |
|
1192 | + if ( empty( $date ) ) { |
|
1193 | 1193 | return $date; |
1194 | 1194 | } |
1195 | 1195 | |
1196 | - if ( empty($date_format) ) { |
|
1197 | - $date_format = get_option('date_format'); |
|
1196 | + if ( empty( $date_format ) ) { |
|
1197 | + $date_format = get_option( 'date_format' ); |
|
1198 | 1198 | } |
1199 | 1199 | |
1200 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1200 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
1201 | 1201 | $frmpro_settings = new FrmProSettings(); |
1202 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1202 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | |
1215 | 1215 | private static function add_time_to_date( $time_format, $date ) { |
1216 | 1216 | if ( empty( $time_format ) ) { |
1217 | - $time_format = get_option('time_format'); |
|
1217 | + $time_format = get_option( 'time_format' ); |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | $trimmed_format = trim( $time_format ); |
@@ -1260,10 +1260,10 @@ discard block |
||
1260 | 1260 | $time_strings = self::get_time_strings(); |
1261 | 1261 | |
1262 | 1262 | foreach ( $time_strings as $k => $v ) { |
1263 | - if ( $diff[ $k ] ) { |
|
1264 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); |
|
1263 | + if ( $diff[$k] ) { |
|
1264 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); |
|
1265 | 1265 | } else { |
1266 | - unset( $time_strings[ $k ] ); |
|
1266 | + unset( $time_strings[$k] ); |
|
1267 | 1267 | } |
1268 | 1268 | } |
1269 | 1269 | |
@@ -1301,7 +1301,7 @@ discard block |
||
1301 | 1301 | */ |
1302 | 1302 | public static function esc_like( $term ) { |
1303 | 1303 | global $wpdb; |
1304 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1304 | + if ( method_exists( $wpdb, 'esc_like' ) ) { |
|
1305 | 1305 | // WP 4.0 |
1306 | 1306 | $term = $wpdb->esc_like( $term ); |
1307 | 1307 | } else { |
@@ -1315,17 +1315,17 @@ discard block |
||
1315 | 1315 | * @param string $order_query |
1316 | 1316 | */ |
1317 | 1317 | public static function esc_order( $order_query ) { |
1318 | - if ( empty($order_query) ) { |
|
1318 | + if ( empty( $order_query ) ) { |
|
1319 | 1319 | return ''; |
1320 | 1320 | } |
1321 | 1321 | |
1322 | 1322 | // remove ORDER BY before santizing |
1323 | - $order_query = strtolower($order_query); |
|
1324 | - if ( strpos($order_query, 'order by') !== false ) { |
|
1325 | - $order_query = str_replace('order by', '', $order_query); |
|
1323 | + $order_query = strtolower( $order_query ); |
|
1324 | + if ( strpos( $order_query, 'order by' ) !== false ) { |
|
1325 | + $order_query = str_replace( 'order by', '', $order_query ); |
|
1326 | 1326 | } |
1327 | 1327 | |
1328 | - $order_query = explode(' ', trim($order_query)); |
|
1328 | + $order_query = explode( ' ', trim( $order_query ) ); |
|
1329 | 1329 | |
1330 | 1330 | $order_fields = array( |
1331 | 1331 | 'id', 'form_key', 'name', 'description', |
@@ -1333,18 +1333,18 @@ discard block |
||
1333 | 1333 | 'default_template', 'status', 'created_at', |
1334 | 1334 | ); |
1335 | 1335 | |
1336 | - $order = trim(trim(reset($order_query), ',')); |
|
1337 | - if ( ! in_array($order, $order_fields) ) { |
|
1336 | + $order = trim( trim( reset( $order_query ), ',' ) ); |
|
1337 | + if ( ! in_array( $order, $order_fields ) ) { |
|
1338 | 1338 | return ''; |
1339 | 1339 | } |
1340 | 1340 | |
1341 | 1341 | $order_by = ''; |
1342 | - if ( count($order_query) > 1 ) { |
|
1342 | + if ( count( $order_query ) > 1 ) { |
|
1343 | 1343 | $order_by = end( $order_query ); |
1344 | 1344 | self::esc_order_by( $order_by ); |
1345 | 1345 | } |
1346 | 1346 | |
1347 | - return ' ORDER BY '. $order . ' '. $order_by; |
|
1347 | + return ' ORDER BY ' . $order . ' ' . $order_by; |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | /** |
@@ -1361,24 +1361,24 @@ discard block |
||
1361 | 1361 | * @param string $limit |
1362 | 1362 | */ |
1363 | 1363 | public static function esc_limit( $limit ) { |
1364 | - if ( empty($limit) ) { |
|
1364 | + if ( empty( $limit ) ) { |
|
1365 | 1365 | return ''; |
1366 | 1366 | } |
1367 | 1367 | |
1368 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1369 | - if ( is_numeric($limit) ) { |
|
1370 | - return ' LIMIT '. $limit; |
|
1368 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); |
|
1369 | + if ( is_numeric( $limit ) ) { |
|
1370 | + return ' LIMIT ' . $limit; |
|
1371 | 1371 | } |
1372 | 1372 | |
1373 | - $limit = explode(',', trim($limit)); |
|
1373 | + $limit = explode( ',', trim( $limit ) ); |
|
1374 | 1374 | foreach ( $limit as $k => $l ) { |
1375 | 1375 | if ( is_numeric( $l ) ) { |
1376 | - $limit[ $k ] = $l; |
|
1376 | + $limit[$k] = $l; |
|
1377 | 1377 | } |
1378 | 1378 | } |
1379 | 1379 | |
1380 | - $limit = implode(',', $limit); |
|
1381 | - return ' LIMIT '. $limit; |
|
1380 | + $limit = implode( ',', $limit ); |
|
1381 | + return ' LIMIT ' . $limit; |
|
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | /** |
@@ -1386,12 +1386,12 @@ discard block |
||
1386 | 1386 | * @since 2.0 |
1387 | 1387 | */ |
1388 | 1388 | public static function prepare_array_values( $array, $type = '%s' ) { |
1389 | - $placeholders = array_fill(0, count($array), $type); |
|
1390 | - return implode(', ', $placeholders); |
|
1389 | + $placeholders = array_fill( 0, count( $array ), $type ); |
|
1390 | + return implode( ', ', $placeholders ); |
|
1391 | 1391 | } |
1392 | 1392 | |
1393 | 1393 | public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
1394 | - if ( empty($where) ) { |
|
1394 | + if ( empty( $where ) ) { |
|
1395 | 1395 | return ''; |
1396 | 1396 | } |
1397 | 1397 | |
@@ -1437,7 +1437,7 @@ discard block |
||
1437 | 1437 | |
1438 | 1438 | public static function get_referer_info() { |
1439 | 1439 | _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
1440 | - return self::get_server_value('HTTP_REFERER'); |
|
1440 | + return self::get_server_value( 'HTTP_REFERER' ); |
|
1441 | 1441 | } |
1442 | 1442 | |
1443 | 1443 | /** |
@@ -1446,19 +1446,19 @@ discard block |
||
1446 | 1446 | public static function json_to_array( $json_vars ) { |
1447 | 1447 | $vars = array(); |
1448 | 1448 | foreach ( $json_vars as $jv ) { |
1449 | - $jv_name = explode('[', $jv['name']); |
|
1450 | - $last = count($jv_name) - 1; |
|
1449 | + $jv_name = explode( '[', $jv['name'] ); |
|
1450 | + $last = count( $jv_name ) - 1; |
|
1451 | 1451 | foreach ( $jv_name as $p => $n ) { |
1452 | - $name = trim($n, ']'); |
|
1453 | - if ( ! isset($l1) ) { |
|
1452 | + $name = trim( $n, ']' ); |
|
1453 | + if ( ! isset( $l1 ) ) { |
|
1454 | 1454 | $l1 = $name; |
1455 | 1455 | } |
1456 | 1456 | |
1457 | - if ( ! isset($l2) ) { |
|
1457 | + if ( ! isset( $l2 ) ) { |
|
1458 | 1458 | $l2 = $name; |
1459 | 1459 | } |
1460 | 1460 | |
1461 | - if ( ! isset($l3) ) { |
|
1461 | + if ( ! isset( $l3 ) ) { |
|
1462 | 1462 | $l3 = $name; |
1463 | 1463 | } |
1464 | 1464 | |
@@ -1472,24 +1472,24 @@ discard block |
||
1472 | 1472 | |
1473 | 1473 | case 1: |
1474 | 1474 | $l2 = $name; |
1475 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1475 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
1476 | 1476 | break; |
1477 | 1477 | |
1478 | 1478 | case 2: |
1479 | 1479 | $l3 = $name; |
1480 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1480 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
1481 | 1481 | break; |
1482 | 1482 | |
1483 | 1483 | case 3: |
1484 | 1484 | $l4 = $name; |
1485 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1485 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
1486 | 1486 | break; |
1487 | 1487 | } |
1488 | 1488 | |
1489 | - unset($this_val, $n); |
|
1489 | + unset( $this_val, $n ); |
|
1490 | 1490 | } |
1491 | 1491 | |
1492 | - unset($last, $jv); |
|
1492 | + unset( $last, $jv ); |
|
1493 | 1493 | } |
1494 | 1494 | |
1495 | 1495 | return $vars; |
@@ -1502,8 +1502,8 @@ discard block |
||
1502 | 1502 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
1503 | 1503 | if ( $name == '' ) { |
1504 | 1504 | $vars[] = $val; |
1505 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1506 | - $vars[ $l1 ] = $val; |
|
1505 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
1506 | + $vars[$l1] = $val; |
|
1507 | 1507 | } |
1508 | 1508 | } |
1509 | 1509 | |
@@ -1518,7 +1518,7 @@ discard block |
||
1518 | 1518 | 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
1519 | 1519 | ); |
1520 | 1520 | |
1521 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1521 | + if ( ! isset( $tooltips[$name] ) ) { |
|
1522 | 1522 | return; |
1523 | 1523 | } |
1524 | 1524 | |
@@ -1528,7 +1528,7 @@ discard block |
||
1528 | 1528 | echo ' class="frm_help"'; |
1529 | 1529 | } |
1530 | 1530 | |
1531 | - echo ' title="'. esc_attr( $tooltips[ $name ] ); |
|
1531 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
1532 | 1532 | |
1533 | 1533 | if ( 'open' != $class ) { |
1534 | 1534 | echo '"'; |
@@ -1580,13 +1580,13 @@ discard block |
||
1580 | 1580 | } |
1581 | 1581 | |
1582 | 1582 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1583 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
1583 | + if ( ! isset( $post_content[$key] ) ) { |
|
1584 | 1584 | return; |
1585 | 1585 | } |
1586 | 1586 | |
1587 | 1587 | if ( is_array( $val ) ) { |
1588 | 1588 | foreach ( $val as $k1 => $v1 ) { |
1589 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
1589 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
1590 | 1590 | unset( $k1, $v1 ); |
1591 | 1591 | } |
1592 | 1592 | } else { |
@@ -1594,7 +1594,7 @@ discard block |
||
1594 | 1594 | $val = stripslashes( $val ); |
1595 | 1595 | |
1596 | 1596 | // Add backslashes before double quotes and forward slashes only |
1597 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
1597 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
1598 | 1598 | } |
1599 | 1599 | } |
1600 | 1600 | |
@@ -1611,7 +1611,7 @@ discard block |
||
1611 | 1611 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); |
1612 | 1612 | |
1613 | 1613 | if ( empty( $settings['ID'] ) ) { |
1614 | - unset( $settings['ID']); |
|
1614 | + unset( $settings['ID'] ); |
|
1615 | 1615 | } |
1616 | 1616 | |
1617 | 1617 | // delete all caches for this group |
@@ -1645,17 +1645,17 @@ discard block |
||
1645 | 1645 | } |
1646 | 1646 | |
1647 | 1647 | public static function maybe_json_decode( $string ) { |
1648 | - if ( is_array($string) ) { |
|
1648 | + if ( is_array( $string ) ) { |
|
1649 | 1649 | return $string; |
1650 | 1650 | } |
1651 | 1651 | |
1652 | - $new_string = json_decode($string, true); |
|
1653 | - if ( function_exists('json_last_error') ) { |
|
1652 | + $new_string = json_decode( $string, true ); |
|
1653 | + if ( function_exists( 'json_last_error' ) ) { |
|
1654 | 1654 | // php 5.3+ |
1655 | 1655 | if ( json_last_error() == JSON_ERROR_NONE ) { |
1656 | 1656 | $string = $new_string; |
1657 | 1657 | } |
1658 | - } else if ( isset($new_string) ) { |
|
1658 | + } else if ( isset( $new_string ) ) { |
|
1659 | 1659 | // php < 5.3 fallback |
1660 | 1660 | $string = $new_string; |
1661 | 1661 | } |
@@ -1671,11 +1671,11 @@ discard block |
||
1671 | 1671 | public static function maybe_highlight_menu( $post_type ) { |
1672 | 1672 | global $post, $pagenow; |
1673 | 1673 | |
1674 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1674 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
1675 | 1675 | return; |
1676 | 1676 | } |
1677 | 1677 | |
1678 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1678 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
1679 | 1679 | return; |
1680 | 1680 | } |
1681 | 1681 | |
@@ -1773,11 +1773,11 @@ discard block |
||
1773 | 1773 | $frm_version = self::plugin_version(); |
1774 | 1774 | |
1775 | 1775 | // check if Formidable meets minimum requirements |
1776 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1776 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
1777 | 1777 | return; |
1778 | 1778 | } |
1779 | 1779 | |
1780 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1780 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
1781 | 1781 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
1782 | 1782 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
1783 | 1783 | '</div></td></tr>'; |
@@ -1785,38 +1785,38 @@ discard block |
||
1785 | 1785 | |
1786 | 1786 | public static function locales( $type = 'date' ) { |
1787 | 1787 | $locales = array( |
1788 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1789 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1790 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1788 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1789 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1790 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1791 | 1791 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
1792 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1793 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1792 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1793 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1794 | 1794 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
1795 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1796 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1795 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1796 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1797 | 1797 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
1798 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1798 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1799 | 1799 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
1800 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1800 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1801 | 1801 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
1802 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1802 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1803 | 1803 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
1804 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1805 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1806 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1807 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1808 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1804 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1805 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1806 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1807 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1808 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1809 | 1809 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
1810 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1810 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1811 | 1811 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
1812 | 1812 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
1813 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1813 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1814 | 1814 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
1815 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1815 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1816 | 1816 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
1817 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1818 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1819 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1817 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1818 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1819 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1820 | 1820 | ); |
1821 | 1821 | |
1822 | 1822 | if ( $type == 'captcha' ) { |
@@ -1835,8 +1835,8 @@ discard block |
||
1835 | 1835 | ); |
1836 | 1836 | } |
1837 | 1837 | |
1838 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1839 | - $locales = apply_filters('frm_locales', $locales); |
|
1838 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
1839 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
1840 | 1840 | |
1841 | 1841 | return $locales; |
1842 | 1842 | } |
@@ -12,50 +12,50 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public static $plug_version = '2.0.21.1'; |
14 | 14 | |
15 | - /** |
|
16 | - * @since 1.07.02 |
|
17 | - * |
|
18 | - * @param none |
|
19 | - * @return string The version of this plugin |
|
20 | - */ |
|
21 | - public static function plugin_version() { |
|
22 | - return self::$plug_version; |
|
23 | - } |
|
24 | - |
|
25 | - public static function plugin_folder() { |
|
26 | - return basename(self::plugin_path()); |
|
27 | - } |
|
28 | - |
|
29 | - public static function plugin_path() { |
|
30 | - return dirname(dirname(dirname(__FILE__))); |
|
31 | - } |
|
32 | - |
|
33 | - public static function plugin_url() { |
|
34 | - //prevously FRM_URL constant |
|
35 | - return plugins_url( '', self::plugin_path() .'/formidable.php' ); |
|
36 | - } |
|
15 | + /** |
|
16 | + * @since 1.07.02 |
|
17 | + * |
|
18 | + * @param none |
|
19 | + * @return string The version of this plugin |
|
20 | + */ |
|
21 | + public static function plugin_version() { |
|
22 | + return self::$plug_version; |
|
23 | + } |
|
24 | + |
|
25 | + public static function plugin_folder() { |
|
26 | + return basename(self::plugin_path()); |
|
27 | + } |
|
28 | + |
|
29 | + public static function plugin_path() { |
|
30 | + return dirname(dirname(dirname(__FILE__))); |
|
31 | + } |
|
32 | + |
|
33 | + public static function plugin_url() { |
|
34 | + //prevously FRM_URL constant |
|
35 | + return plugins_url( '', self::plugin_path() .'/formidable.php' ); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | public static function relative_plugin_url() { |
39 | 39 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
40 | 40 | } |
41 | 41 | |
42 | - /** |
|
43 | - * @return string Site URL |
|
44 | - */ |
|
45 | - public static function site_url() { |
|
46 | - return site_url(); |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Get the name of this site |
|
51 | - * Used for [sitename] shortcode |
|
52 | - * |
|
53 | - * @since 2.0 |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public static function site_name() { |
|
57 | - return get_option('blogname'); |
|
58 | - } |
|
42 | + /** |
|
43 | + * @return string Site URL |
|
44 | + */ |
|
45 | + public static function site_url() { |
|
46 | + return site_url(); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Get the name of this site |
|
51 | + * Used for [sitename] shortcode |
|
52 | + * |
|
53 | + * @since 2.0 |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public static function site_name() { |
|
57 | + return get_option('blogname'); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | public static function make_affiliate_url( $url ) { |
61 | 61 | $affiliate_id = self::get_affiliate(); |
@@ -75,78 +75,78 @@ discard block |
||
75 | 75 | return $affiliate_id; |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * Get the Formidable settings |
|
80 | - * |
|
81 | - * @since 2.0 |
|
82 | - * |
|
83 | - * @param None |
|
84 | - * @return FrmSettings $frm_setings |
|
85 | - */ |
|
86 | - public static function get_settings() { |
|
87 | - global $frm_settings; |
|
88 | - if ( empty($frm_settings) ) { |
|
89 | - $frm_settings = new FrmSettings(); |
|
90 | - } |
|
91 | - return $frm_settings; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Show a message in place of pro features |
|
96 | - * |
|
97 | - * @since 2.0 |
|
98 | - */ |
|
78 | + /** |
|
79 | + * Get the Formidable settings |
|
80 | + * |
|
81 | + * @since 2.0 |
|
82 | + * |
|
83 | + * @param None |
|
84 | + * @return FrmSettings $frm_setings |
|
85 | + */ |
|
86 | + public static function get_settings() { |
|
87 | + global $frm_settings; |
|
88 | + if ( empty($frm_settings) ) { |
|
89 | + $frm_settings = new FrmSettings(); |
|
90 | + } |
|
91 | + return $frm_settings; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Show a message in place of pro features |
|
96 | + * |
|
97 | + * @since 2.0 |
|
98 | + */ |
|
99 | 99 | public static function update_message( $features, $class = '' ) { |
100 | 100 | _deprecated_function( __FUNCTION__, '2.0.19' ); |
101 | - } |
|
102 | - |
|
103 | - public static function pro_is_installed() { |
|
104 | - return apply_filters('frm_pro_installed', false); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Check for certain page in Formidable settings |
|
109 | - * |
|
110 | - * @since 2.0 |
|
111 | - * |
|
112 | - * @param string $page The name of the page to check |
|
113 | - * @return boolean |
|
114 | - */ |
|
101 | + } |
|
102 | + |
|
103 | + public static function pro_is_installed() { |
|
104 | + return apply_filters('frm_pro_installed', false); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Check for certain page in Formidable settings |
|
109 | + * |
|
110 | + * @since 2.0 |
|
111 | + * |
|
112 | + * @param string $page The name of the page to check |
|
113 | + * @return boolean |
|
114 | + */ |
|
115 | 115 | public static function is_admin_page( $page = 'formidable' ) { |
116 | - global $pagenow; |
|
116 | + global $pagenow; |
|
117 | 117 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
118 | - if ( $pagenow ) { |
|
118 | + if ( $pagenow ) { |
|
119 | 119 | return $pagenow == 'admin.php' && $get_page == $page; |
120 | - } |
|
120 | + } |
|
121 | 121 | |
122 | 122 | return is_admin() && $get_page == $page; |
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Check for the form preview page |
|
127 | - * |
|
128 | - * @since 2.0 |
|
129 | - * |
|
130 | - * @param None |
|
131 | - * @return boolean |
|
132 | - */ |
|
133 | - public static function is_preview_page() { |
|
134 | - global $pagenow; |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Check for the form preview page |
|
127 | + * |
|
128 | + * @since 2.0 |
|
129 | + * |
|
130 | + * @param None |
|
131 | + * @return boolean |
|
132 | + */ |
|
133 | + public static function is_preview_page() { |
|
134 | + global $pagenow; |
|
135 | 135 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
136 | 136 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
137 | - } |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * Check for ajax except the form preview page |
|
141 | - * |
|
142 | - * @since 2.0 |
|
143 | - * |
|
144 | - * @param None |
|
145 | - * @return boolean |
|
146 | - */ |
|
147 | - public static function doing_ajax() { |
|
148 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
149 | - } |
|
139 | + /** |
|
140 | + * Check for ajax except the form preview page |
|
141 | + * |
|
142 | + * @since 2.0 |
|
143 | + * |
|
144 | + * @param None |
|
145 | + * @return boolean |
|
146 | + */ |
|
147 | + public static function doing_ajax() { |
|
148 | + return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
149 | + } |
|
150 | 150 | |
151 | 151 | /** |
152 | 152 | * @since 2.0.8 |
@@ -156,101 +156,101 @@ discard block |
||
156 | 156 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
157 | 157 | } |
158 | 158 | |
159 | - /** |
|
160 | - * Check if on an admin page |
|
161 | - * |
|
162 | - * @since 2.0 |
|
163 | - * |
|
164 | - * @param None |
|
165 | - * @return boolean |
|
166 | - */ |
|
167 | - public static function is_admin() { |
|
168 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
169 | - } |
|
170 | - |
|
171 | - /** |
|
172 | - * Check if value contains blank value or empty array |
|
173 | - * |
|
174 | - * @since 2.0 |
|
175 | - * @param $value - value to check |
|
176 | - * @return boolean |
|
177 | - */ |
|
178 | - public static function is_empty_value( $value, $empty = '' ) { |
|
179 | - return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
180 | - } |
|
181 | - |
|
182 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
183 | - return ! self::is_empty_value( $value, $empty ); |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Get any value from the $_SERVER |
|
188 | - * |
|
189 | - * @since 2.0 |
|
190 | - * @param string $value |
|
191 | - * @return string |
|
192 | - */ |
|
159 | + /** |
|
160 | + * Check if on an admin page |
|
161 | + * |
|
162 | + * @since 2.0 |
|
163 | + * |
|
164 | + * @param None |
|
165 | + * @return boolean |
|
166 | + */ |
|
167 | + public static function is_admin() { |
|
168 | + return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
169 | + } |
|
170 | + |
|
171 | + /** |
|
172 | + * Check if value contains blank value or empty array |
|
173 | + * |
|
174 | + * @since 2.0 |
|
175 | + * @param $value - value to check |
|
176 | + * @return boolean |
|
177 | + */ |
|
178 | + public static function is_empty_value( $value, $empty = '' ) { |
|
179 | + return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
180 | + } |
|
181 | + |
|
182 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
183 | + return ! self::is_empty_value( $value, $empty ); |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Get any value from the $_SERVER |
|
188 | + * |
|
189 | + * @since 2.0 |
|
190 | + * @param string $value |
|
191 | + * @return string |
|
192 | + */ |
|
193 | 193 | public static function get_server_value( $value ) { |
194 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * Check for the IP address in several places |
|
199 | - * Used by [ip] shortcode |
|
200 | - * |
|
201 | - * @return string The IP address of the current user |
|
202 | - */ |
|
203 | - public static function get_ip_address() { |
|
194 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * Check for the IP address in several places |
|
199 | + * Used by [ip] shortcode |
|
200 | + * |
|
201 | + * @return string The IP address of the current user |
|
202 | + */ |
|
203 | + public static function get_ip_address() { |
|
204 | 204 | $ip = ''; |
205 | - foreach ( array( |
|
206 | - 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
207 | - 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
208 | - ) as $key ) { |
|
209 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
210 | - continue; |
|
211 | - } |
|
212 | - |
|
213 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
214 | - $ip = trim($ip); // just to be safe |
|
215 | - |
|
216 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
217 | - return $ip; |
|
218 | - } |
|
219 | - } |
|
220 | - } |
|
205 | + foreach ( array( |
|
206 | + 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
207 | + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
208 | + ) as $key ) { |
|
209 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
210 | + continue; |
|
211 | + } |
|
212 | + |
|
213 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
214 | + $ip = trim($ip); // just to be safe |
|
215 | + |
|
216 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
217 | + return $ip; |
|
218 | + } |
|
219 | + } |
|
220 | + } |
|
221 | 221 | |
222 | 222 | return sanitize_text_field( $ip ); |
223 | - } |
|
223 | + } |
|
224 | 224 | |
225 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
226 | - if ( strpos($param, '[') ) { |
|
227 | - $params = explode('[', $param); |
|
228 | - $param = $params[0]; |
|
229 | - } |
|
225 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
226 | + if ( strpos($param, '[') ) { |
|
227 | + $params = explode('[', $param); |
|
228 | + $param = $params[0]; |
|
229 | + } |
|
230 | 230 | |
231 | 231 | if ( $src == 'get' ) { |
232 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
233 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
234 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
235 | - } |
|
232 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
233 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
234 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
235 | + } |
|
236 | 236 | self::sanitize_value( $sanitize, $value ); |
237 | 237 | } else { |
238 | - $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
239 | - } |
|
238 | + $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
239 | + } |
|
240 | 240 | |
241 | 241 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
242 | - foreach ( $params as $k => $p ) { |
|
243 | - if ( ! $k || ! is_array($value) ) { |
|
244 | - continue; |
|
245 | - } |
|
242 | + foreach ( $params as $k => $p ) { |
|
243 | + if ( ! $k || ! is_array($value) ) { |
|
244 | + continue; |
|
245 | + } |
|
246 | 246 | |
247 | - $p = trim($p, ']'); |
|
248 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
249 | - } |
|
250 | - } |
|
247 | + $p = trim($p, ']'); |
|
248 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
249 | + } |
|
250 | + } |
|
251 | 251 | |
252 | - return $value; |
|
253 | - } |
|
252 | + return $value; |
|
253 | + } |
|
254 | 254 | |
255 | 255 | /** |
256 | 256 | * |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) { |
273 | 273 | return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
274 | - } |
|
274 | + } |
|
275 | 275 | |
276 | 276 | /** |
277 | 277 | * Get a GET/POST/REQUEST value and sanitize it |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
308 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
309 | - * |
|
310 | - * @since 2.0.8 |
|
311 | - * @param string $value |
|
312 | - * @return string $value |
|
313 | - */ |
|
308 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
309 | + * |
|
310 | + * @since 2.0.8 |
|
311 | + * @param string $value |
|
312 | + * @return string $value |
|
313 | + */ |
|
314 | 314 | public static function preserve_backslashes( $value ) { |
315 | 315 | // If backslashes have already been added, don't add them again |
316 | 316 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
333 | - $temp_values = $values; |
|
334 | - foreach ( $temp_values as $k => $val ) { |
|
335 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
332 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
333 | + $temp_values = $values; |
|
334 | + foreach ( $temp_values as $k => $val ) { |
|
335 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
336 | 336 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
337 | - } |
|
338 | - } |
|
339 | - } |
|
337 | + } |
|
338 | + } |
|
339 | + } |
|
340 | 340 | |
341 | 341 | public static function sanitize_array( &$values ) { |
342 | 342 | $temp_values = $values; |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | */ |
352 | 352 | public static function kses( $value, $allowed = array() ) { |
353 | 353 | $html = array( |
354 | - 'a' => array( |
|
354 | + 'a' => array( |
|
355 | 355 | 'href' => array(), |
356 | 356 | 'title' => array(), |
357 | 357 | 'id' => array(), |
358 | 358 | 'class' => array(), |
359 | - ), |
|
359 | + ), |
|
360 | 360 | ); |
361 | 361 | |
362 | 362 | $allowed_html = array(); |
@@ -367,176 +367,176 @@ discard block |
||
367 | 367 | return wp_kses( $value, $allowed_html ); |
368 | 368 | } |
369 | 369 | |
370 | - /** |
|
371 | - * Used when switching the action for a bulk action |
|
372 | - * @since 2.0 |
|
373 | - */ |
|
374 | - public static function remove_get_action() { |
|
375 | - if ( ! isset($_GET) ) { |
|
376 | - return; |
|
377 | - } |
|
370 | + /** |
|
371 | + * Used when switching the action for a bulk action |
|
372 | + * @since 2.0 |
|
373 | + */ |
|
374 | + public static function remove_get_action() { |
|
375 | + if ( ! isset($_GET) ) { |
|
376 | + return; |
|
377 | + } |
|
378 | 378 | |
379 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
380 | - if ( ! empty( $new_action ) ) { |
|
379 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
380 | + if ( ! empty( $new_action ) ) { |
|
381 | 381 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
382 | - } |
|
383 | - } |
|
384 | - |
|
385 | - /** |
|
386 | - * Check the WP query for a parameter |
|
387 | - * |
|
388 | - * @since 2.0 |
|
389 | - * @return string|array |
|
390 | - */ |
|
391 | - public static function get_query_var( $value, $param ) { |
|
392 | - if ( $value != '' ) { |
|
393 | - return $value; |
|
394 | - } |
|
395 | - |
|
396 | - global $wp_query; |
|
397 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
398 | - $value = $wp_query->query_vars[ $param ]; |
|
399 | - } |
|
400 | - |
|
401 | - return $value; |
|
402 | - } |
|
403 | - |
|
404 | - /** |
|
405 | - * @param string $type |
|
406 | - */ |
|
407 | - public static function trigger_hook_load( $type, $object = null ) { |
|
408 | - // only load the form hooks once |
|
409 | - $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object); |
|
410 | - if ( ! $hooks_loaded ) { |
|
411 | - do_action('frm_load_'. $type .'_hooks'); |
|
412 | - } |
|
413 | - } |
|
414 | - |
|
415 | - /** |
|
416 | - * Check cache before fetching values and saving to cache |
|
417 | - * |
|
418 | - * @since 2.0 |
|
419 | - * |
|
420 | - * @param string $cache_key The unique name for this cache |
|
421 | - * @param string $group The name of the cache group |
|
422 | - * @param string $query If blank, don't run a db call |
|
423 | - * @param string $type The wpdb function to use with this query |
|
424 | - * @return mixed $results The cache or query results |
|
425 | - */ |
|
426 | - public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
427 | - $results = wp_cache_get($cache_key, $group); |
|
428 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
429 | - return $results; |
|
430 | - } |
|
431 | - |
|
432 | - if ( 'get_posts' == $type ) { |
|
433 | - $results = get_posts($query); |
|
434 | - } else { |
|
435 | - global $wpdb; |
|
436 | - $results = $wpdb->{$type}($query); |
|
437 | - } |
|
382 | + } |
|
383 | + } |
|
384 | + |
|
385 | + /** |
|
386 | + * Check the WP query for a parameter |
|
387 | + * |
|
388 | + * @since 2.0 |
|
389 | + * @return string|array |
|
390 | + */ |
|
391 | + public static function get_query_var( $value, $param ) { |
|
392 | + if ( $value != '' ) { |
|
393 | + return $value; |
|
394 | + } |
|
395 | + |
|
396 | + global $wp_query; |
|
397 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
398 | + $value = $wp_query->query_vars[ $param ]; |
|
399 | + } |
|
400 | + |
|
401 | + return $value; |
|
402 | + } |
|
403 | + |
|
404 | + /** |
|
405 | + * @param string $type |
|
406 | + */ |
|
407 | + public static function trigger_hook_load( $type, $object = null ) { |
|
408 | + // only load the form hooks once |
|
409 | + $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object); |
|
410 | + if ( ! $hooks_loaded ) { |
|
411 | + do_action('frm_load_'. $type .'_hooks'); |
|
412 | + } |
|
413 | + } |
|
414 | + |
|
415 | + /** |
|
416 | + * Check cache before fetching values and saving to cache |
|
417 | + * |
|
418 | + * @since 2.0 |
|
419 | + * |
|
420 | + * @param string $cache_key The unique name for this cache |
|
421 | + * @param string $group The name of the cache group |
|
422 | + * @param string $query If blank, don't run a db call |
|
423 | + * @param string $type The wpdb function to use with this query |
|
424 | + * @return mixed $results The cache or query results |
|
425 | + */ |
|
426 | + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
427 | + $results = wp_cache_get($cache_key, $group); |
|
428 | + if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
429 | + return $results; |
|
430 | + } |
|
431 | + |
|
432 | + if ( 'get_posts' == $type ) { |
|
433 | + $results = get_posts($query); |
|
434 | + } else { |
|
435 | + global $wpdb; |
|
436 | + $results = $wpdb->{$type}($query); |
|
437 | + } |
|
438 | 438 | |
439 | 439 | if ( ! self::prevent_caching() ) { |
440 | 440 | wp_cache_set( $cache_key, $results, $group, $time ); |
441 | 441 | } |
442 | 442 | |
443 | - return $results; |
|
444 | - } |
|
443 | + return $results; |
|
444 | + } |
|
445 | 445 | |
446 | - /** |
|
447 | - * Data that should be stored for a long time can be stored in a transient. |
|
448 | - * First check the cache, then check the transient |
|
449 | - * @since 2.0 |
|
450 | - * @return mixed The cached value or false |
|
451 | - */ |
|
446 | + /** |
|
447 | + * Data that should be stored for a long time can be stored in a transient. |
|
448 | + * First check the cache, then check the transient |
|
449 | + * @since 2.0 |
|
450 | + * @return mixed The cached value or false |
|
451 | + */ |
|
452 | 452 | public static function check_cache_and_transient( $cache_key ) { |
453 | - // check caching layer first |
|
454 | - $results = self::check_cache( $cache_key ); |
|
455 | - if ( $results ) { |
|
456 | - return $results; |
|
457 | - } |
|
458 | - |
|
459 | - // then check the transient |
|
460 | - $results = get_transient($cache_key); |
|
461 | - if ( $results ) { |
|
462 | - wp_cache_set($cache_key, $results); |
|
463 | - } |
|
464 | - |
|
465 | - return $results; |
|
466 | - } |
|
467 | - |
|
468 | - /** |
|
469 | - * @since 2.0 |
|
470 | - * @param string $cache_key |
|
471 | - */ |
|
453 | + // check caching layer first |
|
454 | + $results = self::check_cache( $cache_key ); |
|
455 | + if ( $results ) { |
|
456 | + return $results; |
|
457 | + } |
|
458 | + |
|
459 | + // then check the transient |
|
460 | + $results = get_transient($cache_key); |
|
461 | + if ( $results ) { |
|
462 | + wp_cache_set($cache_key, $results); |
|
463 | + } |
|
464 | + |
|
465 | + return $results; |
|
466 | + } |
|
467 | + |
|
468 | + /** |
|
469 | + * @since 2.0 |
|
470 | + * @param string $cache_key |
|
471 | + */ |
|
472 | 472 | public static function delete_cache_and_transient( $cache_key ) { |
473 | - delete_transient($cache_key); |
|
474 | - wp_cache_delete($cache_key); |
|
475 | - } |
|
476 | - |
|
477 | - /** |
|
478 | - * Delete all caching in a single group |
|
479 | - * |
|
480 | - * @since 2.0 |
|
481 | - * |
|
482 | - * @param string $group The name of the cache group |
|
483 | - * @return boolean True or False |
|
484 | - */ |
|
473 | + delete_transient($cache_key); |
|
474 | + wp_cache_delete($cache_key); |
|
475 | + } |
|
476 | + |
|
477 | + /** |
|
478 | + * Delete all caching in a single group |
|
479 | + * |
|
480 | + * @since 2.0 |
|
481 | + * |
|
482 | + * @param string $group The name of the cache group |
|
483 | + * @return boolean True or False |
|
484 | + */ |
|
485 | 485 | public static function cache_delete_group( $group ) { |
486 | - global $wp_object_cache; |
|
487 | - |
|
488 | - if ( isset( $wp_object_cache->cache[ $group ] ) ) { |
|
489 | - foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { |
|
490 | - wp_cache_delete($k, $group); |
|
491 | - } |
|
492 | - return true; |
|
493 | - } |
|
494 | - |
|
495 | - return false; |
|
496 | - } |
|
497 | - |
|
498 | - /** |
|
499 | - * Check a value from a shortcode to see if true or false. |
|
500 | - * True when value is 1, true, 'true', 'yes' |
|
501 | - * |
|
502 | - * @since 1.07.10 |
|
503 | - * |
|
504 | - * @param string $value The value to compare |
|
505 | - * @return boolean True or False |
|
506 | - */ |
|
486 | + global $wp_object_cache; |
|
487 | + |
|
488 | + if ( isset( $wp_object_cache->cache[ $group ] ) ) { |
|
489 | + foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { |
|
490 | + wp_cache_delete($k, $group); |
|
491 | + } |
|
492 | + return true; |
|
493 | + } |
|
494 | + |
|
495 | + return false; |
|
496 | + } |
|
497 | + |
|
498 | + /** |
|
499 | + * Check a value from a shortcode to see if true or false. |
|
500 | + * True when value is 1, true, 'true', 'yes' |
|
501 | + * |
|
502 | + * @since 1.07.10 |
|
503 | + * |
|
504 | + * @param string $value The value to compare |
|
505 | + * @return boolean True or False |
|
506 | + */ |
|
507 | 507 | public static function is_true( $value ) { |
508 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
509 | - } |
|
508 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
509 | + } |
|
510 | 510 | |
511 | - /** |
|
512 | - * Used to filter shortcode in text widgets |
|
513 | - */ |
|
514 | - public static function widget_text_filter_callback( $matches ) { |
|
515 | - return do_shortcode( $matches[0] ); |
|
516 | - } |
|
511 | + /** |
|
512 | + * Used to filter shortcode in text widgets |
|
513 | + */ |
|
514 | + public static function widget_text_filter_callback( $matches ) { |
|
515 | + return do_shortcode( $matches[0] ); |
|
516 | + } |
|
517 | 517 | |
518 | 518 | public static function load_scripts( $scripts ) { |
519 | - _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
|
520 | - foreach ( (array) $scripts as $s ) { |
|
521 | - wp_enqueue_script($s); |
|
522 | - } |
|
523 | - } |
|
519 | + _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
|
520 | + foreach ( (array) $scripts as $s ) { |
|
521 | + wp_enqueue_script($s); |
|
522 | + } |
|
523 | + } |
|
524 | 524 | |
525 | 525 | public static function load_styles( $styles ) { |
526 | - _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
|
527 | - foreach ( (array) $styles as $s ) { |
|
528 | - wp_enqueue_style($s); |
|
529 | - } |
|
530 | - } |
|
526 | + _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
|
527 | + foreach ( (array) $styles as $s ) { |
|
528 | + wp_enqueue_style($s); |
|
529 | + } |
|
530 | + } |
|
531 | 531 | |
532 | - public static function get_pages() { |
|
532 | + public static function get_pages() { |
|
533 | 533 | return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
534 | - } |
|
534 | + } |
|
535 | 535 | |
536 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
537 | - $pages = self::get_pages(); |
|
536 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
537 | + $pages = self::get_pages(); |
|
538 | 538 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
539 | - ?> |
|
539 | + ?> |
|
540 | 540 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
541 | 541 | <option value=""> </option> |
542 | 542 | <?php foreach ( $pages as $page ) { ?> |
@@ -546,107 +546,107 @@ discard block |
||
546 | 546 | <?php } ?> |
547 | 547 | </select> |
548 | 548 | <?php |
549 | - } |
|
549 | + } |
|
550 | 550 | |
551 | 551 | public static function post_edit_link( $post_id ) { |
552 | - $post = get_post($post_id); |
|
553 | - if ( $post ) { |
|
554 | - return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>'; |
|
555 | - } |
|
556 | - return ''; |
|
557 | - } |
|
552 | + $post = get_post($post_id); |
|
553 | + if ( $post ) { |
|
554 | + return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>'; |
|
555 | + } |
|
556 | + return ''; |
|
557 | + } |
|
558 | 558 | |
559 | 559 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
560 | - ?> |
|
560 | + ?> |
|
561 | 561 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
562 | - echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
563 | - ?> class="frm_multiselect"> |
|
562 | + echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
563 | + ?> class="frm_multiselect"> |
|
564 | 564 | <?php self::roles_options($capability); ?> |
565 | 565 | </select> |
566 | 566 | <?php |
567 | - } |
|
567 | + } |
|
568 | 568 | |
569 | 569 | public static function roles_options( $capability ) { |
570 | - global $frm_vars; |
|
571 | - if ( isset($frm_vars['editable_roles']) ) { |
|
572 | - $editable_roles = $frm_vars['editable_roles']; |
|
573 | - } else { |
|
574 | - $editable_roles = get_editable_roles(); |
|
575 | - $frm_vars['editable_roles'] = $editable_roles; |
|
576 | - } |
|
577 | - |
|
578 | - foreach ( $editable_roles as $role => $details ) { |
|
579 | - $name = translate_user_role($details['name'] ); ?> |
|
570 | + global $frm_vars; |
|
571 | + if ( isset($frm_vars['editable_roles']) ) { |
|
572 | + $editable_roles = $frm_vars['editable_roles']; |
|
573 | + } else { |
|
574 | + $editable_roles = get_editable_roles(); |
|
575 | + $frm_vars['editable_roles'] = $editable_roles; |
|
576 | + } |
|
577 | + |
|
578 | + foreach ( $editable_roles as $role => $details ) { |
|
579 | + $name = translate_user_role($details['name'] ); ?> |
|
580 | 580 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
581 | 581 | <?php |
582 | - unset($role, $details); |
|
583 | - } |
|
584 | - } |
|
582 | + unset($role, $details); |
|
583 | + } |
|
584 | + } |
|
585 | 585 | |
586 | 586 | public static function frm_capabilities( $type = 'auto' ) { |
587 | - $cap = array( |
|
588 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
589 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
590 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
591 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
592 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
593 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
594 | - ); |
|
587 | + $cap = array( |
|
588 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
589 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
590 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
591 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
592 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
593 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
594 | + ); |
|
595 | 595 | |
596 | 596 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
597 | - return $cap; |
|
598 | - } |
|
597 | + return $cap; |
|
598 | + } |
|
599 | 599 | |
600 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
601 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
602 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
603 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
600 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
601 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
602 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
603 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
604 | 604 | |
605 | - return $cap; |
|
606 | - } |
|
605 | + return $cap; |
|
606 | + } |
|
607 | 607 | |
608 | 608 | public static function user_has_permission( $needed_role ) { |
609 | - if ( $needed_role == '-1' ) { |
|
610 | - return false; |
|
609 | + if ( $needed_role == '-1' ) { |
|
610 | + return false; |
|
611 | 611 | } |
612 | 612 | |
613 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
614 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
615 | - return true; |
|
616 | - } |
|
613 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
614 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
615 | + return true; |
|
616 | + } |
|
617 | 617 | |
618 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
619 | - foreach ( $roles as $role ) { |
|
618 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
619 | + foreach ( $roles as $role ) { |
|
620 | 620 | if ( current_user_can( $role ) ) { |
621 | - return true; |
|
621 | + return true; |
|
622 | 622 | } |
623 | - if ( $role == $needed_role ) { |
|
624 | - break; |
|
623 | + if ( $role == $needed_role ) { |
|
624 | + break; |
|
625 | 625 | } |
626 | - } |
|
627 | - return false; |
|
628 | - } |
|
629 | - |
|
630 | - /** |
|
631 | - * Make sure administrators can see Formidable menu |
|
632 | - * |
|
633 | - * @since 2.0 |
|
634 | - */ |
|
635 | - public static function maybe_add_permissions() { |
|
626 | + } |
|
627 | + return false; |
|
628 | + } |
|
629 | + |
|
630 | + /** |
|
631 | + * Make sure administrators can see Formidable menu |
|
632 | + * |
|
633 | + * @since 2.0 |
|
634 | + */ |
|
635 | + public static function maybe_add_permissions() { |
|
636 | 636 | self::force_capability( 'frm_view_entries' ); |
637 | 637 | |
638 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
639 | - return; |
|
640 | - } |
|
638 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
639 | + return; |
|
640 | + } |
|
641 | 641 | |
642 | 642 | $user_id = get_current_user_id(); |
643 | 643 | $user = new WP_User( $user_id ); |
644 | - $frm_roles = self::frm_capabilities(); |
|
645 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
644 | + $frm_roles = self::frm_capabilities(); |
|
645 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
646 | 646 | $user->add_cap( $frm_role ); |
647 | - unset($frm_role, $frm_role_description); |
|
648 | - } |
|
649 | - } |
|
647 | + unset($frm_role, $frm_role_description); |
|
648 | + } |
|
649 | + } |
|
650 | 650 | |
651 | 651 | /** |
652 | 652 | * Make sure admins have permission to see the menu items |
@@ -662,28 +662,28 @@ discard block |
||
662 | 662 | } |
663 | 663 | } |
664 | 664 | |
665 | - /** |
|
666 | - * Check if the user has permision for action. |
|
667 | - * Return permission message and stop the action if no permission |
|
668 | - * @since 2.0 |
|
669 | - * @param string $permission |
|
670 | - */ |
|
665 | + /** |
|
666 | + * Check if the user has permision for action. |
|
667 | + * Return permission message and stop the action if no permission |
|
668 | + * @since 2.0 |
|
669 | + * @param string $permission |
|
670 | + */ |
|
671 | 671 | public static function permission_check( $permission, $show_message = 'show' ) { |
672 | - $permission_error = self::permission_nonce_error($permission); |
|
673 | - if ( $permission_error !== false ) { |
|
674 | - if ( 'hide' == $show_message ) { |
|
675 | - $permission_error = ''; |
|
676 | - } |
|
677 | - wp_die($permission_error); |
|
678 | - } |
|
679 | - } |
|
680 | - |
|
681 | - /** |
|
682 | - * Check user permission and nonce |
|
683 | - * @since 2.0 |
|
684 | - * @param string $permission |
|
685 | - * @return false|string The permission message or false if allowed |
|
686 | - */ |
|
672 | + $permission_error = self::permission_nonce_error($permission); |
|
673 | + if ( $permission_error !== false ) { |
|
674 | + if ( 'hide' == $show_message ) { |
|
675 | + $permission_error = ''; |
|
676 | + } |
|
677 | + wp_die($permission_error); |
|
678 | + } |
|
679 | + } |
|
680 | + |
|
681 | + /** |
|
682 | + * Check user permission and nonce |
|
683 | + * @since 2.0 |
|
684 | + * @param string $permission |
|
685 | + * @return false|string The permission message or false if allowed |
|
686 | + */ |
|
687 | 687 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
688 | 688 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
689 | 689 | $frm_settings = self::get_settings(); |
@@ -691,75 +691,75 @@ discard block |
||
691 | 691 | } |
692 | 692 | |
693 | 693 | $error = false; |
694 | - if ( empty($nonce_name) ) { |
|
695 | - return $error; |
|
696 | - } |
|
694 | + if ( empty($nonce_name) ) { |
|
695 | + return $error; |
|
696 | + } |
|
697 | 697 | |
698 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
699 | - $frm_settings = self::get_settings(); |
|
700 | - $error = $frm_settings->admin_permission; |
|
701 | - } |
|
698 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
699 | + $frm_settings = self::get_settings(); |
|
700 | + $error = $frm_settings->admin_permission; |
|
701 | + } |
|
702 | 702 | |
703 | - return $error; |
|
704 | - } |
|
703 | + return $error; |
|
704 | + } |
|
705 | 705 | |
706 | - public static function checked( $values, $current ) { |
|
706 | + public static function checked( $values, $current ) { |
|
707 | 707 | if ( self::check_selected( $values, $current ) ) { |
708 | - echo ' checked="checked"'; |
|
708 | + echo ' checked="checked"'; |
|
709 | 709 | } |
710 | - } |
|
710 | + } |
|
711 | 711 | |
712 | 712 | public static function check_selected( $values, $current ) { |
713 | - $values = self::recursive_function_map( $values, 'trim' ); |
|
714 | - $current = trim($current); |
|
715 | - |
|
716 | - return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current ); |
|
717 | - } |
|
718 | - |
|
719 | - /** |
|
720 | - * Check if current field option is an "other" option |
|
721 | - * |
|
722 | - * @since 2.0 |
|
723 | - * |
|
724 | - * @param string $opt_key |
|
725 | - * @return boolean Returns true if current field option is an "Other" option |
|
726 | - */ |
|
727 | - public static function is_other_opt( $opt_key ) { |
|
728 | - _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
729 | - return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
730 | - } |
|
731 | - |
|
732 | - /** |
|
733 | - * Get value that belongs in "Other" text box |
|
734 | - * |
|
735 | - * @since 2.0 |
|
736 | - * |
|
737 | - * @param string $opt_key |
|
738 | - * @param array $field |
|
739 | - * @return string $other_val |
|
740 | - */ |
|
741 | - public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
713 | + $values = self::recursive_function_map( $values, 'trim' ); |
|
714 | + $current = trim($current); |
|
715 | + |
|
716 | + return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current ); |
|
717 | + } |
|
718 | + |
|
719 | + /** |
|
720 | + * Check if current field option is an "other" option |
|
721 | + * |
|
722 | + * @since 2.0 |
|
723 | + * |
|
724 | + * @param string $opt_key |
|
725 | + * @return boolean Returns true if current field option is an "Other" option |
|
726 | + */ |
|
727 | + public static function is_other_opt( $opt_key ) { |
|
728 | + _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
729 | + return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
730 | + } |
|
731 | + |
|
732 | + /** |
|
733 | + * Get value that belongs in "Other" text box |
|
734 | + * |
|
735 | + * @since 2.0 |
|
736 | + * |
|
737 | + * @param string $opt_key |
|
738 | + * @param array $field |
|
739 | + * @return string $other_val |
|
740 | + */ |
|
741 | + public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
742 | 742 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' ); |
743 | 743 | return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) ); |
744 | - } |
|
745 | - |
|
746 | - /** |
|
747 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
748 | - * Intended for front-end use |
|
749 | - * |
|
750 | - * @since 2.0 |
|
751 | - * |
|
752 | - * @param array $field |
|
753 | - * @param boolean $other_opt |
|
754 | - * @param string $checked |
|
755 | - * @param array $args should include opt_key and field name |
|
756 | - * @return string $other_val |
|
757 | - */ |
|
758 | - public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
744 | + } |
|
745 | + |
|
746 | + /** |
|
747 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
748 | + * Intended for front-end use |
|
749 | + * |
|
750 | + * @since 2.0 |
|
751 | + * |
|
752 | + * @param array $field |
|
753 | + * @param boolean $other_opt |
|
754 | + * @param string $checked |
|
755 | + * @param array $args should include opt_key and field name |
|
756 | + * @return string $other_val |
|
757 | + */ |
|
758 | + public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
759 | 759 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' ); |
760 | 760 | $args['field'] = $field; |
761 | 761 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
762 | - } |
|
762 | + } |
|
763 | 763 | |
764 | 764 | public static function recursive_function_map( $value, $function ) { |
765 | 765 | if ( is_array( $value ) ) { |
@@ -789,333 +789,333 @@ discard block |
||
789 | 789 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
790 | 790 | } |
791 | 791 | |
792 | - /** |
|
793 | - * Flatten a multi-dimensional array |
|
794 | - */ |
|
792 | + /** |
|
793 | + * Flatten a multi-dimensional array |
|
794 | + */ |
|
795 | 795 | public static function array_flatten( $array, $keys = 'keep' ) { |
796 | - $return = array(); |
|
797 | - foreach ( $array as $key => $value ) { |
|
798 | - if ( is_array($value) ) { |
|
796 | + $return = array(); |
|
797 | + foreach ( $array as $key => $value ) { |
|
798 | + if ( is_array($value) ) { |
|
799 | 799 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
800 | - } else { |
|
800 | + } else { |
|
801 | 801 | if ( $keys == 'keep' ) { |
802 | 802 | $return[ $key ] = $value; |
803 | 803 | } else { |
804 | 804 | $return[] = $value; |
805 | 805 | } |
806 | - } |
|
807 | - } |
|
808 | - return $return; |
|
809 | - } |
|
810 | - |
|
811 | - public static function esc_textarea( $text ) { |
|
812 | - $safe_text = str_replace('"', '"', $text); |
|
813 | - $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
|
814 | - return apply_filters( 'esc_textarea', $safe_text, $text ); |
|
815 | - } |
|
816 | - |
|
817 | - /** |
|
818 | - * Add auto paragraphs to text areas |
|
819 | - * @since 2.0 |
|
820 | - */ |
|
806 | + } |
|
807 | + } |
|
808 | + return $return; |
|
809 | + } |
|
810 | + |
|
811 | + public static function esc_textarea( $text ) { |
|
812 | + $safe_text = str_replace('"', '"', $text); |
|
813 | + $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
|
814 | + return apply_filters( 'esc_textarea', $safe_text, $text ); |
|
815 | + } |
|
816 | + |
|
817 | + /** |
|
818 | + * Add auto paragraphs to text areas |
|
819 | + * @since 2.0 |
|
820 | + */ |
|
821 | 821 | public static function use_wpautop( $content ) { |
822 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
823 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
824 | - } |
|
825 | - return $content; |
|
826 | - } |
|
822 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
823 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
824 | + } |
|
825 | + return $content; |
|
826 | + } |
|
827 | 827 | |
828 | 828 | public static function replace_quotes( $val ) { |
829 | - //Replace double quotes |
|
829 | + //Replace double quotes |
|
830 | 830 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
831 | - //Replace single quotes |
|
832 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
833 | - return $val; |
|
834 | - } |
|
835 | - |
|
836 | - /** |
|
837 | - * @since 2.0 |
|
838 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
839 | - */ |
|
840 | - public static function jquery_ui_base_url() { |
|
841 | - $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core'); |
|
842 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
843 | - return $url; |
|
844 | - } |
|
845 | - |
|
846 | - /** |
|
847 | - * @param string $handle |
|
848 | - */ |
|
831 | + //Replace single quotes |
|
832 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
833 | + return $val; |
|
834 | + } |
|
835 | + |
|
836 | + /** |
|
837 | + * @since 2.0 |
|
838 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
839 | + */ |
|
840 | + public static function jquery_ui_base_url() { |
|
841 | + $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core'); |
|
842 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
843 | + return $url; |
|
844 | + } |
|
845 | + |
|
846 | + /** |
|
847 | + * @param string $handle |
|
848 | + */ |
|
849 | 849 | public static function script_version( $handle ) { |
850 | - global $wp_scripts; |
|
851 | - if ( ! $wp_scripts ) { |
|
852 | - return false; |
|
853 | - } |
|
850 | + global $wp_scripts; |
|
851 | + if ( ! $wp_scripts ) { |
|
852 | + return false; |
|
853 | + } |
|
854 | 854 | |
855 | - $ver = 0; |
|
855 | + $ver = 0; |
|
856 | 856 | |
857 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
858 | - return $ver; |
|
859 | - } |
|
857 | + if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
858 | + return $ver; |
|
859 | + } |
|
860 | 860 | |
861 | - $query = $wp_scripts->registered[ $handle ]; |
|
862 | - if ( is_object( $query ) ) { |
|
863 | - $ver = $query->ver; |
|
864 | - } |
|
861 | + $query = $wp_scripts->registered[ $handle ]; |
|
862 | + if ( is_object( $query ) ) { |
|
863 | + $ver = $query->ver; |
|
864 | + } |
|
865 | 865 | |
866 | - return $ver; |
|
867 | - } |
|
866 | + return $ver; |
|
867 | + } |
|
868 | 868 | |
869 | 869 | public static function js_redirect( $url ) { |
870 | 870 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
871 | - } |
|
871 | + } |
|
872 | 872 | |
873 | 873 | public static function get_user_id_param( $user_id ) { |
874 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
875 | - return $user_id; |
|
876 | - } |
|
874 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
875 | + return $user_id; |
|
876 | + } |
|
877 | 877 | |
878 | 878 | if ( $user_id == 'current' ) { |
879 | 879 | $user_id = get_current_user_id(); |
880 | 880 | } else { |
881 | - if ( is_email($user_id) ) { |
|
882 | - $user = get_user_by('email', $user_id); |
|
883 | - } else { |
|
884 | - $user = get_user_by('login', $user_id); |
|
885 | - } |
|
881 | + if ( is_email($user_id) ) { |
|
882 | + $user = get_user_by('email', $user_id); |
|
883 | + } else { |
|
884 | + $user = get_user_by('login', $user_id); |
|
885 | + } |
|
886 | 886 | |
887 | - if ( $user ) { |
|
888 | - $user_id = $user->ID; |
|
889 | - } |
|
890 | - unset($user); |
|
891 | - } |
|
887 | + if ( $user ) { |
|
888 | + $user_id = $user->ID; |
|
889 | + } |
|
890 | + unset($user); |
|
891 | + } |
|
892 | 892 | |
893 | - return $user_id; |
|
894 | - } |
|
893 | + return $user_id; |
|
894 | + } |
|
895 | 895 | |
896 | 896 | public static function get_file_contents( $filename, $atts = array() ) { |
897 | - if ( ! is_file($filename) ) { |
|
898 | - return false; |
|
899 | - } |
|
900 | - |
|
901 | - extract($atts); |
|
902 | - ob_start(); |
|
903 | - include($filename); |
|
904 | - $contents = ob_get_contents(); |
|
905 | - ob_end_clean(); |
|
906 | - return $contents; |
|
907 | - } |
|
908 | - |
|
909 | - /** |
|
910 | - * @param string $table_name |
|
911 | - * @param string $column |
|
912 | - */ |
|
913 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) { |
|
914 | - global $wpdb; |
|
915 | - |
|
916 | - $key = ''; |
|
917 | - |
|
918 | - if ( ! empty( $name ) ) { |
|
919 | - $key = sanitize_key($name); |
|
920 | - } |
|
897 | + if ( ! is_file($filename) ) { |
|
898 | + return false; |
|
899 | + } |
|
900 | + |
|
901 | + extract($atts); |
|
902 | + ob_start(); |
|
903 | + include($filename); |
|
904 | + $contents = ob_get_contents(); |
|
905 | + ob_end_clean(); |
|
906 | + return $contents; |
|
907 | + } |
|
908 | + |
|
909 | + /** |
|
910 | + * @param string $table_name |
|
911 | + * @param string $column |
|
912 | + */ |
|
913 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) { |
|
914 | + global $wpdb; |
|
915 | + |
|
916 | + $key = ''; |
|
917 | + |
|
918 | + if ( ! empty( $name ) ) { |
|
919 | + $key = sanitize_key($name); |
|
920 | + } |
|
921 | 921 | |
922 | 922 | if ( empty( $key ) ) { |
923 | - $max_slug_value = pow(36, $num_chars); |
|
924 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
925 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
926 | - } |
|
923 | + $max_slug_value = pow(36, $num_chars); |
|
924 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
925 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
926 | + } |
|
927 | 927 | |
928 | 928 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
929 | - $key = $key .'a'; |
|
930 | - } |
|
929 | + $key = $key .'a'; |
|
930 | + } |
|
931 | 931 | |
932 | 932 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
933 | 933 | |
934 | - if ( $key_check || is_numeric($key_check) ) { |
|
935 | - $suffix = 2; |
|
934 | + if ( $key_check || is_numeric($key_check) ) { |
|
935 | + $suffix = 2; |
|
936 | 936 | do { |
937 | 937 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
938 | 938 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
939 | 939 | $suffix++; |
940 | 940 | } while ($key_check || is_numeric($key_check)); |
941 | 941 | $key = $alt_post_name; |
942 | - } |
|
943 | - return $key; |
|
944 | - } |
|
945 | - |
|
946 | - /** |
|
947 | - * Editing a Form or Entry |
|
948 | - * @param string $table |
|
949 | - * @return bool|array |
|
950 | - */ |
|
951 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
952 | - if ( ! $record ) { |
|
953 | - return false; |
|
954 | - } |
|
955 | - |
|
956 | - global $frm_vars; |
|
957 | - |
|
958 | - if ( empty($post_values) ) { |
|
959 | - $post_values = stripslashes_deep($_POST); |
|
960 | - } |
|
942 | + } |
|
943 | + return $key; |
|
944 | + } |
|
945 | + |
|
946 | + /** |
|
947 | + * Editing a Form or Entry |
|
948 | + * @param string $table |
|
949 | + * @return bool|array |
|
950 | + */ |
|
951 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
952 | + if ( ! $record ) { |
|
953 | + return false; |
|
954 | + } |
|
955 | + |
|
956 | + global $frm_vars; |
|
957 | + |
|
958 | + if ( empty($post_values) ) { |
|
959 | + $post_values = stripslashes_deep($_POST); |
|
960 | + } |
|
961 | 961 | |
962 | 962 | $values = array( 'id' => $record->id, 'fields' => array() ); |
963 | 963 | |
964 | 964 | foreach ( array( 'name', 'description' ) as $var ) { |
965 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
966 | - $values[ $var ] = self::get_param( $var, $default_val ); |
|
967 | - unset($var, $default_val); |
|
968 | - } |
|
969 | - |
|
970 | - $values['description'] = self::use_wpautop($values['description']); |
|
971 | - $frm_settings = self::get_settings(); |
|
972 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
973 | - |
|
974 | - foreach ( (array) $fields as $field ) { |
|
975 | - // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
976 | - if ( ! $is_form_builder ) { |
|
977 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
978 | - } |
|
965 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
966 | + $values[ $var ] = self::get_param( $var, $default_val ); |
|
967 | + unset($var, $default_val); |
|
968 | + } |
|
969 | + |
|
970 | + $values['description'] = self::use_wpautop($values['description']); |
|
971 | + $frm_settings = self::get_settings(); |
|
972 | + $is_form_builder = self::is_admin_page('formidable' ); |
|
973 | + |
|
974 | + foreach ( (array) $fields as $field ) { |
|
975 | + // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
976 | + if ( ! $is_form_builder ) { |
|
977 | + $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
978 | + } |
|
979 | 979 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
980 | 980 | self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
981 | - } |
|
981 | + } |
|
982 | 982 | |
983 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
983 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
984 | 984 | |
985 | - if ( $table == 'entries' ) { |
|
986 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
987 | - } else if ( $table == 'forms' ) { |
|
988 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
989 | - } |
|
985 | + if ( $table == 'entries' ) { |
|
986 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
987 | + } else if ( $table == 'forms' ) { |
|
988 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
989 | + } |
|
990 | 990 | |
991 | - return $values; |
|
992 | - } |
|
991 | + return $values; |
|
992 | + } |
|
993 | 993 | |
994 | 994 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
995 | - $post_values = $args['post_values']; |
|
996 | - |
|
997 | - if ( $args['default'] ) { |
|
998 | - $meta_value = $field->default_value; |
|
999 | - } else { |
|
1000 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1001 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
1002 | - $field->field_options['custom_field'] = ''; |
|
1003 | - } |
|
995 | + $post_values = $args['post_values']; |
|
996 | + |
|
997 | + if ( $args['default'] ) { |
|
998 | + $meta_value = $field->default_value; |
|
999 | + } else { |
|
1000 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1001 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
1002 | + $field->field_options['custom_field'] = ''; |
|
1003 | + } |
|
1004 | 1004 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
1005 | - } else { |
|
1005 | + } else { |
|
1006 | 1006 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
1007 | - } |
|
1008 | - } |
|
1009 | - |
|
1010 | - $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type; |
|
1011 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1012 | - |
|
1013 | - $field_array = array( |
|
1014 | - 'id' => $field->id, |
|
1015 | - 'value' => $new_value, |
|
1016 | - 'default_value' => $field->default_value, |
|
1017 | - 'name' => $field->name, |
|
1018 | - 'description' => $field->description, |
|
1019 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1020 | - 'options' => $field->options, |
|
1021 | - 'required' => $field->required, |
|
1022 | - 'field_key' => $field->field_key, |
|
1023 | - 'field_order' => $field->field_order, |
|
1024 | - 'form_id' => $field->form_id, |
|
1007 | + } |
|
1008 | + } |
|
1009 | + |
|
1010 | + $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type; |
|
1011 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1012 | + |
|
1013 | + $field_array = array( |
|
1014 | + 'id' => $field->id, |
|
1015 | + 'value' => $new_value, |
|
1016 | + 'default_value' => $field->default_value, |
|
1017 | + 'name' => $field->name, |
|
1018 | + 'description' => $field->description, |
|
1019 | + 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1020 | + 'options' => $field->options, |
|
1021 | + 'required' => $field->required, |
|
1022 | + 'field_key' => $field->field_key, |
|
1023 | + 'field_order' => $field->field_order, |
|
1024 | + 'form_id' => $field->form_id, |
|
1025 | 1025 | 'parent_form_id' => $args['parent_form_id'], |
1026 | - ); |
|
1026 | + ); |
|
1027 | 1027 | |
1028 | - $args['field_type'] = $field_type; |
|
1029 | - self::fill_field_opts($field, $field_array, $args); |
|
1028 | + $args['field_type'] = $field_type; |
|
1029 | + self::fill_field_opts($field, $field_array, $args); |
|
1030 | 1030 | |
1031 | - $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); |
|
1031 | + $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); |
|
1032 | 1032 | |
1033 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1034 | - $field_array['unique_msg'] = ''; |
|
1035 | - } |
|
1033 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1034 | + $field_array['unique_msg'] = ''; |
|
1035 | + } |
|
1036 | 1036 | |
1037 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
1037 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
1038 | 1038 | |
1039 | - $values['fields'][ $field->id ] = $field_array; |
|
1040 | - } |
|
1039 | + $values['fields'][ $field->id ] = $field_array; |
|
1040 | + } |
|
1041 | 1041 | |
1042 | 1042 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1043 | - $post_values = $args['post_values']; |
|
1044 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1045 | - |
|
1046 | - foreach ( $opt_defaults as $opt => $default_opt ) { |
|
1047 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt .'_'. $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt .'_'. $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
1048 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1049 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1050 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1051 | - if ( $args['field_type'] == 'captcha' ) { |
|
1052 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1053 | - } else { |
|
1054 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1055 | - } |
|
1056 | - } |
|
1057 | - } |
|
1058 | - |
|
1059 | - if ( $field_array['custom_html'] == '' ) { |
|
1060 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1061 | - } |
|
1062 | - } |
|
1063 | - |
|
1064 | - /** |
|
1065 | - * @param string $table |
|
1066 | - */ |
|
1043 | + $post_values = $args['post_values']; |
|
1044 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1045 | + |
|
1046 | + foreach ( $opt_defaults as $opt => $default_opt ) { |
|
1047 | + $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt .'_'. $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt .'_'. $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
1048 | + if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1049 | + $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1050 | + } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1051 | + if ( $args['field_type'] == 'captcha' ) { |
|
1052 | + $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1053 | + } else { |
|
1054 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1055 | + } |
|
1056 | + } |
|
1057 | + } |
|
1058 | + |
|
1059 | + if ( $field_array['custom_html'] == '' ) { |
|
1060 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1061 | + } |
|
1062 | + } |
|
1063 | + |
|
1064 | + /** |
|
1065 | + * @param string $table |
|
1066 | + */ |
|
1067 | 1067 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
1068 | - if ( $table == 'entries' ) { |
|
1069 | - $form = $record->form_id; |
|
1068 | + if ( $table == 'entries' ) { |
|
1069 | + $form = $record->form_id; |
|
1070 | 1070 | FrmForm::maybe_get_form( $form ); |
1071 | - } else { |
|
1072 | - $form = $record; |
|
1073 | - } |
|
1071 | + } else { |
|
1072 | + $form = $record; |
|
1073 | + } |
|
1074 | 1074 | |
1075 | - if ( ! $form ) { |
|
1076 | - return; |
|
1077 | - } |
|
1075 | + if ( ! $form ) { |
|
1076 | + return; |
|
1077 | + } |
|
1078 | 1078 | |
1079 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1079 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1080 | 1080 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1081 | 1081 | |
1082 | - if ( ! is_array($form->options) ) { |
|
1083 | - return; |
|
1084 | - } |
|
1082 | + if ( ! is_array($form->options) ) { |
|
1083 | + return; |
|
1084 | + } |
|
1085 | 1085 | |
1086 | - foreach ( $form->options as $opt => $value ) { |
|
1087 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1088 | - } |
|
1086 | + foreach ( $form->options as $opt => $value ) { |
|
1087 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1088 | + } |
|
1089 | 1089 | |
1090 | - self::fill_form_defaults($post_values, $values); |
|
1091 | - } |
|
1090 | + self::fill_form_defaults($post_values, $values); |
|
1091 | + } |
|
1092 | 1092 | |
1093 | - /** |
|
1094 | - * Set to POST value or default |
|
1095 | - */ |
|
1093 | + /** |
|
1094 | + * Set to POST value or default |
|
1095 | + */ |
|
1096 | 1096 | private static function fill_form_defaults( $post_values, array &$values ) { |
1097 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
1097 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
1098 | 1098 | |
1099 | - foreach ( $form_defaults as $opt => $default ) { |
|
1100 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1099 | + foreach ( $form_defaults as $opt => $default ) { |
|
1100 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1101 | 1101 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
1102 | - } |
|
1102 | + } |
|
1103 | 1103 | |
1104 | - unset($opt, $defaut); |
|
1105 | - } |
|
1104 | + unset($opt, $defaut); |
|
1105 | + } |
|
1106 | 1106 | |
1107 | - if ( ! isset($values['custom_style']) ) { |
|
1108 | - $frm_settings = self::get_settings(); |
|
1107 | + if ( ! isset($values['custom_style']) ) { |
|
1108 | + $frm_settings = self::get_settings(); |
|
1109 | 1109 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
1110 | - } |
|
1110 | + } |
|
1111 | 1111 | |
1112 | 1112 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1113 | - if ( ! isset( $values[ $h .'_html' ] ) ) { |
|
1114 | - $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1115 | - } |
|
1116 | - unset($h); |
|
1117 | - } |
|
1118 | - } |
|
1113 | + if ( ! isset( $values[ $h .'_html' ] ) ) { |
|
1114 | + $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1115 | + } |
|
1116 | + unset($h); |
|
1117 | + } |
|
1118 | + } |
|
1119 | 1119 | |
1120 | 1120 | public static function get_meta_value( $field_id, $entry ) { |
1121 | 1121 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' ); |
@@ -1123,69 +1123,69 @@ discard block |
||
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | public static function insert_opt_html( $args ) { |
1126 | - $class = ''; |
|
1127 | - if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
1128 | - $class .= 'show_frm_not_email_to'; |
|
1129 | - } |
|
1130 | - ?> |
|
1126 | + $class = ''; |
|
1127 | + if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
1128 | + $class .= 'show_frm_not_email_to'; |
|
1129 | + } |
|
1130 | + ?> |
|
1131 | 1131 | <li> |
1132 | 1132 | <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
1133 | 1133 | <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
1134 | 1134 | <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
1135 | 1135 | </li> |
1136 | 1136 | <?php |
1137 | - } |
|
1137 | + } |
|
1138 | 1138 | |
1139 | - public static function get_us_states() { |
|
1140 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' ); |
|
1141 | - return FrmFieldsHelper::get_us_states(); |
|
1142 | - } |
|
1139 | + public static function get_us_states() { |
|
1140 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' ); |
|
1141 | + return FrmFieldsHelper::get_us_states(); |
|
1142 | + } |
|
1143 | 1143 | |
1144 | - public static function get_countries() { |
|
1145 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' ); |
|
1146 | - return FrmFieldsHelper::get_countries(); |
|
1147 | - } |
|
1144 | + public static function get_countries() { |
|
1145 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' ); |
|
1146 | + return FrmFieldsHelper::get_countries(); |
|
1147 | + } |
|
1148 | 1148 | |
1149 | 1149 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
1150 | - if ( is_array( $str ) ) { |
|
1151 | - return; |
|
1150 | + if ( is_array( $str ) ) { |
|
1151 | + return; |
|
1152 | 1152 | } |
1153 | 1153 | |
1154 | - $length = (int) $length; |
|
1154 | + $length = (int) $length; |
|
1155 | 1155 | $str = wp_strip_all_tags( $str ); |
1156 | 1156 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
1157 | 1157 | |
1158 | 1158 | if ( $length == 0 ) { |
1159 | - return ''; |
|
1160 | - } else if ( $length <= 10 ) { |
|
1159 | + return ''; |
|
1160 | + } else if ( $length <= 10 ) { |
|
1161 | 1161 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
1162 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
1163 | - } |
|
1162 | + return $sub . (($length < $original_len) ? $continue : ''); |
|
1163 | + } |
|
1164 | 1164 | |
1165 | - $sub = ''; |
|
1166 | - $len = 0; |
|
1165 | + $sub = ''; |
|
1166 | + $len = 0; |
|
1167 | 1167 | |
1168 | 1168 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
1169 | 1169 | |
1170 | 1170 | foreach ( $words as $word ) { |
1171 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
1171 | + $part = (($sub != '') ? ' ' : '') . $word; |
|
1172 | 1172 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
1173 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
1174 | - break; |
|
1175 | - } |
|
1173 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
1174 | + break; |
|
1175 | + } |
|
1176 | 1176 | |
1177 | - $sub .= $part; |
|
1177 | + $sub .= $part; |
|
1178 | 1178 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
1179 | 1179 | |
1180 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1181 | - break; |
|
1182 | - } |
|
1180 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1181 | + break; |
|
1182 | + } |
|
1183 | 1183 | |
1184 | - unset($total_len, $word); |
|
1185 | - } |
|
1184 | + unset($total_len, $word); |
|
1185 | + } |
|
1186 | 1186 | |
1187 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1188 | - } |
|
1187 | + return $sub . (($len < $original_len) ? $continue : ''); |
|
1188 | + } |
|
1189 | 1189 | |
1190 | 1190 | public static function mb_function( $function_names, $args ) { |
1191 | 1191 | $mb_function_name = $function_names[0]; |
@@ -1197,18 +1197,18 @@ discard block |
||
1197 | 1197 | } |
1198 | 1198 | |
1199 | 1199 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1200 | - if ( empty($date) ) { |
|
1201 | - return $date; |
|
1202 | - } |
|
1200 | + if ( empty($date) ) { |
|
1201 | + return $date; |
|
1202 | + } |
|
1203 | 1203 | |
1204 | - if ( empty($date_format) ) { |
|
1205 | - $date_format = get_option('date_format'); |
|
1206 | - } |
|
1204 | + if ( empty($date_format) ) { |
|
1205 | + $date_format = get_option('date_format'); |
|
1206 | + } |
|
1207 | 1207 | |
1208 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1209 | - $frmpro_settings = new FrmProSettings(); |
|
1210 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1211 | - } |
|
1208 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1209 | + $frmpro_settings = new FrmProSettings(); |
|
1210 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1211 | + } |
|
1212 | 1212 | |
1213 | 1213 | $formatted = self::get_localized_date( $date_format, $date ); |
1214 | 1214 | |
@@ -1217,8 +1217,8 @@ discard block |
||
1217 | 1217 | $formatted .= self::add_time_to_date( $time_format, $date ); |
1218 | 1218 | } |
1219 | 1219 | |
1220 | - return $formatted; |
|
1221 | - } |
|
1220 | + return $formatted; |
|
1221 | + } |
|
1222 | 1222 | |
1223 | 1223 | private static function add_time_to_date( $time_format, $date ) { |
1224 | 1224 | if ( empty( $time_format ) ) { |
@@ -1299,61 +1299,61 @@ discard block |
||
1299 | 1299 | ); |
1300 | 1300 | } |
1301 | 1301 | |
1302 | - /** |
|
1303 | - * Added for < WP 4.0 compatability |
|
1304 | - * |
|
1305 | - * @since 1.07.10 |
|
1306 | - * |
|
1307 | - * @param string $term The value to escape |
|
1308 | - * @return string The escaped value |
|
1309 | - */ |
|
1302 | + /** |
|
1303 | + * Added for < WP 4.0 compatability |
|
1304 | + * |
|
1305 | + * @since 1.07.10 |
|
1306 | + * |
|
1307 | + * @param string $term The value to escape |
|
1308 | + * @return string The escaped value |
|
1309 | + */ |
|
1310 | 1310 | public static function esc_like( $term ) { |
1311 | - global $wpdb; |
|
1312 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1311 | + global $wpdb; |
|
1312 | + if ( method_exists($wpdb, 'esc_like') ) { |
|
1313 | 1313 | // WP 4.0 |
1314 | - $term = $wpdb->esc_like( $term ); |
|
1315 | - } else { |
|
1316 | - $term = like_escape( $term ); |
|
1317 | - } |
|
1314 | + $term = $wpdb->esc_like( $term ); |
|
1315 | + } else { |
|
1316 | + $term = like_escape( $term ); |
|
1317 | + } |
|
1318 | 1318 | |
1319 | - return $term; |
|
1320 | - } |
|
1319 | + return $term; |
|
1320 | + } |
|
1321 | 1321 | |
1322 | - /** |
|
1323 | - * @param string $order_query |
|
1324 | - */ |
|
1322 | + /** |
|
1323 | + * @param string $order_query |
|
1324 | + */ |
|
1325 | 1325 | public static function esc_order( $order_query ) { |
1326 | - if ( empty($order_query) ) { |
|
1327 | - return ''; |
|
1328 | - } |
|
1329 | - |
|
1330 | - // remove ORDER BY before santizing |
|
1331 | - $order_query = strtolower($order_query); |
|
1332 | - if ( strpos($order_query, 'order by') !== false ) { |
|
1333 | - $order_query = str_replace('order by', '', $order_query); |
|
1334 | - } |
|
1335 | - |
|
1336 | - $order_query = explode(' ', trim($order_query)); |
|
1337 | - |
|
1338 | - $order_fields = array( |
|
1339 | - 'id', 'form_key', 'name', 'description', |
|
1340 | - 'parent_form_id', 'logged_in', 'is_template', |
|
1341 | - 'default_template', 'status', 'created_at', |
|
1342 | - ); |
|
1343 | - |
|
1344 | - $order = trim(trim(reset($order_query), ',')); |
|
1345 | - if ( ! in_array($order, $order_fields) ) { |
|
1346 | - return ''; |
|
1347 | - } |
|
1348 | - |
|
1349 | - $order_by = ''; |
|
1350 | - if ( count($order_query) > 1 ) { |
|
1326 | + if ( empty($order_query) ) { |
|
1327 | + return ''; |
|
1328 | + } |
|
1329 | + |
|
1330 | + // remove ORDER BY before santizing |
|
1331 | + $order_query = strtolower($order_query); |
|
1332 | + if ( strpos($order_query, 'order by') !== false ) { |
|
1333 | + $order_query = str_replace('order by', '', $order_query); |
|
1334 | + } |
|
1335 | + |
|
1336 | + $order_query = explode(' ', trim($order_query)); |
|
1337 | + |
|
1338 | + $order_fields = array( |
|
1339 | + 'id', 'form_key', 'name', 'description', |
|
1340 | + 'parent_form_id', 'logged_in', 'is_template', |
|
1341 | + 'default_template', 'status', 'created_at', |
|
1342 | + ); |
|
1343 | + |
|
1344 | + $order = trim(trim(reset($order_query), ',')); |
|
1345 | + if ( ! in_array($order, $order_fields) ) { |
|
1346 | + return ''; |
|
1347 | + } |
|
1348 | + |
|
1349 | + $order_by = ''; |
|
1350 | + if ( count($order_query) > 1 ) { |
|
1351 | 1351 | $order_by = end( $order_query ); |
1352 | 1352 | self::esc_order_by( $order_by ); |
1353 | - } |
|
1353 | + } |
|
1354 | 1354 | |
1355 | - return ' ORDER BY '. $order . ' '. $order_by; |
|
1356 | - } |
|
1355 | + return ' ORDER BY '. $order . ' '. $order_by; |
|
1356 | + } |
|
1357 | 1357 | |
1358 | 1358 | /** |
1359 | 1359 | * Make sure this is ordering by either ASC or DESC |
@@ -1365,183 +1365,183 @@ discard block |
||
1365 | 1365 | } |
1366 | 1366 | } |
1367 | 1367 | |
1368 | - /** |
|
1369 | - * @param string $limit |
|
1370 | - */ |
|
1368 | + /** |
|
1369 | + * @param string $limit |
|
1370 | + */ |
|
1371 | 1371 | public static function esc_limit( $limit ) { |
1372 | - if ( empty($limit) ) { |
|
1373 | - return ''; |
|
1374 | - } |
|
1375 | - |
|
1376 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1377 | - if ( is_numeric($limit) ) { |
|
1378 | - return ' LIMIT '. $limit; |
|
1379 | - } |
|
1380 | - |
|
1381 | - $limit = explode(',', trim($limit)); |
|
1382 | - foreach ( $limit as $k => $l ) { |
|
1383 | - if ( is_numeric( $l ) ) { |
|
1384 | - $limit[ $k ] = $l; |
|
1385 | - } |
|
1386 | - } |
|
1387 | - |
|
1388 | - $limit = implode(',', $limit); |
|
1389 | - return ' LIMIT '. $limit; |
|
1390 | - } |
|
1391 | - |
|
1392 | - /** |
|
1393 | - * Get an array of values ready to go through $wpdb->prepare |
|
1394 | - * @since 2.0 |
|
1395 | - */ |
|
1396 | - public static function prepare_array_values( $array, $type = '%s' ) { |
|
1397 | - $placeholders = array_fill(0, count($array), $type); |
|
1398 | - return implode(', ', $placeholders); |
|
1399 | - } |
|
1400 | - |
|
1401 | - public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
1402 | - if ( empty($where) ) { |
|
1403 | - return ''; |
|
1404 | - } |
|
1372 | + if ( empty($limit) ) { |
|
1373 | + return ''; |
|
1374 | + } |
|
1375 | + |
|
1376 | + $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1377 | + if ( is_numeric($limit) ) { |
|
1378 | + return ' LIMIT '. $limit; |
|
1379 | + } |
|
1380 | + |
|
1381 | + $limit = explode(',', trim($limit)); |
|
1382 | + foreach ( $limit as $k => $l ) { |
|
1383 | + if ( is_numeric( $l ) ) { |
|
1384 | + $limit[ $k ] = $l; |
|
1385 | + } |
|
1386 | + } |
|
1387 | + |
|
1388 | + $limit = implode(',', $limit); |
|
1389 | + return ' LIMIT '. $limit; |
|
1390 | + } |
|
1391 | + |
|
1392 | + /** |
|
1393 | + * Get an array of values ready to go through $wpdb->prepare |
|
1394 | + * @since 2.0 |
|
1395 | + */ |
|
1396 | + public static function prepare_array_values( $array, $type = '%s' ) { |
|
1397 | + $placeholders = array_fill(0, count($array), $type); |
|
1398 | + return implode(', ', $placeholders); |
|
1399 | + } |
|
1400 | + |
|
1401 | + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
1402 | + if ( empty($where) ) { |
|
1403 | + return ''; |
|
1404 | + } |
|
1405 | 1405 | |
1406 | 1406 | if ( is_array( $where ) ) { |
1407 | - global $wpdb; |
|
1408 | - FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
1407 | + global $wpdb; |
|
1408 | + FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
1409 | 1409 | $where = $wpdb->prepare( $where['where'], $where['values'] ); |
1410 | 1410 | } else { |
1411 | - $where = $starts_with . $where; |
|
1412 | - } |
|
1411 | + $where = $starts_with . $where; |
|
1412 | + } |
|
1413 | 1413 | |
1414 | - return $where; |
|
1415 | - } |
|
1414 | + return $where; |
|
1415 | + } |
|
1416 | 1416 | |
1417 | - // Pagination Methods |
|
1417 | + // Pagination Methods |
|
1418 | 1418 | |
1419 | - /** |
|
1420 | - * @param integer $current_p |
|
1421 | - */ |
|
1419 | + /** |
|
1420 | + * @param integer $current_p |
|
1421 | + */ |
|
1422 | 1422 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
1423 | 1423 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
1424 | 1424 | } |
1425 | 1425 | |
1426 | - /** |
|
1427 | - * @param integer $current_p |
|
1428 | - */ |
|
1429 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
1430 | - if ( $current_p == 1 ) { |
|
1431 | - return 1; |
|
1432 | - } else { |
|
1433 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
1434 | - } |
|
1435 | - } |
|
1436 | - |
|
1437 | - /** |
|
1438 | - * @param string $table_name |
|
1439 | - */ |
|
1440 | - public static function &getRecordCount( $where = '', $table_name ) { |
|
1441 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' ); |
|
1442 | - $count = FrmDb::get_count( $table_name, $where ); |
|
1443 | - return $count; |
|
1444 | - } |
|
1445 | - |
|
1446 | - public static function get_referer_info() { |
|
1447 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
|
1448 | - return self::get_server_value('HTTP_REFERER'); |
|
1449 | - } |
|
1426 | + /** |
|
1427 | + * @param integer $current_p |
|
1428 | + */ |
|
1429 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
1430 | + if ( $current_p == 1 ) { |
|
1431 | + return 1; |
|
1432 | + } else { |
|
1433 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
1434 | + } |
|
1435 | + } |
|
1436 | + |
|
1437 | + /** |
|
1438 | + * @param string $table_name |
|
1439 | + */ |
|
1440 | + public static function &getRecordCount( $where = '', $table_name ) { |
|
1441 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' ); |
|
1442 | + $count = FrmDb::get_count( $table_name, $where ); |
|
1443 | + return $count; |
|
1444 | + } |
|
1445 | + |
|
1446 | + public static function get_referer_info() { |
|
1447 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
|
1448 | + return self::get_server_value('HTTP_REFERER'); |
|
1449 | + } |
|
1450 | 1450 | |
1451 | 1451 | /** |
1452 | 1452 | * @return array |
1453 | 1453 | */ |
1454 | 1454 | public static function json_to_array( $json_vars ) { |
1455 | - $vars = array(); |
|
1456 | - foreach ( $json_vars as $jv ) { |
|
1457 | - $jv_name = explode('[', $jv['name']); |
|
1458 | - $last = count($jv_name) - 1; |
|
1459 | - foreach ( $jv_name as $p => $n ) { |
|
1460 | - $name = trim($n, ']'); |
|
1461 | - if ( ! isset($l1) ) { |
|
1462 | - $l1 = $name; |
|
1463 | - } |
|
1464 | - |
|
1465 | - if ( ! isset($l2) ) { |
|
1466 | - $l2 = $name; |
|
1467 | - } |
|
1468 | - |
|
1469 | - if ( ! isset($l3) ) { |
|
1470 | - $l3 = $name; |
|
1471 | - } |
|
1472 | - |
|
1473 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
1474 | - |
|
1475 | - switch ( $p ) { |
|
1476 | - case 0: |
|
1477 | - $l1 = $name; |
|
1478 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
1479 | - break; |
|
1480 | - |
|
1481 | - case 1: |
|
1482 | - $l2 = $name; |
|
1483 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1484 | - break; |
|
1485 | - |
|
1486 | - case 2: |
|
1487 | - $l3 = $name; |
|
1488 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1489 | - break; |
|
1490 | - |
|
1491 | - case 3: |
|
1492 | - $l4 = $name; |
|
1493 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1494 | - break; |
|
1495 | - } |
|
1496 | - |
|
1497 | - unset($this_val, $n); |
|
1498 | - } |
|
1499 | - |
|
1500 | - unset($last, $jv); |
|
1501 | - } |
|
1502 | - |
|
1503 | - return $vars; |
|
1504 | - } |
|
1505 | - |
|
1506 | - /** |
|
1507 | - * @param string $name |
|
1508 | - * @param string $l1 |
|
1509 | - */ |
|
1510 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
1511 | - if ( $name == '' ) { |
|
1512 | - $vars[] = $val; |
|
1513 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1514 | - $vars[ $l1 ] = $val; |
|
1515 | - } |
|
1516 | - } |
|
1455 | + $vars = array(); |
|
1456 | + foreach ( $json_vars as $jv ) { |
|
1457 | + $jv_name = explode('[', $jv['name']); |
|
1458 | + $last = count($jv_name) - 1; |
|
1459 | + foreach ( $jv_name as $p => $n ) { |
|
1460 | + $name = trim($n, ']'); |
|
1461 | + if ( ! isset($l1) ) { |
|
1462 | + $l1 = $name; |
|
1463 | + } |
|
1464 | + |
|
1465 | + if ( ! isset($l2) ) { |
|
1466 | + $l2 = $name; |
|
1467 | + } |
|
1468 | + |
|
1469 | + if ( ! isset($l3) ) { |
|
1470 | + $l3 = $name; |
|
1471 | + } |
|
1472 | + |
|
1473 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
1474 | + |
|
1475 | + switch ( $p ) { |
|
1476 | + case 0: |
|
1477 | + $l1 = $name; |
|
1478 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
1479 | + break; |
|
1480 | + |
|
1481 | + case 1: |
|
1482 | + $l2 = $name; |
|
1483 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1484 | + break; |
|
1485 | + |
|
1486 | + case 2: |
|
1487 | + $l3 = $name; |
|
1488 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1489 | + break; |
|
1490 | + |
|
1491 | + case 3: |
|
1492 | + $l4 = $name; |
|
1493 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1494 | + break; |
|
1495 | + } |
|
1496 | + |
|
1497 | + unset($this_val, $n); |
|
1498 | + } |
|
1499 | + |
|
1500 | + unset($last, $jv); |
|
1501 | + } |
|
1502 | + |
|
1503 | + return $vars; |
|
1504 | + } |
|
1505 | + |
|
1506 | + /** |
|
1507 | + * @param string $name |
|
1508 | + * @param string $l1 |
|
1509 | + */ |
|
1510 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
1511 | + if ( $name == '' ) { |
|
1512 | + $vars[] = $val; |
|
1513 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1514 | + $vars[ $l1 ] = $val; |
|
1515 | + } |
|
1516 | + } |
|
1517 | 1517 | |
1518 | 1518 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
1519 | - $tooltips = array( |
|
1520 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
1521 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
1522 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1523 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1524 | - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1525 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
1526 | - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
1527 | - ); |
|
1528 | - |
|
1529 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1530 | - return; |
|
1531 | - } |
|
1532 | - |
|
1533 | - if ( 'open' == $class ) { |
|
1534 | - echo ' frm_help"'; |
|
1535 | - } else { |
|
1536 | - echo ' class="frm_help"'; |
|
1537 | - } |
|
1538 | - |
|
1539 | - echo ' title="'. esc_attr( $tooltips[ $name ] ); |
|
1540 | - |
|
1541 | - if ( 'open' != $class ) { |
|
1542 | - echo '"'; |
|
1543 | - } |
|
1544 | - } |
|
1519 | + $tooltips = array( |
|
1520 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
1521 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
1522 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1523 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1524 | + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1525 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
1526 | + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
1527 | + ); |
|
1528 | + |
|
1529 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
1530 | + return; |
|
1531 | + } |
|
1532 | + |
|
1533 | + if ( 'open' == $class ) { |
|
1534 | + echo ' frm_help"'; |
|
1535 | + } else { |
|
1536 | + echo ' class="frm_help"'; |
|
1537 | + } |
|
1538 | + |
|
1539 | + echo ' title="'. esc_attr( $tooltips[ $name ] ); |
|
1540 | + |
|
1541 | + if ( 'open' != $class ) { |
|
1542 | + echo '"'; |
|
1543 | + } |
|
1544 | + } |
|
1545 | 1545 | |
1546 | 1546 | /** |
1547 | 1547 | * Add the current_page class to that page in the form nav |
@@ -1557,35 +1557,35 @@ discard block |
||
1557 | 1557 | } |
1558 | 1558 | } |
1559 | 1559 | |
1560 | - /** |
|
1561 | - * Prepare and json_encode post content |
|
1562 | - * |
|
1563 | - * @since 2.0 |
|
1564 | - * |
|
1565 | - * @param array $post_content |
|
1566 | - * @return string $post_content ( json encoded array ) |
|
1567 | - */ |
|
1568 | - public static function prepare_and_encode( $post_content ) { |
|
1569 | - //Loop through array to strip slashes and add only the needed ones |
|
1560 | + /** |
|
1561 | + * Prepare and json_encode post content |
|
1562 | + * |
|
1563 | + * @since 2.0 |
|
1564 | + * |
|
1565 | + * @param array $post_content |
|
1566 | + * @return string $post_content ( json encoded array ) |
|
1567 | + */ |
|
1568 | + public static function prepare_and_encode( $post_content ) { |
|
1569 | + //Loop through array to strip slashes and add only the needed ones |
|
1570 | 1570 | foreach ( $post_content as $key => $val ) { |
1571 | 1571 | // Replace problematic characters (like ") |
1572 | 1572 | $val = str_replace( '"', '"', $val ); |
1573 | 1573 | |
1574 | 1574 | self::prepare_action_slashes( $val, $key, $post_content ); |
1575 | - unset( $key, $val ); |
|
1576 | - } |
|
1575 | + unset( $key, $val ); |
|
1576 | + } |
|
1577 | 1577 | |
1578 | - // json_encode the array |
|
1579 | - $post_content = json_encode( $post_content ); |
|
1578 | + // json_encode the array |
|
1579 | + $post_content = json_encode( $post_content ); |
|
1580 | 1580 | |
1581 | - // add extra slashes for \r\n since WP strips them |
|
1581 | + // add extra slashes for \r\n since WP strips them |
|
1582 | 1582 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
1583 | 1583 | |
1584 | - // allow for " |
|
1585 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
1584 | + // allow for " |
|
1585 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
1586 | 1586 | |
1587 | - return $post_content; |
|
1588 | - } |
|
1587 | + return $post_content; |
|
1588 | + } |
|
1589 | 1589 | |
1590 | 1590 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1591 | 1591 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1653,64 +1653,64 @@ discard block |
||
1653 | 1653 | } |
1654 | 1654 | |
1655 | 1655 | public static function maybe_json_decode( $string ) { |
1656 | - if ( is_array($string) ) { |
|
1657 | - return $string; |
|
1658 | - } |
|
1656 | + if ( is_array($string) ) { |
|
1657 | + return $string; |
|
1658 | + } |
|
1659 | 1659 | |
1660 | - $new_string = json_decode($string, true); |
|
1661 | - if ( function_exists('json_last_error') ) { |
|
1660 | + $new_string = json_decode($string, true); |
|
1661 | + if ( function_exists('json_last_error') ) { |
|
1662 | 1662 | // php 5.3+ |
1663 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
1664 | - $string = $new_string; |
|
1665 | - } |
|
1666 | - } else if ( isset($new_string) ) { |
|
1663 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
1664 | + $string = $new_string; |
|
1665 | + } |
|
1666 | + } else if ( isset($new_string) ) { |
|
1667 | 1667 | // php < 5.3 fallback |
1668 | - $string = $new_string; |
|
1669 | - } |
|
1670 | - return $string; |
|
1671 | - } |
|
1672 | - |
|
1673 | - /** |
|
1674 | - * @since 1.07.10 |
|
1675 | - * |
|
1676 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
1677 | - * @return echo The javascript to open and highlight the Formidable menu |
|
1678 | - */ |
|
1668 | + $string = $new_string; |
|
1669 | + } |
|
1670 | + return $string; |
|
1671 | + } |
|
1672 | + |
|
1673 | + /** |
|
1674 | + * @since 1.07.10 |
|
1675 | + * |
|
1676 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
1677 | + * @return echo The javascript to open and highlight the Formidable menu |
|
1678 | + */ |
|
1679 | 1679 | public static function maybe_highlight_menu( $post_type ) { |
1680 | - global $post, $pagenow; |
|
1680 | + global $post, $pagenow; |
|
1681 | 1681 | |
1682 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1683 | - return; |
|
1684 | - } |
|
1682 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1683 | + return; |
|
1684 | + } |
|
1685 | 1685 | |
1686 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1687 | - return; |
|
1688 | - } |
|
1686 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
1687 | + return; |
|
1688 | + } |
|
1689 | 1689 | |
1690 | - self::load_admin_wide_js(); |
|
1691 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
1692 | - } |
|
1690 | + self::load_admin_wide_js(); |
|
1691 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
1692 | + } |
|
1693 | 1693 | |
1694 | - /** |
|
1695 | - * Load the JS file on non-Formidable pages in the admin area |
|
1696 | - * @since 2.0 |
|
1697 | - */ |
|
1694 | + /** |
|
1695 | + * Load the JS file on non-Formidable pages in the admin area |
|
1696 | + * @since 2.0 |
|
1697 | + */ |
|
1698 | 1698 | public static function load_admin_wide_js( $load = true ) { |
1699 | - $version = FrmAppHelper::plugin_version(); |
|
1699 | + $version = FrmAppHelper::plugin_version(); |
|
1700 | 1700 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
1701 | 1701 | |
1702 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
1702 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
1703 | 1703 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
1704 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
1704 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
1705 | 1705 | 'url' => FrmAppHelper::plugin_url(), |
1706 | 1706 | 'loading' => __( 'Loading…' ), |
1707 | 1707 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
1708 | - ) ); |
|
1708 | + ) ); |
|
1709 | 1709 | |
1710 | 1710 | if ( $load ) { |
1711 | 1711 | wp_enqueue_script( 'formidable_admin_global' ); |
1712 | 1712 | } |
1713 | - } |
|
1713 | + } |
|
1714 | 1714 | |
1715 | 1715 | /** |
1716 | 1716 | * @since 2.0.9 |
@@ -1719,9 +1719,9 @@ discard block |
||
1719 | 1719 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
1720 | 1720 | } |
1721 | 1721 | |
1722 | - /** |
|
1723 | - * @param string $location |
|
1724 | - */ |
|
1722 | + /** |
|
1723 | + * @param string $location |
|
1724 | + */ |
|
1725 | 1725 | public static function localize_script( $location ) { |
1726 | 1726 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
1727 | 1727 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1771,81 +1771,81 @@ discard block |
||
1771 | 1771 | } |
1772 | 1772 | } |
1773 | 1773 | |
1774 | - /** |
|
1775 | - * @since 1.07.10 |
|
1776 | - * |
|
1777 | - * @param float $min_version The version the add-on requires |
|
1778 | - * @return echo The message on the plugins listing page |
|
1779 | - */ |
|
1774 | + /** |
|
1775 | + * @since 1.07.10 |
|
1776 | + * |
|
1777 | + * @param float $min_version The version the add-on requires |
|
1778 | + * @return echo The message on the plugins listing page |
|
1779 | + */ |
|
1780 | 1780 | public static function min_version_notice( $min_version ) { |
1781 | - $frm_version = self::plugin_version(); |
|
1781 | + $frm_version = self::plugin_version(); |
|
1782 | 1782 | |
1783 | - // check if Formidable meets minimum requirements |
|
1784 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1785 | - return; |
|
1786 | - } |
|
1783 | + // check if Formidable meets minimum requirements |
|
1784 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1785 | + return; |
|
1786 | + } |
|
1787 | 1787 | |
1788 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1788 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1789 | 1789 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
1790 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
1791 | - '</div></td></tr>'; |
|
1792 | - } |
|
1793 | - |
|
1794 | - public static function locales( $type = 'date' ) { |
|
1795 | - $locales = array( |
|
1796 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1797 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1798 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1799 | - 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
1800 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1801 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1802 | - 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
1803 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1804 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1805 | - 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
1806 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1807 | - 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
1808 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1809 | - 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
1810 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1811 | - 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
1812 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1813 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1814 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1815 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1816 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1817 | - 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
1818 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1819 | - 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
1820 | - 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
1821 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1822 | - 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
1823 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1824 | - 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
1825 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1826 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1827 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1828 | - ); |
|
1829 | - |
|
1830 | - if ( $type == 'captcha' ) { |
|
1831 | - // remove the languages unavailable for the captcha |
|
1832 | - $unset = array( |
|
1833 | - '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
1834 | - 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
1835 | - 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
1836 | - ); |
|
1837 | - } else { |
|
1838 | - // remove the languages unavailable for the datepicker |
|
1839 | - $unset = array( |
|
1840 | - 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
1841 | - 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
1842 | - 'es-419', 'tr', |
|
1843 | - ); |
|
1844 | - } |
|
1845 | - |
|
1846 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1847 | - $locales = apply_filters('frm_locales', $locales); |
|
1848 | - |
|
1849 | - return $locales; |
|
1850 | - } |
|
1790 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
1791 | + '</div></td></tr>'; |
|
1792 | + } |
|
1793 | + |
|
1794 | + public static function locales( $type = 'date' ) { |
|
1795 | + $locales = array( |
|
1796 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1797 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1798 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1799 | + 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
1800 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1801 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1802 | + 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
1803 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1804 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1805 | + 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
1806 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1807 | + 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
1808 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1809 | + 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
1810 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1811 | + 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
1812 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1813 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1814 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1815 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1816 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1817 | + 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
1818 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1819 | + 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
1820 | + 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
1821 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1822 | + 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
1823 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1824 | + 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
1825 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1826 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1827 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1828 | + ); |
|
1829 | + |
|
1830 | + if ( $type == 'captcha' ) { |
|
1831 | + // remove the languages unavailable for the captcha |
|
1832 | + $unset = array( |
|
1833 | + '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
1834 | + 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
1835 | + 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
1836 | + ); |
|
1837 | + } else { |
|
1838 | + // remove the languages unavailable for the datepicker |
|
1839 | + $unset = array( |
|
1840 | + 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
1841 | + 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
1842 | + 'es-419', 'tr', |
|
1843 | + ); |
|
1844 | + } |
|
1845 | + |
|
1846 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
1847 | + $locales = apply_filters('frm_locales', $locales); |
|
1848 | + |
|
1849 | + return $locales; |
|
1850 | + } |
|
1851 | 1851 | } |
@@ -61,6 +61,9 @@ discard block |
||
61 | 61 | return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); |
62 | 62 | } |
63 | 63 | |
64 | + /** |
|
65 | + * @param integer $entry_id |
|
66 | + */ |
|
64 | 67 | public static function update_entry_metas( $entry_id, $values ) { |
65 | 68 | global $wpdb; |
66 | 69 | |
@@ -286,6 +289,7 @@ discard block |
||
286 | 289 | * @param string|array $where |
287 | 290 | * @param string $order_by |
288 | 291 | * @param string $limit |
292 | + * @param boolean $unique |
|
289 | 293 | */ |
290 | 294 | private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) { |
291 | 295 | global $wpdb; |
@@ -5,27 +5,27 @@ discard block |
||
5 | 5 | |
6 | 6 | class FrmEntryMeta { |
7 | 7 | |
8 | - /** |
|
9 | - * @param string $meta_key |
|
10 | - */ |
|
8 | + /** |
|
9 | + * @param string $meta_key |
|
10 | + */ |
|
11 | 11 | public static function add_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) { |
12 | - global $wpdb; |
|
12 | + global $wpdb; |
|
13 | 13 | |
14 | - if ( FrmAppHelper::is_empty_value( $meta_value ) ) { |
|
15 | - // don't save blank fields |
|
16 | - return; |
|
17 | - } |
|
14 | + if ( FrmAppHelper::is_empty_value( $meta_value ) ) { |
|
15 | + // don't save blank fields |
|
16 | + return; |
|
17 | + } |
|
18 | 18 | |
19 | - $new_values = array( |
|
19 | + $new_values = array( |
|
20 | 20 | 'meta_value' => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ), |
21 | - 'item_id' => $entry_id, |
|
22 | - 'field_id' => $field_id, |
|
23 | - 'created_at' => current_time('mysql', 1), |
|
24 | - ); |
|
21 | + 'item_id' => $entry_id, |
|
22 | + 'field_id' => $field_id, |
|
23 | + 'created_at' => current_time('mysql', 1), |
|
24 | + ); |
|
25 | 25 | |
26 | - $new_values = apply_filters('frm_add_entry_meta', $new_values); |
|
26 | + $new_values = apply_filters('frm_add_entry_meta', $new_values); |
|
27 | 27 | |
28 | - $query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values ); |
|
28 | + $query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values ); |
|
29 | 29 | |
30 | 30 | if ( $query_results ) { |
31 | 31 | self::clear_cache(); |
@@ -34,40 +34,40 @@ discard block |
||
34 | 34 | $id = 0; |
35 | 35 | } |
36 | 36 | |
37 | - return $id; |
|
38 | - } |
|
37 | + return $id; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param string $meta_key |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @param string $meta_key |
|
42 | + */ |
|
43 | 43 | public static function update_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) { |
44 | - if ( ! $field_id ) { |
|
45 | - return false; |
|
46 | - } |
|
44 | + if ( ! $field_id ) { |
|
45 | + return false; |
|
46 | + } |
|
47 | 47 | |
48 | - global $wpdb; |
|
48 | + global $wpdb; |
|
49 | 49 | |
50 | - $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id ); |
|
51 | - $values['meta_value'] = $meta_value; |
|
52 | - $values = apply_filters('frm_update_entry_meta', $values); |
|
50 | + $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id ); |
|
51 | + $values['meta_value'] = $meta_value; |
|
52 | + $values = apply_filters('frm_update_entry_meta', $values); |
|
53 | 53 | if ( is_array($values['meta_value']) ) { |
54 | 54 | $values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' ); |
55 | 55 | } |
56 | - $meta_value = maybe_serialize($values['meta_value']); |
|
56 | + $meta_value = maybe_serialize($values['meta_value']); |
|
57 | 57 | |
58 | - wp_cache_delete( $entry_id, 'frm_entry'); |
|
58 | + wp_cache_delete( $entry_id, 'frm_entry'); |
|
59 | 59 | self::clear_cache(); |
60 | 60 | |
61 | - return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); |
|
62 | - } |
|
61 | + return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | public static function update_entry_metas( $entry_id, $values ) { |
65 | - global $wpdb; |
|
65 | + global $wpdb; |
|
66 | 66 | |
67 | 67 | $prev_values = FrmDb::get_col( $wpdb->prefix .'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' ); |
68 | 68 | |
69 | - foreach ( $values as $field_id => $meta_value ) { |
|
70 | - // set the value for the file upload field and add new tags (in Pro version) |
|
69 | + foreach ( $values as $field_id => $meta_value ) { |
|
70 | + // set the value for the file upload field and add new tags (in Pro version) |
|
71 | 71 | $meta_value = apply_filters( 'frm_prepare_data_before_db', $meta_value, $field_id, $entry_id ); |
72 | 72 | |
73 | 73 | if ( $prev_values && in_array($field_id, $prev_values) ) { |
@@ -85,39 +85,39 @@ discard block |
||
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - if ( empty($prev_values) ) { |
|
89 | - return; |
|
90 | - } |
|
88 | + if ( empty($prev_values) ) { |
|
89 | + return; |
|
90 | + } |
|
91 | 91 | |
92 | - $prev_values = array_diff($prev_values, array_keys($values)); |
|
92 | + $prev_values = array_diff($prev_values, array_keys($values)); |
|
93 | 93 | |
94 | - if ( empty($prev_values) ) { |
|
95 | - return; |
|
96 | - } |
|
94 | + if ( empty($prev_values) ) { |
|
95 | + return; |
|
96 | + } |
|
97 | 97 | |
98 | 98 | // prepare the query |
99 | 99 | $where = array( 'item_id' => $entry_id, 'field_id' => $prev_values ); |
100 | 100 | FrmDb::get_where_clause_and_values( $where ); |
101 | 101 | |
102 | - // Delete any leftovers |
|
103 | - $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) ); |
|
102 | + // Delete any leftovers |
|
103 | + $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) ); |
|
104 | 104 | self::clear_cache(); |
105 | - } |
|
105 | + } |
|
106 | 106 | |
107 | 107 | public static function duplicate_entry_metas( $old_id, $new_id ) { |
108 | - $metas = self::get_entry_meta_info($old_id); |
|
109 | - foreach ( $metas as $meta ) { |
|
110 | - self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value); |
|
111 | - unset($meta); |
|
112 | - } |
|
108 | + $metas = self::get_entry_meta_info($old_id); |
|
109 | + foreach ( $metas as $meta ) { |
|
110 | + self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value); |
|
111 | + unset($meta); |
|
112 | + } |
|
113 | 113 | self::clear_cache(); |
114 | - } |
|
114 | + } |
|
115 | 115 | |
116 | 116 | public static function delete_entry_meta( $entry_id, $field_id ) { |
117 | - global $wpdb; |
|
117 | + global $wpdb; |
|
118 | 118 | self::clear_cache(); |
119 | - return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id)); |
|
120 | - } |
|
119 | + return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id)); |
|
120 | + } |
|
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Clear entry meta caching |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | public static function get_entry_meta_by_field( $entry_id, $field_id ) { |
145 | - global $wpdb; |
|
145 | + global $wpdb; |
|
146 | 146 | |
147 | 147 | if ( is_object( $entry_id ) ) { |
148 | 148 | $entry = $entry_id; |
@@ -155,24 +155,24 @@ discard block |
||
155 | 155 | |
156 | 156 | if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) { |
157 | 157 | $result = $cached->metas[ $field_id ]; |
158 | - return stripslashes_deep($result); |
|
159 | - } |
|
158 | + return stripslashes_deep($result); |
|
159 | + } |
|
160 | 160 | |
161 | 161 | $get_table = $wpdb->prefix .'frm_item_metas'; |
162 | 162 | $query = array( 'item_id' => $entry_id ); |
163 | - if ( is_numeric($field_id) ) { |
|
163 | + if ( is_numeric($field_id) ) { |
|
164 | 164 | $query['field_id'] = $field_id; |
165 | - } else { |
|
165 | + } else { |
|
166 | 166 | $get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; |
167 | 167 | $query['fi.field_key'] = $field_id; |
168 | - } |
|
168 | + } |
|
169 | 169 | |
170 | 170 | $result = FrmDb::get_var( $get_table, $query, 'meta_value' ); |
171 | - $result = maybe_unserialize($result); |
|
172 | - $result = stripslashes_deep($result); |
|
171 | + $result = maybe_unserialize($result); |
|
172 | + $result = stripslashes_deep($result); |
|
173 | 173 | |
174 | - return $result; |
|
175 | - } |
|
174 | + return $result; |
|
175 | + } |
|
176 | 176 | |
177 | 177 | public static function get_entry_meta( $entry_id, $field_id ) { |
178 | 178 | _deprecated_function( __FUNCTION__, '2.0', 'FrmEntryMeta::get_entry_meta_by_field' ); |
@@ -180,117 +180,117 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | public static function get_entry_metas( $entry_id ) { |
183 | - _deprecated_function( __FUNCTION__, '1.07.10'); |
|
183 | + _deprecated_function( __FUNCTION__, '1.07.10'); |
|
184 | 184 | |
185 | - global $wpdb; |
|
185 | + global $wpdb; |
|
186 | 186 | return FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id ), 'meta_value' ); |
187 | - } |
|
187 | + } |
|
188 | 188 | |
189 | - public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) { |
|
189 | + public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) { |
|
190 | 190 | $defaults = array( 'value' => false, 'unique' => false, 'stripslashes' => true, 'is_draft' => false ); |
191 | - $args = wp_parse_args( $args, $defaults ); |
|
191 | + $args = wp_parse_args( $args, $defaults ); |
|
192 | 192 | |
193 | - $query = array(); |
|
194 | - self::meta_field_query($field_id, $order, $limit, $args, $query); |
|
195 | - $query = implode(' ', $query); |
|
193 | + $query = array(); |
|
194 | + self::meta_field_query($field_id, $order, $limit, $args, $query); |
|
195 | + $query = implode(' ', $query); |
|
196 | 196 | |
197 | - $cache_key = 'entry_metas_for_field_'. $field_id . $order . $limit . maybe_serialize($args); |
|
198 | - $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col'); |
|
197 | + $cache_key = 'entry_metas_for_field_'. $field_id . $order . $limit . maybe_serialize($args); |
|
198 | + $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col'); |
|
199 | 199 | |
200 | - if ( ! $args['stripslashes'] ) { |
|
201 | - return $values; |
|
202 | - } |
|
200 | + if ( ! $args['stripslashes'] ) { |
|
201 | + return $values; |
|
202 | + } |
|
203 | 203 | |
204 | 204 | foreach ( $values as $k => $v ) { |
205 | 205 | $values[ $k ] = maybe_unserialize( $v ); |
206 | - unset($k, $v); |
|
207 | - } |
|
206 | + unset($k, $v); |
|
207 | + } |
|
208 | 208 | |
209 | - return stripslashes_deep($values); |
|
210 | - } |
|
209 | + return stripslashes_deep($values); |
|
210 | + } |
|
211 | 211 | |
212 | - /** |
|
213 | - * @param string $order |
|
214 | - * @param string $limit |
|
215 | - */ |
|
212 | + /** |
|
213 | + * @param string $order |
|
214 | + * @param string $limit |
|
215 | + */ |
|
216 | 216 | private static function meta_field_query( $field_id, $order, $limit, $args, array &$query ) { |
217 | - global $wpdb; |
|
218 | - $query[] = 'SELECT'; |
|
219 | - $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value'; |
|
220 | - $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em '; |
|
221 | - |
|
222 | - if ( ! $args['is_draft'] ) { |
|
223 | - $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)'; |
|
224 | - } |
|
225 | - |
|
226 | - if ( is_numeric($field_id) ) { |
|
227 | - $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); |
|
228 | - } else { |
|
229 | - $query[] = $wpdb->prepare('LEFT JOIN '. $wpdb->prefix .'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id); |
|
230 | - } |
|
231 | - |
|
232 | - if ( ! $args['is_draft'] ) { |
|
233 | - $query[] = 'AND e.is_draft=0'; |
|
234 | - } |
|
235 | - |
|
236 | - if ( $args['value'] ) { |
|
237 | - $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']); |
|
238 | - } |
|
239 | - $query[] = $order . $limit; |
|
240 | - } |
|
217 | + global $wpdb; |
|
218 | + $query[] = 'SELECT'; |
|
219 | + $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value'; |
|
220 | + $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em '; |
|
221 | + |
|
222 | + if ( ! $args['is_draft'] ) { |
|
223 | + $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)'; |
|
224 | + } |
|
225 | + |
|
226 | + if ( is_numeric($field_id) ) { |
|
227 | + $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); |
|
228 | + } else { |
|
229 | + $query[] = $wpdb->prepare('LEFT JOIN '. $wpdb->prefix .'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id); |
|
230 | + } |
|
231 | + |
|
232 | + if ( ! $args['is_draft'] ) { |
|
233 | + $query[] = 'AND e.is_draft=0'; |
|
234 | + } |
|
235 | + |
|
236 | + if ( $args['value'] ) { |
|
237 | + $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']); |
|
238 | + } |
|
239 | + $query[] = $order . $limit; |
|
240 | + } |
|
241 | 241 | |
242 | 242 | public static function get_entry_meta_info( $entry_id ) { |
243 | 243 | return FrmDb::get_results( 'frm_item_metas', array( 'item_id' => $entry_id ) ); |
244 | - } |
|
244 | + } |
|
245 | 245 | |
246 | 246 | public static function getAll( $where = array(), $order_by = '', $limit = '', $stripslashes = false ) { |
247 | - global $wpdb; |
|
248 | - $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key, |
|
247 | + global $wpdb; |
|
248 | + $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key, |
|
249 | 249 | fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options |
250 | 250 | FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id' . |
251 | - FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
251 | + FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
252 | 252 | |
253 | - $cache_key = 'all_'. maybe_serialize($where) . $order_by . $limit; |
|
254 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results')); |
|
253 | + $cache_key = 'all_'. maybe_serialize($where) . $order_by . $limit; |
|
254 | + $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results')); |
|
255 | 255 | |
256 | - if ( ! $results || ! $stripslashes ) { |
|
257 | - return $results; |
|
258 | - } |
|
256 | + if ( ! $results || ! $stripslashes ) { |
|
257 | + return $results; |
|
258 | + } |
|
259 | 259 | |
260 | - foreach ( $results as $k => $result ) { |
|
260 | + foreach ( $results as $k => $result ) { |
|
261 | 261 | $results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) ); |
262 | - unset($k, $result); |
|
263 | - } |
|
262 | + unset($k, $result); |
|
263 | + } |
|
264 | 264 | |
265 | - return $results; |
|
266 | - } |
|
265 | + return $results; |
|
266 | + } |
|
267 | 267 | |
268 | - public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) { |
|
268 | + public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) { |
|
269 | 269 | $defaults = array( |
270 | 270 | 'is_draft' => false, |
271 | 271 | 'user_id' => '', |
272 | 272 | 'group_by' => '', |
273 | 273 | ); |
274 | - $args = wp_parse_args($args, $defaults); |
|
274 | + $args = wp_parse_args($args, $defaults); |
|
275 | 275 | |
276 | - $query = array(); |
|
277 | - self::get_ids_query($where, $order_by, $limit, $unique, $args, $query ); |
|
278 | - $query = implode(' ', $query); |
|
276 | + $query = array(); |
|
277 | + self::get_ids_query($where, $order_by, $limit, $unique, $args, $query ); |
|
278 | + $query = implode(' ', $query); |
|
279 | 279 | |
280 | - $cache_key = 'ids_'. maybe_serialize($where) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize($args); |
|
281 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col')); |
|
280 | + $cache_key = 'ids_'. maybe_serialize($where) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize($args); |
|
281 | + $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col')); |
|
282 | 282 | |
283 | - return $results; |
|
284 | - } |
|
283 | + return $results; |
|
284 | + } |
|
285 | 285 | |
286 | - /** |
|
287 | - * @param string|array $where |
|
288 | - * @param string $order_by |
|
289 | - * @param string $limit |
|
290 | - */ |
|
286 | + /** |
|
287 | + * @param string|array $where |
|
288 | + * @param string $order_by |
|
289 | + * @param string $limit |
|
290 | + */ |
|
291 | 291 | private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) { |
292 | - global $wpdb; |
|
293 | - $query[] = 'SELECT'; |
|
292 | + global $wpdb; |
|
293 | + $query[] = 'SELECT'; |
|
294 | 294 | |
295 | 295 | $defaults = array( 'return_parent_id' => false ); |
296 | 296 | $args = array_merge( $defaults, $args ); |
@@ -301,91 +301,91 @@ discard block |
||
301 | 301 | $query[] = $unique ? 'DISTINCT(it.item_id)' : 'it.item_id'; |
302 | 302 | } |
303 | 303 | |
304 | - $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id'; |
|
304 | + $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id'; |
|
305 | 305 | |
306 | - $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=it.item_id)'; |
|
307 | - if ( is_array($where) ) { |
|
308 | - if ( ! $args['is_draft'] ) { |
|
309 | - $where['e.is_draft'] = 0; |
|
310 | - } else if ( $args['is_draft'] == 1 ) { |
|
311 | - $where['e.is_draft'] = 1; |
|
312 | - } |
|
306 | + $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=it.item_id)'; |
|
307 | + if ( is_array($where) ) { |
|
308 | + if ( ! $args['is_draft'] ) { |
|
309 | + $where['e.is_draft'] = 0; |
|
310 | + } else if ( $args['is_draft'] == 1 ) { |
|
311 | + $where['e.is_draft'] = 1; |
|
312 | + } |
|
313 | 313 | |
314 | - if ( ! empty($args['user_id']) ) { |
|
315 | - $where['e.user_id'] = $args['user_id']; |
|
316 | - } |
|
317 | - $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
314 | + if ( ! empty($args['user_id']) ) { |
|
315 | + $where['e.user_id'] = $args['user_id']; |
|
316 | + } |
|
317 | + $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
318 | 318 | |
319 | 319 | if ( $args['group_by'] ) { |
320 | 320 | $query[] = ' GROUP BY '. sanitize_text_field( $args['group_by'] ); |
321 | 321 | } |
322 | - return; |
|
323 | - } |
|
322 | + return; |
|
323 | + } |
|
324 | 324 | |
325 | 325 | $draft_where = $user_where = ''; |
326 | - if ( ! $args['is_draft'] ) { |
|
326 | + if ( ! $args['is_draft'] ) { |
|
327 | 327 | $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 0 ); |
328 | - } else if ( $args['is_draft'] == 1 ) { |
|
328 | + } else if ( $args['is_draft'] == 1 ) { |
|
329 | 329 | $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 ); |
330 | - } |
|
331 | - |
|
332 | - if ( ! empty($args['user_id']) ) { |
|
333 | - $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); |
|
334 | - } |
|
335 | - |
|
336 | - if ( strpos($where, ' GROUP BY ') ) { |
|
337 | - // don't inject WHERE filtering after GROUP BY |
|
338 | - $parts = explode(' GROUP BY ', $where); |
|
339 | - $where = $parts[0]; |
|
340 | - $where .= $draft_where . $user_where; |
|
341 | - $where .= ' GROUP BY '. $parts[1]; |
|
342 | - } else { |
|
343 | - $where .= $draft_where . $user_where; |
|
344 | - } |
|
330 | + } |
|
331 | + |
|
332 | + if ( ! empty($args['user_id']) ) { |
|
333 | + $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); |
|
334 | + } |
|
335 | + |
|
336 | + if ( strpos($where, ' GROUP BY ') ) { |
|
337 | + // don't inject WHERE filtering after GROUP BY |
|
338 | + $parts = explode(' GROUP BY ', $where); |
|
339 | + $where = $parts[0]; |
|
340 | + $where .= $draft_where . $user_where; |
|
341 | + $where .= ' GROUP BY '. $parts[1]; |
|
342 | + } else { |
|
343 | + $where .= $draft_where . $user_where; |
|
344 | + } |
|
345 | 345 | |
346 | 346 | // The query has already been prepared |
347 | 347 | $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
348 | - } |
|
348 | + } |
|
349 | 349 | |
350 | - public static function search_entry_metas( $search, $field_id = '', $operator ) { |
|
351 | - $cache_key = 'search_'. maybe_serialize($search) . $field_id . $operator; |
|
352 | - $results = wp_cache_get($cache_key, 'frm_entry'); |
|
353 | - if ( false !== $results ) { |
|
354 | - return $results; |
|
355 | - } |
|
350 | + public static function search_entry_metas( $search, $field_id = '', $operator ) { |
|
351 | + $cache_key = 'search_'. maybe_serialize($search) . $field_id . $operator; |
|
352 | + $results = wp_cache_get($cache_key, 'frm_entry'); |
|
353 | + if ( false !== $results ) { |
|
354 | + return $results; |
|
355 | + } |
|
356 | 356 | |
357 | - global $wpdb; |
|
357 | + global $wpdb; |
|
358 | 358 | if ( is_array( $search ) ) { |
359 | - $where = ''; |
|
359 | + $where = ''; |
|
360 | 360 | foreach ( $search as $field => $value ) { |
361 | 361 | if ( $value <= 0 || ! in_array( $field, array( 'year', 'month', 'day' ) ) ) { |
362 | - continue; |
|
363 | - } |
|
364 | - |
|
365 | - switch ( $field ) { |
|
366 | - case 'year': |
|
367 | - $value = '%'. $value; |
|
368 | - break; |
|
369 | - case 'month': |
|
370 | - $value .= '%'; |
|
371 | - break; |
|
372 | - case 'day': |
|
373 | - $value = '%'. $value .'%'; |
|
374 | - } |
|
375 | - $where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value); |
|
376 | - } |
|
377 | - $where .= $wpdb->prepare(' field_id=%d', $field_id); |
|
378 | - $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where); |
|
379 | - } else { |
|
362 | + continue; |
|
363 | + } |
|
364 | + |
|
365 | + switch ( $field ) { |
|
366 | + case 'year': |
|
367 | + $value = '%'. $value; |
|
368 | + break; |
|
369 | + case 'month': |
|
370 | + $value .= '%'; |
|
371 | + break; |
|
372 | + case 'day': |
|
373 | + $value = '%'. $value .'%'; |
|
374 | + } |
|
375 | + $where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value); |
|
376 | + } |
|
377 | + $where .= $wpdb->prepare(' field_id=%d', $field_id); |
|
378 | + $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where); |
|
379 | + } else { |
|
380 | 380 | if ( $operator == 'LIKE' ) { |
381 | - $search = '%' . $search . '%'; |
|
381 | + $search = '%' . $search . '%'; |
|
382 | 382 | } |
383 | - $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id); |
|
384 | - } |
|
383 | + $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id); |
|
384 | + } |
|
385 | 385 | |
386 | - $results = $wpdb->get_col($query, 0); |
|
387 | - wp_cache_set($cache_key, $results, 'frm_entry', 300); |
|
386 | + $results = $wpdb->get_col($query, 0); |
|
387 | + wp_cache_set($cache_key, $results, 'frm_entry', 300); |
|
388 | 388 | |
389 | - return $results; |
|
390 | - } |
|
389 | + return $results; |
|
390 | + } |
|
391 | 391 | } |
@@ -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 | |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | 'meta_value' => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ), |
21 | 21 | 'item_id' => $entry_id, |
22 | 22 | 'field_id' => $field_id, |
23 | - 'created_at' => current_time('mysql', 1), |
|
23 | + 'created_at' => current_time( 'mysql', 1 ), |
|
24 | 24 | ); |
25 | 25 | |
26 | - $new_values = apply_filters('frm_add_entry_meta', $new_values); |
|
26 | + $new_values = apply_filters( 'frm_add_entry_meta', $new_values ); |
|
27 | 27 | |
28 | - $query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values ); |
|
28 | + $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values ); |
|
29 | 29 | |
30 | 30 | if ( $query_results ) { |
31 | 31 | self::clear_cache(); |
@@ -49,32 +49,32 @@ discard block |
||
49 | 49 | |
50 | 50 | $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id ); |
51 | 51 | $values['meta_value'] = $meta_value; |
52 | - $values = apply_filters('frm_update_entry_meta', $values); |
|
53 | - if ( is_array($values['meta_value']) ) { |
|
52 | + $values = apply_filters( 'frm_update_entry_meta', $values ); |
|
53 | + if ( is_array( $values['meta_value'] ) ) { |
|
54 | 54 | $values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' ); |
55 | 55 | } |
56 | - $meta_value = maybe_serialize($values['meta_value']); |
|
56 | + $meta_value = maybe_serialize( $values['meta_value'] ); |
|
57 | 57 | |
58 | - wp_cache_delete( $entry_id, 'frm_entry'); |
|
58 | + wp_cache_delete( $entry_id, 'frm_entry' ); |
|
59 | 59 | self::clear_cache(); |
60 | 60 | |
61 | - return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); |
|
61 | + return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | public static function update_entry_metas( $entry_id, $values ) { |
65 | 65 | global $wpdb; |
66 | 66 | |
67 | - $prev_values = FrmDb::get_col( $wpdb->prefix .'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' ); |
|
67 | + $prev_values = FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' ); |
|
68 | 68 | |
69 | 69 | foreach ( $values as $field_id => $meta_value ) { |
70 | 70 | // set the value for the file upload field and add new tags (in Pro version) |
71 | 71 | $meta_value = apply_filters( 'frm_prepare_data_before_db', $meta_value, $field_id, $entry_id ); |
72 | 72 | |
73 | - if ( $prev_values && in_array($field_id, $prev_values) ) { |
|
73 | + if ( $prev_values && in_array( $field_id, $prev_values ) ) { |
|
74 | 74 | |
75 | 75 | if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) { |
76 | 76 | // remove blank fields |
77 | - unset( $values[ $field_id ] ); |
|
77 | + unset( $values[$field_id] ); |
|
78 | 78 | } else { |
79 | 79 | // if value exists, then update it |
80 | 80 | self::update_entry_meta( $entry_id, $field_id, '', $meta_value ); |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - if ( empty($prev_values) ) { |
|
88 | + if ( empty( $prev_values ) ) { |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | - $prev_values = array_diff($prev_values, array_keys($values)); |
|
92 | + $prev_values = array_diff( $prev_values, array_keys( $values ) ); |
|
93 | 93 | |
94 | - if ( empty($prev_values) ) { |
|
94 | + if ( empty( $prev_values ) ) { |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | public static function duplicate_entry_metas( $old_id, $new_id ) { |
108 | - $metas = self::get_entry_meta_info($old_id); |
|
108 | + $metas = self::get_entry_meta_info( $old_id ); |
|
109 | 109 | foreach ( $metas as $meta ) { |
110 | - self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value); |
|
111 | - unset($meta); |
|
110 | + self::add_entry_meta( $new_id, $meta->field_id, null, $meta->meta_value ); |
|
111 | + unset( $meta ); |
|
112 | 112 | } |
113 | 113 | self::clear_cache(); |
114 | 114 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | public static function delete_entry_meta( $entry_id, $field_id ) { |
117 | 117 | global $wpdb; |
118 | 118 | self::clear_cache(); |
119 | - return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id)); |
|
119 | + return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id ) ); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public static function get_meta_value( $entry, $field_id ) { |
137 | 137 | if ( isset( $entry->metas ) ) { |
138 | - return isset( $entry->metas[ $field_id ] ) ? $entry->metas[ $field_id ] : false; |
|
138 | + return isset( $entry->metas[$field_id] ) ? $entry->metas[$field_id] : false; |
|
139 | 139 | } else { |
140 | 140 | return self::get_entry_meta_by_field( $entry->id, $field_id ); |
141 | 141 | } |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | $cached = FrmAppHelper::check_cache( $entry_id, 'frm_entry' ); |
154 | 154 | } |
155 | 155 | |
156 | - if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) { |
|
157 | - $result = $cached->metas[ $field_id ]; |
|
158 | - return stripslashes_deep($result); |
|
156 | + if ( $cached && isset( $cached->metas ) && isset( $cached->metas[$field_id] ) ) { |
|
157 | + $result = $cached->metas[$field_id]; |
|
158 | + return stripslashes_deep( $result ); |
|
159 | 159 | } |
160 | 160 | |
161 | - $get_table = $wpdb->prefix .'frm_item_metas'; |
|
161 | + $get_table = $wpdb->prefix . 'frm_item_metas'; |
|
162 | 162 | $query = array( 'item_id' => $entry_id ); |
163 | - if ( is_numeric($field_id) ) { |
|
163 | + if ( is_numeric( $field_id ) ) { |
|
164 | 164 | $query['field_id'] = $field_id; |
165 | 165 | } else { |
166 | 166 | $get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | $result = FrmDb::get_var( $get_table, $query, 'meta_value' ); |
171 | - $result = maybe_unserialize($result); |
|
172 | - $result = stripslashes_deep($result); |
|
171 | + $result = maybe_unserialize( $result ); |
|
172 | + $result = stripslashes_deep( $result ); |
|
173 | 173 | |
174 | 174 | return $result; |
175 | 175 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | public static function get_entry_metas( $entry_id ) { |
183 | - _deprecated_function( __FUNCTION__, '1.07.10'); |
|
183 | + _deprecated_function( __FUNCTION__, '1.07.10' ); |
|
184 | 184 | |
185 | 185 | global $wpdb; |
186 | 186 | return FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id ), 'meta_value' ); |
@@ -191,22 +191,22 @@ discard block |
||
191 | 191 | $args = wp_parse_args( $args, $defaults ); |
192 | 192 | |
193 | 193 | $query = array(); |
194 | - self::meta_field_query($field_id, $order, $limit, $args, $query); |
|
195 | - $query = implode(' ', $query); |
|
194 | + self::meta_field_query( $field_id, $order, $limit, $args, $query ); |
|
195 | + $query = implode( ' ', $query ); |
|
196 | 196 | |
197 | - $cache_key = 'entry_metas_for_field_'. $field_id . $order . $limit . maybe_serialize($args); |
|
198 | - $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col'); |
|
197 | + $cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args ); |
|
198 | + $values = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_col' ); |
|
199 | 199 | |
200 | 200 | if ( ! $args['stripslashes'] ) { |
201 | 201 | return $values; |
202 | 202 | } |
203 | 203 | |
204 | 204 | foreach ( $values as $k => $v ) { |
205 | - $values[ $k ] = maybe_unserialize( $v ); |
|
206 | - unset($k, $v); |
|
205 | + $values[$k] = maybe_unserialize( $v ); |
|
206 | + unset( $k, $v ); |
|
207 | 207 | } |
208 | 208 | |
209 | - return stripslashes_deep($values); |
|
209 | + return stripslashes_deep( $values ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -217,16 +217,16 @@ discard block |
||
217 | 217 | global $wpdb; |
218 | 218 | $query[] = 'SELECT'; |
219 | 219 | $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value'; |
220 | - $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em '; |
|
220 | + $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas em '; |
|
221 | 221 | |
222 | 222 | if ( ! $args['is_draft'] ) { |
223 | - $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)'; |
|
223 | + $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)'; |
|
224 | 224 | } |
225 | 225 | |
226 | - if ( is_numeric($field_id) ) { |
|
227 | - $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); |
|
226 | + if ( is_numeric( $field_id ) ) { |
|
227 | + $query[] = $wpdb->prepare( 'WHERE em.field_id=%d', $field_id ); |
|
228 | 228 | } else { |
229 | - $query[] = $wpdb->prepare('LEFT JOIN '. $wpdb->prefix .'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id); |
|
229 | + $query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id ); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | if ( ! $args['is_draft'] ) { |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | if ( $args['value'] ) { |
237 | - $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']); |
|
237 | + $query[] = $wpdb->prepare( ' AND meta_value=%s', $args['value'] ); |
|
238 | 238 | } |
239 | 239 | $query[] = $order . $limit; |
240 | 240 | } |
@@ -247,19 +247,19 @@ discard block |
||
247 | 247 | global $wpdb; |
248 | 248 | $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key, |
249 | 249 | fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options |
250 | - FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id' . |
|
251 | - FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
250 | + FROM '. $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' . |
|
251 | + FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
252 | 252 | |
253 | - $cache_key = 'all_'. maybe_serialize($where) . $order_by . $limit; |
|
254 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results')); |
|
253 | + $cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit; |
|
254 | + $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_row' : 'get_results' ) ); |
|
255 | 255 | |
256 | 256 | if ( ! $results || ! $stripslashes ) { |
257 | 257 | return $results; |
258 | 258 | } |
259 | 259 | |
260 | 260 | foreach ( $results as $k => $result ) { |
261 | - $results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) ); |
|
262 | - unset($k, $result); |
|
261 | + $results[$k]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) ); |
|
262 | + unset( $k, $result ); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | return $results; |
@@ -271,14 +271,14 @@ discard block |
||
271 | 271 | 'user_id' => '', |
272 | 272 | 'group_by' => '', |
273 | 273 | ); |
274 | - $args = wp_parse_args($args, $defaults); |
|
274 | + $args = wp_parse_args( $args, $defaults ); |
|
275 | 275 | |
276 | 276 | $query = array(); |
277 | - self::get_ids_query($where, $order_by, $limit, $unique, $args, $query ); |
|
278 | - $query = implode(' ', $query); |
|
277 | + self::get_ids_query( $where, $order_by, $limit, $unique, $args, $query ); |
|
278 | + $query = implode( ' ', $query ); |
|
279 | 279 | |
280 | - $cache_key = 'ids_'. maybe_serialize($where) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize($args); |
|
281 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col')); |
|
280 | + $cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args ); |
|
281 | + $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_var' : 'get_col' ) ); |
|
282 | 282 | |
283 | 283 | return $results; |
284 | 284 | } |
@@ -301,23 +301,23 @@ discard block |
||
301 | 301 | $query[] = $unique ? 'DISTINCT(it.item_id)' : 'it.item_id'; |
302 | 302 | } |
303 | 303 | |
304 | - $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id'; |
|
304 | + $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; |
|
305 | 305 | |
306 | - $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=it.item_id)'; |
|
307 | - if ( is_array($where) ) { |
|
306 | + $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)'; |
|
307 | + if ( is_array( $where ) ) { |
|
308 | 308 | if ( ! $args['is_draft'] ) { |
309 | 309 | $where['e.is_draft'] = 0; |
310 | 310 | } else if ( $args['is_draft'] == 1 ) { |
311 | 311 | $where['e.is_draft'] = 1; |
312 | 312 | } |
313 | 313 | |
314 | - if ( ! empty($args['user_id']) ) { |
|
314 | + if ( ! empty( $args['user_id'] ) ) { |
|
315 | 315 | $where['e.user_id'] = $args['user_id']; |
316 | 316 | } |
317 | - $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
317 | + $query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
318 | 318 | |
319 | 319 | if ( $args['group_by'] ) { |
320 | - $query[] = ' GROUP BY '. sanitize_text_field( $args['group_by'] ); |
|
320 | + $query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] ); |
|
321 | 321 | } |
322 | 322 | return; |
323 | 323 | } |
@@ -329,27 +329,27 @@ discard block |
||
329 | 329 | $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 ); |
330 | 330 | } |
331 | 331 | |
332 | - if ( ! empty($args['user_id']) ) { |
|
333 | - $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); |
|
332 | + if ( ! empty( $args['user_id'] ) ) { |
|
333 | + $user_where = $wpdb->prepare( ' AND e.user_id=%d', $args['user_id'] ); |
|
334 | 334 | } |
335 | 335 | |
336 | - if ( strpos($where, ' GROUP BY ') ) { |
|
336 | + if ( strpos( $where, ' GROUP BY ' ) ) { |
|
337 | 337 | // don't inject WHERE filtering after GROUP BY |
338 | - $parts = explode(' GROUP BY ', $where); |
|
338 | + $parts = explode( ' GROUP BY ', $where ); |
|
339 | 339 | $where = $parts[0]; |
340 | 340 | $where .= $draft_where . $user_where; |
341 | - $where .= ' GROUP BY '. $parts[1]; |
|
341 | + $where .= ' GROUP BY ' . $parts[1]; |
|
342 | 342 | } else { |
343 | 343 | $where .= $draft_where . $user_where; |
344 | 344 | } |
345 | 345 | |
346 | 346 | // The query has already been prepared |
347 | - $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
347 | + $query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | public static function search_entry_metas( $search, $field_id = '', $operator ) { |
351 | - $cache_key = 'search_'. maybe_serialize($search) . $field_id . $operator; |
|
352 | - $results = wp_cache_get($cache_key, 'frm_entry'); |
|
351 | + $cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator; |
|
352 | + $results = wp_cache_get( $cache_key, 'frm_entry' ); |
|
353 | 353 | if ( false !== $results ) { |
354 | 354 | return $results; |
355 | 355 | } |
@@ -364,27 +364,27 @@ discard block |
||
364 | 364 | |
365 | 365 | switch ( $field ) { |
366 | 366 | case 'year': |
367 | - $value = '%'. $value; |
|
367 | + $value = '%' . $value; |
|
368 | 368 | break; |
369 | 369 | case 'month': |
370 | 370 | $value .= '%'; |
371 | 371 | break; |
372 | 372 | case 'day': |
373 | - $value = '%'. $value .'%'; |
|
373 | + $value = '%' . $value . '%'; |
|
374 | 374 | } |
375 | - $where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value); |
|
375 | + $where .= $wpdb->prepare( ' meta_value ' . $operator . ' %s and', $value ); |
|
376 | 376 | } |
377 | - $where .= $wpdb->prepare(' field_id=%d', $field_id); |
|
378 | - $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where); |
|
377 | + $where .= $wpdb->prepare( ' field_id=%d', $field_id ); |
|
378 | + $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas" . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ); |
|
379 | 379 | } else { |
380 | 380 | if ( $operator == 'LIKE' ) { |
381 | 381 | $search = '%' . $search . '%'; |
382 | 382 | } |
383 | - $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id); |
|
383 | + $query = $wpdb->prepare( "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id ); |
|
384 | 384 | } |
385 | 385 | |
386 | - $results = $wpdb->get_col($query, 0); |
|
387 | - wp_cache_set($cache_key, $results, 'frm_entry', 300); |
|
386 | + $results = $wpdb->get_col( $query, 0 ); |
|
387 | + wp_cache_set( $cache_key, $results, 'frm_entry', 300 ); |
|
388 | 388 | |
389 | 389 | return $results; |
390 | 390 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | public $id = 0; // the id of the post |
5 | 5 | |
6 | 6 | /** |
7 | - * @param int|string $id The id of the stylsheet or 'default' |
|
7 | + * @param integer $id The id of the stylsheet or 'default' |
|
8 | 8 | */ |
9 | 9 | public function __construct( $id = 0 ) { |
10 | 10 | $this->id = $id; |
@@ -1,52 +1,52 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class FrmStyle { |
3 | - public $number = false; // Unique ID number of the current instance. |
|
3 | + public $number = false; // Unique ID number of the current instance. |
|
4 | 4 | public $id = 0; // the id of the post |
5 | 5 | |
6 | 6 | /** |
7 | 7 | * @param int|string $id The id of the stylsheet or 'default' |
8 | 8 | */ |
9 | 9 | public function __construct( $id = 0 ) { |
10 | - $this->id = $id; |
|
11 | - } |
|
10 | + $this->id = $id; |
|
11 | + } |
|
12 | 12 | |
13 | - public function get_new() { |
|
13 | + public function get_new() { |
|
14 | 14 | $this->id = 0; |
15 | 15 | |
16 | - $max_slug_value = pow(36, 6); |
|
17 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
18 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
19 | - |
|
20 | - $style = array( |
|
21 | - 'post_type' => FrmStylesController::$post_type, |
|
22 | - 'ID' => '', |
|
23 | - 'post_title' => __( 'New Style', 'formidable' ), |
|
24 | - 'post_name' => $key, |
|
25 | - 'post_content' => $this->get_defaults(), |
|
26 | - 'menu_order' => '', |
|
27 | - 'post_status' => 'publish', |
|
28 | - ); |
|
16 | + $max_slug_value = pow(36, 6); |
|
17 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
18 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
19 | + |
|
20 | + $style = array( |
|
21 | + 'post_type' => FrmStylesController::$post_type, |
|
22 | + 'ID' => '', |
|
23 | + 'post_title' => __( 'New Style', 'formidable' ), |
|
24 | + 'post_name' => $key, |
|
25 | + 'post_content' => $this->get_defaults(), |
|
26 | + 'menu_order' => '', |
|
27 | + 'post_status' => 'publish', |
|
28 | + ); |
|
29 | 29 | |
30 | - return (object) $style; |
|
31 | - } |
|
30 | + return (object) $style; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | public function save( $settings ) { |
34 | 34 | return FrmAppHelper::save_settings( $settings, 'frm_styles' ); |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | 37 | public function duplicate( $id ) { |
38 | - // duplicating is a pro feature |
|
39 | - } |
|
38 | + // duplicating is a pro feature |
|
39 | + } |
|
40 | 40 | |
41 | - public function update( $id = 'default' ) { |
|
41 | + public function update( $id = 'default' ) { |
|
42 | 42 | $all_instances = $this->get_all(); |
43 | 43 | |
44 | 44 | if ( empty($id) ) { |
45 | - $new_style = (array) $this->get_new(); |
|
46 | - $all_instances[] = $new_style; |
|
45 | + $new_style = (array) $this->get_new(); |
|
46 | + $all_instances[] = $new_style; |
|
47 | 47 | } |
48 | 48 | |
49 | - $action_ids = array(); |
|
49 | + $action_ids = array(); |
|
50 | 50 | |
51 | 51 | foreach ( $all_instances as $number => $new_instance ) { |
52 | 52 | $new_instance = stripslashes_deep( (array) $new_instance); |
@@ -54,40 +54,40 @@ discard block |
||
54 | 54 | if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) { |
55 | 55 | $all_instances[ $number ] = $new_instance; |
56 | 56 | |
57 | - if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
58 | - // this style was set to default, so remove default setting on previous default style |
|
59 | - $new_instance['menu_order'] = 0; |
|
60 | - $action_ids[] = $this->save($new_instance); |
|
61 | - } |
|
57 | + if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
58 | + // this style was set to default, so remove default setting on previous default style |
|
59 | + $new_instance['menu_order'] = 0; |
|
60 | + $action_ids[] = $this->save($new_instance); |
|
61 | + } |
|
62 | 62 | |
63 | - // don't continue if not saving this style |
|
64 | - continue; |
|
63 | + // don't continue if not saving this style |
|
64 | + continue; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | $new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] ); |
68 | 68 | $new_instance['post_content'] = $_POST['frm_style_setting']['post_content']; |
69 | 69 | $new_instance['post_type'] = FrmStylesController::$post_type; |
70 | - $new_instance['post_status'] = 'publish'; |
|
70 | + $new_instance['post_status'] = 'publish'; |
|
71 | 71 | $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0; |
72 | 72 | |
73 | - if ( empty($id) ) { |
|
74 | - $new_instance['post_name'] = $new_instance['post_title']; |
|
75 | - } |
|
73 | + if ( empty($id) ) { |
|
74 | + $new_instance['post_name'] = $new_instance['post_title']; |
|
75 | + } |
|
76 | 76 | |
77 | - $default_settings = $this->get_defaults(); |
|
77 | + $default_settings = $this->get_defaults(); |
|
78 | 78 | |
79 | - foreach ( $default_settings as $setting => $default ) { |
|
79 | + foreach ( $default_settings as $setting => $default ) { |
|
80 | 80 | if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) { |
81 | - //if is a color |
|
81 | + //if is a color |
|
82 | 82 | $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] ); |
83 | 83 | } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { |
84 | 84 | $new_instance['post_content'][ $setting ] = 0; |
85 | - } |
|
86 | - } |
|
85 | + } |
|
86 | + } |
|
87 | 87 | |
88 | 88 | $all_instances[ $number ] = $new_instance; |
89 | 89 | |
90 | - $action_ids[] = $this->save($new_instance); |
|
90 | + $action_ids[] = $this->save($new_instance); |
|
91 | 91 | |
92 | 92 | } |
93 | 93 | |
@@ -96,74 +96,74 @@ discard block |
||
96 | 96 | return $action_ids; |
97 | 97 | } |
98 | 98 | |
99 | - /** |
|
100 | - * Create static css file |
|
101 | - */ |
|
99 | + /** |
|
100 | + * Create static css file |
|
101 | + */ |
|
102 | 102 | public function save_settings( $styles ) { |
103 | - $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php'; |
|
103 | + $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php'; |
|
104 | 104 | |
105 | - if ( ! is_file($filename) ) { |
|
106 | - return; |
|
107 | - } |
|
105 | + if ( ! is_file($filename) ) { |
|
106 | + return; |
|
107 | + } |
|
108 | 108 | |
109 | - $defaults = $this->get_defaults(); |
|
110 | - $uploads = wp_upload_dir(); |
|
111 | - $target_path = $uploads['basedir'] .'/formidable'; |
|
112 | - $needed_dirs = array( $target_path, $target_path .'/css' ); |
|
113 | - $dirs_exist = true; |
|
109 | + $defaults = $this->get_defaults(); |
|
110 | + $uploads = wp_upload_dir(); |
|
111 | + $target_path = $uploads['basedir'] .'/formidable'; |
|
112 | + $needed_dirs = array( $target_path, $target_path .'/css' ); |
|
113 | + $dirs_exist = true; |
|
114 | 114 | |
115 | - $saving = true; |
|
116 | - $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n"; |
|
115 | + $saving = true; |
|
116 | + $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n"; |
|
117 | 117 | |
118 | - ob_start(); |
|
119 | - $frm_style = $this; |
|
120 | - include($filename); |
|
118 | + ob_start(); |
|
119 | + $frm_style = $this; |
|
120 | + include($filename); |
|
121 | 121 | $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) ); |
122 | - ob_end_clean(); |
|
122 | + ob_end_clean(); |
|
123 | 123 | |
124 | - $access_type = get_filesystem_method(); |
|
125 | - if ( $access_type === 'direct' ) { |
|
126 | - $creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() ); |
|
124 | + $access_type = get_filesystem_method(); |
|
125 | + if ( $access_type === 'direct' ) { |
|
126 | + $creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() ); |
|
127 | 127 | } else { |
128 | 128 | $creds = $this->get_ftp_creds( $access_type ); |
129 | 129 | } |
130 | 130 | |
131 | 131 | if ( ! empty( $creds ) ) { |
132 | - // initialize the API |
|
133 | - if ( ! WP_Filesystem( $creds ) ) { |
|
134 | - // any problems and we exit |
|
135 | - $dirs_exist = false; |
|
132 | + // initialize the API |
|
133 | + if ( ! WP_Filesystem( $creds ) ) { |
|
134 | + // any problems and we exit |
|
135 | + $dirs_exist = false; |
|
136 | 136 | } |
137 | 137 | |
138 | - if ( $dirs_exist ) { |
|
139 | - global $wp_filesystem; |
|
138 | + if ( $dirs_exist ) { |
|
139 | + global $wp_filesystem; |
|
140 | 140 | |
141 | - $chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
142 | - $chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
141 | + $chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
142 | + $chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
143 | 143 | |
144 | - // Create the directories if need be: |
|
145 | - foreach ( $needed_dirs as $_dir ) { |
|
146 | - // Only check to see if the Dir exists upon creation failure. Less I/O this way. |
|
147 | - if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) { |
|
148 | - $dirs_exist = false; |
|
149 | - } |
|
150 | - } |
|
144 | + // Create the directories if need be: |
|
145 | + foreach ( $needed_dirs as $_dir ) { |
|
146 | + // Only check to see if the Dir exists upon creation failure. Less I/O this way. |
|
147 | + if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) { |
|
148 | + $dirs_exist = false; |
|
149 | + } |
|
150 | + } |
|
151 | 151 | |
152 | - $index_path = $target_path .'/index.php'; |
|
153 | - $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file ); |
|
152 | + $index_path = $target_path .'/index.php'; |
|
153 | + $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file ); |
|
154 | 154 | |
155 | - // only write the file if the folders exist |
|
156 | - if ( $dirs_exist ) { |
|
157 | - $css_file = $target_path .'/css/formidablepro.css'; |
|
158 | - $wp_filesystem->put_contents( $css_file, $css, $chmod_file ); |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
155 | + // only write the file if the folders exist |
|
156 | + if ( $dirs_exist ) { |
|
157 | + $css_file = $target_path .'/css/formidablepro.css'; |
|
158 | + $wp_filesystem->put_contents( $css_file, $css, $chmod_file ); |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | 162 | |
163 | - update_option('frmpro_css', $css); |
|
163 | + update_option('frmpro_css', $css); |
|
164 | 164 | |
165 | - delete_transient('frmpro_css'); |
|
166 | - set_transient('frmpro_css', $css); |
|
165 | + delete_transient('frmpro_css'); |
|
166 | + set_transient('frmpro_css', $css); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | private function get_ftp_creds( $type ) { |
@@ -217,271 +217,271 @@ discard block |
||
217 | 217 | } |
218 | 218 | |
219 | 219 | public function destroy( $id ) { |
220 | - return wp_delete_post($id); |
|
221 | - } |
|
220 | + return wp_delete_post($id); |
|
221 | + } |
|
222 | 222 | |
223 | - public function get_one() { |
|
224 | - if ( 'default' == $this->id ) { |
|
225 | - $style = $this->get_default_style(); |
|
226 | - if ( $style ) { |
|
227 | - $this->id = $style->ID; |
|
228 | - } else { |
|
229 | - $this->id = 0; |
|
230 | - } |
|
231 | - return $style; |
|
232 | - } |
|
223 | + public function get_one() { |
|
224 | + if ( 'default' == $this->id ) { |
|
225 | + $style = $this->get_default_style(); |
|
226 | + if ( $style ) { |
|
227 | + $this->id = $style->ID; |
|
228 | + } else { |
|
229 | + $this->id = 0; |
|
230 | + } |
|
231 | + return $style; |
|
232 | + } |
|
233 | 233 | |
234 | - $style = get_post($this->id); |
|
234 | + $style = get_post($this->id); |
|
235 | 235 | |
236 | - if ( ! $style ) { |
|
237 | - return $style; |
|
238 | - } |
|
236 | + if ( ! $style ) { |
|
237 | + return $style; |
|
238 | + } |
|
239 | 239 | |
240 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
240 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
241 | 241 | |
242 | - $default_values = $this->get_defaults(); |
|
242 | + $default_values = $this->get_defaults(); |
|
243 | 243 | |
244 | - // fill default values |
|
245 | - $style->post_content = $this->override_defaults($style->post_content); |
|
246 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
244 | + // fill default values |
|
245 | + $style->post_content = $this->override_defaults($style->post_content); |
|
246 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
247 | 247 | |
248 | - return $style; |
|
249 | - } |
|
248 | + return $style; |
|
249 | + } |
|
250 | 250 | |
251 | - public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
252 | - $post_atts = array( |
|
251 | + public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
252 | + $post_atts = array( |
|
253 | 253 | 'post_type' => FrmStylesController::$post_type, |
254 | 254 | 'post_status' => 'publish', |
255 | 255 | 'numberposts' => $limit, |
256 | 256 | 'orderby' => $orderby, |
257 | 257 | 'order' => $order, |
258 | - ); |
|
259 | - |
|
260 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
261 | - |
|
262 | - if ( empty($temp_styles) ) { |
|
263 | - global $wpdb; |
|
264 | - // make sure there wasn't a conflict with the query |
|
265 | - $query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish'); |
|
266 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
267 | - |
|
268 | - if ( empty($temp_styles) ) { |
|
269 | - // create a new style if there are none |
|
270 | - $new = $this->get_new(); |
|
271 | - $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
272 | - $new->menu_order = 1; |
|
273 | - $new = $this->save( (array) $new); |
|
274 | - $this->update('default'); |
|
275 | - |
|
276 | - $post_atts['include'] = $new; |
|
277 | - |
|
278 | - $temp_styles = get_posts( $post_atts ); |
|
279 | - } |
|
280 | - } |
|
281 | - |
|
282 | - $default_values = $this->get_defaults(); |
|
283 | - $default_style = false; |
|
284 | - |
|
285 | - $styles = array(); |
|
286 | - foreach ( $temp_styles as $style ) { |
|
287 | - $this->id = $style->ID; |
|
288 | - if ( $style->menu_order ) { |
|
289 | - if ( $default_style ) { |
|
290 | - // only return one default |
|
291 | - $style->menu_order = 0; |
|
292 | - } else { |
|
293 | - // check for a default style |
|
294 | - $default_style = $style->ID; |
|
295 | - } |
|
296 | - } |
|
297 | - |
|
298 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
299 | - |
|
300 | - // fill default values |
|
301 | - $style->post_content = $this->override_defaults($style->post_content); |
|
302 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
258 | + ); |
|
259 | + |
|
260 | + $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
261 | + |
|
262 | + if ( empty($temp_styles) ) { |
|
263 | + global $wpdb; |
|
264 | + // make sure there wasn't a conflict with the query |
|
265 | + $query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish'); |
|
266 | + $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
267 | + |
|
268 | + if ( empty($temp_styles) ) { |
|
269 | + // create a new style if there are none |
|
270 | + $new = $this->get_new(); |
|
271 | + $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
272 | + $new->menu_order = 1; |
|
273 | + $new = $this->save( (array) $new); |
|
274 | + $this->update('default'); |
|
275 | + |
|
276 | + $post_atts['include'] = $new; |
|
277 | + |
|
278 | + $temp_styles = get_posts( $post_atts ); |
|
279 | + } |
|
280 | + } |
|
281 | + |
|
282 | + $default_values = $this->get_defaults(); |
|
283 | + $default_style = false; |
|
284 | + |
|
285 | + $styles = array(); |
|
286 | + foreach ( $temp_styles as $style ) { |
|
287 | + $this->id = $style->ID; |
|
288 | + if ( $style->menu_order ) { |
|
289 | + if ( $default_style ) { |
|
290 | + // only return one default |
|
291 | + $style->menu_order = 0; |
|
292 | + } else { |
|
293 | + // check for a default style |
|
294 | + $default_style = $style->ID; |
|
295 | + } |
|
296 | + } |
|
297 | + |
|
298 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
299 | + |
|
300 | + // fill default values |
|
301 | + $style->post_content = $this->override_defaults($style->post_content); |
|
302 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
303 | 303 | |
304 | 304 | $styles[ $style->ID ] = $style; |
305 | - } |
|
305 | + } |
|
306 | 306 | |
307 | - if ( ! $default_style ) { |
|
308 | - $default_style = reset($styles); |
|
307 | + if ( ! $default_style ) { |
|
308 | + $default_style = reset($styles); |
|
309 | 309 | $styles[ $default_style->ID ]->menu_order = 1; |
310 | - } |
|
310 | + } |
|
311 | 311 | |
312 | - return $styles; |
|
313 | - } |
|
312 | + return $styles; |
|
313 | + } |
|
314 | 314 | |
315 | 315 | public function get_default_style( $styles = null ) { |
316 | - if ( ! isset($styles) ) { |
|
316 | + if ( ! isset($styles) ) { |
|
317 | 317 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
318 | - } |
|
318 | + } |
|
319 | 319 | |
320 | - foreach ( $styles as $style ) { |
|
321 | - if ( $style->menu_order ) { |
|
322 | - return $style; |
|
323 | - } |
|
324 | - } |
|
325 | - } |
|
320 | + foreach ( $styles as $style ) { |
|
321 | + if ( $style->menu_order ) { |
|
322 | + return $style; |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | 327 | public function override_defaults( $settings ) { |
328 | - if ( ! is_array($settings) ) { |
|
329 | - return $settings; |
|
330 | - } |
|
331 | - |
|
332 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
333 | - |
|
334 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
335 | - $settings['form_desc_size'] = $settings['description_font_size']; |
|
336 | - $settings['form_desc_color'] = $settings['description_color']; |
|
337 | - $settings['title_color'] = $settings['label_color']; |
|
338 | - } |
|
339 | - |
|
340 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
341 | - $settings['section_color'] = $settings['label_color']; |
|
342 | - $settings['section_border_color'] = $settings['border_color']; |
|
343 | - } |
|
344 | - |
|
345 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
346 | - $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
347 | - $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
348 | - $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
349 | - |
|
350 | - $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
351 | - $settings['submit_active_color'] = $settings['submit_text_color']; |
|
352 | - $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
353 | - } |
|
354 | - |
|
355 | - return $settings; |
|
328 | + if ( ! is_array($settings) ) { |
|
329 | + return $settings; |
|
330 | + } |
|
331 | + |
|
332 | + $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
333 | + |
|
334 | + if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
335 | + $settings['form_desc_size'] = $settings['description_font_size']; |
|
336 | + $settings['form_desc_color'] = $settings['description_color']; |
|
337 | + $settings['title_color'] = $settings['label_color']; |
|
338 | + } |
|
339 | + |
|
340 | + if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
341 | + $settings['section_color'] = $settings['label_color']; |
|
342 | + $settings['section_border_color'] = $settings['border_color']; |
|
343 | + } |
|
344 | + |
|
345 | + if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
346 | + $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
347 | + $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
348 | + $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
349 | + |
|
350 | + $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
351 | + $settings['submit_active_color'] = $settings['submit_text_color']; |
|
352 | + $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
353 | + } |
|
354 | + |
|
355 | + return $settings; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | public function get_defaults() { |
359 | - return array( |
|
360 | - 'theme_css' => 'ui-lightness', |
|
361 | - 'theme_name' => 'UI Lightness', |
|
359 | + return array( |
|
360 | + 'theme_css' => 'ui-lightness', |
|
361 | + 'theme_name' => 'UI Lightness', |
|
362 | 362 | |
363 | 363 | 'center_form' => '', |
364 | - 'form_width' => '100%', |
|
365 | - 'form_align' => 'left', |
|
366 | - 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
367 | - 'fieldset' => '0px', |
|
368 | - 'fieldset_color' => '000000', |
|
369 | - 'fieldset_padding' => '0 0 15px 0', |
|
370 | - 'fieldset_bg_color' => '', |
|
371 | - |
|
372 | - 'title_size' => '20px', |
|
373 | - 'title_color' => '444444', |
|
364 | + 'form_width' => '100%', |
|
365 | + 'form_align' => 'left', |
|
366 | + 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
367 | + 'fieldset' => '0px', |
|
368 | + 'fieldset_color' => '000000', |
|
369 | + 'fieldset_padding' => '0 0 15px 0', |
|
370 | + 'fieldset_bg_color' => '', |
|
371 | + |
|
372 | + 'title_size' => '20px', |
|
373 | + 'title_color' => '444444', |
|
374 | 374 | 'title_margin_top' => '10px', |
375 | 375 | 'title_margin_bottom' => '10px', |
376 | - 'form_desc_size' => '14px', |
|
377 | - 'form_desc_color' => '666666', |
|
376 | + 'form_desc_size' => '14px', |
|
377 | + 'form_desc_color' => '666666', |
|
378 | 378 | 'form_desc_margin_top' => '10px', |
379 | 379 | 'form_desc_margin_bottom' => '25px', |
380 | 380 | |
381 | - 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
382 | - 'font_size' => '14px', |
|
383 | - 'label_color' => '444444', |
|
384 | - 'weight' => 'bold', |
|
385 | - 'position' => 'none', |
|
386 | - 'align' => 'left', |
|
387 | - 'width' => '150px', |
|
388 | - 'required_color' => 'B94A48', |
|
389 | - 'required_weight' => 'bold', |
|
390 | - 'label_padding' => '0 0 3px 0', |
|
391 | - |
|
392 | - 'description_font_size' => '12px', |
|
393 | - 'description_color' => '666666', |
|
394 | - 'description_weight' => 'normal', |
|
395 | - 'description_style' => 'normal', |
|
396 | - 'description_align' => 'left', |
|
397 | - |
|
398 | - 'field_font_size' => '14px', |
|
399 | - 'field_height' => '32px', |
|
400 | - 'line_height' => 'normal', |
|
401 | - 'field_width' => '100%', |
|
402 | - 'auto_width' => false, |
|
403 | - 'field_pad' => '6px 10px', |
|
404 | - 'field_margin' => '20px', |
|
381 | + 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
382 | + 'font_size' => '14px', |
|
383 | + 'label_color' => '444444', |
|
384 | + 'weight' => 'bold', |
|
385 | + 'position' => 'none', |
|
386 | + 'align' => 'left', |
|
387 | + 'width' => '150px', |
|
388 | + 'required_color' => 'B94A48', |
|
389 | + 'required_weight' => 'bold', |
|
390 | + 'label_padding' => '0 0 3px 0', |
|
391 | + |
|
392 | + 'description_font_size' => '12px', |
|
393 | + 'description_color' => '666666', |
|
394 | + 'description_weight' => 'normal', |
|
395 | + 'description_style' => 'normal', |
|
396 | + 'description_align' => 'left', |
|
397 | + |
|
398 | + 'field_font_size' => '14px', |
|
399 | + 'field_height' => '32px', |
|
400 | + 'line_height' => 'normal', |
|
401 | + 'field_width' => '100%', |
|
402 | + 'auto_width' => false, |
|
403 | + 'field_pad' => '6px 10px', |
|
404 | + 'field_margin' => '20px', |
|
405 | 405 | 'field_weight' => 'normal', |
406 | - 'text_color' => '555555', |
|
407 | - //'border_color_hv' => 'cccccc', |
|
408 | - 'border_color' => 'cccccc', |
|
409 | - 'field_border_width' => '1px', |
|
410 | - 'field_border_style' => 'solid', |
|
411 | - |
|
412 | - 'bg_color' => 'ffffff', |
|
413 | - //'bg_color_hv' => 'ffffff', |
|
406 | + 'text_color' => '555555', |
|
407 | + //'border_color_hv' => 'cccccc', |
|
408 | + 'border_color' => 'cccccc', |
|
409 | + 'field_border_width' => '1px', |
|
410 | + 'field_border_style' => 'solid', |
|
411 | + |
|
412 | + 'bg_color' => 'ffffff', |
|
413 | + //'bg_color_hv' => 'ffffff', |
|
414 | 414 | 'remove_box_shadow' => '', |
415 | - 'bg_color_active' => 'ffffff', |
|
415 | + 'bg_color_active' => 'ffffff', |
|
416 | 416 | 'border_color_active' => '66afe9', |
417 | 417 | 'remove_box_shadow_active' => '', |
418 | - 'text_color_error' => '444444', |
|
419 | - 'bg_color_error' => 'ffffff', |
|
418 | + 'text_color_error' => '444444', |
|
419 | + 'bg_color_error' => 'ffffff', |
|
420 | 420 | 'border_color_error' => 'B94A48', |
421 | 421 | 'border_width_error' => '1px', |
422 | 422 | 'border_style_error' => 'solid', |
423 | - 'bg_color_disabled' => 'ffffff', |
|
424 | - 'border_color_disabled' => 'E5E5E5', |
|
425 | - 'text_color_disabled' => 'A1A1A1', |
|
426 | - |
|
427 | - 'radio_align' => 'block', |
|
428 | - 'check_align' => 'block', |
|
429 | - 'check_font_size' => '13px', |
|
430 | - 'check_label_color' => '444444', |
|
431 | - 'check_weight' => 'normal', |
|
432 | - |
|
433 | - 'section_font_size' => '18px', |
|
434 | - 'section_color' => '444444', |
|
435 | - 'section_weight' => 'bold', |
|
436 | - 'section_pad' => '15px 0 3px 0', |
|
437 | - 'section_mar_top' => '15px', |
|
423 | + 'bg_color_disabled' => 'ffffff', |
|
424 | + 'border_color_disabled' => 'E5E5E5', |
|
425 | + 'text_color_disabled' => 'A1A1A1', |
|
426 | + |
|
427 | + 'radio_align' => 'block', |
|
428 | + 'check_align' => 'block', |
|
429 | + 'check_font_size' => '13px', |
|
430 | + 'check_label_color' => '444444', |
|
431 | + 'check_weight' => 'normal', |
|
432 | + |
|
433 | + 'section_font_size' => '18px', |
|
434 | + 'section_color' => '444444', |
|
435 | + 'section_weight' => 'bold', |
|
436 | + 'section_pad' => '15px 0 3px 0', |
|
437 | + 'section_mar_top' => '15px', |
|
438 | 438 | 'section_mar_bottom' => '12px', |
439 | - 'section_bg_color' => '', |
|
440 | - 'section_border_color' => 'e8e8e8', |
|
441 | - 'section_border_width' => '2px', |
|
442 | - 'section_border_style' => 'solid', |
|
443 | - 'section_border_loc' => '-top', |
|
444 | - 'collapse_icon' => '6', |
|
445 | - 'collapse_pos' => 'after', |
|
446 | - 'repeat_icon' => '1', |
|
447 | - |
|
448 | - 'submit_style' => false, |
|
449 | - 'submit_font_size' => '14px', |
|
450 | - 'submit_width' => 'auto', |
|
451 | - 'submit_height' => 'auto', |
|
452 | - 'submit_bg_color' => 'ffffff', |
|
453 | - 'submit_border_color' => 'cccccc', |
|
454 | - 'submit_border_width' => '1px', |
|
455 | - 'submit_text_color' => '444444', |
|
456 | - 'submit_weight' => 'normal', |
|
457 | - 'submit_border_radius' => '4px', |
|
458 | - 'submit_bg_img' => '', |
|
459 | - 'submit_margin' => '10px', |
|
460 | - 'submit_padding' => '6px 11px', |
|
461 | - 'submit_shadow_color' => 'eeeeee', |
|
462 | - 'submit_hover_bg_color' => 'efefef', |
|
463 | - 'submit_hover_color' => '444444', |
|
464 | - 'submit_hover_border_color' => 'cccccc', |
|
465 | - 'submit_active_bg_color' => 'efefef', |
|
466 | - 'submit_active_color' => '444444', |
|
467 | - 'submit_active_border_color' => 'cccccc', |
|
468 | - |
|
469 | - 'border_radius' => '4px', |
|
470 | - 'error_bg' => 'F2DEDE', |
|
471 | - 'error_border' => 'EBCCD1', |
|
472 | - 'error_text' => 'B94A48', |
|
473 | - 'error_font_size' => '14px', |
|
474 | - |
|
475 | - 'success_bg_color' => 'DFF0D8', |
|
476 | - 'success_border_color' => 'D6E9C6', |
|
477 | - 'success_text_color' => '468847', |
|
478 | - 'success_font_size' => '14px', |
|
479 | - |
|
480 | - 'important_style' => false, |
|
481 | - |
|
482 | - 'custom_css' => '', |
|
483 | - ); |
|
484 | - } |
|
439 | + 'section_bg_color' => '', |
|
440 | + 'section_border_color' => 'e8e8e8', |
|
441 | + 'section_border_width' => '2px', |
|
442 | + 'section_border_style' => 'solid', |
|
443 | + 'section_border_loc' => '-top', |
|
444 | + 'collapse_icon' => '6', |
|
445 | + 'collapse_pos' => 'after', |
|
446 | + 'repeat_icon' => '1', |
|
447 | + |
|
448 | + 'submit_style' => false, |
|
449 | + 'submit_font_size' => '14px', |
|
450 | + 'submit_width' => 'auto', |
|
451 | + 'submit_height' => 'auto', |
|
452 | + 'submit_bg_color' => 'ffffff', |
|
453 | + 'submit_border_color' => 'cccccc', |
|
454 | + 'submit_border_width' => '1px', |
|
455 | + 'submit_text_color' => '444444', |
|
456 | + 'submit_weight' => 'normal', |
|
457 | + 'submit_border_radius' => '4px', |
|
458 | + 'submit_bg_img' => '', |
|
459 | + 'submit_margin' => '10px', |
|
460 | + 'submit_padding' => '6px 11px', |
|
461 | + 'submit_shadow_color' => 'eeeeee', |
|
462 | + 'submit_hover_bg_color' => 'efefef', |
|
463 | + 'submit_hover_color' => '444444', |
|
464 | + 'submit_hover_border_color' => 'cccccc', |
|
465 | + 'submit_active_bg_color' => 'efefef', |
|
466 | + 'submit_active_color' => '444444', |
|
467 | + 'submit_active_border_color' => 'cccccc', |
|
468 | + |
|
469 | + 'border_radius' => '4px', |
|
470 | + 'error_bg' => 'F2DEDE', |
|
471 | + 'error_border' => 'EBCCD1', |
|
472 | + 'error_text' => 'B94A48', |
|
473 | + 'error_font_size' => '14px', |
|
474 | + |
|
475 | + 'success_bg_color' => 'DFF0D8', |
|
476 | + 'success_border_color' => 'D6E9C6', |
|
477 | + 'success_text_color' => '468847', |
|
478 | + 'success_font_size' => '14px', |
|
479 | + |
|
480 | + 'important_style' => false, |
|
481 | + |
|
482 | + 'custom_css' => '', |
|
483 | + ); |
|
484 | + } |
|
485 | 485 | |
486 | 486 | public function get_field_name( $field_name, $post_field = 'post_content' ) { |
487 | 487 | return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']'; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class FrmStyle { |
3 | - public $number = false; // Unique ID number of the current instance. |
|
3 | + public $number = false; // Unique ID number of the current instance. |
|
4 | 4 | public $id = 0; // the id of the post |
5 | 5 | |
6 | 6 | /** |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | public function get_new() { |
14 | 14 | $this->id = 0; |
15 | 15 | |
16 | - $max_slug_value = pow(36, 6); |
|
16 | + $max_slug_value = pow( 36, 6 ); |
|
17 | 17 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
18 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
18 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
19 | 19 | |
20 | 20 | $style = array( |
21 | 21 | 'post_type' => FrmStylesController::$post_type, |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function update( $id = 'default' ) { |
42 | 42 | $all_instances = $this->get_all(); |
43 | 43 | |
44 | - if ( empty($id) ) { |
|
44 | + if ( empty( $id ) ) { |
|
45 | 45 | $new_style = (array) $this->get_new(); |
46 | 46 | $all_instances[] = $new_style; |
47 | 47 | } |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | $action_ids = array(); |
50 | 50 | |
51 | 51 | foreach ( $all_instances as $number => $new_instance ) { |
52 | - $new_instance = stripslashes_deep( (array) $new_instance); |
|
52 | + $new_instance = stripslashes_deep( (array) $new_instance ); |
|
53 | 53 | $this->id = $new_instance['ID']; |
54 | - if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) { |
|
55 | - $all_instances[ $number ] = $new_instance; |
|
54 | + if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) { |
|
55 | + $all_instances[$number] = $new_instance; |
|
56 | 56 | |
57 | - if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
57 | + if ( $new_instance['menu_order'] && $_POST && empty( $_POST['prev_menu_order'] ) && isset( $_POST['frm_style_setting']['menu_order'] ) ) { |
|
58 | 58 | // this style was set to default, so remove default setting on previous default style |
59 | 59 | $new_instance['menu_order'] = 0; |
60 | - $action_ids[] = $this->save($new_instance); |
|
60 | + $action_ids[] = $this->save( $new_instance ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // don't continue if not saving this style |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | $new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] ); |
68 | 68 | $new_instance['post_content'] = $_POST['frm_style_setting']['post_content']; |
69 | 69 | $new_instance['post_type'] = FrmStylesController::$post_type; |
70 | - $new_instance['post_status'] = 'publish'; |
|
70 | + $new_instance['post_status'] = 'publish'; |
|
71 | 71 | $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0; |
72 | 72 | |
73 | - if ( empty($id) ) { |
|
73 | + if ( empty( $id ) ) { |
|
74 | 74 | $new_instance['post_name'] = $new_instance['post_title']; |
75 | 75 | } |
76 | 76 | |
@@ -79,19 +79,19 @@ discard block |
||
79 | 79 | foreach ( $default_settings as $setting => $default ) { |
80 | 80 | if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) { |
81 | 81 | //if is a color |
82 | - $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] ); |
|
83 | - } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { |
|
84 | - $new_instance['post_content'][ $setting ] = 0; |
|
82 | + $new_instance['post_content'][$setting] = str_replace( '#', '', $new_instance['post_content'][$setting] ); |
|
83 | + } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][$setting] ) ) { |
|
84 | + $new_instance['post_content'][$setting] = 0; |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - $all_instances[ $number ] = $new_instance; |
|
88 | + $all_instances[$number] = $new_instance; |
|
89 | 89 | |
90 | - $action_ids[] = $this->save($new_instance); |
|
90 | + $action_ids[] = $this->save( $new_instance ); |
|
91 | 91 | |
92 | 92 | } |
93 | 93 | |
94 | - $this->save_settings($all_instances); |
|
94 | + $this->save_settings( $all_instances ); |
|
95 | 95 | |
96 | 96 | return $action_ids; |
97 | 97 | } |
@@ -100,31 +100,31 @@ discard block |
||
100 | 100 | * Create static css file |
101 | 101 | */ |
102 | 102 | public function save_settings( $styles ) { |
103 | - $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php'; |
|
104 | - update_option( 'frm_last_style_update', date('njGi') ); |
|
103 | + $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php'; |
|
104 | + update_option( 'frm_last_style_update', date( 'njGi' ) ); |
|
105 | 105 | |
106 | - if ( ! is_file($filename) ) { |
|
106 | + if ( ! is_file( $filename ) ) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | 110 | $defaults = $this->get_defaults(); |
111 | 111 | $uploads = wp_upload_dir(); |
112 | - $target_path = $uploads['basedir'] .'/formidable'; |
|
113 | - $needed_dirs = array( $target_path, $target_path .'/css' ); |
|
112 | + $target_path = $uploads['basedir'] . '/formidable'; |
|
113 | + $needed_dirs = array( $target_path, $target_path . '/css' ); |
|
114 | 114 | $dirs_exist = true; |
115 | 115 | |
116 | 116 | $saving = true; |
117 | - $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n"; |
|
117 | + $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n"; |
|
118 | 118 | |
119 | 119 | ob_start(); |
120 | 120 | $frm_style = $this; |
121 | - include($filename); |
|
121 | + include( $filename ); |
|
122 | 122 | $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) ); |
123 | 123 | ob_end_clean(); |
124 | 124 | |
125 | 125 | $access_type = get_filesystem_method(); |
126 | 126 | if ( $access_type === 'direct' ) { |
127 | - $creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() ); |
|
127 | + $creds = request_filesystem_credentials( site_url() . '/wp-admin/', '', false, false, array() ); |
|
128 | 128 | } else { |
129 | 129 | $creds = $this->get_ftp_creds( $access_type ); |
130 | 130 | } |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | if ( $dirs_exist ) { |
140 | 140 | global $wp_filesystem; |
141 | 141 | |
142 | - $chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
143 | - $chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
142 | + $chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
143 | + $chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
144 | 144 | |
145 | 145 | // Create the directories if need be: |
146 | 146 | foreach ( $needed_dirs as $_dir ) { |
@@ -150,33 +150,33 @@ discard block |
||
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | - $index_path = $target_path .'/index.php'; |
|
153 | + $index_path = $target_path . '/index.php'; |
|
154 | 154 | $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file ); |
155 | 155 | |
156 | 156 | // only write the file if the folders exist |
157 | 157 | if ( $dirs_exist ) { |
158 | - $css_file = $target_path .'/css/formidablepro.css'; |
|
158 | + $css_file = $target_path . '/css/formidablepro.css'; |
|
159 | 159 | $wp_filesystem->put_contents( $css_file, $css, $chmod_file ); |
160 | 160 | } |
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | - update_option('frmpro_css', $css); |
|
164 | + update_option( 'frmpro_css', $css ); |
|
165 | 165 | |
166 | - delete_transient('frmpro_css'); |
|
167 | - set_transient('frmpro_css', $css); |
|
166 | + delete_transient( 'frmpro_css' ); |
|
167 | + set_transient( 'frmpro_css', $css ); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | private function get_ftp_creds( $type ) { |
171 | 171 | $credentials = get_option( 'ftp_credentials', array( 'hostname' => '', 'username' => '' ) ); |
172 | 172 | |
173 | - $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname']; |
|
174 | - $credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username']; |
|
175 | - $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : ''; |
|
173 | + $credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname']; |
|
174 | + $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username']; |
|
175 | + $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : ''; |
|
176 | 176 | |
177 | 177 | // Check to see if we are setting the public/private keys for ssh |
178 | - $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : ''; |
|
179 | - $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : ''; |
|
178 | + $credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : ''; |
|
179 | + $credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : ''; |
|
180 | 180 | |
181 | 181 | // Sanitize the hostname, Some people might pass in odd-data: |
182 | 182 | $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | } |
219 | 219 | |
220 | 220 | public function destroy( $id ) { |
221 | - return wp_delete_post($id); |
|
221 | + return wp_delete_post( $id ); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | public function get_one() { |
@@ -232,19 +232,19 @@ discard block |
||
232 | 232 | return $style; |
233 | 233 | } |
234 | 234 | |
235 | - $style = get_post($this->id); |
|
235 | + $style = get_post( $this->id ); |
|
236 | 236 | |
237 | 237 | if ( ! $style ) { |
238 | 238 | return $style; |
239 | 239 | } |
240 | 240 | |
241 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
241 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
|
242 | 242 | |
243 | 243 | $default_values = $this->get_defaults(); |
244 | 244 | |
245 | 245 | // fill default values |
246 | - $style->post_content = $this->override_defaults($style->post_content); |
|
247 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
246 | + $style->post_content = $this->override_defaults( $style->post_content ); |
|
247 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
|
248 | 248 | |
249 | 249 | return $style; |
250 | 250 | } |
@@ -258,21 +258,21 @@ discard block |
||
258 | 258 | 'order' => $order, |
259 | 259 | ); |
260 | 260 | |
261 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
261 | + $temp_styles = FrmAppHelper::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' ); |
|
262 | 262 | |
263 | - if ( empty($temp_styles) ) { |
|
263 | + if ( empty( $temp_styles ) ) { |
|
264 | 264 | global $wpdb; |
265 | 265 | // make sure there wasn't a conflict with the query |
266 | - $query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish'); |
|
267 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
266 | + $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); |
|
267 | + $temp_styles = FrmAppHelper::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' ); |
|
268 | 268 | |
269 | - if ( empty($temp_styles) ) { |
|
269 | + if ( empty( $temp_styles ) ) { |
|
270 | 270 | // create a new style if there are none |
271 | 271 | $new = $this->get_new(); |
272 | 272 | $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
273 | 273 | $new->menu_order = 1; |
274 | - $new = $this->save( (array) $new); |
|
275 | - $this->update('default'); |
|
274 | + $new = $this->save( (array) $new ); |
|
275 | + $this->update( 'default' ); |
|
276 | 276 | |
277 | 277 | $post_atts['include'] = $new; |
278 | 278 | |
@@ -296,25 +296,25 @@ discard block |
||
296 | 296 | } |
297 | 297 | } |
298 | 298 | |
299 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
299 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
|
300 | 300 | |
301 | 301 | // fill default values |
302 | - $style->post_content = $this->override_defaults($style->post_content); |
|
303 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
302 | + $style->post_content = $this->override_defaults( $style->post_content ); |
|
303 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
|
304 | 304 | |
305 | - $styles[ $style->ID ] = $style; |
|
305 | + $styles[$style->ID] = $style; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | if ( ! $default_style ) { |
309 | - $default_style = reset($styles); |
|
310 | - $styles[ $default_style->ID ]->menu_order = 1; |
|
309 | + $default_style = reset( $styles ); |
|
310 | + $styles[$default_style->ID]->menu_order = 1; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | return $styles; |
314 | 314 | } |
315 | 315 | |
316 | 316 | public function get_default_style( $styles = null ) { |
317 | - if ( ! isset($styles) ) { |
|
317 | + if ( ! isset( $styles ) ) { |
|
318 | 318 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
319 | 319 | } |
320 | 320 | |
@@ -326,24 +326,24 @@ discard block |
||
326 | 326 | } |
327 | 327 | |
328 | 328 | public function override_defaults( $settings ) { |
329 | - if ( ! is_array($settings) ) { |
|
329 | + if ( ! is_array( $settings ) ) { |
|
330 | 330 | return $settings; |
331 | 331 | } |
332 | 332 | |
333 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
333 | + $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height']; |
|
334 | 334 | |
335 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
335 | + if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) { |
|
336 | 336 | $settings['form_desc_size'] = $settings['description_font_size']; |
337 | 337 | $settings['form_desc_color'] = $settings['description_color']; |
338 | 338 | $settings['title_color'] = $settings['label_color']; |
339 | 339 | } |
340 | 340 | |
341 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
341 | + if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) { |
|
342 | 342 | $settings['section_color'] = $settings['label_color']; |
343 | 343 | $settings['section_border_color'] = $settings['border_color']; |
344 | 344 | } |
345 | 345 | |
346 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
346 | + if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) { |
|
347 | 347 | $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
348 | 348 | $settings['submit_hover_color'] = $settings['submit_text_color']; |
349 | 349 | $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | } |
486 | 486 | |
487 | 487 | public function get_field_name( $field_name, $post_field = 'post_content' ) { |
488 | - return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']'; |
|
488 | + return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']'; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | public static function get_bold_options() { |
@@ -1,109 +1,109 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmFormActionsController { |
4 | - public static $action_post_type = 'frm_form_actions'; |
|
5 | - public static $registered_actions; |
|
6 | - |
|
7 | - public static function register_post_types() { |
|
8 | - register_post_type( self::$action_post_type, array( |
|
9 | - 'label' => __( 'Form Actions', 'formidable' ), |
|
10 | - 'description' => '', |
|
11 | - 'public' => false, |
|
12 | - 'show_ui' => false, |
|
13 | - 'exclude_from_search' => true, |
|
14 | - 'show_in_nav_menus' => false, |
|
15 | - 'show_in_menu' => true, |
|
16 | - 'capability_type' => 'page', |
|
17 | - 'supports' => array( |
|
4 | + public static $action_post_type = 'frm_form_actions'; |
|
5 | + public static $registered_actions; |
|
6 | + |
|
7 | + public static function register_post_types() { |
|
8 | + register_post_type( self::$action_post_type, array( |
|
9 | + 'label' => __( 'Form Actions', 'formidable' ), |
|
10 | + 'description' => '', |
|
11 | + 'public' => false, |
|
12 | + 'show_ui' => false, |
|
13 | + 'exclude_from_search' => true, |
|
14 | + 'show_in_nav_menus' => false, |
|
15 | + 'show_in_menu' => true, |
|
16 | + 'capability_type' => 'page', |
|
17 | + 'supports' => array( |
|
18 | 18 | 'title', 'editor', 'excerpt', 'custom-fields', |
19 | 19 | 'page-attributes', |
20 | - ), |
|
21 | - 'has_archive' => false, |
|
22 | - ) ); |
|
23 | - |
|
24 | - /** |
|
25 | - * post_content: json settings |
|
26 | - * menu_order: form id |
|
27 | - * post_excerpt: action type |
|
28 | - */ |
|
29 | - |
|
30 | - self::actions_init(); |
|
31 | - } |
|
32 | - |
|
33 | - public static function actions_init() { |
|
34 | - self::$registered_actions = new Frm_Form_Action_Factory(); |
|
35 | - self::register_actions(); |
|
36 | - do_action( 'frm_form_actions_init' ); |
|
37 | - } |
|
38 | - |
|
39 | - public static function register_actions() { |
|
40 | - $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
41 | - 'email' => 'FrmEmailAction', |
|
42 | - 'wppost' => 'FrmDefPostAction', |
|
43 | - 'register' => 'FrmDefRegAction', |
|
44 | - 'paypal' => 'FrmDefPayPalAction', |
|
45 | - //'aweber' => 'FrmDefAweberAction', |
|
46 | - 'mailchimp' => 'FrmDefMlcmpAction', |
|
47 | - 'twilio' => 'FrmDefTwilioAction', |
|
48 | - 'highrise' => 'FrmDefHrsAction', |
|
49 | - ) ); |
|
50 | - |
|
51 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
52 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
53 | - |
|
54 | - foreach ( $action_classes as $action_class ) { |
|
55 | - self::$registered_actions->register($action_class); |
|
56 | - } |
|
57 | - } |
|
20 | + ), |
|
21 | + 'has_archive' => false, |
|
22 | + ) ); |
|
23 | + |
|
24 | + /** |
|
25 | + * post_content: json settings |
|
26 | + * menu_order: form id |
|
27 | + * post_excerpt: action type |
|
28 | + */ |
|
29 | + |
|
30 | + self::actions_init(); |
|
31 | + } |
|
32 | + |
|
33 | + public static function actions_init() { |
|
34 | + self::$registered_actions = new Frm_Form_Action_Factory(); |
|
35 | + self::register_actions(); |
|
36 | + do_action( 'frm_form_actions_init' ); |
|
37 | + } |
|
38 | + |
|
39 | + public static function register_actions() { |
|
40 | + $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
41 | + 'email' => 'FrmEmailAction', |
|
42 | + 'wppost' => 'FrmDefPostAction', |
|
43 | + 'register' => 'FrmDefRegAction', |
|
44 | + 'paypal' => 'FrmDefPayPalAction', |
|
45 | + //'aweber' => 'FrmDefAweberAction', |
|
46 | + 'mailchimp' => 'FrmDefMlcmpAction', |
|
47 | + 'twilio' => 'FrmDefTwilioAction', |
|
48 | + 'highrise' => 'FrmDefHrsAction', |
|
49 | + ) ); |
|
50 | + |
|
51 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
52 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
53 | + |
|
54 | + foreach ( $action_classes as $action_class ) { |
|
55 | + self::$registered_actions->register($action_class); |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | 59 | public static function get_form_actions( $action = 'all' ) { |
60 | - $temp_actions = self::$registered_actions; |
|
61 | - if ( empty($temp_actions) ) { |
|
62 | - self::actions_init(); |
|
63 | - $temp_actions = self::$registered_actions->actions; |
|
64 | - } else { |
|
65 | - $temp_actions = $temp_actions->actions; |
|
66 | - } |
|
60 | + $temp_actions = self::$registered_actions; |
|
61 | + if ( empty($temp_actions) ) { |
|
62 | + self::actions_init(); |
|
63 | + $temp_actions = self::$registered_actions->actions; |
|
64 | + } else { |
|
65 | + $temp_actions = $temp_actions->actions; |
|
66 | + } |
|
67 | 67 | |
68 | - $actions = array(); |
|
68 | + $actions = array(); |
|
69 | 69 | |
70 | - foreach ( $temp_actions as $a ) { |
|
71 | - if ( 'all' != $action && $a->id_base == $action ) { |
|
72 | - return $a; |
|
73 | - } |
|
70 | + foreach ( $temp_actions as $a ) { |
|
71 | + if ( 'all' != $action && $a->id_base == $action ) { |
|
72 | + return $a; |
|
73 | + } |
|
74 | 74 | |
75 | 75 | $actions[ $a->id_base ] = $a; |
76 | - } |
|
77 | - unset( $temp_actions, $a ); |
|
78 | - |
|
79 | - $action_limit = 10; |
|
80 | - if ( count( $actions ) <= $action_limit ) { |
|
81 | - return $actions; |
|
82 | - } |
|
83 | - |
|
84 | - // remove the last few inactive icons if there are too many |
|
85 | - $temp_actions = $actions; |
|
86 | - arsort( $temp_actions ); |
|
87 | - foreach ( $temp_actions as $type => $a ) { |
|
88 | - if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
76 | + } |
|
77 | + unset( $temp_actions, $a ); |
|
78 | + |
|
79 | + $action_limit = 10; |
|
80 | + if ( count( $actions ) <= $action_limit ) { |
|
81 | + return $actions; |
|
82 | + } |
|
83 | + |
|
84 | + // remove the last few inactive icons if there are too many |
|
85 | + $temp_actions = $actions; |
|
86 | + arsort( $temp_actions ); |
|
87 | + foreach ( $temp_actions as $type => $a ) { |
|
88 | + if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
89 | 89 | unset( $actions[ $type ] ); |
90 | - if ( count( $actions ) <= $action_limit ) { |
|
91 | - break; |
|
92 | - } |
|
93 | - } |
|
94 | - unset( $type, $a ); |
|
95 | - } |
|
90 | + if ( count( $actions ) <= $action_limit ) { |
|
91 | + break; |
|
92 | + } |
|
93 | + } |
|
94 | + unset( $type, $a ); |
|
95 | + } |
|
96 | 96 | |
97 | - return $actions; |
|
98 | - } |
|
97 | + return $actions; |
|
98 | + } |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * @since 2.0 |
102 | 102 | */ |
103 | - public static function list_actions( $form, $values ) { |
|
104 | - if ( empty( $form ) ) { |
|
105 | - return; |
|
106 | - } |
|
103 | + public static function list_actions( $form, $values ) { |
|
104 | + if ( empty( $form ) ) { |
|
105 | + return; |
|
106 | + } |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * use this hook to migrate old settings into a new action |
@@ -113,114 +113,114 @@ discard block |
||
113 | 113 | |
114 | 114 | $form_actions = FrmFormAction::get_action_for_form( $form->id ); |
115 | 115 | |
116 | - $action_controls = self::get_form_actions(); |
|
116 | + $action_controls = self::get_form_actions(); |
|
117 | 117 | |
118 | - $action_map = array(); |
|
118 | + $action_map = array(); |
|
119 | 119 | |
120 | 120 | foreach ( $action_controls as $key => $control ) { |
121 | - $action_map[ $control->id_base ] = $key; |
|
122 | - } |
|
121 | + $action_map[ $control->id_base ] = $key; |
|
122 | + } |
|
123 | 123 | |
124 | - foreach ( $form_actions as $action ) { |
|
125 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
126 | - // don't try and show settings if action no longer exists |
|
127 | - continue; |
|
128 | - } |
|
124 | + foreach ( $form_actions as $action ) { |
|
125 | + if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
126 | + // don't try and show settings if action no longer exists |
|
127 | + continue; |
|
128 | + } |
|
129 | 129 | |
130 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
131 | - } |
|
132 | - } |
|
130 | + self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
131 | + } |
|
132 | + } |
|
133 | 133 | |
134 | 134 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
135 | - $action_control->_set($action_key); |
|
136 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
137 | - } |
|
135 | + $action_control->_set($action_key); |
|
136 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
137 | + } |
|
138 | 138 | |
139 | - public static function add_form_action() { |
|
140 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
139 | + public static function add_form_action() { |
|
140 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
141 | 141 | |
142 | - global $frm_vars; |
|
142 | + global $frm_vars; |
|
143 | 143 | |
144 | 144 | $action_key = absint( $_POST['list_id'] ); |
145 | - $action_type = sanitize_text_field( $_POST['type'] ); |
|
145 | + $action_type = sanitize_text_field( $_POST['type'] ); |
|
146 | 146 | |
147 | - $action_control = self::get_form_actions( $action_type ); |
|
148 | - $action_control->_set($action_key); |
|
147 | + $action_control = self::get_form_actions( $action_type ); |
|
148 | + $action_control->_set($action_key); |
|
149 | 149 | |
150 | - $form_id = absint( $_POST['form_id'] ); |
|
150 | + $form_id = absint( $_POST['form_id'] ); |
|
151 | 151 | |
152 | - $form_action = $action_control->prepare_new($form_id); |
|
152 | + $form_action = $action_control->prepare_new($form_id); |
|
153 | 153 | |
154 | - $values = array(); |
|
155 | - $form = self::fields_to_values($form_id, $values); |
|
154 | + $values = array(); |
|
155 | + $form = self::fields_to_values($form_id, $values); |
|
156 | 156 | |
157 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
158 | - wp_die(); |
|
159 | - } |
|
157 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
158 | + wp_die(); |
|
159 | + } |
|
160 | 160 | |
161 | - public static function fill_action() { |
|
162 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
161 | + public static function fill_action() { |
|
162 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
163 | 163 | |
164 | - $action_key = absint( $_POST['action_id'] ); |
|
165 | - $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
164 | + $action_key = absint( $_POST['action_id'] ); |
|
165 | + $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
166 | 166 | |
167 | - $action_control = self::get_form_actions( $action_type ); |
|
168 | - if ( empty($action_control) ) { |
|
169 | - wp_die(); |
|
170 | - } |
|
167 | + $action_control = self::get_form_actions( $action_type ); |
|
168 | + if ( empty($action_control) ) { |
|
169 | + wp_die(); |
|
170 | + } |
|
171 | 171 | |
172 | - $form_action = $action_control->get_single_action( $action_key ); |
|
172 | + $form_action = $action_control->get_single_action( $action_key ); |
|
173 | 173 | |
174 | - $values = array(); |
|
175 | - $form = self::fields_to_values($form_action->menu_order, $values); |
|
174 | + $values = array(); |
|
175 | + $form = self::fields_to_values($form_action->menu_order, $values); |
|
176 | 176 | |
177 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php'); |
|
178 | - wp_die(); |
|
179 | - } |
|
177 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php'); |
|
178 | + wp_die(); |
|
179 | + } |
|
180 | 180 | |
181 | 181 | private static function fields_to_values( $form_id, array &$values ) { |
182 | - $form = FrmForm::getOne($form_id); |
|
182 | + $form = FrmForm::getOne($form_id); |
|
183 | 183 | |
184 | 184 | $values = array( 'fields' => array(), 'id' => $form->id ); |
185 | 185 | |
186 | - $fields = FrmField::get_all_for_form($form->id); |
|
187 | - foreach ( $fields as $k => $f ) { |
|
188 | - $f = (array) $f; |
|
189 | - $opts = (array) $f['field_options']; |
|
190 | - $f = array_merge($opts, $f); |
|
191 | - if ( ! isset( $f['post_field'] ) ) { |
|
192 | - $f['post_field'] = ''; |
|
193 | - } |
|
194 | - $values['fields'][] = $f; |
|
195 | - unset($k, $f); |
|
196 | - } |
|
197 | - |
|
198 | - return $form; |
|
199 | - } |
|
186 | + $fields = FrmField::get_all_for_form($form->id); |
|
187 | + foreach ( $fields as $k => $f ) { |
|
188 | + $f = (array) $f; |
|
189 | + $opts = (array) $f['field_options']; |
|
190 | + $f = array_merge($opts, $f); |
|
191 | + if ( ! isset( $f['post_field'] ) ) { |
|
192 | + $f['post_field'] = ''; |
|
193 | + } |
|
194 | + $values['fields'][] = $f; |
|
195 | + unset($k, $f); |
|
196 | + } |
|
197 | + |
|
198 | + return $form; |
|
199 | + } |
|
200 | 200 | |
201 | 201 | public static function update_settings( $form_id ) { |
202 | - global $wpdb; |
|
202 | + global $wpdb; |
|
203 | 203 | |
204 | - $registered_actions = self::$registered_actions->actions; |
|
204 | + $registered_actions = self::$registered_actions->actions; |
|
205 | 205 | |
206 | 206 | $old_actions = FrmDb::get_col( $wpdb->posts, array( 'post_type' => self::$action_post_type, 'menu_order' => $form_id ), 'ID' ); |
207 | - $new_actions = array(); |
|
207 | + $new_actions = array(); |
|
208 | 208 | |
209 | - foreach ( $registered_actions as $registered_action ) { |
|
210 | - $action_ids = $registered_action->update_callback($form_id); |
|
211 | - if ( ! empty( $action_ids ) ) { |
|
212 | - $new_actions[] = $action_ids; |
|
213 | - } |
|
214 | - } |
|
209 | + foreach ( $registered_actions as $registered_action ) { |
|
210 | + $action_ids = $registered_action->update_callback($form_id); |
|
211 | + if ( ! empty( $action_ids ) ) { |
|
212 | + $new_actions[] = $action_ids; |
|
213 | + } |
|
214 | + } |
|
215 | 215 | |
216 | - //Only use array_merge if there are new actions |
|
217 | - if ( ! empty( $new_actions ) ) { |
|
218 | - $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
219 | - } |
|
220 | - $old_actions = array_diff( $old_actions, $new_actions ); |
|
216 | + //Only use array_merge if there are new actions |
|
217 | + if ( ! empty( $new_actions ) ) { |
|
218 | + $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
219 | + } |
|
220 | + $old_actions = array_diff( $old_actions, $new_actions ); |
|
221 | 221 | |
222 | 222 | self::delete_missing_actions( $old_actions ); |
223 | - } |
|
223 | + } |
|
224 | 224 | |
225 | 225 | public static function delete_missing_actions( $old_actions ) { |
226 | 226 | if ( ! empty( $old_actions ) ) { |
@@ -235,36 +235,36 @@ discard block |
||
235 | 235 | self::trigger_actions( 'create', $form_id, $entry_id, 'all', $args ); |
236 | 236 | } |
237 | 237 | |
238 | - /** |
|
239 | - * @param string $event |
|
240 | - */ |
|
238 | + /** |
|
239 | + * @param string $event |
|
240 | + */ |
|
241 | 241 | public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) { |
242 | 242 | $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type ); |
243 | 243 | |
244 | 244 | if ( empty( $form_actions ) ) { |
245 | - return; |
|
246 | - } |
|
245 | + return; |
|
246 | + } |
|
247 | 247 | |
248 | 248 | FrmForm::maybe_get_form( $form ); |
249 | 249 | |
250 | - $link_settings = self::get_form_actions( $type ); |
|
251 | - if ( 'all' != $type ) { |
|
252 | - $link_settings = array( $type => $link_settings ); |
|
253 | - } |
|
250 | + $link_settings = self::get_form_actions( $type ); |
|
251 | + if ( 'all' != $type ) { |
|
252 | + $link_settings = array( $type => $link_settings ); |
|
253 | + } |
|
254 | 254 | |
255 | - $stored_actions = $action_priority = array(); |
|
255 | + $stored_actions = $action_priority = array(); |
|
256 | 256 | |
257 | 257 | $importing = in_array( $event, array( 'create', 'update' ) ) && defined( 'WP_IMPORTING' ) && WP_IMPORTING; |
258 | 258 | |
259 | - foreach ( $form_actions as $action ) { |
|
259 | + foreach ( $form_actions as $action ) { |
|
260 | 260 | $trigger_on_import = $importing && in_array( 'import', $action->post_content['event'] ); |
261 | 261 | if ( ! in_array( $event, $action->post_content['event'] ) && ! $trigger_on_import ) { |
262 | - continue; |
|
263 | - } |
|
262 | + continue; |
|
263 | + } |
|
264 | 264 | |
265 | - if ( ! is_object( $entry ) ) { |
|
266 | - $entry = FrmEntry::getOne( $entry, true ); |
|
267 | - } |
|
265 | + if ( ! is_object( $entry ) ) { |
|
266 | + $entry = FrmEntry::getOne( $entry, true ); |
|
267 | + } |
|
268 | 268 | |
269 | 269 | if ( empty( $entry ) || $entry->is_draft ) { |
270 | 270 | continue; |
@@ -273,66 +273,66 @@ discard block |
||
273 | 273 | $child_entry = ( ( $form && is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ( isset( $args['is_child'] ) && $args['is_child'] ) ); |
274 | 274 | |
275 | 275 | if ( $child_entry ) { |
276 | - //don't trigger actions for sub forms |
|
277 | - continue; |
|
278 | - } |
|
276 | + //don't trigger actions for sub forms |
|
277 | + continue; |
|
278 | + } |
|
279 | 279 | |
280 | - // check conditional logic |
|
280 | + // check conditional logic |
|
281 | 281 | $stop = FrmFormAction::action_conditions_met( $action, $entry ); |
282 | - if ( $stop ) { |
|
283 | - continue; |
|
284 | - } |
|
282 | + if ( $stop ) { |
|
283 | + continue; |
|
284 | + } |
|
285 | 285 | |
286 | - // store actions so they can be triggered with the correct priority |
|
287 | - $stored_actions[ $action->ID ] = $action; |
|
288 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
286 | + // store actions so they can be triggered with the correct priority |
|
287 | + $stored_actions[ $action->ID ] = $action; |
|
288 | + $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
289 | 289 | |
290 | - unset($action); |
|
291 | - } |
|
290 | + unset($action); |
|
291 | + } |
|
292 | 292 | |
293 | - if ( ! empty( $stored_actions ) ) { |
|
294 | - asort($action_priority); |
|
293 | + if ( ! empty( $stored_actions ) ) { |
|
294 | + asort($action_priority); |
|
295 | 295 | |
296 | - // make sure hooks are loaded |
|
297 | - new FrmNotification(); |
|
296 | + // make sure hooks are loaded |
|
297 | + new FrmNotification(); |
|
298 | 298 | |
299 | - foreach ( $action_priority as $action_id => $priority ) { |
|
300 | - $action = $stored_actions[ $action_id ]; |
|
301 | - do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event); |
|
302 | - do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form); |
|
299 | + foreach ( $action_priority as $action_id => $priority ) { |
|
300 | + $action = $stored_actions[ $action_id ]; |
|
301 | + do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event); |
|
302 | + do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form); |
|
303 | 303 | |
304 | - // If post is created, get updated $entry object |
|
305 | - if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
306 | - $entry = FrmEntry::getOne($entry->id, true); |
|
307 | - } |
|
308 | - } |
|
309 | - } |
|
310 | - } |
|
304 | + // If post is created, get updated $entry object |
|
305 | + if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
306 | + $entry = FrmEntry::getOne($entry->id, true); |
|
307 | + } |
|
308 | + } |
|
309 | + } |
|
310 | + } |
|
311 | 311 | |
312 | 312 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
313 | - if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
314 | - // continue if we know which actions to copy |
|
315 | - return; |
|
316 | - } |
|
313 | + if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
314 | + // continue if we know which actions to copy |
|
315 | + return; |
|
316 | + } |
|
317 | 317 | |
318 | - $action_controls = self::get_form_actions( ); |
|
318 | + $action_controls = self::get_form_actions( ); |
|
319 | 319 | |
320 | - foreach ( $action_controls as $action_control ) { |
|
321 | - $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
322 | - unset( $action_control ); |
|
323 | - } |
|
324 | - } |
|
320 | + foreach ( $action_controls as $action_control ) { |
|
321 | + $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
322 | + unset( $action_control ); |
|
323 | + } |
|
324 | + } |
|
325 | 325 | |
326 | - public static function limit_by_type( $where ) { |
|
327 | - global $frm_vars, $wpdb; |
|
326 | + public static function limit_by_type( $where ) { |
|
327 | + global $frm_vars, $wpdb; |
|
328 | 328 | |
329 | - if ( ! isset( $frm_vars['action_type'] ) ) { |
|
330 | - return $where; |
|
331 | - } |
|
329 | + if ( ! isset( $frm_vars['action_type'] ) ) { |
|
330 | + return $where; |
|
331 | + } |
|
332 | 332 | |
333 | - $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
334 | - return $where; |
|
335 | - } |
|
333 | + $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
334 | + return $where; |
|
335 | + } |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | foreach ( $keys as $key ) { |
360 | 360 | // don't register new action if old action with the same id is already registered |
361 | 361 | if ( ! isset( $this->actions[ $key ] ) ) { |
362 | - $this->actions[ $key ]->_register(); |
|
362 | + $this->actions[ $key ]->_register(); |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | } |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | 'highrise' => 'FrmDefHrsAction', |
49 | 49 | ) ); |
50 | 50 | |
51 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
52 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
51 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' ); |
|
52 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' ); |
|
53 | 53 | |
54 | 54 | foreach ( $action_classes as $action_class ) { |
55 | - self::$registered_actions->register($action_class); |
|
55 | + self::$registered_actions->register( $action_class ); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | 59 | public static function get_form_actions( $action = 'all' ) { |
60 | 60 | $temp_actions = self::$registered_actions; |
61 | - if ( empty($temp_actions) ) { |
|
61 | + if ( empty( $temp_actions ) ) { |
|
62 | 62 | self::actions_init(); |
63 | 63 | $temp_actions = self::$registered_actions->actions; |
64 | 64 | } else { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | return $a; |
73 | 73 | } |
74 | 74 | |
75 | - $actions[ $a->id_base ] = $a; |
|
75 | + $actions[$a->id_base] = $a; |
|
76 | 76 | } |
77 | 77 | unset( $temp_actions, $a ); |
78 | 78 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | arsort( $temp_actions ); |
87 | 87 | foreach ( $temp_actions as $type => $a ) { |
88 | 88 | if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
89 | - unset( $actions[ $type ] ); |
|
89 | + unset( $actions[$type] ); |
|
90 | 90 | if ( count( $actions ) <= $action_limit ) { |
91 | 91 | break; |
92 | 92 | } |
@@ -118,22 +118,22 @@ discard block |
||
118 | 118 | $action_map = array(); |
119 | 119 | |
120 | 120 | foreach ( $action_controls as $key => $control ) { |
121 | - $action_map[ $control->id_base ] = $key; |
|
121 | + $action_map[$control->id_base] = $key; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | foreach ( $form_actions as $action ) { |
125 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
125 | + if ( ! isset( $action_map[$action->post_excerpt] ) ) { |
|
126 | 126 | // don't try and show settings if action no longer exists |
127 | 127 | continue; |
128 | 128 | } |
129 | 129 | |
130 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
130 | + self::action_control( $action, $form, $action->ID, $action_controls[$action_map[$action->post_excerpt]], $values ); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | 134 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
135 | - $action_control->_set($action_key); |
|
136 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
135 | + $action_control->_set( $action_key ); |
|
136 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | public static function add_form_action() { |
@@ -145,16 +145,16 @@ discard block |
||
145 | 145 | $action_type = sanitize_text_field( $_POST['type'] ); |
146 | 146 | |
147 | 147 | $action_control = self::get_form_actions( $action_type ); |
148 | - $action_control->_set($action_key); |
|
148 | + $action_control->_set( $action_key ); |
|
149 | 149 | |
150 | 150 | $form_id = absint( $_POST['form_id'] ); |
151 | 151 | |
152 | - $form_action = $action_control->prepare_new($form_id); |
|
152 | + $form_action = $action_control->prepare_new( $form_id ); |
|
153 | 153 | |
154 | 154 | $values = array(); |
155 | - $form = self::fields_to_values($form_id, $values); |
|
155 | + $form = self::fields_to_values( $form_id, $values ); |
|
156 | 156 | |
157 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/form_action.php'); |
|
157 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
|
158 | 158 | wp_die(); |
159 | 159 | } |
160 | 160 | |
@@ -165,34 +165,34 @@ discard block |
||
165 | 165 | $action_type = sanitize_text_field( $_POST['action_type'] ); |
166 | 166 | |
167 | 167 | $action_control = self::get_form_actions( $action_type ); |
168 | - if ( empty($action_control) ) { |
|
168 | + if ( empty( $action_control ) ) { |
|
169 | 169 | wp_die(); |
170 | 170 | } |
171 | 171 | |
172 | 172 | $form_action = $action_control->get_single_action( $action_key ); |
173 | 173 | |
174 | 174 | $values = array(); |
175 | - $form = self::fields_to_values($form_action->menu_order, $values); |
|
175 | + $form = self::fields_to_values( $form_action->menu_order, $values ); |
|
176 | 176 | |
177 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-form-actions/_action_inside.php'); |
|
177 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); |
|
178 | 178 | wp_die(); |
179 | 179 | } |
180 | 180 | |
181 | 181 | private static function fields_to_values( $form_id, array &$values ) { |
182 | - $form = FrmForm::getOne($form_id); |
|
182 | + $form = FrmForm::getOne( $form_id ); |
|
183 | 183 | |
184 | 184 | $values = array( 'fields' => array(), 'id' => $form->id ); |
185 | 185 | |
186 | - $fields = FrmField::get_all_for_form($form->id); |
|
186 | + $fields = FrmField::get_all_for_form( $form->id ); |
|
187 | 187 | foreach ( $fields as $k => $f ) { |
188 | 188 | $f = (array) $f; |
189 | 189 | $opts = (array) $f['field_options']; |
190 | - $f = array_merge($opts, $f); |
|
190 | + $f = array_merge( $opts, $f ); |
|
191 | 191 | if ( ! isset( $f['post_field'] ) ) { |
192 | 192 | $f['post_field'] = ''; |
193 | 193 | } |
194 | 194 | $values['fields'][] = $f; |
195 | - unset($k, $f); |
|
195 | + unset( $k, $f ); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | return $form; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $new_actions = array(); |
208 | 208 | |
209 | 209 | foreach ( $registered_actions as $registered_action ) { |
210 | - $action_ids = $registered_action->update_callback($form_id); |
|
210 | + $action_ids = $registered_action->update_callback( $form_id ); |
|
211 | 211 | if ( ! empty( $action_ids ) ) { |
212 | 212 | $new_actions[] = $action_ids; |
213 | 213 | } |
@@ -284,33 +284,33 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | // store actions so they can be triggered with the correct priority |
287 | - $stored_actions[ $action->ID ] = $action; |
|
288 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
287 | + $stored_actions[$action->ID] = $action; |
|
288 | + $action_priority[$action->ID] = $link_settings[$action->post_excerpt]->action_options['priority']; |
|
289 | 289 | |
290 | - unset($action); |
|
290 | + unset( $action ); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | if ( ! empty( $stored_actions ) ) { |
294 | - asort($action_priority); |
|
294 | + asort( $action_priority ); |
|
295 | 295 | |
296 | 296 | // make sure hooks are loaded |
297 | 297 | new FrmNotification(); |
298 | 298 | |
299 | 299 | foreach ( $action_priority as $action_id => $priority ) { |
300 | - $action = $stored_actions[ $action_id ]; |
|
301 | - do_action('frm_trigger_'. $action->post_excerpt .'_action', $action, $entry, $form, $event); |
|
302 | - do_action('frm_trigger_'. $action->post_excerpt .'_'. $event .'_action', $action, $entry, $form); |
|
300 | + $action = $stored_actions[$action_id]; |
|
301 | + do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); |
|
302 | + do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); |
|
303 | 303 | |
304 | 304 | // If post is created, get updated $entry object |
305 | 305 | if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
306 | - $entry = FrmEntry::getOne($entry->id, true); |
|
306 | + $entry = FrmEntry::getOne( $entry->id, true ); |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | 312 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
313 | - if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
313 | + if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) { |
|
314 | 314 | // continue if we know which actions to copy |
315 | 315 | return; |
316 | 316 | } |
@@ -344,22 +344,22 @@ discard block |
||
344 | 344 | } |
345 | 345 | |
346 | 346 | public function register( $action_class ) { |
347 | - $this->actions[ $action_class ] = new $action_class(); |
|
347 | + $this->actions[$action_class] = new $action_class(); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | public function unregister( $action_class ) { |
351 | - if ( isset( $this->actions[ $action_class ] ) ) { |
|
352 | - unset($this->actions[ $action_class ]); |
|
351 | + if ( isset( $this->actions[$action_class] ) ) { |
|
352 | + unset( $this->actions[$action_class] ); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
356 | 356 | public function _register_actions() { |
357 | - $keys = array_keys($this->actions); |
|
357 | + $keys = array_keys( $this->actions ); |
|
358 | 358 | |
359 | 359 | foreach ( $keys as $key ) { |
360 | 360 | // don't register new action if old action with the same id is already registered |
361 | - if ( ! isset( $this->actions[ $key ] ) ) { |
|
362 | - $this->actions[ $key ]->_register(); |
|
361 | + if ( ! isset( $this->actions[$key] ) ) { |
|
362 | + $this->actions[$key]->_register(); |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | } |
@@ -143,8 +143,8 @@ |
||
143 | 143 | add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
144 | 144 | |
145 | 145 | // Addons Controller |
146 | - add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
|
147 | - add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
|
146 | + add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
|
147 | + add_action( 'wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
|
148 | 148 | |
149 | 149 | // Fields Controller |
150 | 150 | add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
@@ -1,91 +1,91 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmHooksController { |
4 | - /** |
|
5 | - * Trigger plugin-wide hook loading |
|
6 | - */ |
|
7 | - public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
8 | - $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
9 | - |
|
10 | - $trigger_hooks = $hooks; |
|
11 | - $hooks = (array) $hooks; |
|
12 | - |
|
13 | - if ( 'load_hooks' == $trigger_hooks ) { |
|
14 | - if ( is_admin() ) { |
|
15 | - $hooks[] = 'load_admin_hooks'; |
|
16 | - if ( defined( 'DOING_AJAX' ) ) { |
|
17 | - $hooks[] = 'load_ajax_hooks'; |
|
18 | - $hooks[] = 'load_form_hooks'; |
|
19 | - } |
|
20 | - } |
|
21 | - |
|
22 | - if ( is_multisite() ) { |
|
23 | - $hooks[] = 'load_multisite_hooks'; |
|
24 | - } |
|
25 | - } else { |
|
26 | - // Make sure the hooks are only triggered once |
|
27 | - add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
28 | - } |
|
29 | - unset( $trigger_hooks ); |
|
30 | - |
|
31 | - // Instansiate Controllers |
|
32 | - foreach ( $controllers as $c ) { |
|
33 | - foreach ( $hooks as $hook ) { |
|
4 | + /** |
|
5 | + * Trigger plugin-wide hook loading |
|
6 | + */ |
|
7 | + public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
8 | + $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
9 | + |
|
10 | + $trigger_hooks = $hooks; |
|
11 | + $hooks = (array) $hooks; |
|
12 | + |
|
13 | + if ( 'load_hooks' == $trigger_hooks ) { |
|
14 | + if ( is_admin() ) { |
|
15 | + $hooks[] = 'load_admin_hooks'; |
|
16 | + if ( defined( 'DOING_AJAX' ) ) { |
|
17 | + $hooks[] = 'load_ajax_hooks'; |
|
18 | + $hooks[] = 'load_form_hooks'; |
|
19 | + } |
|
20 | + } |
|
21 | + |
|
22 | + if ( is_multisite() ) { |
|
23 | + $hooks[] = 'load_multisite_hooks'; |
|
24 | + } |
|
25 | + } else { |
|
26 | + // Make sure the hooks are only triggered once |
|
27 | + add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
28 | + } |
|
29 | + unset( $trigger_hooks ); |
|
30 | + |
|
31 | + // Instansiate Controllers |
|
32 | + foreach ( $controllers as $c ) { |
|
33 | + foreach ( $hooks as $hook ) { |
|
34 | 34 | call_user_func( array( $c, $hook ) ); |
35 | 35 | unset( $hook ); |
36 | - } |
|
36 | + } |
|
37 | 37 | unset( $c ); |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - } |
|
40 | + } |
|
41 | 41 | |
42 | - public static function trigger_load_form_hooks() { |
|
43 | - self::trigger_load_hook( 'load_form_hooks' ); |
|
44 | - } |
|
42 | + public static function trigger_load_form_hooks() { |
|
43 | + self::trigger_load_hook( 'load_form_hooks' ); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | public static function load_hooks() { |
47 | - if ( ! is_admin() ) { |
|
48 | - add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
49 | - } |
|
50 | - |
|
51 | - add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
52 | - add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
53 | - |
|
54 | - // Entries controller |
|
55 | - add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
56 | - add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
57 | - add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
58 | - add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 ); |
|
59 | - add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); |
|
60 | - |
|
61 | - // Form Actions Controller |
|
62 | - add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
47 | + if ( ! is_admin() ) { |
|
48 | + add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
49 | + } |
|
50 | + |
|
51 | + add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
52 | + add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
53 | + |
|
54 | + // Entries controller |
|
55 | + add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
56 | + add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
57 | + add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
58 | + add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 ); |
|
59 | + add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); |
|
60 | + |
|
61 | + // Form Actions Controller |
|
62 | + add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
63 | 63 | add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 ); |
64 | 64 | |
65 | - // Forms Controller |
|
66 | - add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
65 | + // Forms Controller |
|
66 | + add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
67 | 67 | add_action( 'init', 'FrmFormsController::front_head' ); |
68 | - add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
69 | - add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
70 | - add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
68 | + add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
69 | + add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
70 | + add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
71 | 71 | add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 ); |
72 | 72 | |
73 | 73 | add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' ); |
74 | 74 | |
75 | - // Form Shortcodes |
|
76 | - add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
75 | + // Form Shortcodes |
|
76 | + add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
77 | 77 | |
78 | - // Styles Controller |
|
79 | - add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
80 | - add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
81 | - add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
82 | - add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
83 | - } |
|
78 | + // Styles Controller |
|
79 | + add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
80 | + add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
81 | + add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
82 | + add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
83 | + } |
|
84 | 84 | |
85 | 85 | public static function load_admin_hooks() { |
86 | - add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
87 | - add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
88 | - add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
86 | + add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
87 | + add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
88 | + add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
89 | 89 | add_action( 'admin_init', 'FrmAppController::admin_init', 11 ); |
90 | 90 | add_filter( 'admin_body_class', 'FrmAppController::wp_admin_body_class' ); |
91 | 91 | add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' ); |
@@ -94,122 +94,122 @@ discard block |
||
94 | 94 | // Addons Controller |
95 | 95 | add_action( 'admin_menu', 'FrmAddonsController::menu', 100 ); |
96 | 96 | |
97 | - // Entries Controller |
|
98 | - add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
99 | - add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
100 | - add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
101 | - add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
102 | - add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
97 | + // Entries Controller |
|
98 | + add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
99 | + add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
100 | + add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
101 | + add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
102 | + add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
103 | 103 | |
104 | - // Fields Controller |
|
105 | - add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
104 | + // Fields Controller |
|
105 | + add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
106 | 106 | |
107 | - // Form Actions Controller |
|
108 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
109 | - add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
110 | - } |
|
111 | - add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
107 | + // Form Actions Controller |
|
108 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
109 | + add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
110 | + } |
|
111 | + add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
112 | 112 | |
113 | - // Forms Controller |
|
114 | - add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
115 | - add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
113 | + // Forms Controller |
|
114 | + add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
115 | + add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
116 | 116 | |
117 | - add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
118 | - add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
117 | + add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
118 | + add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
119 | 119 | add_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); |
120 | 120 | |
121 | - // Forms Model |
|
122 | - add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
121 | + // Forms Model |
|
122 | + add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
123 | 123 | |
124 | - // Settings Controller |
|
125 | - add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
126 | - add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
124 | + // Settings Controller |
|
125 | + add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
126 | + add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
127 | 127 | |
128 | - // Styles Controller |
|
129 | - add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
130 | - add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
128 | + // Styles Controller |
|
129 | + add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
130 | + add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
131 | 131 | |
132 | - // XML Controller |
|
133 | - add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
134 | - } |
|
132 | + // XML Controller |
|
133 | + add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
134 | + } |
|
135 | 135 | |
136 | 136 | public static function load_ajax_hooks() { |
137 | 137 | add_action( 'wp_ajax_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
138 | 138 | add_action( 'wp_ajax_nopriv_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
139 | 139 | add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' ); |
140 | - add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
141 | - add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
140 | + add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
141 | + add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
142 | 142 | |
143 | 143 | // Addons Controller |
144 | 144 | add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
145 | 145 | add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
146 | 146 | |
147 | - // Fields Controller |
|
148 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
149 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
150 | - add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' ); |
|
151 | - add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
152 | - add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
153 | - add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
154 | - add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
155 | - add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
156 | - add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); |
|
157 | - add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); |
|
158 | - add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
159 | - add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
160 | - add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
161 | - |
|
162 | - // Form Actions Controller |
|
163 | - add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
164 | - add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
165 | - |
|
166 | - // Forms Controller |
|
147 | + // Fields Controller |
|
148 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
149 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
150 | + add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' ); |
|
151 | + add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
152 | + add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
153 | + add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
154 | + add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
155 | + add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
156 | + add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); |
|
157 | + add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); |
|
158 | + add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
159 | + add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
160 | + add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
161 | + |
|
162 | + // Form Actions Controller |
|
163 | + add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
164 | + add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
165 | + |
|
166 | + // Forms Controller |
|
167 | 167 | add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' ); |
168 | 168 | add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' ); |
169 | 169 | add_action( 'wp_ajax_frm_form_key_in_place_edit', 'FrmFormsController::edit_key' ); |
170 | 170 | add_action( 'wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description' ); |
171 | - add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
172 | - add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
173 | - add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
174 | - add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
175 | - |
|
176 | - // Styles Controller |
|
177 | - add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
178 | - add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
179 | - add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
180 | - add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
171 | + add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
172 | + add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
173 | + add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
174 | + add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
175 | + |
|
176 | + // Styles Controller |
|
177 | + add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
178 | + add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
179 | + add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
180 | + add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
181 | 181 | add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' ); |
182 | 182 | add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' ); |
183 | 183 | |
184 | - // XML Controller |
|
184 | + // XML Controller |
|
185 | 185 | add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' ); |
186 | 186 | add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' ); |
187 | - add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
188 | - } |
|
187 | + add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
188 | + } |
|
189 | 189 | |
190 | 190 | public static function load_form_hooks() { |
191 | - // Fields Controller |
|
192 | - add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
193 | - add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
194 | - add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
195 | - add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
191 | + // Fields Controller |
|
192 | + add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
193 | + add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
194 | + add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
195 | + add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
196 | 196 | |
197 | 197 | // Forms Controller |
198 | 198 | add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' ); |
199 | 199 | |
200 | - // Styles Controller |
|
201 | - add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
202 | - } |
|
200 | + // Styles Controller |
|
201 | + add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
202 | + } |
|
203 | 203 | |
204 | 204 | public static function load_view_hooks() { |
205 | - // Hooks go here when a view is loaded |
|
206 | - } |
|
205 | + // Hooks go here when a view is loaded |
|
206 | + } |
|
207 | 207 | |
208 | 208 | public static function load_multisite_hooks() { |
209 | 209 | add_action( 'init', 'FrmAppController::front_head' ); |
210 | 210 | add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' ); |
211 | 211 | |
212 | - // drop tables when mu site is deleted |
|
213 | - add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
214 | - } |
|
212 | + // drop tables when mu site is deleted |
|
213 | + add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
214 | + } |
|
215 | 215 | } |
@@ -2,78 +2,78 @@ |
||
2 | 2 | |
3 | 3 | class FrmSettingsController { |
4 | 4 | |
5 | - public static function menu() { |
|
5 | + public static function menu() { |
|
6 | 6 | // Make sure admins can see the menu items |
7 | 7 | FrmAppHelper::force_capability( 'frm_change_settings' ); |
8 | 8 | |
9 | - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
|
10 | - } |
|
9 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
|
10 | + } |
|
11 | 11 | |
12 | - public static function license_box() { |
|
12 | + public static function license_box() { |
|
13 | 13 | $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); |
14 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
|
15 | - } |
|
14 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
|
15 | + } |
|
16 | 16 | |
17 | - public static function display_form( $errors = array(), $message = '' ) { |
|
18 | - global $frm_vars; |
|
17 | + public static function display_form( $errors = array(), $message = '' ) { |
|
18 | + global $frm_vars; |
|
19 | 19 | |
20 | - $frm_settings = FrmAppHelper::get_settings(); |
|
21 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
20 | + $frm_settings = FrmAppHelper::get_settings(); |
|
21 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
22 | 22 | |
23 | - $uploads = wp_upload_dir(); |
|
24 | - $target_path = $uploads['basedir'] . '/formidable/css'; |
|
23 | + $uploads = wp_upload_dir(); |
|
24 | + $target_path = $uploads['basedir'] . '/formidable/css'; |
|
25 | 25 | |
26 | 26 | $sections = array(); |
27 | 27 | if ( apply_filters( 'frm_include_addon_page', false ) ) { |
28 | 28 | $sections['licenses'] = array( 'class' => 'FrmAddonsController', 'function' => 'show_addons' ); |
29 | 29 | } |
30 | - $sections = apply_filters( 'frm_add_settings_section', $sections ); |
|
30 | + $sections = apply_filters( 'frm_add_settings_section', $sections ); |
|
31 | 31 | |
32 | - $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
|
32 | + $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
|
33 | 33 | |
34 | - require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); |
|
35 | - } |
|
34 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); |
|
35 | + } |
|
36 | 36 | |
37 | - public static function process_form( $stop_load = false ) { |
|
38 | - global $frm_vars; |
|
37 | + public static function process_form( $stop_load = false ) { |
|
38 | + global $frm_vars; |
|
39 | 39 | |
40 | - $frm_settings = FrmAppHelper::get_settings(); |
|
40 | + $frm_settings = FrmAppHelper::get_settings(); |
|
41 | 41 | |
42 | 42 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
43 | 43 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
44 | - wp_die( $frm_settings->admin_permission ); |
|
45 | - } |
|
44 | + wp_die( $frm_settings->admin_permission ); |
|
45 | + } |
|
46 | 46 | |
47 | - $errors = array(); |
|
48 | - $message = ''; |
|
47 | + $errors = array(); |
|
48 | + $message = ''; |
|
49 | 49 | |
50 | - if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { |
|
51 | - //$errors = $frm_settings->validate($_POST,array()); |
|
52 | - $frm_settings->update( stripslashes_deep( $_POST ) ); |
|
50 | + if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { |
|
51 | + //$errors = $frm_settings->validate($_POST,array()); |
|
52 | + $frm_settings->update( stripslashes_deep( $_POST ) ); |
|
53 | 53 | |
54 | - if ( empty( $errors ) ) { |
|
55 | - $frm_settings->store(); |
|
56 | - $message = __( 'Settings Saved', 'formidable' ); |
|
57 | - } |
|
58 | - } else { |
|
59 | - $message = __( 'Settings Saved', 'formidable' ); |
|
60 | - } |
|
54 | + if ( empty( $errors ) ) { |
|
55 | + $frm_settings->store(); |
|
56 | + $message = __( 'Settings Saved', 'formidable' ); |
|
57 | + } |
|
58 | + } else { |
|
59 | + $message = __( 'Settings Saved', 'formidable' ); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | if ( $stop_load == 'stop_load' ) { |
63 | - $frm_vars['settings_routed'] = true; |
|
64 | - return; |
|
65 | - } |
|
63 | + $frm_vars['settings_routed'] = true; |
|
64 | + return; |
|
65 | + } |
|
66 | 66 | |
67 | - self::display_form( $errors, $message ); |
|
68 | - } |
|
67 | + self::display_form( $errors, $message ); |
|
68 | + } |
|
69 | 69 | |
70 | - public static function route( $stop_load = false ) { |
|
71 | - $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
70 | + public static function route( $stop_load = false ) { |
|
71 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
72 | 72 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
73 | - if ( $action == 'process-form' ) { |
|
74 | - return self::process_form( $stop_load ); |
|
75 | - } else if ( $stop_load != 'stop_load' ) { |
|
76 | - return self::display_form(); |
|
77 | - } |
|
78 | - } |
|
73 | + if ( $action == 'process-form' ) { |
|
74 | + return self::process_form( $stop_load ); |
|
75 | + } else if ( $stop_load != 'stop_load' ) { |
|
76 | + return self::display_form(); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | } |
@@ -41,25 +41,25 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | public static function menu() { |
44 | - add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route'); |
|
44 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | public static function admin_init() { |
48 | - if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
48 | + if ( ! FrmAppHelper::is_admin_page( 'formidable-styles' ) ) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | 52 | self::load_pro_hooks(); |
53 | - wp_enqueue_script('jquery-ui-datepicker'); |
|
53 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
54 | 54 | |
55 | 55 | $version = FrmAppHelper::plugin_version(); |
56 | 56 | wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version ); |
57 | 57 | |
58 | - wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css'); |
|
58 | + wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' ); |
|
59 | 59 | |
60 | - $style = apply_filters('frm_style_head', false); |
|
60 | + $style = apply_filters( 'frm_style_head', false ); |
|
61 | 61 | if ( $style ) { |
62 | - wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content)); |
|
62 | + wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php' ) . '?action=frmpro_load_css&flat=1&' . http_build_query( $style->post_content ) ); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | |
130 | 130 | public static function new_style( $return = '' ) { |
131 | 131 | FrmAppHelper::update_message( __( 'create multiple styling templates', 'formidable' ), 'wrap' ); |
132 | - self::load_styler('default'); |
|
132 | + self::load_styler( 'default' ); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | public static function duplicate() { |
136 | 136 | FrmAppHelper::update_message( __( 'duplicate styling templates', 'formidable' ), 'wrap' ); |
137 | - self::load_styler('default'); |
|
137 | + self::load_styler( 'default' ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | public static function edit( $style_id = false, $message = '' ) { |
141 | 141 | if ( ! $style_id ) { |
142 | 142 | $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
143 | - if ( empty($style_id) ) { |
|
143 | + if ( empty( $style_id ) ) { |
|
144 | 144 | $style_id = 'default'; |
145 | 145 | } |
146 | 146 | } |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | if ( 'default' == $style_id ) { |
149 | 149 | $style = 'default'; |
150 | 150 | } else { |
151 | - $frm_style = new FrmStyle($style_id); |
|
151 | + $frm_style = new FrmStyle( $style_id ); |
|
152 | 152 | $style = $frm_style->get_one(); |
153 | 153 | $style = $style->ID; |
154 | 154 | } |
155 | 155 | |
156 | - self::load_styler($style, $message); |
|
156 | + self::load_styler( $style, $message ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | public static function save() { |
@@ -163,17 +163,17 @@ discard block |
||
163 | 163 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
164 | 164 | |
165 | 165 | if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
166 | - $id = $frm_style->update($post_id); |
|
167 | - if ( empty($post_id) && ! empty($id) ) { |
|
166 | + $id = $frm_style->update( $post_id ); |
|
167 | + if ( empty( $post_id ) && ! empty( $id ) ) { |
|
168 | 168 | // set the post id to the new style so it will be loaded for editing |
169 | - $post_id = reset($id); |
|
169 | + $post_id = reset( $id ); |
|
170 | 170 | } |
171 | 171 | // include the CSS that includes this style |
172 | 172 | echo '<link href="' . esc_url( admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />'; |
173 | 173 | $message = __( 'Your styling settings have been saved.', 'formidable' ); |
174 | 174 | } |
175 | 175 | |
176 | - return self::edit($post_id, $message); |
|
176 | + return self::edit( $post_id, $message ); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | public static function load_styler( $style, $message = '' ) { |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | $frm_style = new FrmStyle(); |
183 | 183 | $styles = $frm_style->get_all(); |
184 | 184 | |
185 | - if ( is_numeric($style) ) { |
|
186 | - $style = $styles[ $style ]; |
|
185 | + if ( is_numeric( $style ) ) { |
|
186 | + $style = $styles[$style]; |
|
187 | 187 | } else if ( 'default' == $style ) { |
188 | - $style = $frm_style->get_default_style($styles); |
|
188 | + $style = $frm_style->get_default_style( $styles ); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | self::add_meta_boxes(); |
192 | 192 | |
193 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php'); |
|
193 | + include( FrmAppHelper::plugin_path() . '/classes/views/styles/show.php' ); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -200,13 +200,13 @@ discard block |
||
200 | 200 | private static function manage( $message = '', $forms = array() ) { |
201 | 201 | $frm_style = new FrmStyle(); |
202 | 202 | $styles = $frm_style->get_all(); |
203 | - $default_style = $frm_style->get_default_style($styles); |
|
203 | + $default_style = $frm_style->get_default_style( $styles ); |
|
204 | 204 | |
205 | - if ( empty($forms) ) { |
|
205 | + if ( empty( $forms ) ) { |
|
206 | 206 | $forms = FrmForm::get_published_forms(); |
207 | 207 | } |
208 | 208 | |
209 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php'); |
|
209 | + include( FrmAppHelper::plugin_path() . '/classes/views/styles/manage.php' ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | private static function manage_styles() { |
@@ -219,31 +219,31 @@ discard block |
||
219 | 219 | |
220 | 220 | $forms = FrmForm::get_published_forms(); |
221 | 221 | foreach ( $forms as $form ) { |
222 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
222 | + if ( $_POST['style'][$form->id] == $_POST['prev_style'][$form->id] ) { |
|
223 | 223 | continue; |
224 | 224 | } |
225 | 225 | |
226 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
226 | + $form->options['custom_style'] = $_POST['style'][$form->id]; |
|
227 | 227 | |
228 | 228 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
229 | - unset($form); |
|
229 | + unset( $form ); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | $message = __( 'Your form styles have been saved.', 'formidable' ); |
233 | - return self::manage($message, $forms); |
|
233 | + return self::manage( $message, $forms ); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | public static function custom_css( $message = '', $style = null ) { |
237 | - wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
238 | - wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
237 | + wp_enqueue_style( 'codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css' ); |
|
238 | + wp_enqueue_script( 'codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7' ); |
|
239 | 239 | wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
240 | 240 | |
241 | - if ( ! isset($style) ) { |
|
241 | + if ( ! isset( $style ) ) { |
|
242 | 242 | $frm_style = new FrmStyle(); |
243 | 243 | $style = $frm_style->get_default_style(); |
244 | 244 | } |
245 | 245 | |
246 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php'); |
|
246 | + include( FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php' ); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | public static function save_css() { |
@@ -253,11 +253,11 @@ discard block |
||
253 | 253 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' ); |
254 | 254 | $nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' ); |
255 | 255 | if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) { |
256 | - $frm_style->update($post_id); |
|
256 | + $frm_style->update( $post_id ); |
|
257 | 257 | $message = __( 'Your styling settings have been saved.', 'formidable' ); |
258 | 258 | } |
259 | 259 | |
260 | - return self::custom_css($message); |
|
260 | + return self::custom_css( $message ); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | public static function route() { |
@@ -303,13 +303,13 @@ discard block |
||
303 | 303 | |
304 | 304 | // remove the # from the colors |
305 | 305 | foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
306 | - if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
307 | - $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
306 | + if ( ! is_array( $v ) && strpos( $v, '#' ) === 0 ) { |
|
307 | + $_GET['frm_style_setting']['post_content'][$k] = str_replace( '#', '', $v ); |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | |
311 | 311 | echo '<style type="text/css">'; |
312 | - include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
312 | + include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
|
313 | 313 | echo '</style>'; |
314 | 314 | wp_die(); |
315 | 315 | } |
@@ -331,24 +331,24 @@ discard block |
||
331 | 331 | ); |
332 | 332 | |
333 | 333 | foreach ( $meta_boxes as $nicename => $name ) { |
334 | - add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
|
335 | - unset($nicename, $name); |
|
334 | + add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
|
335 | + unset( $nicename, $name ); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | 339 | public static function include_style_section( $atts, $sec ) { |
340 | - extract($atts); |
|
340 | + extract( $atts ); |
|
341 | 341 | $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' ); |
342 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php'); |
|
342 | + include( FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php' ); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | public static function load_css() { |
346 | - header('Content-type: text/css'); |
|
346 | + header( 'Content-type: text/css' ); |
|
347 | 347 | |
348 | 348 | $frm_style = new FrmStyle(); |
349 | 349 | $defaults = $frm_style->get_defaults(); |
350 | 350 | |
351 | - include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
351 | + include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
|
352 | 352 | wp_die(); |
353 | 353 | } |
354 | 354 | |
@@ -407,11 +407,11 @@ discard block |
||
407 | 407 | $style = 'default'; |
408 | 408 | } |
409 | 409 | |
410 | - $frm_style = new FrmStyle($style); |
|
410 | + $frm_style = new FrmStyle( $style ); |
|
411 | 411 | $style = $frm_style->get_one(); |
412 | 412 | |
413 | 413 | if ( $style ) { |
414 | - $class .= ' frm_style_'. $style->post_name; |
|
414 | + $class .= ' frm_style_' . $style->post_name; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | return $class; |
@@ -421,14 +421,14 @@ discard block |
||
421 | 421 | * @param string $val |
422 | 422 | */ |
423 | 423 | public static function get_style_val( $val, $form = 'default' ) { |
424 | - $style = self::get_form_style($form); |
|
425 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
426 | - return $style->post_content[ $val ]; |
|
424 | + $style = self::get_form_style( $form ); |
|
425 | + if ( $style && isset( $style->post_content[$val] ) ) { |
|
426 | + return $style->post_content[$val]; |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | 430 | public static function show_entry_styles( $default_styles ) { |
431 | - $frm_style = new FrmStyle('default'); |
|
431 | + $frm_style = new FrmStyle( 'default' ); |
|
432 | 432 | $style = $frm_style->get_one(); |
433 | 433 | |
434 | 434 | if ( ! $style ) { |
@@ -442,15 +442,15 @@ discard block |
||
442 | 442 | } else if ( 'alt_bg_color' == $name ) { |
443 | 443 | $setting = 'bg_color_active'; |
444 | 444 | } |
445 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
446 | - unset($name, $val); |
|
445 | + $default_styles[$name] = $style->post_content[$setting]; |
|
446 | + unset( $name, $val ); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | return $default_styles; |
450 | 450 | } |
451 | 451 | |
452 | 452 | public static function &important_style( $important, $field ) { |
453 | - $important = self::get_style_val('important_style', $field['form_id']); |
|
453 | + $important = self::get_style_val( 'important_style', $field['form_id'] ); |
|
454 | 454 | return $important; |
455 | 455 | } |
456 | 456 | |
@@ -476,18 +476,18 @@ discard block |
||
476 | 476 | $i = 0; |
477 | 477 | $first_open = false; |
478 | 478 | do { |
479 | - if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
|
479 | + if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) ) { |
|
480 | 480 | break; |
481 | 481 | } |
482 | 482 | |
483 | 483 | foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
484 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
485 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
484 | + if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) { |
|
485 | + foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) { |
|
486 | 486 | if ( false == $box || ! $box['title'] ) { |
487 | 487 | continue; |
488 | 488 | } |
489 | 489 | |
490 | - $i++; |
|
490 | + $i ++; |
|
491 | 491 | $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
492 | 492 | |
493 | 493 | if ( ! $first_open && empty( $hidden_class ) ) { |
@@ -1,21 +1,21 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmStylesController { |
4 | - public static $post_type = 'frm_styles'; |
|
5 | - public static $screen = 'formidable_page_formidable-styles'; |
|
6 | - |
|
7 | - public static function load_pro_hooks() { |
|
8 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
9 | - FrmProStylesController::load_pro_hooks(); |
|
10 | - } |
|
11 | - } |
|
12 | - |
|
13 | - public static function register_post_types() { |
|
14 | - register_post_type( self::$post_type, array( |
|
15 | - 'label' => __( 'Styles', 'formidable' ), |
|
16 | - 'public' => false, |
|
17 | - 'show_ui' => false, |
|
18 | - 'capability_type' => 'page', |
|
4 | + public static $post_type = 'frm_styles'; |
|
5 | + public static $screen = 'formidable_page_formidable-styles'; |
|
6 | + |
|
7 | + public static function load_pro_hooks() { |
|
8 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
9 | + FrmProStylesController::load_pro_hooks(); |
|
10 | + } |
|
11 | + } |
|
12 | + |
|
13 | + public static function register_post_types() { |
|
14 | + register_post_type( self::$post_type, array( |
|
15 | + 'label' => __( 'Styles', 'formidable' ), |
|
16 | + 'public' => false, |
|
17 | + 'show_ui' => false, |
|
18 | + 'capability_type' => 'page', |
|
19 | 19 | 'capabilities' => array( |
20 | 20 | 'edit_post' => 'frm_change_settings', |
21 | 21 | 'edit_posts' => 'frm_change_settings', |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | 'delete_posts' => 'frm_change_settings', |
26 | 26 | 'read_private_posts' => 'read_private_posts', |
27 | 27 | ), |
28 | - 'supports' => array( |
|
28 | + 'supports' => array( |
|
29 | 29 | 'title', |
30 | - ), |
|
31 | - 'has_archive' => false, |
|
32 | - 'labels' => array( |
|
30 | + ), |
|
31 | + 'has_archive' => false, |
|
32 | + 'labels' => array( |
|
33 | 33 | 'name' => __( 'Styles', 'formidable' ), |
34 | 34 | 'singular_name' => __( 'Style', 'formidable' ), |
35 | 35 | 'menu_name' => __( 'Style', 'formidable' ), |
@@ -37,31 +37,31 @@ discard block |
||
37 | 37 | 'add_new_item' => __( 'Create a New Style', 'formidable' ), |
38 | 38 | 'edit_item' => __( 'Edit Style', 'formidable' ), |
39 | 39 | ), |
40 | - ) ); |
|
41 | - } |
|
40 | + ) ); |
|
41 | + } |
|
42 | 42 | |
43 | - public static function menu() { |
|
44 | - add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route'); |
|
45 | - } |
|
43 | + public static function menu() { |
|
44 | + add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route'); |
|
45 | + } |
|
46 | 46 | |
47 | - public static function admin_init() { |
|
48 | - if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
49 | - return; |
|
50 | - } |
|
47 | + public static function admin_init() { |
|
48 | + if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
49 | + return; |
|
50 | + } |
|
51 | 51 | |
52 | - self::load_pro_hooks(); |
|
53 | - wp_enqueue_script('jquery-ui-datepicker'); |
|
52 | + self::load_pro_hooks(); |
|
53 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
54 | 54 | |
55 | - $version = FrmAppHelper::plugin_version(); |
|
55 | + $version = FrmAppHelper::plugin_version(); |
|
56 | 56 | wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version ); |
57 | 57 | |
58 | - wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css'); |
|
58 | + wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css'); |
|
59 | 59 | |
60 | - $style = apply_filters('frm_style_head', false); |
|
61 | - if ( $style ) { |
|
62 | - wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content)); |
|
63 | - } |
|
64 | - } |
|
60 | + $style = apply_filters('frm_style_head', false); |
|
61 | + if ( $style ) { |
|
62 | + wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content)); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | 66 | public static function enqueue_css( $register = 'enqueue' ) { |
67 | 67 | global $frm_vars; |
@@ -128,229 +128,229 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | public static function new_style( $return = '' ) { |
131 | - self::load_styler('default'); |
|
132 | - } |
|
131 | + self::load_styler('default'); |
|
132 | + } |
|
133 | 133 | |
134 | 134 | public static function duplicate() { |
135 | 135 | self::load_styler('default'); |
136 | 136 | } |
137 | 137 | |
138 | 138 | public static function edit( $style_id = false, $message = '' ) { |
139 | - if ( ! $style_id ) { |
|
139 | + if ( ! $style_id ) { |
|
140 | 140 | $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
141 | - if ( empty($style_id) ) { |
|
142 | - $style_id = 'default'; |
|
143 | - } |
|
144 | - } |
|
145 | - |
|
146 | - if ( 'default' == $style_id ) { |
|
147 | - $style = 'default'; |
|
148 | - } else { |
|
149 | - $frm_style = new FrmStyle($style_id); |
|
150 | - $style = $frm_style->get_one(); |
|
151 | - $style = $style->ID; |
|
152 | - } |
|
153 | - |
|
154 | - self::load_styler($style, $message); |
|
155 | - } |
|
156 | - |
|
157 | - public static function save() { |
|
158 | - $frm_style = new FrmStyle(); |
|
159 | - $message = ''; |
|
141 | + if ( empty($style_id) ) { |
|
142 | + $style_id = 'default'; |
|
143 | + } |
|
144 | + } |
|
145 | + |
|
146 | + if ( 'default' == $style_id ) { |
|
147 | + $style = 'default'; |
|
148 | + } else { |
|
149 | + $frm_style = new FrmStyle($style_id); |
|
150 | + $style = $frm_style->get_one(); |
|
151 | + $style = $style->ID; |
|
152 | + } |
|
153 | + |
|
154 | + self::load_styler($style, $message); |
|
155 | + } |
|
156 | + |
|
157 | + public static function save() { |
|
158 | + $frm_style = new FrmStyle(); |
|
159 | + $message = ''; |
|
160 | 160 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' ); |
161 | 161 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
162 | 162 | |
163 | 163 | if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
164 | - $id = $frm_style->update($post_id); |
|
165 | - if ( empty($post_id) && ! empty($id) ) { |
|
166 | - // set the post id to the new style so it will be loaded for editing |
|
167 | - $post_id = reset($id); |
|
168 | - } |
|
169 | - // include the CSS that includes this style |
|
164 | + $id = $frm_style->update($post_id); |
|
165 | + if ( empty($post_id) && ! empty($id) ) { |
|
166 | + // set the post id to the new style so it will be loaded for editing |
|
167 | + $post_id = reset($id); |
|
168 | + } |
|
169 | + // include the CSS that includes this style |
|
170 | 170 | echo '<link href="' . esc_url( admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />'; |
171 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
172 | - } |
|
171 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
172 | + } |
|
173 | 173 | |
174 | - return self::edit($post_id, $message); |
|
175 | - } |
|
174 | + return self::edit($post_id, $message); |
|
175 | + } |
|
176 | 176 | |
177 | 177 | public static function load_styler( $style, $message = '' ) { |
178 | - global $frm_settings; |
|
178 | + global $frm_settings; |
|
179 | 179 | |
180 | - $frm_style = new FrmStyle(); |
|
181 | - $styles = $frm_style->get_all(); |
|
180 | + $frm_style = new FrmStyle(); |
|
181 | + $styles = $frm_style->get_all(); |
|
182 | 182 | |
183 | - if ( is_numeric($style) ) { |
|
184 | - $style = $styles[ $style ]; |
|
185 | - } else if ( 'default' == $style ) { |
|
186 | - $style = $frm_style->get_default_style($styles); |
|
187 | - } |
|
183 | + if ( is_numeric($style) ) { |
|
184 | + $style = $styles[ $style ]; |
|
185 | + } else if ( 'default' == $style ) { |
|
186 | + $style = $frm_style->get_default_style($styles); |
|
187 | + } |
|
188 | 188 | |
189 | - self::add_meta_boxes(); |
|
189 | + self::add_meta_boxes(); |
|
190 | 190 | |
191 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php'); |
|
192 | - } |
|
191 | + include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php'); |
|
192 | + } |
|
193 | 193 | |
194 | 194 | /** |
195 | 195 | * @param string $message |
196 | 196 | * @param array|object $forms |
197 | 197 | */ |
198 | 198 | private static function manage( $message = '', $forms = array() ) { |
199 | - $frm_style = new FrmStyle(); |
|
200 | - $styles = $frm_style->get_all(); |
|
201 | - $default_style = $frm_style->get_default_style($styles); |
|
199 | + $frm_style = new FrmStyle(); |
|
200 | + $styles = $frm_style->get_all(); |
|
201 | + $default_style = $frm_style->get_default_style($styles); |
|
202 | 202 | |
203 | - if ( empty($forms) ) { |
|
204 | - $forms = FrmForm::get_published_forms(); |
|
205 | - } |
|
203 | + if ( empty($forms) ) { |
|
204 | + $forms = FrmForm::get_published_forms(); |
|
205 | + } |
|
206 | 206 | |
207 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php'); |
|
208 | - } |
|
207 | + include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php'); |
|
208 | + } |
|
209 | 209 | |
210 | - private static function manage_styles() { |
|
210 | + private static function manage_styles() { |
|
211 | 211 | $style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' ); |
212 | 212 | if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) { |
213 | - return self::manage(); |
|
214 | - } |
|
213 | + return self::manage(); |
|
214 | + } |
|
215 | 215 | |
216 | - global $wpdb; |
|
216 | + global $wpdb; |
|
217 | 217 | |
218 | 218 | $forms = FrmForm::get_published_forms(); |
219 | - foreach ( $forms as $form ) { |
|
220 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
221 | - continue; |
|
222 | - } |
|
219 | + foreach ( $forms as $form ) { |
|
220 | + if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
221 | + continue; |
|
222 | + } |
|
223 | 223 | |
224 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
224 | + $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
225 | 225 | |
226 | 226 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
227 | - unset($form); |
|
228 | - } |
|
227 | + unset($form); |
|
228 | + } |
|
229 | 229 | |
230 | - $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
231 | - return self::manage($message, $forms); |
|
232 | - } |
|
230 | + $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
231 | + return self::manage($message, $forms); |
|
232 | + } |
|
233 | 233 | |
234 | - public static function custom_css( $message = '', $style = null ) { |
|
235 | - wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
236 | - wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
237 | - wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
234 | + public static function custom_css( $message = '', $style = null ) { |
|
235 | + wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
236 | + wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
237 | + wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
238 | 238 | |
239 | - if ( ! isset($style) ) { |
|
240 | - $frm_style = new FrmStyle(); |
|
241 | - $style = $frm_style->get_default_style(); |
|
242 | - } |
|
239 | + if ( ! isset($style) ) { |
|
240 | + $frm_style = new FrmStyle(); |
|
241 | + $style = $frm_style->get_default_style(); |
|
242 | + } |
|
243 | 243 | |
244 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php'); |
|
245 | - } |
|
244 | + include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php'); |
|
245 | + } |
|
246 | 246 | |
247 | - public static function save_css() { |
|
248 | - $frm_style = new FrmStyle(); |
|
247 | + public static function save_css() { |
|
248 | + $frm_style = new FrmStyle(); |
|
249 | 249 | |
250 | - $message = ''; |
|
250 | + $message = ''; |
|
251 | 251 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' ); |
252 | 252 | $nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' ); |
253 | 253 | if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) { |
254 | - $frm_style->update($post_id); |
|
255 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
256 | - } |
|
254 | + $frm_style->update($post_id); |
|
255 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
256 | + } |
|
257 | 257 | |
258 | - return self::custom_css($message); |
|
259 | - } |
|
258 | + return self::custom_css($message); |
|
259 | + } |
|
260 | 260 | |
261 | - public static function route() { |
|
261 | + public static function route() { |
|
262 | 262 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
263 | 263 | |
264 | - switch ( $action ) { |
|
265 | - case 'edit': |
|
266 | - case 'save': |
|
267 | - case 'manage': |
|
268 | - case 'manage_styles': |
|
269 | - case 'custom_css': |
|
270 | - case 'save_css': |
|
264 | + switch ( $action ) { |
|
265 | + case 'edit': |
|
266 | + case 'save': |
|
267 | + case 'manage': |
|
268 | + case 'manage_styles': |
|
269 | + case 'custom_css': |
|
270 | + case 'save_css': |
|
271 | 271 | return self::$action(); |
272 | - default: |
|
273 | - do_action( 'frm_style_action_route', $action ); |
|
274 | - if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
275 | - return; |
|
276 | - } |
|
277 | - |
|
278 | - if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
279 | - return self::$action(); |
|
280 | - } |
|
281 | - |
|
282 | - return self::edit(); |
|
283 | - } |
|
284 | - } |
|
285 | - |
|
286 | - public static function reset_styling() { |
|
287 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
288 | - |
|
289 | - $frm_style = new FrmStyle(); |
|
290 | - $defaults = $frm_style->get_defaults(); |
|
291 | - |
|
292 | - echo json_encode( $defaults ); |
|
293 | - wp_die(); |
|
294 | - } |
|
295 | - |
|
296 | - public static function change_styling() { |
|
297 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
298 | - |
|
299 | - $frm_style = new FrmStyle(); |
|
300 | - $defaults = $frm_style->get_defaults(); |
|
301 | - |
|
302 | - // remove the # from the colors |
|
303 | - foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
304 | - if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
305 | - $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
306 | - } |
|
307 | - } |
|
308 | - |
|
309 | - echo '<style type="text/css">'; |
|
310 | - include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
311 | - echo '</style>'; |
|
312 | - wp_die(); |
|
313 | - } |
|
314 | - |
|
315 | - private static function add_meta_boxes() { |
|
316 | - |
|
317 | - // setup meta boxes |
|
318 | - $meta_boxes = array( |
|
319 | - 'general' => __( 'General', 'formidable' ), |
|
320 | - 'form-title' => __( 'Form Title', 'formidable' ), |
|
321 | - 'form-description' => __( 'Form Description', 'formidable' ), |
|
322 | - 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
323 | - 'field-description' => __( 'Field Description', 'formidable' ), |
|
324 | - 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
325 | - 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
326 | - 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
327 | - 'section-fields' => __( 'Section Fields', 'formidable' ), |
|
328 | - 'date-fields' => __( 'Date Fields', 'formidable' ), |
|
329 | - 'buttons' => __( 'Buttons', 'formidable' ), |
|
330 | - 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
331 | - ); |
|
332 | - |
|
333 | - foreach ( $meta_boxes as $nicename => $name ) { |
|
334 | - add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
|
335 | - unset($nicename, $name); |
|
336 | - } |
|
337 | - } |
|
272 | + default: |
|
273 | + do_action( 'frm_style_action_route', $action ); |
|
274 | + if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
275 | + return; |
|
276 | + } |
|
277 | + |
|
278 | + if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
279 | + return self::$action(); |
|
280 | + } |
|
281 | + |
|
282 | + return self::edit(); |
|
283 | + } |
|
284 | + } |
|
285 | + |
|
286 | + public static function reset_styling() { |
|
287 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
288 | + |
|
289 | + $frm_style = new FrmStyle(); |
|
290 | + $defaults = $frm_style->get_defaults(); |
|
291 | + |
|
292 | + echo json_encode( $defaults ); |
|
293 | + wp_die(); |
|
294 | + } |
|
295 | + |
|
296 | + public static function change_styling() { |
|
297 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
298 | + |
|
299 | + $frm_style = new FrmStyle(); |
|
300 | + $defaults = $frm_style->get_defaults(); |
|
301 | + |
|
302 | + // remove the # from the colors |
|
303 | + foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
304 | + if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
305 | + $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
306 | + } |
|
307 | + } |
|
308 | + |
|
309 | + echo '<style type="text/css">'; |
|
310 | + include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
311 | + echo '</style>'; |
|
312 | + wp_die(); |
|
313 | + } |
|
314 | + |
|
315 | + private static function add_meta_boxes() { |
|
316 | + |
|
317 | + // setup meta boxes |
|
318 | + $meta_boxes = array( |
|
319 | + 'general' => __( 'General', 'formidable' ), |
|
320 | + 'form-title' => __( 'Form Title', 'formidable' ), |
|
321 | + 'form-description' => __( 'Form Description', 'formidable' ), |
|
322 | + 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
323 | + 'field-description' => __( 'Field Description', 'formidable' ), |
|
324 | + 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
325 | + 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
326 | + 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
327 | + 'section-fields' => __( 'Section Fields', 'formidable' ), |
|
328 | + 'date-fields' => __( 'Date Fields', 'formidable' ), |
|
329 | + 'buttons' => __( 'Buttons', 'formidable' ), |
|
330 | + 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
331 | + ); |
|
332 | + |
|
333 | + foreach ( $meta_boxes as $nicename => $name ) { |
|
334 | + add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
|
335 | + unset($nicename, $name); |
|
336 | + } |
|
337 | + } |
|
338 | 338 | |
339 | 339 | public static function include_style_section( $atts, $sec ) { |
340 | - extract($atts); |
|
340 | + extract($atts); |
|
341 | 341 | $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' ); |
342 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php'); |
|
343 | - } |
|
342 | + include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php'); |
|
343 | + } |
|
344 | 344 | |
345 | - public static function load_css() { |
|
346 | - header('Content-type: text/css'); |
|
345 | + public static function load_css() { |
|
346 | + header('Content-type: text/css'); |
|
347 | 347 | |
348 | - $frm_style = new FrmStyle(); |
|
349 | - $defaults = $frm_style->get_defaults(); |
|
348 | + $frm_style = new FrmStyle(); |
|
349 | + $defaults = $frm_style->get_defaults(); |
|
350 | 350 | |
351 | - include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
352 | - wp_die(); |
|
353 | - } |
|
351 | + include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
352 | + wp_die(); |
|
353 | + } |
|
354 | 354 | |
355 | 355 | public static function load_saved_css() { |
356 | 356 | $css = get_transient( 'frmpro_css' ); |
@@ -359,142 +359,142 @@ discard block |
||
359 | 359 | wp_die(); |
360 | 360 | } |
361 | 361 | |
362 | - /** |
|
363 | - * Check if the Formidable styling should be loaded, |
|
364 | - * then enqueue it for the footer |
|
365 | - * @since 2.0 |
|
366 | - */ |
|
367 | - public static function enqueue_style() { |
|
368 | - global $frm_vars; |
|
369 | - |
|
370 | - if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
371 | - // the CSS has already been loaded |
|
372 | - return; |
|
373 | - } |
|
374 | - |
|
375 | - $frm_settings = FrmAppHelper::get_settings(); |
|
376 | - if ( $frm_settings->load_style != 'none' ) { |
|
377 | - wp_enqueue_style( 'formidable' ); |
|
378 | - $frm_vars['css_loaded'] = true; |
|
379 | - } |
|
380 | - } |
|
381 | - |
|
382 | - // Get the stylesheets for the form settings page |
|
383 | - public static function get_style_opts() { |
|
384 | - $frm_style = new FrmStyle(); |
|
385 | - $styles = $frm_style->get_all(); |
|
386 | - |
|
387 | - return $styles; |
|
388 | - } |
|
389 | - |
|
390 | - public static function get_form_style( $form = 'default' ) { |
|
391 | - $style = FrmFormsHelper::get_form_style( $form ); |
|
392 | - |
|
393 | - if ( empty( $style ) || 1 == $style ) { |
|
394 | - $style = 'default'; |
|
395 | - } |
|
396 | - |
|
397 | - $frm_style = new FrmStyle( $style ); |
|
398 | - return $frm_style->get_one(); |
|
399 | - } |
|
400 | - |
|
401 | - /** |
|
402 | - * @param string $class |
|
403 | - * @param string $style |
|
404 | - */ |
|
362 | + /** |
|
363 | + * Check if the Formidable styling should be loaded, |
|
364 | + * then enqueue it for the footer |
|
365 | + * @since 2.0 |
|
366 | + */ |
|
367 | + public static function enqueue_style() { |
|
368 | + global $frm_vars; |
|
369 | + |
|
370 | + if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
371 | + // the CSS has already been loaded |
|
372 | + return; |
|
373 | + } |
|
374 | + |
|
375 | + $frm_settings = FrmAppHelper::get_settings(); |
|
376 | + if ( $frm_settings->load_style != 'none' ) { |
|
377 | + wp_enqueue_style( 'formidable' ); |
|
378 | + $frm_vars['css_loaded'] = true; |
|
379 | + } |
|
380 | + } |
|
381 | + |
|
382 | + // Get the stylesheets for the form settings page |
|
383 | + public static function get_style_opts() { |
|
384 | + $frm_style = new FrmStyle(); |
|
385 | + $styles = $frm_style->get_all(); |
|
386 | + |
|
387 | + return $styles; |
|
388 | + } |
|
389 | + |
|
390 | + public static function get_form_style( $form = 'default' ) { |
|
391 | + $style = FrmFormsHelper::get_form_style( $form ); |
|
392 | + |
|
393 | + if ( empty( $style ) || 1 == $style ) { |
|
394 | + $style = 'default'; |
|
395 | + } |
|
396 | + |
|
397 | + $frm_style = new FrmStyle( $style ); |
|
398 | + return $frm_style->get_one(); |
|
399 | + } |
|
400 | + |
|
401 | + /** |
|
402 | + * @param string $class |
|
403 | + * @param string $style |
|
404 | + */ |
|
405 | 405 | public static function get_form_style_class( $class, $style ) { |
406 | - if ( 1 == $style ) { |
|
407 | - $style = 'default'; |
|
408 | - } |
|
406 | + if ( 1 == $style ) { |
|
407 | + $style = 'default'; |
|
408 | + } |
|
409 | 409 | |
410 | - $frm_style = new FrmStyle($style); |
|
411 | - $style = $frm_style->get_one(); |
|
410 | + $frm_style = new FrmStyle($style); |
|
411 | + $style = $frm_style->get_one(); |
|
412 | 412 | |
413 | - if ( $style ) { |
|
414 | - $class .= ' frm_style_'. $style->post_name; |
|
415 | - } |
|
413 | + if ( $style ) { |
|
414 | + $class .= ' frm_style_'. $style->post_name; |
|
415 | + } |
|
416 | 416 | |
417 | - return $class; |
|
418 | - } |
|
417 | + return $class; |
|
418 | + } |
|
419 | 419 | |
420 | - /** |
|
421 | - * @param string $val |
|
422 | - */ |
|
420 | + /** |
|
421 | + * @param string $val |
|
422 | + */ |
|
423 | 423 | public static function get_style_val( $val, $form = 'default' ) { |
424 | - $style = self::get_form_style($form); |
|
425 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
426 | - return $style->post_content[ $val ]; |
|
427 | - } |
|
428 | - } |
|
424 | + $style = self::get_form_style($form); |
|
425 | + if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
426 | + return $style->post_content[ $val ]; |
|
427 | + } |
|
428 | + } |
|
429 | 429 | |
430 | 430 | public static function show_entry_styles( $default_styles ) { |
431 | - $frm_style = new FrmStyle('default'); |
|
432 | - $style = $frm_style->get_one(); |
|
433 | - |
|
434 | - if ( ! $style ) { |
|
435 | - return $default_styles; |
|
436 | - } |
|
437 | - |
|
438 | - foreach ( $default_styles as $name => $val ) { |
|
439 | - $setting = $name; |
|
440 | - if ( 'border_width' == $name ) { |
|
441 | - $setting = 'field_border_width'; |
|
442 | - } else if ( 'alt_bg_color' == $name ) { |
|
443 | - $setting = 'bg_color_active'; |
|
444 | - } |
|
445 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
446 | - unset($name, $val); |
|
447 | - } |
|
448 | - |
|
449 | - return $default_styles; |
|
450 | - } |
|
431 | + $frm_style = new FrmStyle('default'); |
|
432 | + $style = $frm_style->get_one(); |
|
433 | + |
|
434 | + if ( ! $style ) { |
|
435 | + return $default_styles; |
|
436 | + } |
|
437 | + |
|
438 | + foreach ( $default_styles as $name => $val ) { |
|
439 | + $setting = $name; |
|
440 | + if ( 'border_width' == $name ) { |
|
441 | + $setting = 'field_border_width'; |
|
442 | + } else if ( 'alt_bg_color' == $name ) { |
|
443 | + $setting = 'bg_color_active'; |
|
444 | + } |
|
445 | + $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
446 | + unset($name, $val); |
|
447 | + } |
|
448 | + |
|
449 | + return $default_styles; |
|
450 | + } |
|
451 | 451 | |
452 | 452 | public static function &important_style( $important, $field ) { |
453 | - $important = self::get_style_val('important_style', $field['form_id']); |
|
454 | - return $important; |
|
455 | - } |
|
453 | + $important = self::get_style_val('important_style', $field['form_id']); |
|
454 | + return $important; |
|
455 | + } |
|
456 | 456 | |
457 | - /** |
|
458 | - * Fallback for WP < 3.6 |
|
459 | - */ |
|
460 | - public static function do_accordion_sections( $screen, $context, $object ) { |
|
461 | - if ( function_exists( 'do_accordion_sections' ) ) { |
|
462 | - return do_accordion_sections( $screen, $context, $object ); |
|
463 | - } |
|
457 | + /** |
|
458 | + * Fallback for WP < 3.6 |
|
459 | + */ |
|
460 | + public static function do_accordion_sections( $screen, $context, $object ) { |
|
461 | + if ( function_exists( 'do_accordion_sections' ) ) { |
|
462 | + return do_accordion_sections( $screen, $context, $object ); |
|
463 | + } |
|
464 | 464 | |
465 | - global $wp_meta_boxes; |
|
465 | + global $wp_meta_boxes; |
|
466 | 466 | |
467 | - $screen = 'formidable_page_formidable-styles'; |
|
468 | - $screen = convert_to_screen( $screen ); |
|
467 | + $screen = 'formidable_page_formidable-styles'; |
|
468 | + $screen = convert_to_screen( $screen ); |
|
469 | 469 | |
470 | - $page = $screen->id; |
|
470 | + $page = $screen->id; |
|
471 | 471 | |
472 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
473 | - ?> |
|
472 | + $hidden = get_hidden_meta_boxes( $screen ); |
|
473 | + ?> |
|
474 | 474 | <div id="side-sortables" class="accordion-container"> |
475 | 475 | <?php |
476 | - $i = 0; |
|
477 | - $first_open = false; |
|
478 | - do { |
|
476 | + $i = 0; |
|
477 | + $first_open = false; |
|
478 | + do { |
|
479 | 479 | if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
480 | 480 | break; |
481 | 481 | } |
482 | 482 | |
483 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
484 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
485 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
486 | - if ( false == $box || ! $box['title'] ) { |
|
487 | - continue; |
|
483 | + foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
484 | + if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
485 | + foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
486 | + if ( false == $box || ! $box['title'] ) { |
|
487 | + continue; |
|
488 | 488 | } |
489 | 489 | |
490 | - $i++; |
|
491 | - $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
490 | + $i++; |
|
491 | + $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
492 | 492 | |
493 | - if ( ! $first_open && empty( $hidden_class ) ) { |
|
494 | - $first_open = true; |
|
495 | - } |
|
493 | + if ( ! $first_open && empty( $hidden_class ) ) { |
|
494 | + $first_open = true; |
|
495 | + } |
|
496 | 496 | |
497 | - ?> |
|
497 | + ?> |
|
498 | 498 | <div class="postbox <?php echo esc_attr( $box['id'] ); ?>"> |
499 | 499 | <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ) ?>"><br/></div> |
500 | 500 | <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3> |
@@ -505,13 +505,13 @@ discard block |
||
505 | 505 | </div><!-- .accordion-section-content --> |
506 | 506 | </div><!-- .postbox --> |
507 | 507 | <?php |
508 | - } |
|
509 | - } |
|
510 | - } |
|
511 | - } while ( 0 ); |
|
512 | - ?> |
|
508 | + } |
|
509 | + } |
|
510 | + } |
|
511 | + } while ( 0 ); |
|
512 | + ?> |
|
513 | 513 | </div><!-- .accordion-container --> |
514 | 514 | <?php |
515 | - return $i; |
|
516 | - } |
|
515 | + return $i; |
|
516 | + } |
|
517 | 517 | } |
@@ -121,6 +121,9 @@ |
||
121 | 121 | $stylesheet_urls['formidable'] = $url; |
122 | 122 | } |
123 | 123 | |
124 | + /** |
|
125 | + * @param string $version |
|
126 | + */ |
|
124 | 127 | private static function get_css_version( $css_key, $version ) { |
125 | 128 | if ( 'formidable' == $css_key ) { |
126 | 129 | $this_version = get_option( 'frm_last_style_update' ); |
@@ -5,68 +5,68 @@ discard block |
||
5 | 5 | |
6 | 6 | class FrmEntriesHelper { |
7 | 7 | |
8 | - public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
9 | - global $frm_vars; |
|
10 | - $values = array(); |
|
8 | + public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
9 | + global $frm_vars; |
|
10 | + $values = array(); |
|
11 | 11 | foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) { |
12 | - $values[ $var ] = FrmAppHelper::get_post_param( $var, $default ); |
|
13 | - } |
|
14 | - |
|
15 | - $values['fields'] = array(); |
|
16 | - if ( empty($fields) ) { |
|
17 | - return apply_filters('frm_setup_new_entry', $values); |
|
18 | - } |
|
19 | - |
|
20 | - foreach ( (array) $fields as $field ) { |
|
21 | - $new_value = self::get_field_value_for_new_entry( $field, $reset ); |
|
22 | - |
|
23 | - $field_array = array( |
|
24 | - 'id' => $field->id, |
|
25 | - 'value' => $new_value, |
|
26 | - 'default_value' => $field->default_value, |
|
27 | - 'name' => $field->name, |
|
28 | - 'description' => $field->description, |
|
29 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
30 | - 'options' => $field->options, |
|
31 | - 'required' => $field->required, |
|
32 | - 'field_key' => $field->field_key, |
|
33 | - 'field_order' => $field->field_order, |
|
34 | - 'form_id' => $field->form_id, |
|
12 | + $values[ $var ] = FrmAppHelper::get_post_param( $var, $default ); |
|
13 | + } |
|
14 | + |
|
15 | + $values['fields'] = array(); |
|
16 | + if ( empty($fields) ) { |
|
17 | + return apply_filters('frm_setup_new_entry', $values); |
|
18 | + } |
|
19 | + |
|
20 | + foreach ( (array) $fields as $field ) { |
|
21 | + $new_value = self::get_field_value_for_new_entry( $field, $reset ); |
|
22 | + |
|
23 | + $field_array = array( |
|
24 | + 'id' => $field->id, |
|
25 | + 'value' => $new_value, |
|
26 | + 'default_value' => $field->default_value, |
|
27 | + 'name' => $field->name, |
|
28 | + 'description' => $field->description, |
|
29 | + 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
30 | + 'options' => $field->options, |
|
31 | + 'required' => $field->required, |
|
32 | + 'field_key' => $field->field_key, |
|
33 | + 'field_order' => $field->field_order, |
|
34 | + 'form_id' => $field->form_id, |
|
35 | 35 | 'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id, |
36 | - ); |
|
36 | + ); |
|
37 | 37 | |
38 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
39 | - $opt_defaults['required_indicator'] = ''; |
|
38 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
39 | + $opt_defaults['required_indicator'] = ''; |
|
40 | 40 | $opt_defaults['original_type'] = $field->type; |
41 | 41 | |
42 | 42 | foreach ( $opt_defaults as $opt => $default_opt ) { |
43 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
44 | - unset($opt, $default_opt); |
|
45 | - } |
|
43 | + $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
44 | + unset($opt, $default_opt); |
|
45 | + } |
|
46 | 46 | |
47 | - unset($opt_defaults); |
|
47 | + unset($opt_defaults); |
|
48 | 48 | |
49 | - if ( $field_array['custom_html'] == '' ) { |
|
50 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
51 | - } |
|
49 | + if ( $field_array['custom_html'] == '' ) { |
|
50 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
51 | + } |
|
52 | 52 | |
53 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field); |
|
54 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
53 | + $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field); |
|
54 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
55 | 55 | |
56 | - $values['fields'][] = $field_array; |
|
56 | + $values['fields'][] = $field_array; |
|
57 | 57 | |
58 | - if ( ! $form || ! isset($form->id) ) { |
|
59 | - $form = FrmForm::getOne($field->form_id); |
|
60 | - } |
|
61 | - } |
|
58 | + if ( ! $form || ! isset($form->id) ) { |
|
59 | + $form = FrmForm::getOne($field->form_id); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | - $form->options = maybe_unserialize($form->options); |
|
64 | - if ( is_array($form->options) ) { |
|
65 | - foreach ( $form->options as $opt => $value ) { |
|
66 | - $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); |
|
67 | - unset($opt, $value); |
|
68 | - } |
|
69 | - } |
|
63 | + $form->options = maybe_unserialize($form->options); |
|
64 | + if ( is_array($form->options) ) { |
|
65 | + foreach ( $form->options as $opt => $value ) { |
|
66 | + $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); |
|
67 | + unset($opt, $value); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | 71 | $form_defaults = FrmFormsHelper::get_default_opts(); |
72 | 72 | |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | $values = array_merge( $form_defaults, $values ); |
77 | 77 | |
78 | 78 | return apply_filters( 'frm_setup_new_entry', $values ); |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | 81 | /** |
82 | - * Set the value for each field |
|
83 | - * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
84 | - * |
|
85 | - * @since 2.0.13 |
|
86 | - * |
|
87 | - * @param object $field - this is passed by reference since it is an object |
|
88 | - * @param boolean $reset |
|
89 | - * @return string|array $new_value |
|
90 | - */ |
|
82 | + * Set the value for each field |
|
83 | + * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
84 | + * |
|
85 | + * @since 2.0.13 |
|
86 | + * |
|
87 | + * @param object $field - this is passed by reference since it is an object |
|
88 | + * @param boolean $reset |
|
89 | + * @return string|array $new_value |
|
90 | + */ |
|
91 | 91 | private static function get_field_value_for_new_entry( $field, $reset ) { |
92 | 92 | //If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array |
93 | 93 | $return_array = FrmField::is_field_with_multiple_values( $field ); |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | |
119 | 119 | public static function setup_edit_vars( $values, $record ) { |
120 | 120 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
121 | - $values['form_id'] = $record->form_id; |
|
122 | - $values['is_draft'] = $record->is_draft; |
|
123 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
124 | - } |
|
121 | + $values['form_id'] = $record->form_id; |
|
122 | + $values['is_draft'] = $record->is_draft; |
|
123 | + return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
124 | + } |
|
125 | 125 | |
126 | - public static function get_admin_params( $form = null ) { |
|
126 | + public static function get_admin_params( $form = null ) { |
|
127 | 127 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' ); |
128 | 128 | return FrmForm::set_current_form( $form ); |
129 | - } |
|
129 | + } |
|
130 | 130 | |
131 | 131 | public static function set_current_form( $form_id ) { |
132 | 132 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' ); |
@@ -138,280 +138,280 @@ discard block |
||
138 | 138 | return FrmForm::get_current_form( $form_id ); |
139 | 139 | } |
140 | 140 | |
141 | - public static function get_current_form_id() { |
|
141 | + public static function get_current_form_id() { |
|
142 | 142 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' ); |
143 | 143 | return FrmForm::get_current_form_id(); |
144 | - } |
|
144 | + } |
|
145 | 145 | |
146 | - public static function maybe_get_entry( &$entry ) { |
|
146 | + public static function maybe_get_entry( &$entry ) { |
|
147 | 147 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' ); |
148 | 148 | FrmEntry::maybe_get_entry( $entry ); |
149 | - } |
|
149 | + } |
|
150 | 150 | |
151 | 151 | public static function replace_default_message( $message, $atts ) { |
152 | - if ( strpos($message, '[default-message') === false && |
|
153 | - strpos($message, '[default_message') === false && |
|
154 | - ! empty( $message ) ) { |
|
155 | - return $message; |
|
156 | - } |
|
157 | - |
|
158 | - if ( empty($message) ) { |
|
159 | - $message = '[default-message]'; |
|
160 | - } |
|
161 | - |
|
162 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
163 | - |
|
164 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
165 | - $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
166 | - if ( $add_atts ) { |
|
167 | - $this_atts = array_merge($atts, $add_atts); |
|
168 | - } else { |
|
169 | - $this_atts = $atts; |
|
170 | - } |
|
152 | + if ( strpos($message, '[default-message') === false && |
|
153 | + strpos($message, '[default_message') === false && |
|
154 | + ! empty( $message ) ) { |
|
155 | + return $message; |
|
156 | + } |
|
157 | + |
|
158 | + if ( empty($message) ) { |
|
159 | + $message = '[default-message]'; |
|
160 | + } |
|
161 | + |
|
162 | + preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
163 | + |
|
164 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
165 | + $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
166 | + if ( $add_atts ) { |
|
167 | + $this_atts = array_merge($atts, $add_atts); |
|
168 | + } else { |
|
169 | + $this_atts = $atts; |
|
170 | + } |
|
171 | 171 | |
172 | 172 | $default = FrmEntryFormat::show_entry( $this_atts ); |
173 | 173 | |
174 | - // Add the default message |
|
175 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
176 | - } |
|
174 | + // Add the default message |
|
175 | + $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
176 | + } |
|
177 | 177 | |
178 | - return $message; |
|
179 | - } |
|
178 | + return $message; |
|
179 | + } |
|
180 | 180 | |
181 | 181 | public static function prepare_display_value( $entry, $field, $atts ) { |
182 | 182 | $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
183 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
183 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
184 | 184 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
185 | - } |
|
185 | + } |
|
186 | 186 | |
187 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
188 | - return self::display_value($field_value, $field, $atts); |
|
189 | - } |
|
187 | + if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
188 | + return self::display_value($field_value, $field, $atts); |
|
189 | + } |
|
190 | 190 | |
191 | - // this is an embeded form |
|
192 | - $val = ''; |
|
191 | + // this is an embeded form |
|
192 | + $val = ''; |
|
193 | 193 | |
194 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
195 | - //this is a repeating section |
|
194 | + if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
195 | + //this is a repeating section |
|
196 | 196 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
197 | - } else { |
|
198 | - // get all values for this field |
|
199 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
197 | + } else { |
|
198 | + // get all values for this field |
|
199 | + $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
200 | 200 | |
201 | - if ( $child_values ) { |
|
202 | - $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
203 | - } |
|
204 | - } |
|
201 | + if ( $child_values ) { |
|
202 | + $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
203 | + } |
|
204 | + } |
|
205 | 205 | |
206 | - $field_value = array(); |
|
206 | + $field_value = array(); |
|
207 | 207 | |
208 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
209 | - return $val; |
|
210 | - } |
|
208 | + if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
209 | + return $val; |
|
210 | + } |
|
211 | 211 | |
212 | - foreach ( $child_entries as $child_entry ) { |
|
213 | - $atts['item_id'] = $child_entry->id; |
|
214 | - $atts['post_id'] = $child_entry->post_id; |
|
212 | + foreach ( $child_entries as $child_entry ) { |
|
213 | + $atts['item_id'] = $child_entry->id; |
|
214 | + $atts['post_id'] = $child_entry->post_id; |
|
215 | 215 | |
216 | - // get the value for this field -- check for post values as well |
|
217 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
216 | + // get the value for this field -- check for post values as well |
|
217 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
218 | 218 | |
219 | - if ( $entry_val ) { |
|
220 | - // foreach entry get display_value |
|
221 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
222 | - } |
|
219 | + if ( $entry_val ) { |
|
220 | + // foreach entry get display_value |
|
221 | + $field_value[] = self::display_value($entry_val, $field, $atts); |
|
222 | + } |
|
223 | 223 | |
224 | - unset($child_entry); |
|
225 | - } |
|
224 | + unset($child_entry); |
|
225 | + } |
|
226 | 226 | |
227 | - $val = implode(', ', (array) $field_value ); |
|
227 | + $val = implode(', ', (array) $field_value ); |
|
228 | 228 | $val = wp_kses_post( $val ); |
229 | 229 | |
230 | - return $val; |
|
231 | - } |
|
230 | + return $val; |
|
231 | + } |
|
232 | 232 | |
233 | - /** |
|
234 | - * Prepare the saved value for display |
|
235 | - * @return string |
|
236 | - */ |
|
233 | + /** |
|
234 | + * Prepare the saved value for display |
|
235 | + * @return string |
|
236 | + */ |
|
237 | 237 | public static function display_value( $value, $field, $atts = array() ) { |
238 | 238 | |
239 | - $defaults = array( |
|
240 | - 'type' => '', 'html' => false, 'show_filename' => true, |
|
241 | - 'truncate' => false, 'sep' => ', ', 'post_id' => 0, |
|
242 | - 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, |
|
239 | + $defaults = array( |
|
240 | + 'type' => '', 'html' => false, 'show_filename' => true, |
|
241 | + 'truncate' => false, 'sep' => ', ', 'post_id' => 0, |
|
242 | + 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, |
|
243 | 243 | 'return_array' => false, |
244 | - ); |
|
244 | + ); |
|
245 | 245 | |
246 | - $atts = wp_parse_args( $atts, $defaults ); |
|
247 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
246 | + $atts = wp_parse_args( $atts, $defaults ); |
|
247 | + $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
248 | 248 | |
249 | - if ( ! isset($field->field_options['post_field']) ) { |
|
250 | - $field->field_options['post_field'] = ''; |
|
251 | - } |
|
249 | + if ( ! isset($field->field_options['post_field']) ) { |
|
250 | + $field->field_options['post_field'] = ''; |
|
251 | + } |
|
252 | 252 | |
253 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
254 | - $field->field_options['custom_field'] = ''; |
|
255 | - } |
|
253 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
254 | + $field->field_options['custom_field'] = ''; |
|
255 | + } |
|
256 | 256 | |
257 | - if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
258 | - $atts['pre_truncate'] = $atts['truncate']; |
|
259 | - $atts['truncate'] = true; |
|
260 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
257 | + if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
258 | + $atts['pre_truncate'] = $atts['truncate']; |
|
259 | + $atts['truncate'] = true; |
|
260 | + $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
261 | 261 | |
262 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
263 | - $atts['truncate'] = $atts['pre_truncate']; |
|
264 | - } |
|
262 | + $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
263 | + $atts['truncate'] = $atts['pre_truncate']; |
|
264 | + } |
|
265 | 265 | |
266 | - if ( $value == '' ) { |
|
267 | - return $value; |
|
268 | - } |
|
266 | + if ( $value == '' ) { |
|
267 | + return $value; |
|
268 | + } |
|
269 | 269 | |
270 | - $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
270 | + $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
271 | 271 | |
272 | - $new_value = ''; |
|
272 | + $new_value = ''; |
|
273 | 273 | |
274 | - if ( is_array($value) && $atts['type'] != 'file' ) { |
|
275 | - foreach ( $value as $val ) { |
|
276 | - if ( is_array($val) ) { |
|
274 | + if ( is_array($value) && $atts['type'] != 'file' ) { |
|
275 | + foreach ( $value as $val ) { |
|
276 | + if ( is_array($val) ) { |
|
277 | 277 | //TODO: add options for display (li or ,) |
278 | - $new_value .= implode($atts['sep'], $val); |
|
279 | - if ( $atts['type'] != 'data' ) { |
|
280 | - $new_value .= '<br/>'; |
|
281 | - } |
|
282 | - } |
|
283 | - unset($val); |
|
284 | - } |
|
285 | - } |
|
286 | - |
|
287 | - if ( ! empty($new_value) ) { |
|
288 | - $value = $new_value; |
|
289 | - } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
290 | - $value = implode($atts['sep'], $value); |
|
291 | - } |
|
292 | - |
|
293 | - if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
294 | - $value = FrmAppHelper::truncate($value, 50); |
|
295 | - } |
|
278 | + $new_value .= implode($atts['sep'], $val); |
|
279 | + if ( $atts['type'] != 'data' ) { |
|
280 | + $new_value .= '<br/>'; |
|
281 | + } |
|
282 | + } |
|
283 | + unset($val); |
|
284 | + } |
|
285 | + } |
|
286 | + |
|
287 | + if ( ! empty($new_value) ) { |
|
288 | + $value = $new_value; |
|
289 | + } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
290 | + $value = implode($atts['sep'], $value); |
|
291 | + } |
|
292 | + |
|
293 | + if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
294 | + $value = FrmAppHelper::truncate($value, 50); |
|
295 | + } |
|
296 | 296 | |
297 | 297 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
298 | 298 | $value = wp_kses_post( $value ); |
299 | 299 | } |
300 | 300 | |
301 | - return apply_filters('frm_display_value', $value, $field, $atts); |
|
302 | - } |
|
301 | + return apply_filters('frm_display_value', $value, $field, $atts); |
|
302 | + } |
|
303 | 303 | |
304 | 304 | public static function set_posted_value( $field, $value, $args ) { |
305 | - // If validating a field with "other" opt, set back to prev value now |
|
306 | - if ( isset( $args['other'] ) && $args['other'] ) { |
|
307 | - $value = $args['temp_value']; |
|
308 | - } |
|
309 | - if ( empty($args['parent_field_id']) ) { |
|
310 | - $_POST['item_meta'][ $field->id ] = $value; |
|
311 | - } else { |
|
312 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
313 | - } |
|
314 | - } |
|
305 | + // If validating a field with "other" opt, set back to prev value now |
|
306 | + if ( isset( $args['other'] ) && $args['other'] ) { |
|
307 | + $value = $args['temp_value']; |
|
308 | + } |
|
309 | + if ( empty($args['parent_field_id']) ) { |
|
310 | + $_POST['item_meta'][ $field->id ] = $value; |
|
311 | + } else { |
|
312 | + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
313 | + } |
|
314 | + } |
|
315 | 315 | |
316 | 316 | public static function get_posted_value( $field, &$value, $args ) { |
317 | 317 | $field_id = is_object( $field ) ? $field->id : $field; |
318 | 318 | |
319 | - if ( empty($args['parent_field_id']) ) { |
|
320 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
321 | - } else { |
|
322 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
323 | - } |
|
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * Check if field has an "Other" option and if any other values are posted |
|
328 | - * |
|
329 | - * @since 2.0 |
|
330 | - * |
|
331 | - * @param object $field |
|
332 | - * @param string|array $value |
|
333 | - * @param array $args |
|
334 | - */ |
|
335 | - public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
336 | - $args['other'] = false; |
|
337 | - if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
338 | - return; |
|
339 | - } |
|
340 | - |
|
341 | - // Get other value for fields in repeating section |
|
342 | - self::set_other_repeating_vals( $field, $value, $args ); |
|
343 | - |
|
344 | - // Check if there are any posted "Other" values |
|
319 | + if ( empty($args['parent_field_id']) ) { |
|
320 | + $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
321 | + } else { |
|
322 | + $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
323 | + } |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * Check if field has an "Other" option and if any other values are posted |
|
328 | + * |
|
329 | + * @since 2.0 |
|
330 | + * |
|
331 | + * @param object $field |
|
332 | + * @param string|array $value |
|
333 | + * @param array $args |
|
334 | + */ |
|
335 | + public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
336 | + $args['other'] = false; |
|
337 | + if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
338 | + return; |
|
339 | + } |
|
340 | + |
|
341 | + // Get other value for fields in repeating section |
|
342 | + self::set_other_repeating_vals( $field, $value, $args ); |
|
343 | + |
|
344 | + // Check if there are any posted "Other" values |
|
345 | 345 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
346 | 346 | |
347 | - // Save original value |
|
348 | - $args['temp_value'] = $value; |
|
349 | - $args['other'] = true; |
|
350 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
351 | - |
|
352 | - // Set the validation value now |
|
353 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
354 | - } |
|
355 | - } |
|
356 | - |
|
357 | - /** |
|
358 | - * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
359 | - * |
|
360 | - * @since 2.0 |
|
361 | - * |
|
362 | - * @param object $field |
|
363 | - * @param string|array $value |
|
364 | - * @param array $args |
|
365 | - */ |
|
366 | - public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
367 | - if ( ! $args['parent_field_id'] ) { |
|
368 | - return; |
|
369 | - } |
|
370 | - |
|
371 | - // Check if there are any other posted "other" values for this field |
|
347 | + // Save original value |
|
348 | + $args['temp_value'] = $value; |
|
349 | + $args['other'] = true; |
|
350 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
351 | + |
|
352 | + // Set the validation value now |
|
353 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
354 | + } |
|
355 | + } |
|
356 | + |
|
357 | + /** |
|
358 | + * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
359 | + * |
|
360 | + * @since 2.0 |
|
361 | + * |
|
362 | + * @param object $field |
|
363 | + * @param string|array $value |
|
364 | + * @param array $args |
|
365 | + */ |
|
366 | + public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
367 | + if ( ! $args['parent_field_id'] ) { |
|
368 | + return; |
|
369 | + } |
|
370 | + |
|
371 | + // Check if there are any other posted "other" values for this field |
|
372 | 372 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
373 | - // Save original value |
|
374 | - $args['temp_value'] = $value; |
|
375 | - $args['other'] = true; |
|
376 | - |
|
377 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
378 | - |
|
379 | - // Set the validation value now |
|
380 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
381 | - } |
|
382 | - } |
|
383 | - |
|
384 | - /** |
|
385 | - * Modify value used for validation |
|
386 | - * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
387 | - * It also adds any text from the free text fields to the value |
|
388 | - * |
|
389 | - * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
390 | - * |
|
391 | - * @since 2.0 |
|
392 | - * |
|
393 | - * @param string|array $value |
|
394 | - * @param string|array $other_vals (usually of posted values) |
|
395 | - * @param object $field |
|
396 | - * @param array $args |
|
397 | - */ |
|
398 | - public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
399 | - // Checkboxes and multi-select dropdowns |
|
400 | - if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
401 | - // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
402 | - $value = array_merge( $value, $other_vals ); |
|
403 | - $value = array_filter( $value ); |
|
404 | - if ( count( $value ) == 0 ) { |
|
405 | - $value = ''; |
|
406 | - } |
|
407 | - } else { |
|
373 | + // Save original value |
|
374 | + $args['temp_value'] = $value; |
|
375 | + $args['other'] = true; |
|
376 | + |
|
377 | + $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
378 | + |
|
379 | + // Set the validation value now |
|
380 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
381 | + } |
|
382 | + } |
|
383 | + |
|
384 | + /** |
|
385 | + * Modify value used for validation |
|
386 | + * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
387 | + * It also adds any text from the free text fields to the value |
|
388 | + * |
|
389 | + * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
390 | + * |
|
391 | + * @since 2.0 |
|
392 | + * |
|
393 | + * @param string|array $value |
|
394 | + * @param string|array $other_vals (usually of posted values) |
|
395 | + * @param object $field |
|
396 | + * @param array $args |
|
397 | + */ |
|
398 | + public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
399 | + // Checkboxes and multi-select dropdowns |
|
400 | + if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
401 | + // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
402 | + $value = array_merge( $value, $other_vals ); |
|
403 | + $value = array_filter( $value ); |
|
404 | + if ( count( $value ) == 0 ) { |
|
405 | + $value = ''; |
|
406 | + } |
|
407 | + } else { |
|
408 | 408 | // Radio and dropdowns |
409 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
410 | - $other_key = reset( $other_key ); |
|
409 | + $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
410 | + $other_key = reset( $other_key ); |
|
411 | 411 | |
412 | - // Multi-select dropdown |
|
413 | - if ( is_array( $value ) ) { |
|
414 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
412 | + // Multi-select dropdown |
|
413 | + if ( is_array( $value ) ) { |
|
414 | + $o_key = array_search( $field->options[ $other_key ], $value ); |
|
415 | 415 | |
416 | 416 | if ( $o_key !== false ) { |
417 | 417 | // Modify the original value so other key will be preserved |
@@ -426,20 +426,20 @@ discard block |
||
426 | 426 | $args['temp_value'] = $value; |
427 | 427 | $value[ $other_key ] = reset( $other_vals ); |
428 | 428 | } |
429 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
430 | - $value = $other_vals; |
|
431 | - } |
|
432 | - } |
|
433 | - } |
|
429 | + } else if ( $field->options[ $other_key ] == $value ) { |
|
430 | + $value = $other_vals; |
|
431 | + } |
|
432 | + } |
|
433 | + } |
|
434 | 434 | |
435 | 435 | public static function enqueue_scripts( $params ) { |
436 | 436 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' ); |
437 | 437 | return FrmFormsController::enqueue_scripts( $params ); |
438 | 438 | } |
439 | 439 | |
440 | - // Add submitted values to a string for spam checking |
|
440 | + // Add submitted values to a string for spam checking |
|
441 | 441 | public static function entry_array_to_string( $values ) { |
442 | - $content = ''; |
|
442 | + $content = ''; |
|
443 | 443 | foreach ( $values['item_meta'] as $val ) { |
444 | 444 | if ( $content != '' ) { |
445 | 445 | $content .= "\n\n"; |
@@ -447,14 +447,14 @@ discard block |
||
447 | 447 | |
448 | 448 | if ( is_array($val) ) { |
449 | 449 | $val = FrmAppHelper::array_flatten( $val ); |
450 | - $val = implode(',', $val); |
|
450 | + $val = implode(',', $val); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | $content .= $val; |
454 | 454 | } |
455 | 455 | |
456 | 456 | return $content; |
457 | - } |
|
457 | + } |
|
458 | 458 | |
459 | 459 | public static function fill_entry_values( $atts, $f, array &$values ) { |
460 | 460 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_values' ); |
@@ -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 | |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | global $frm_vars; |
10 | 10 | $values = array(); |
11 | 11 | foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) { |
12 | - $values[ $var ] = FrmAppHelper::get_post_param( $var, $default ); |
|
12 | + $values[$var] = FrmAppHelper::get_post_param( $var, $default ); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | $values['fields'] = array(); |
16 | - if ( empty($fields) ) { |
|
17 | - return apply_filters('frm_setup_new_entry', $values); |
|
16 | + if ( empty( $fields ) ) { |
|
17 | + return apply_filters( 'frm_setup_new_entry', $values ); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | foreach ( (array) $fields as $field ) { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | 'default_value' => $field->default_value, |
27 | 27 | 'name' => $field->name, |
28 | 28 | 'description' => $field->description, |
29 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
29 | + 'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ), |
|
30 | 30 | 'options' => $field->options, |
31 | 31 | 'required' => $field->required, |
32 | 32 | 'field_key' => $field->field_key, |
@@ -35,43 +35,43 @@ discard block |
||
35 | 35 | 'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id, |
36 | 36 | ); |
37 | 37 | |
38 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
38 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
39 | 39 | $opt_defaults['required_indicator'] = ''; |
40 | 40 | $opt_defaults['original_type'] = $field->type; |
41 | 41 | |
42 | 42 | foreach ( $opt_defaults as $opt => $default_opt ) { |
43 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
44 | - unset($opt, $default_opt); |
|
43 | + $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt; |
|
44 | + unset( $opt, $default_opt ); |
|
45 | 45 | } |
46 | 46 | |
47 | - unset($opt_defaults); |
|
47 | + unset( $opt_defaults ); |
|
48 | 48 | |
49 | 49 | if ( $field_array['custom_html'] == '' ) { |
50 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
50 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type ); |
|
51 | 51 | } |
52 | 52 | |
53 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field); |
|
53 | + $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field ); |
|
54 | 54 | $field_array = array_merge( $field->field_options, $field_array ); |
55 | 55 | |
56 | 56 | $values['fields'][] = $field_array; |
57 | 57 | |
58 | - if ( ! $form || ! isset($form->id) ) { |
|
59 | - $form = FrmForm::getOne($field->form_id); |
|
58 | + if ( ! $form || ! isset( $form->id ) ) { |
|
59 | + $form = FrmForm::getOne( $field->form_id ); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | - $form->options = maybe_unserialize($form->options); |
|
64 | - if ( is_array($form->options) ) { |
|
63 | + $form->options = maybe_unserialize( $form->options ); |
|
64 | + if ( is_array( $form->options ) ) { |
|
65 | 65 | foreach ( $form->options as $opt => $value ) { |
66 | - $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); |
|
67 | - unset($opt, $value); |
|
66 | + $values[$opt] = FrmAppHelper::get_post_param( $opt, $value ); |
|
67 | + unset( $opt, $value ); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | 71 | $form_defaults = FrmFormsHelper::get_default_opts(); |
72 | 72 | |
73 | 73 | $frm_settings = FrmAppHelper::get_settings(); |
74 | - $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
74 | + $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
75 | 75 | |
76 | 76 | $values = array_merge( $form_defaults, $values ); |
77 | 77 | |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | $return_array = FrmField::is_field_with_multiple_values( $field ); |
94 | 94 | |
95 | 95 | // Do any shortcodes in default value and allow customization of default value |
96 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array); |
|
96 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array ); |
|
97 | 97 | // Calls FrmProFieldsHelper::get_default_value |
98 | 98 | |
99 | 99 | $new_value = $field->default_value; |
100 | 100 | |
101 | - if ( ! $reset && $_POST && isset( $_POST['item_meta'][ $field->id ] ) ) { |
|
101 | + if ( ! $reset && $_POST && isset( $_POST['item_meta'][$field->id] ) ) { |
|
102 | 102 | // If value was posted, get it |
103 | 103 | |
104 | - $new_value = stripslashes_deep( $_POST['item_meta'][ $field->id ] ); |
|
104 | + $new_value = stripslashes_deep( $_POST['item_meta'][$field->id] ); |
|
105 | 105 | |
106 | 106 | } else if ( FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
107 | 107 | // If clear on focus is selected, the value should be blank (unless it was posted, of course) |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | if ( ! is_array( $new_value ) ) { |
113 | - $new_value = str_replace('"', '"', $new_value); |
|
113 | + $new_value = str_replace( '"', '"', $new_value ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return $new_value; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
121 | 121 | $values['form_id'] = $record->form_id; |
122 | 122 | $values['is_draft'] = $record->is_draft; |
123 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
123 | + return apply_filters( 'frm_setup_edit_entry_vars', $values, $record ); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | public static function get_admin_params( $form = null ) { |
@@ -149,22 +149,22 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | public static function replace_default_message( $message, $atts ) { |
152 | - if ( strpos($message, '[default-message') === false && |
|
153 | - strpos($message, '[default_message') === false && |
|
152 | + if ( strpos( $message, '[default-message' ) === false && |
|
153 | + strpos( $message, '[default_message' ) === false && |
|
154 | 154 | ! empty( $message ) ) { |
155 | 155 | return $message; |
156 | 156 | } |
157 | 157 | |
158 | - if ( empty($message) ) { |
|
158 | + if ( empty( $message ) ) { |
|
159 | 159 | $message = '[default-message]'; |
160 | 160 | } |
161 | 161 | |
162 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
162 | + preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER ); |
|
163 | 163 | |
164 | 164 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
165 | - $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
165 | + $add_atts = shortcode_parse_atts( $shortcodes[2][$short_key] ); |
|
166 | 166 | if ( $add_atts ) { |
167 | - $this_atts = array_merge($atts, $add_atts); |
|
167 | + $this_atts = array_merge( $atts, $add_atts ); |
|
168 | 168 | } else { |
169 | 169 | $this_atts = $atts; |
170 | 170 | } |
@@ -172,31 +172,31 @@ discard block |
||
172 | 172 | $default = FrmEntryFormat::show_entry( $this_atts ); |
173 | 173 | |
174 | 174 | // Add the default message |
175 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
175 | + $message = str_replace( $shortcodes[0][$short_key], $default, $message ); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | return $message; |
179 | 179 | } |
180 | 180 | |
181 | 181 | public static function prepare_display_value( $entry, $field, $atts ) { |
182 | - $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
|
182 | + $field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false; |
|
183 | 183 | if ( FrmAppHelper::pro_is_installed() ) { |
184 | 184 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
185 | 185 | } |
186 | 186 | |
187 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
188 | - return self::display_value($field_value, $field, $atts); |
|
187 | + if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) { |
|
188 | + return self::display_value( $field_value, $field, $atts ); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | // this is an embeded form |
192 | 192 | $val = ''; |
193 | 193 | |
194 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
194 | + if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) { |
|
195 | 195 | //this is a repeating section |
196 | 196 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
197 | 197 | } else { |
198 | 198 | // get all values for this field |
199 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
199 | + $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false; |
|
200 | 200 | |
201 | 201 | if ( $child_values ) { |
202 | 202 | $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | $field_value = array(); |
207 | 207 | |
208 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
208 | + if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
209 | 209 | return $val; |
210 | 210 | } |
211 | 211 | |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | $atts['post_id'] = $child_entry->post_id; |
215 | 215 | |
216 | 216 | // get the value for this field -- check for post values as well |
217 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
217 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field ); |
|
218 | 218 | |
219 | 219 | if ( $entry_val ) { |
220 | 220 | // foreach entry get display_value |
221 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
221 | + $field_value[] = self::display_value( $entry_val, $field, $atts ); |
|
222 | 222 | } |
223 | 223 | |
224 | - unset($child_entry); |
|
224 | + unset( $child_entry ); |
|
225 | 225 | } |
226 | 226 | |
227 | - $val = implode(', ', (array) $field_value ); |
|
227 | + $val = implode( ', ', (array) $field_value ); |
|
228 | 228 | $val = wp_kses_post( $val ); |
229 | 229 | |
230 | 230 | return $val; |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | ); |
245 | 245 | |
246 | 246 | $atts = wp_parse_args( $atts, $defaults ); |
247 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
247 | + $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value ); |
|
248 | 248 | |
249 | - if ( ! isset($field->field_options['post_field']) ) { |
|
249 | + if ( ! isset( $field->field_options['post_field'] ) ) { |
|
250 | 250 | $field->field_options['post_field'] = ''; |
251 | 251 | } |
252 | 252 | |
253 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
253 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
254 | 254 | $field->field_options['custom_field'] = ''; |
255 | 255 | } |
256 | 256 | |
257 | 257 | if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
258 | 258 | $atts['pre_truncate'] = $atts['truncate']; |
259 | 259 | $atts['truncate'] = true; |
260 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
260 | + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0; |
|
261 | 261 | |
262 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
262 | + $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts ); |
|
263 | 263 | $atts['truncate'] = $atts['pre_truncate']; |
264 | 264 | } |
265 | 265 | |
@@ -267,38 +267,38 @@ discard block |
||
267 | 267 | return $value; |
268 | 268 | } |
269 | 269 | |
270 | - $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
270 | + $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts ); |
|
271 | 271 | |
272 | 272 | $new_value = ''; |
273 | 273 | |
274 | - if ( is_array($value) && $atts['type'] != 'file' ) { |
|
274 | + if ( is_array( $value ) && $atts['type'] != 'file' ) { |
|
275 | 275 | foreach ( $value as $val ) { |
276 | - if ( is_array($val) ) { |
|
276 | + if ( is_array( $val ) ) { |
|
277 | 277 | //TODO: add options for display (li or ,) |
278 | - $new_value .= implode($atts['sep'], $val); |
|
278 | + $new_value .= implode( $atts['sep'], $val ); |
|
279 | 279 | if ( $atts['type'] != 'data' ) { |
280 | 280 | $new_value .= '<br/>'; |
281 | 281 | } |
282 | 282 | } |
283 | - unset($val); |
|
283 | + unset( $val ); |
|
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | - if ( ! empty($new_value) ) { |
|
287 | + if ( ! empty( $new_value ) ) { |
|
288 | 288 | $value = $new_value; |
289 | - } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
290 | - $value = implode($atts['sep'], $value); |
|
289 | + } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
290 | + $value = implode( $atts['sep'], $value ); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
294 | - $value = FrmAppHelper::truncate($value, 50); |
|
294 | + $value = FrmAppHelper::truncate( $value, 50 ); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
298 | 298 | $value = wp_kses_post( $value ); |
299 | 299 | } |
300 | 300 | |
301 | - return apply_filters('frm_display_value', $value, $field, $atts); |
|
301 | + return apply_filters( 'frm_display_value', $value, $field, $atts ); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | public static function set_posted_value( $field, $value, $args ) { |
@@ -306,20 +306,20 @@ discard block |
||
306 | 306 | if ( isset( $args['other'] ) && $args['other'] ) { |
307 | 307 | $value = $args['temp_value']; |
308 | 308 | } |
309 | - if ( empty($args['parent_field_id']) ) { |
|
310 | - $_POST['item_meta'][ $field->id ] = $value; |
|
309 | + if ( empty( $args['parent_field_id'] ) ) { |
|
310 | + $_POST['item_meta'][$field->id] = $value; |
|
311 | 311 | } else { |
312 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
312 | + $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value; |
|
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
316 | 316 | public static function get_posted_value( $field, &$value, $args ) { |
317 | 317 | $field_id = is_object( $field ) ? $field->id : $field; |
318 | 318 | |
319 | - if ( empty($args['parent_field_id']) ) { |
|
320 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
319 | + if ( empty( $args['parent_field_id'] ) ) { |
|
320 | + $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : ''; |
|
321 | 321 | } else { |
322 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
322 | + $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : ''; |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | self::set_other_repeating_vals( $field, $value, $args ); |
343 | 343 | |
344 | 344 | // Check if there are any posted "Other" values |
345 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
|
345 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) { |
|
346 | 346 | |
347 | 347 | // Save original value |
348 | 348 | $args['temp_value'] = $value; |
349 | 349 | $args['other'] = true; |
350 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
350 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] ); |
|
351 | 351 | |
352 | 352 | // Set the validation value now |
353 | 353 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | } |
370 | 370 | |
371 | 371 | // Check if there are any other posted "other" values for this field |
372 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
|
372 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) { |
|
373 | 373 | // Save original value |
374 | 374 | $args['temp_value'] = $value; |
375 | 375 | $args['other'] = true; |
376 | 376 | |
377 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
377 | + $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id]; |
|
378 | 378 | |
379 | 379 | // Set the validation value now |
380 | 380 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -406,27 +406,27 @@ discard block |
||
406 | 406 | } |
407 | 407 | } else { |
408 | 408 | // Radio and dropdowns |
409 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
409 | + $other_key = array_filter( array_keys( $field->options ), 'is_string' ); |
|
410 | 410 | $other_key = reset( $other_key ); |
411 | 411 | |
412 | 412 | // Multi-select dropdown |
413 | 413 | if ( is_array( $value ) ) { |
414 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
414 | + $o_key = array_search( $field->options[$other_key], $value ); |
|
415 | 415 | |
416 | 416 | if ( $o_key !== false ) { |
417 | 417 | // Modify the original value so other key will be preserved |
418 | - $value[ $other_key ] = $value[ $o_key ]; |
|
418 | + $value[$other_key] = $value[$o_key]; |
|
419 | 419 | |
420 | 420 | // By default, the array keys will be numeric for multi-select dropdowns |
421 | 421 | // If going backwards and forwards between pages, the array key will match the other key |
422 | 422 | if ( $o_key != $other_key ) { |
423 | - unset( $value[ $o_key ] ); |
|
423 | + unset( $value[$o_key] ); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | $args['temp_value'] = $value; |
427 | - $value[ $other_key ] = reset( $other_vals ); |
|
427 | + $value[$other_key] = reset( $other_vals ); |
|
428 | 428 | } |
429 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
429 | + } else if ( $field->options[$other_key] == $value ) { |
|
430 | 430 | $value = $other_vals; |
431 | 431 | } |
432 | 432 | } |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | $content .= "\n\n"; |
446 | 446 | } |
447 | 447 | |
448 | - if ( is_array($val) ) { |
|
448 | + if ( is_array( $val ) ) { |
|
449 | 449 | $val = FrmAppHelper::array_flatten( $val ); |
450 | - $val = implode(',', $val); |
|
450 | + $val = implode( ',', $val ); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | $content .= $val; |
@@ -492,6 +492,6 @@ discard block |
||
492 | 492 | } |
493 | 493 | |
494 | 494 | public static function entries_dropdown() { |
495 | - _deprecated_function( __FUNCTION__, '1.07.09'); |
|
495 | + _deprecated_function( __FUNCTION__, '1.07.09' ); |
|
496 | 496 | } |
497 | 497 | } |
@@ -6,46 +6,46 @@ discard block |
||
6 | 6 | protected $field; |
7 | 7 | |
8 | 8 | public function prepare_items() { |
9 | - global $wpdb, $per_page; |
|
9 | + global $wpdb, $per_page; |
|
10 | 10 | |
11 | 11 | $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' ); |
12 | 12 | |
13 | - $form_id = $this->params['form']; |
|
14 | - if ( ! $form_id ) { |
|
15 | - $this->items = array(); |
|
16 | - $this->set_pagination_args( array( |
|
17 | - 'total_items' => 0, |
|
13 | + $form_id = $this->params['form']; |
|
14 | + if ( ! $form_id ) { |
|
15 | + $this->items = array(); |
|
16 | + $this->set_pagination_args( array( |
|
17 | + 'total_items' => 0, |
|
18 | 18 | 'per_page' => $per_page, |
19 | - ) ); |
|
20 | - return; |
|
21 | - } |
|
19 | + ) ); |
|
20 | + return; |
|
21 | + } |
|
22 | 22 | |
23 | 23 | $default_orderby = 'id'; |
24 | 24 | $default_order = 'DESC'; |
25 | 25 | |
26 | - $s_query = array( 'it.form_id' => $form_id ); |
|
26 | + $s_query = array( 'it.form_id' => $form_id ); |
|
27 | 27 | |
28 | 28 | $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
29 | 29 | |
30 | - if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
31 | - $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
32 | - $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid); |
|
33 | - } |
|
30 | + if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
31 | + $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
32 | + $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid); |
|
33 | + } |
|
34 | 34 | |
35 | - $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
36 | - if ( strpos($orderby, 'meta') !== false ) { |
|
37 | - $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
35 | + $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
36 | + if ( strpos($orderby, 'meta') !== false ) { |
|
37 | + $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
38 | 38 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | 41 | $order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order; |
42 | 42 | $order = ' ORDER BY ' . $orderby . ' ' . $order; |
43 | 43 | |
44 | - $page = $this->get_pagenum(); |
|
44 | + $page = $this->get_pagenum(); |
|
45 | 45 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
46 | 46 | |
47 | - $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false); |
|
48 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
47 | + $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false); |
|
48 | + $total_items = FrmEntry::getRecordCount($s_query); |
|
49 | 49 | |
50 | 50 | $this->set_pagination_args( array( |
51 | 51 | 'total_items' => $total_items, |
@@ -54,19 +54,19 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | public function no_items() { |
57 | - $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
58 | - if ( ! empty($s) ) { |
|
59 | - _e( 'No Entries Found', 'formidable' ); |
|
60 | - return; |
|
61 | - } |
|
62 | - |
|
63 | - $form_id = $form = $this->params['form']; |
|
64 | - if ( $form_id ) { |
|
65 | - $form = FrmForm::getOne($form_id); |
|
66 | - } |
|
67 | - $colspan = $this->get_column_count(); |
|
68 | - |
|
69 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php'); |
|
57 | + $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
58 | + if ( ! empty($s) ) { |
|
59 | + _e( 'No Entries Found', 'formidable' ); |
|
60 | + return; |
|
61 | + } |
|
62 | + |
|
63 | + $form_id = $form = $this->params['form']; |
|
64 | + if ( $form_id ) { |
|
65 | + $form = FrmForm::getOne($form_id); |
|
66 | + } |
|
67 | + $colspan = $this->get_column_count(); |
|
68 | + |
|
69 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | public function search_box( $text, $input_id ) { |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * Gets the name of the primary column in the Entries screen |
|
78 | - * |
|
79 | - * @since 2.0.14 |
|
80 | - * |
|
81 | - * @return string $primary_column |
|
82 | - */ |
|
77 | + * Gets the name of the primary column in the Entries screen |
|
78 | + * |
|
79 | + * @since 2.0.14 |
|
80 | + * |
|
81 | + * @return string $primary_column |
|
82 | + */ |
|
83 | 83 | protected function get_primary_column_name() { |
84 | 84 | $columns = get_column_headers( $this->screen ); |
85 | 85 | $hidden = get_hidden_columns( $this->screen ); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | $this->get_actions( $actions, $item, $view_link ); |
105 | 105 | |
106 | - $action_links = $this->row_actions( $actions ); |
|
106 | + $action_links = $this->row_actions( $actions ); |
|
107 | 107 | |
108 | 108 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
109 | 109 | $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $r = "<tr id='item-action-{$item->id}'$style>"; |
112 | 112 | |
113 | 113 | list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
114 | - $action_col = false; |
|
114 | + $action_col = false; |
|
115 | 115 | |
116 | 116 | foreach ( $columns as $column_name => $column_display_name ) { |
117 | 117 | $class = $column_name .' column-'. $column_name; |
@@ -123,14 +123,14 @@ discard block |
||
123 | 123 | if ( in_array( $column_name, $hidden ) ) { |
124 | 124 | $class .= ' frm_hidden'; |
125 | 125 | } else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) { |
126 | - $action_col = $column_name; |
|
127 | - } |
|
126 | + $action_col = $column_name; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
130 | 130 | unset($class); |
131 | 131 | $attributes .= ' data-colname="' . $column_display_name . '"'; |
132 | 132 | |
133 | - $col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name); |
|
133 | + $col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name); |
|
134 | 134 | $this->column_name = $col_name; |
135 | 135 | |
136 | 136 | switch ( $col_name ) { |
@@ -140,30 +140,30 @@ discard block |
||
140 | 140 | case 'ip': |
141 | 141 | case 'id': |
142 | 142 | case 'item_key': |
143 | - $val = $item->{$col_name}; |
|
144 | - break; |
|
143 | + $val = $item->{$col_name}; |
|
144 | + break; |
|
145 | 145 | case 'name': |
146 | 146 | case 'description': |
147 | - $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
148 | - break; |
|
147 | + $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
148 | + break; |
|
149 | 149 | case 'created_at': |
150 | 150 | case 'updated_at': |
151 | - $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
151 | + $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
152 | 152 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
153 | 153 | break; |
154 | 154 | case 'is_draft': |
155 | - $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
156 | - break; |
|
155 | + $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
156 | + break; |
|
157 | 157 | case 'form_id': |
158 | - $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
159 | - break; |
|
158 | + $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
159 | + break; |
|
160 | 160 | case 'post_id': |
161 | - $val = FrmAppHelper::post_edit_link($item->post_id); |
|
162 | - break; |
|
161 | + $val = FrmAppHelper::post_edit_link($item->post_id); |
|
162 | + break; |
|
163 | 163 | case 'user_id': |
164 | - $user = get_userdata($item->user_id); |
|
165 | - $val = $user->user_login; |
|
166 | - break; |
|
164 | + $user = get_userdata($item->user_id); |
|
165 | + $val = $user->user_login; |
|
166 | + break; |
|
167 | 167 | default: |
168 | 168 | $val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) ); |
169 | 169 | if ( $val === false ) { |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | if ( isset( $val ) ) { |
176 | - $r .= "<td $attributes>"; |
|
176 | + $r .= "<td $attributes>"; |
|
177 | 177 | if ( $column_name == $action_col ) { |
178 | 178 | $edit_link = '?page=formidable-entries&frm_action=edit&id='. $item->id; |
179 | 179 | $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; |
180 | - $r .= $action_links; |
|
180 | + $r .= $action_links; |
|
181 | 181 | } else { |
182 | - $r .= $val; |
|
183 | - } |
|
184 | - $r .= '</td>'; |
|
182 | + $r .= $val; |
|
183 | + } |
|
184 | + $r .= '</td>'; |
|
185 | 185 | } |
186 | 186 | unset($val); |
187 | 187 | } |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | return $r; |
191 | 191 | } |
192 | 192 | |
193 | - /** |
|
194 | - * @param string $view_link |
|
195 | - */ |
|
196 | - private function get_actions( &$actions, $item, $view_link ) { |
|
193 | + /** |
|
194 | + * @param string $view_link |
|
195 | + */ |
|
196 | + private function get_actions( &$actions, $item, $view_link ) { |
|
197 | 197 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">'. __( 'View', 'formidable' ) .'</a>'; |
198 | 198 | |
199 | - if ( current_user_can('frm_delete_entries') ) { |
|
200 | - $delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form']; |
|
199 | + if ( current_user_can('frm_delete_entries') ) { |
|
200 | + $delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form']; |
|
201 | 201 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
202 | - } |
|
202 | + } |
|
203 | 203 | |
204 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
205 | - } |
|
204 | + $actions = apply_filters('frm_row_actions', $actions, $item); |
|
205 | + } |
|
206 | 206 | |
207 | 207 | private function get_column_value( $item, &$val ) { |
208 | 208 | $col_name = $this->column_name; |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | |
26 | 26 | $s_query = array( 'it.form_id' => $form_id ); |
27 | 27 | |
28 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
28 | + $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; |
|
29 | 29 | |
30 | 30 | if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
31 | 31 | $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
32 | - $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid); |
|
32 | + $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
36 | - if ( strpos($orderby, 'meta') !== false ) { |
|
36 | + if ( strpos( $orderby, 'meta' ) !== false ) { |
|
37 | 37 | $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
38 | 38 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
39 | 39 | } |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | $page = $this->get_pagenum(); |
45 | 45 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
46 | 46 | |
47 | - $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false); |
|
48 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
47 | + $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false ); |
|
48 | + $total_items = FrmEntry::getRecordCount( $s_query ); |
|
49 | 49 | |
50 | 50 | $this->set_pagination_args( array( |
51 | 51 | 'total_items' => $total_items, |
@@ -55,18 +55,18 @@ discard block |
||
55 | 55 | |
56 | 56 | public function no_items() { |
57 | 57 | $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
58 | - if ( ! empty($s) ) { |
|
58 | + if ( ! empty( $s ) ) { |
|
59 | 59 | _e( 'No Entries Found', 'formidable' ); |
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | $form_id = $form = $this->params['form']; |
64 | 64 | if ( $form_id ) { |
65 | - $form = FrmForm::getOne($form_id); |
|
65 | + $form = FrmForm::getOne( $form_id ); |
|
66 | 66 | } |
67 | 67 | $colspan = $this->get_column_count(); |
68 | 68 | |
69 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php'); |
|
69 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | public function search_box( $text, $input_id ) { |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | public function single_row( $item, $style = '' ) { |
100 | 100 | // Set up the hover actions for this user |
101 | 101 | $actions = array(); |
102 | - $view_link = '?page=formidable-entries&frm_action=show&id='. $item->id; |
|
102 | + $view_link = '?page=formidable-entries&frm_action=show&id=' . $item->id; |
|
103 | 103 | |
104 | 104 | $this->get_actions( $actions, $item, $view_link ); |
105 | 105 | |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | |
111 | 111 | $r = "<tr id='item-action-{$item->id}'$style>"; |
112 | 112 | |
113 | - list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
|
113 | + list( $columns, $hidden,, $primary ) = $this->get_column_info(); |
|
114 | 114 | $action_col = false; |
115 | 115 | |
116 | 116 | foreach ( $columns as $column_name => $column_display_name ) { |
117 | - $class = $column_name .' column-'. $column_name; |
|
117 | + $class = $column_name . ' column-' . $column_name; |
|
118 | 118 | |
119 | 119 | if ( $column_name === $primary ) { |
120 | 120 | $class .= ' column-primary'; |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
130 | - unset($class); |
|
131 | - $attributes .= ' data-colname="' . $column_display_name . '"'; |
|
130 | + unset( $class ); |
|
131 | + $attributes .= ' data-colname="' . $column_display_name . '"'; |
|
132 | 132 | |
133 | - $col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name); |
|
133 | + $col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name ); |
|
134 | 134 | $this->column_name = $col_name; |
135 | 135 | |
136 | 136 | switch ( $col_name ) { |
@@ -144,24 +144,24 @@ discard block |
||
144 | 144 | break; |
145 | 145 | case 'name': |
146 | 146 | case 'description': |
147 | - $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
147 | + $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 ); |
|
148 | 148 | break; |
149 | 149 | case 'created_at': |
150 | 150 | case 'updated_at': |
151 | - $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
151 | + $date = FrmAppHelper::get_formatted_time( $item->{$col_name}); |
|
152 | 152 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
153 | 153 | break; |
154 | 154 | case 'is_draft': |
155 | - $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
155 | + $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' ); |
|
156 | 156 | break; |
157 | 157 | case 'form_id': |
158 | - $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
158 | + $val = FrmFormsHelper::edit_form_link( $item->form_id ); |
|
159 | 159 | break; |
160 | 160 | case 'post_id': |
161 | - $val = FrmAppHelper::post_edit_link($item->post_id); |
|
161 | + $val = FrmAppHelper::post_edit_link( $item->post_id ); |
|
162 | 162 | break; |
163 | 163 | case 'user_id': |
164 | - $user = get_userdata($item->user_id); |
|
164 | + $user = get_userdata( $item->user_id ); |
|
165 | 165 | $val = $user->user_login; |
166 | 166 | break; |
167 | 167 | default: |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | if ( isset( $val ) ) { |
176 | 176 | $r .= "<td $attributes>"; |
177 | 177 | if ( $column_name == $action_col ) { |
178 | - $edit_link = '?page=formidable-entries&frm_action=edit&id='. $item->id; |
|
178 | + $edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id; |
|
179 | 179 | $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; |
180 | 180 | $r .= $action_links; |
181 | 181 | } else { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | $r .= '</td>'; |
185 | 185 | } |
186 | - unset($val); |
|
186 | + unset( $val ); |
|
187 | 187 | } |
188 | 188 | $r .= '</tr>'; |
189 | 189 | |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | * @param string $view_link |
195 | 195 | */ |
196 | 196 | private function get_actions( &$actions, $item, $view_link ) { |
197 | - $actions['view'] = '<a href="' . esc_url( $view_link ) . '">'. __( 'View', 'formidable' ) .'</a>'; |
|
197 | + $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
|
198 | 198 | |
199 | - if ( current_user_can('frm_delete_entries') ) { |
|
200 | - $delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form']; |
|
199 | + if ( current_user_can( 'frm_delete_entries' ) ) { |
|
200 | + $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
|
201 | 201 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
202 | 202 | } |
203 | 203 | |
204 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
204 | + $actions = apply_filters( 'frm_row_actions', $actions, $item ); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | private function get_column_value( $item, &$val ) { |