@@ -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,11 +23,11 @@ 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() { |
@@ -54,7 +54,7 @@ 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 ) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | public static function get_affiliate() { |
69 | - $affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') ); |
|
69 | + $affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) ); |
|
70 | 70 | $affiliate_id = strtolower( $affiliate_id ); |
71 | 71 | $allowed_affiliates = array( 'mojo' ); |
72 | 72 | if ( ! in_array( $affiliate_id, $allowed_affiliates ) ) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function get_settings() { |
87 | 87 | global $frm_settings; |
88 | - if ( empty($frm_settings) ) { |
|
88 | + if ( empty( $frm_settings ) ) { |
|
89 | 89 | $frm_settings = new FrmSettings(); |
90 | 90 | } |
91 | 91 | return $frm_settings; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | public static function pro_is_installed() { |
109 | - return apply_filters('frm_pro_installed', false); |
|
109 | + return apply_filters( 'frm_pro_installed', false ); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return boolean |
151 | 151 | */ |
152 | 152 | public static function doing_ajax() { |
153 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
153 | + return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page(); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @return boolean |
171 | 171 | */ |
172 | 172 | public static function is_admin() { |
173 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
173 | + return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @return string |
197 | 197 | */ |
198 | 198 | public static function get_server_value( $value ) { |
199 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
199 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
212 | 212 | 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
213 | 213 | ) as $key ) { |
214 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
214 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
215 | 215 | continue; |
216 | 216 | } |
217 | 217 | |
218 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
219 | - $ip = trim($ip); // just to be safe |
|
218 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
219 | + $ip = trim( $ip ); // just to be safe |
|
220 | 220 | |
221 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
221 | + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
|
222 | 222 | return $ip; |
223 | 223 | } |
224 | 224 | } |
@@ -228,15 +228,15 @@ discard block |
||
228 | 228 | } |
229 | 229 | |
230 | 230 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
231 | - if ( strpos($param, '[') ) { |
|
232 | - $params = explode('[', $param); |
|
231 | + if ( strpos( $param, '[' ) ) { |
|
232 | + $params = explode( '[', $param ); |
|
233 | 233 | $param = $params[0]; |
234 | 234 | } |
235 | 235 | |
236 | 236 | if ( $src == 'get' ) { |
237 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
238 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
239 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
237 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); |
|
238 | + if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { |
|
239 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) ); |
|
240 | 240 | } |
241 | 241 | self::sanitize_value( $sanitize, $value ); |
242 | 242 | } else { |
@@ -245,12 +245,12 @@ discard block |
||
245 | 245 | |
246 | 246 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
247 | 247 | foreach ( $params as $k => $p ) { |
248 | - if ( ! $k || ! is_array($value) ) { |
|
248 | + if ( ! $k || ! is_array( $value ) ) { |
|
249 | 249 | continue; |
250 | 250 | } |
251 | 251 | |
252 | - $p = trim($p, ']'); |
|
253 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
252 | + $p = trim( $p, ']' ); |
|
253 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
@@ -292,16 +292,16 @@ discard block |
||
292 | 292 | |
293 | 293 | $value = $args['default']; |
294 | 294 | if ( $args['type'] == 'get' ) { |
295 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
296 | - $value = $_GET[ $args['param'] ]; |
|
295 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
296 | + $value = $_GET[$args['param']]; |
|
297 | 297 | } |
298 | 298 | } else if ( $args['type'] == 'post' ) { |
299 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
300 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
299 | + if ( isset( $_POST[$args['param']] ) ) { |
|
300 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
301 | 301 | } |
302 | 302 | } else { |
303 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
304 | - $value = $_REQUEST[ $args['param'] ]; |
|
303 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
304 | + $value = $_REQUEST[$args['param']]; |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | if ( is_array( $value ) ) { |
330 | 330 | $temp_values = $value; |
331 | 331 | foreach ( $temp_values as $k => $v ) { |
332 | - FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] ); |
|
332 | + FrmAppHelper::sanitize_value( $sanitize, $value[$k] ); |
|
333 | 333 | } |
334 | 334 | } else { |
335 | 335 | $value = call_user_func( $sanitize, $value ); |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | public static function sanitize_request( $sanitize_method, &$values ) { |
341 | 341 | $temp_values = $values; |
342 | 342 | foreach ( $temp_values as $k => $val ) { |
343 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
344 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
343 | + if ( isset( $sanitize_method[$k] ) ) { |
|
344 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | public static function sanitize_array( &$values ) { |
350 | 350 | $temp_values = $values; |
351 | 351 | foreach ( $temp_values as $k => $val ) { |
352 | - $values[ $k ] = wp_kses_post( $val ); |
|
352 | + $values[$k] = wp_kses_post( $val ); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | |
370 | 370 | $allowed_html = array(); |
371 | 371 | foreach ( $allowed as $a ) { |
372 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
372 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | return wp_kses( $value, $allowed_html ); |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @since 2.0 |
381 | 381 | */ |
382 | 382 | public static function remove_get_action() { |
383 | - if ( ! isset($_GET) ) { |
|
383 | + if ( ! isset( $_GET ) ) { |
|
384 | 384 | return; |
385 | 385 | } |
386 | 386 | |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | } |
403 | 403 | |
404 | 404 | global $wp_query; |
405 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
406 | - $value = $wp_query->query_vars[ $param ]; |
|
405 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
406 | + $value = $wp_query->query_vars[$param]; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | return $value; |
@@ -432,16 +432,16 @@ discard block |
||
432 | 432 | * @return mixed $results The cache or query results |
433 | 433 | */ |
434 | 434 | public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
435 | - $results = wp_cache_get($cache_key, $group); |
|
436 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
435 | + $results = wp_cache_get( $cache_key, $group ); |
|
436 | + if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) { |
|
437 | 437 | return $results; |
438 | 438 | } |
439 | 439 | |
440 | 440 | if ( 'get_posts' == $type ) { |
441 | - $results = get_posts($query); |
|
441 | + $results = get_posts( $query ); |
|
442 | 442 | } else { |
443 | 443 | global $wpdb; |
444 | - $results = $wpdb->{$type}($query); |
|
444 | + $results = $wpdb->{$type}( $query ); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | if ( ! self::prevent_caching() ) { |
@@ -465,9 +465,9 @@ discard block |
||
465 | 465 | } |
466 | 466 | |
467 | 467 | // then check the transient |
468 | - $results = get_transient($cache_key); |
|
468 | + $results = get_transient( $cache_key ); |
|
469 | 469 | if ( $results ) { |
470 | - wp_cache_set($cache_key, $results); |
|
470 | + wp_cache_set( $cache_key, $results ); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | return $results; |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * @param string $cache_key |
479 | 479 | */ |
480 | 480 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
481 | - delete_transient($cache_key); |
|
481 | + delete_transient( $cache_key ); |
|
482 | 482 | wp_cache_delete( $cache_key, $group ); |
483 | 483 | } |
484 | 484 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | global $wp_object_cache; |
495 | 495 | |
496 | 496 | if ( is_callable( array( $wp_object_cache, '__get' ) ) ) { |
497 | - $group_cache = $wp_object_cache->__get('cache'); |
|
497 | + $group_cache = $wp_object_cache->__get( 'cache' ); |
|
498 | 498 | } elseif ( is_callable( array( $wp_object_cache, 'redis_status' ) ) && $wp_object_cache->redis_status() ) { |
499 | 499 | // check if the object cache is overridden by Redis |
500 | 500 | $wp_object_cache->flush(); |
@@ -504,8 +504,8 @@ discard block |
||
504 | 504 | $group_cache = $wp_object_cache->cache; |
505 | 505 | } |
506 | 506 | |
507 | - if ( isset( $group_cache[ $group ] ) ) { |
|
508 | - foreach ( $group_cache[ $group ] as $k => $v ) { |
|
507 | + if ( isset( $group_cache[$group] ) ) { |
|
508 | + foreach ( $group_cache[$group] as $k => $v ) { |
|
509 | 509 | wp_cache_delete( $k, $group ); |
510 | 510 | } |
511 | 511 | return true; |
@@ -535,17 +535,17 @@ discard block |
||
535 | 535 | } |
536 | 536 | |
537 | 537 | public static function get_pages() { |
538 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
538 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
542 | 542 | $pages = self::get_pages(); |
543 | 543 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
544 | 544 | ?> |
545 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
545 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
546 | 546 | <option value=""> </option> |
547 | 547 | <?php foreach ( $pages as $page ) { ?> |
548 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
548 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
549 | 549 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
550 | 550 | </option> |
551 | 551 | <?php } ?> |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | } |
555 | 555 | |
556 | 556 | public static function post_edit_link( $post_id ) { |
557 | - $post = get_post($post_id); |
|
557 | + $post = get_post( $post_id ); |
|
558 | 558 | if ( $post ) { |
559 | 559 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
560 | 560 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
@@ -564,17 +564,17 @@ discard block |
||
564 | 564 | |
565 | 565 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
566 | 566 | ?> |
567 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
|
567 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php |
|
568 | 568 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
569 | 569 | ?> class="frm_multiselect"> |
570 | - <?php self::roles_options($capability); ?> |
|
570 | + <?php self::roles_options( $capability ); ?> |
|
571 | 571 | </select> |
572 | 572 | <?php |
573 | 573 | } |
574 | 574 | |
575 | 575 | public static function roles_options( $capability ) { |
576 | 576 | global $frm_vars; |
577 | - if ( isset($frm_vars['editable_roles']) ) { |
|
577 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
578 | 578 | $editable_roles = $frm_vars['editable_roles']; |
579 | 579 | } else { |
580 | 580 | $editable_roles = get_editable_roles(); |
@@ -582,10 +582,10 @@ discard block |
||
582 | 582 | } |
583 | 583 | |
584 | 584 | foreach ( $editable_roles as $role => $details ) { |
585 | - $name = translate_user_role($details['name'] ); ?> |
|
586 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
585 | + $name = translate_user_role( $details['name'] ); ?> |
|
586 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
587 | 587 | <?php |
588 | - unset($role, $details); |
|
588 | + unset( $role, $details ); |
|
589 | 589 | } |
590 | 590 | } |
591 | 591 | |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | public static function maybe_add_permissions() { |
642 | 642 | self::force_capability( 'frm_view_entries' ); |
643 | 643 | |
644 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
644 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
645 | 645 | return; |
646 | 646 | } |
647 | 647 | |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | $frm_roles = self::frm_capabilities(); |
651 | 651 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
652 | 652 | $user->add_cap( $frm_role ); |
653 | - unset($frm_role, $frm_role_description); |
|
653 | + unset( $frm_role, $frm_role_description ); |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | |
@@ -675,12 +675,12 @@ discard block |
||
675 | 675 | * @param string $permission |
676 | 676 | */ |
677 | 677 | public static function permission_check( $permission, $show_message = 'show' ) { |
678 | - $permission_error = self::permission_nonce_error($permission); |
|
678 | + $permission_error = self::permission_nonce_error( $permission ); |
|
679 | 679 | if ( $permission_error !== false ) { |
680 | 680 | if ( 'hide' == $show_message ) { |
681 | 681 | $permission_error = ''; |
682 | 682 | } |
683 | - wp_die($permission_error); |
|
683 | + wp_die( $permission_error ); |
|
684 | 684 | } |
685 | 685 | } |
686 | 686 | |
@@ -697,11 +697,11 @@ discard block |
||
697 | 697 | } |
698 | 698 | |
699 | 699 | $error = false; |
700 | - if ( empty($nonce_name) ) { |
|
700 | + if ( empty( $nonce_name ) ) { |
|
701 | 701 | return $error; |
702 | 702 | } |
703 | 703 | |
704 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
704 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
705 | 705 | $frm_settings = self::get_settings(); |
706 | 706 | $error = $frm_settings->admin_permission; |
707 | 707 | } |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | } else { |
782 | 782 | foreach ( $value as $k => $v ) { |
783 | 783 | if ( ! is_array( $v ) ) { |
784 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
784 | + $value[$k] = call_user_func( $original_function, $v ); |
|
785 | 785 | } |
786 | 786 | } |
787 | 787 | } |
@@ -802,11 +802,11 @@ discard block |
||
802 | 802 | public static function array_flatten( $array, $keys = 'keep' ) { |
803 | 803 | $return = array(); |
804 | 804 | foreach ( $array as $key => $value ) { |
805 | - if ( is_array($value) ) { |
|
805 | + if ( is_array( $value ) ) { |
|
806 | 806 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
807 | 807 | } else { |
808 | 808 | if ( $keys == 'keep' ) { |
809 | - $return[ $key ] = $value; |
|
809 | + $return[$key] = $value; |
|
810 | 810 | } else { |
811 | 811 | $return[] = $value; |
812 | 812 | } |
@@ -829,8 +829,8 @@ discard block |
||
829 | 829 | * @since 2.0 |
830 | 830 | */ |
831 | 831 | public static function use_wpautop( $content ) { |
832 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
833 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
832 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
833 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
834 | 834 | } |
835 | 835 | return $content; |
836 | 836 | } |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | * @return string The base Google APIS url for the current version of jQuery UI |
849 | 849 | */ |
850 | 850 | public static function jquery_ui_base_url() { |
851 | - $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core'); |
|
852 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
851 | + $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' ); |
|
852 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
853 | 853 | return $url; |
854 | 854 | } |
855 | 855 | |
@@ -864,11 +864,11 @@ discard block |
||
864 | 864 | |
865 | 865 | $ver = 0; |
866 | 866 | |
867 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
867 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
868 | 868 | return $ver; |
869 | 869 | } |
870 | 870 | |
871 | - $query = $wp_scripts->registered[ $handle ]; |
|
871 | + $query = $wp_scripts->registered[$handle]; |
|
872 | 872 | if ( is_object( $query ) ) { |
873 | 873 | $ver = $query->ver; |
874 | 874 | } |
@@ -881,36 +881,36 @@ discard block |
||
881 | 881 | } |
882 | 882 | |
883 | 883 | public static function get_user_id_param( $user_id ) { |
884 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
884 | + if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
|
885 | 885 | return $user_id; |
886 | 886 | } |
887 | 887 | |
888 | 888 | if ( $user_id == 'current' ) { |
889 | 889 | $user_id = get_current_user_id(); |
890 | 890 | } else { |
891 | - if ( is_email($user_id) ) { |
|
892 | - $user = get_user_by('email', $user_id); |
|
891 | + if ( is_email( $user_id ) ) { |
|
892 | + $user = get_user_by( 'email', $user_id ); |
|
893 | 893 | } else { |
894 | - $user = get_user_by('login', $user_id); |
|
894 | + $user = get_user_by( 'login', $user_id ); |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | if ( $user ) { |
898 | 898 | $user_id = $user->ID; |
899 | 899 | } |
900 | - unset($user); |
|
900 | + unset( $user ); |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | return $user_id; |
904 | 904 | } |
905 | 905 | |
906 | 906 | public static function get_file_contents( $filename, $atts = array() ) { |
907 | - if ( ! is_file($filename) ) { |
|
907 | + if ( ! is_file( $filename ) ) { |
|
908 | 908 | return false; |
909 | 909 | } |
910 | 910 | |
911 | - extract($atts); |
|
911 | + extract( $atts ); |
|
912 | 912 | ob_start(); |
913 | - include($filename); |
|
913 | + include( $filename ); |
|
914 | 914 | $contents = ob_get_contents(); |
915 | 915 | ob_end_clean(); |
916 | 916 | return $contents; |
@@ -926,28 +926,28 @@ discard block |
||
926 | 926 | $key = ''; |
927 | 927 | |
928 | 928 | if ( ! empty( $name ) ) { |
929 | - $key = sanitize_key($name); |
|
929 | + $key = sanitize_key( $name ); |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | if ( empty( $key ) ) { |
933 | - $max_slug_value = pow(36, $num_chars); |
|
933 | + $max_slug_value = pow( 36, $num_chars ); |
|
934 | 934 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
935 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
935 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
936 | 936 | } |
937 | 937 | |
938 | - if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
938 | + if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
939 | 939 | $key = $key . 'a'; |
940 | 940 | } |
941 | 941 | |
942 | 942 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
943 | 943 | |
944 | - if ( $key_check || is_numeric($key_check) ) { |
|
944 | + if ( $key_check || is_numeric( $key_check ) ) { |
|
945 | 945 | $suffix = 2; |
946 | 946 | do { |
947 | 947 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
948 | 948 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
949 | - $suffix++; |
|
950 | - } while ($key_check || is_numeric($key_check)); |
|
949 | + $suffix ++; |
|
950 | + } while ( $key_check || is_numeric( $key_check ) ); |
|
951 | 951 | $key = $alt_post_name; |
952 | 952 | } |
953 | 953 | return $key; |
@@ -963,32 +963,32 @@ discard block |
||
963 | 963 | return false; |
964 | 964 | } |
965 | 965 | |
966 | - if ( empty($post_values) ) { |
|
967 | - $post_values = stripslashes_deep($_POST); |
|
966 | + if ( empty( $post_values ) ) { |
|
967 | + $post_values = stripslashes_deep( $_POST ); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | $values = array( 'id' => $record->id, 'fields' => array() ); |
971 | 971 | |
972 | 972 | foreach ( array( 'name', 'description' ) as $var ) { |
973 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
974 | - $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
975 | - unset($var, $default_val); |
|
973 | + $default_val = isset( $record->{$var}) ? $record->{$var} : ''; |
|
974 | + $values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
975 | + unset( $var, $default_val ); |
|
976 | 976 | } |
977 | 977 | |
978 | - $values['description'] = self::use_wpautop($values['description']); |
|
978 | + $values['description'] = self::use_wpautop( $values['description'] ); |
|
979 | 979 | $frm_settings = self::get_settings(); |
980 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
980 | + $is_form_builder = self::is_admin_page( 'formidable' ); |
|
981 | 981 | |
982 | 982 | foreach ( (array) $fields as $field ) { |
983 | 983 | // Make sure to filter default values (for placeholder text), but not on the form builder page |
984 | 984 | if ( ! $is_form_builder ) { |
985 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
985 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
|
986 | 986 | } |
987 | 987 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
988 | - self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
988 | + self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
989 | 989 | } |
990 | 990 | |
991 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
991 | + self::fill_form_opts( $record, $table, $post_values, $values ); |
|
992 | 992 | |
993 | 993 | if ( $table == 'entries' ) { |
994 | 994 | $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
@@ -1005,8 +1005,8 @@ discard block |
||
1005 | 1005 | if ( $args['default'] ) { |
1006 | 1006 | $meta_value = $field->default_value; |
1007 | 1007 | } else { |
1008 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1009 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
1008 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
|
1009 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
1010 | 1010 | $field->field_options['custom_field'] = ''; |
1011 | 1011 | } |
1012 | 1012 | $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 ) ); |
@@ -1015,8 +1015,8 @@ discard block |
||
1015 | 1015 | } |
1016 | 1016 | } |
1017 | 1017 | |
1018 | - $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
|
1019 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1018 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
1019 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
1020 | 1020 | |
1021 | 1021 | $field_array = array( |
1022 | 1022 | 'id' => $field->id, |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | 'default_value' => $field->default_value, |
1025 | 1025 | 'name' => $field->name, |
1026 | 1026 | 'description' => $field->description, |
1027 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1027 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), |
|
1028 | 1028 | 'options' => $field->options, |
1029 | 1029 | 'required' => $field->required, |
1030 | 1030 | 'field_key' => $field->field_key, |
@@ -1034,40 +1034,40 @@ discard block |
||
1034 | 1034 | ); |
1035 | 1035 | |
1036 | 1036 | $args['field_type'] = $field_type; |
1037 | - self::fill_field_opts($field, $field_array, $args); |
|
1037 | + self::fill_field_opts( $field, $field_array, $args ); |
|
1038 | 1038 | // Track the original field's type |
1039 | 1039 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
1040 | 1040 | |
1041 | 1041 | $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
1042 | 1042 | |
1043 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1043 | + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
|
1044 | 1044 | $field_array['unique_msg'] = ''; |
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | $field_array = array_merge( $field->field_options, $field_array ); |
1048 | 1048 | |
1049 | - $values['fields'][ $field->id ] = $field_array; |
|
1049 | + $values['fields'][$field->id] = $field_array; |
|
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1053 | 1053 | $post_values = $args['post_values']; |
1054 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1054 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
1055 | 1055 | |
1056 | 1056 | foreach ( $opt_defaults as $opt => $default_opt ) { |
1057 | - $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 ); |
|
1058 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1059 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1060 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1057 | + $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 ); |
|
1058 | + if ( $opt == 'blank' && $field_array[$opt] == '' ) { |
|
1059 | + $field_array[$opt] = $args['frm_settings']->blank_msg; |
|
1060 | + } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { |
|
1061 | 1061 | if ( $args['field_type'] == 'captcha' ) { |
1062 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1062 | + $field_array[$opt] = $args['frm_settings']->re_msg; |
|
1063 | 1063 | } else { |
1064 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1064 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1065 | 1065 | } |
1066 | 1066 | } |
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | if ( $field_array['custom_html'] == '' ) { |
1070 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1070 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); |
|
1071 | 1071 | } |
1072 | 1072 | } |
1073 | 1073 | |
@@ -1086,18 +1086,18 @@ discard block |
||
1086 | 1086 | return; |
1087 | 1087 | } |
1088 | 1088 | |
1089 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1089 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
|
1090 | 1090 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1091 | 1091 | |
1092 | - if ( ! is_array($form->options) ) { |
|
1092 | + if ( ! is_array( $form->options ) ) { |
|
1093 | 1093 | return; |
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | foreach ( $form->options as $opt => $value ) { |
1097 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1097 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | - self::fill_form_defaults($post_values, $values); |
|
1100 | + self::fill_form_defaults( $post_values, $values ); |
|
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | /** |
@@ -1107,23 +1107,23 @@ discard block |
||
1107 | 1107 | $form_defaults = FrmFormsHelper::get_default_opts(); |
1108 | 1108 | |
1109 | 1109 | foreach ( $form_defaults as $opt => $default ) { |
1110 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1111 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
1110 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
1111 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | - unset($opt, $defaut); |
|
1114 | + unset( $opt, $defaut ); |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | - if ( ! isset($values['custom_style']) ) { |
|
1117 | + if ( ! isset( $values['custom_style'] ) ) { |
|
1118 | 1118 | $frm_settings = self::get_settings(); |
1119 | 1119 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1123 | - if ( ! isset( $values[ $h . '_html' ] ) ) { |
|
1124 | - $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1123 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
1124 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
1125 | 1125 | } |
1126 | - unset($h); |
|
1126 | + unset( $h ); |
|
1127 | 1127 | } |
1128 | 1128 | } |
1129 | 1129 | |
@@ -1139,9 +1139,9 @@ discard block |
||
1139 | 1139 | } |
1140 | 1140 | ?> |
1141 | 1141 | <li> |
1142 | - <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> |
|
1143 | - <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> |
|
1144 | - <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> |
|
1142 | + <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> |
|
1143 | + <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> |
|
1144 | + <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> |
|
1145 | 1145 | </li> |
1146 | 1146 | <?php |
1147 | 1147 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | return ''; |
1160 | 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 : ''); |
|
1162 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
|
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | $sub = ''; |
@@ -1168,23 +1168,23 @@ discard block |
||
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) ) { |
|
1173 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
1174 | 1174 | break; |
1175 | 1175 | } |
1176 | 1176 | |
1177 | 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 ) { |
|
1180 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
1181 | 1181 | break; |
1182 | 1182 | } |
1183 | 1183 | |
1184 | - unset($total_len, $word); |
|
1184 | + unset( $total_len, $word ); |
|
1185 | 1185 | } |
1186 | 1186 | |
1187 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1187 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | public static function mb_function( $function_names, $args ) { |
@@ -1197,17 +1197,17 @@ discard block |
||
1197 | 1197 | } |
1198 | 1198 | |
1199 | 1199 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1200 | - if ( empty($date) ) { |
|
1200 | + if ( empty( $date ) ) { |
|
1201 | 1201 | return $date; |
1202 | 1202 | } |
1203 | 1203 | |
1204 | - if ( empty($date_format) ) { |
|
1205 | - $date_format = get_option('date_format'); |
|
1204 | + if ( empty( $date_format ) ) { |
|
1205 | + $date_format = get_option( 'date_format' ); |
|
1206 | 1206 | } |
1207 | 1207 | |
1208 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1208 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
1209 | 1209 | $frmpro_settings = new FrmProSettings(); |
1210 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1210 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
1211 | 1211 | } |
1212 | 1212 | |
1213 | 1213 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | |
1223 | 1223 | private static function add_time_to_date( $time_format, $date ) { |
1224 | 1224 | if ( empty( $time_format ) ) { |
1225 | - $time_format = get_option('time_format'); |
|
1225 | + $time_format = get_option( 'time_format' ); |
|
1226 | 1226 | } |
1227 | 1227 | |
1228 | 1228 | $trimmed_format = trim( $time_format ); |
@@ -1268,10 +1268,10 @@ discard block |
||
1268 | 1268 | $time_strings = self::get_time_strings(); |
1269 | 1269 | |
1270 | 1270 | foreach ( $time_strings as $k => $v ) { |
1271 | - if ( $diff[ $k ] ) { |
|
1272 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); |
|
1271 | + if ( $diff[$k] ) { |
|
1272 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); |
|
1273 | 1273 | } else { |
1274 | - unset( $time_strings[ $k ] ); |
|
1274 | + unset( $time_strings[$k] ); |
|
1275 | 1275 | } |
1276 | 1276 | } |
1277 | 1277 | |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | */ |
1310 | 1310 | public static function esc_like( $term ) { |
1311 | 1311 | global $wpdb; |
1312 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1312 | + if ( method_exists( $wpdb, 'esc_like' ) ) { |
|
1313 | 1313 | // WP 4.0 |
1314 | 1314 | $term = $wpdb->esc_like( $term ); |
1315 | 1315 | } else { |
@@ -1323,17 +1323,17 @@ discard block |
||
1323 | 1323 | * @param string $order_query |
1324 | 1324 | */ |
1325 | 1325 | public static function esc_order( $order_query ) { |
1326 | - if ( empty($order_query) ) { |
|
1326 | + if ( empty( $order_query ) ) { |
|
1327 | 1327 | return ''; |
1328 | 1328 | } |
1329 | 1329 | |
1330 | 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); |
|
1331 | + $order_query = strtolower( $order_query ); |
|
1332 | + if ( strpos( $order_query, 'order by' ) !== false ) { |
|
1333 | + $order_query = str_replace( 'order by', '', $order_query ); |
|
1334 | 1334 | } |
1335 | 1335 | |
1336 | - $order_query = explode(' ', trim($order_query)); |
|
1336 | + $order_query = explode( ' ', trim( $order_query ) ); |
|
1337 | 1337 | |
1338 | 1338 | $order_fields = array( |
1339 | 1339 | 'id', 'form_key', 'name', 'description', |
@@ -1341,13 +1341,13 @@ discard block |
||
1341 | 1341 | 'default_template', 'status', 'created_at', |
1342 | 1342 | ); |
1343 | 1343 | |
1344 | - $order = trim(trim(reset($order_query), ',')); |
|
1345 | - if ( ! in_array($order, $order_fields) ) { |
|
1344 | + $order = trim( trim( reset( $order_query ), ',' ) ); |
|
1345 | + if ( ! in_array( $order, $order_fields ) ) { |
|
1346 | 1346 | return ''; |
1347 | 1347 | } |
1348 | 1348 | |
1349 | 1349 | $order_by = ''; |
1350 | - if ( count($order_query) > 1 ) { |
|
1350 | + if ( count( $order_query ) > 1 ) { |
|
1351 | 1351 | $order_by = end( $order_query ); |
1352 | 1352 | self::esc_order_by( $order_by ); |
1353 | 1353 | } |
@@ -1369,23 +1369,23 @@ discard block |
||
1369 | 1369 | * @param string $limit |
1370 | 1370 | */ |
1371 | 1371 | public static function esc_limit( $limit ) { |
1372 | - if ( empty($limit) ) { |
|
1372 | + if ( empty( $limit ) ) { |
|
1373 | 1373 | return ''; |
1374 | 1374 | } |
1375 | 1375 | |
1376 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1377 | - if ( is_numeric($limit) ) { |
|
1376 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); |
|
1377 | + if ( is_numeric( $limit ) ) { |
|
1378 | 1378 | return ' LIMIT ' . $limit; |
1379 | 1379 | } |
1380 | 1380 | |
1381 | - $limit = explode(',', trim($limit)); |
|
1381 | + $limit = explode( ',', trim( $limit ) ); |
|
1382 | 1382 | foreach ( $limit as $k => $l ) { |
1383 | 1383 | if ( is_numeric( $l ) ) { |
1384 | - $limit[ $k ] = $l; |
|
1384 | + $limit[$k] = $l; |
|
1385 | 1385 | } |
1386 | 1386 | } |
1387 | 1387 | |
1388 | - $limit = implode(',', $limit); |
|
1388 | + $limit = implode( ',', $limit ); |
|
1389 | 1389 | return ' LIMIT ' . $limit; |
1390 | 1390 | } |
1391 | 1391 | |
@@ -1394,12 +1394,12 @@ discard block |
||
1394 | 1394 | * @since 2.0 |
1395 | 1395 | */ |
1396 | 1396 | public static function prepare_array_values( $array, $type = '%s' ) { |
1397 | - $placeholders = array_fill(0, count($array), $type); |
|
1398 | - return implode(', ', $placeholders); |
|
1397 | + $placeholders = array_fill( 0, count( $array ), $type ); |
|
1398 | + return implode( ', ', $placeholders ); |
|
1399 | 1399 | } |
1400 | 1400 | |
1401 | 1401 | public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
1402 | - if ( empty($where) ) { |
|
1402 | + if ( empty( $where ) ) { |
|
1403 | 1403 | return ''; |
1404 | 1404 | } |
1405 | 1405 | |
@@ -1440,19 +1440,19 @@ discard block |
||
1440 | 1440 | public static function json_to_array( $json_vars ) { |
1441 | 1441 | $vars = array(); |
1442 | 1442 | foreach ( $json_vars as $jv ) { |
1443 | - $jv_name = explode('[', $jv['name']); |
|
1444 | - $last = count($jv_name) - 1; |
|
1443 | + $jv_name = explode( '[', $jv['name'] ); |
|
1444 | + $last = count( $jv_name ) - 1; |
|
1445 | 1445 | foreach ( $jv_name as $p => $n ) { |
1446 | - $name = trim($n, ']'); |
|
1447 | - if ( ! isset($l1) ) { |
|
1446 | + $name = trim( $n, ']' ); |
|
1447 | + if ( ! isset( $l1 ) ) { |
|
1448 | 1448 | $l1 = $name; |
1449 | 1449 | } |
1450 | 1450 | |
1451 | - if ( ! isset($l2) ) { |
|
1451 | + if ( ! isset( $l2 ) ) { |
|
1452 | 1452 | $l2 = $name; |
1453 | 1453 | } |
1454 | 1454 | |
1455 | - if ( ! isset($l3) ) { |
|
1455 | + if ( ! isset( $l3 ) ) { |
|
1456 | 1456 | $l3 = $name; |
1457 | 1457 | } |
1458 | 1458 | |
@@ -1466,24 +1466,24 @@ discard block |
||
1466 | 1466 | |
1467 | 1467 | case 1: |
1468 | 1468 | $l2 = $name; |
1469 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1469 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
1470 | 1470 | break; |
1471 | 1471 | |
1472 | 1472 | case 2: |
1473 | 1473 | $l3 = $name; |
1474 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1474 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
1475 | 1475 | break; |
1476 | 1476 | |
1477 | 1477 | case 3: |
1478 | 1478 | $l4 = $name; |
1479 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1479 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
1480 | 1480 | break; |
1481 | 1481 | } |
1482 | 1482 | |
1483 | - unset($this_val, $n); |
|
1483 | + unset( $this_val, $n ); |
|
1484 | 1484 | } |
1485 | 1485 | |
1486 | - unset($last, $jv); |
|
1486 | + unset( $last, $jv ); |
|
1487 | 1487 | } |
1488 | 1488 | |
1489 | 1489 | return $vars; |
@@ -1496,8 +1496,8 @@ discard block |
||
1496 | 1496 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
1497 | 1497 | if ( $name == '' ) { |
1498 | 1498 | $vars[] = $val; |
1499 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1500 | - $vars[ $l1 ] = $val; |
|
1499 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
1500 | + $vars[$l1] = $val; |
|
1501 | 1501 | } |
1502 | 1502 | } |
1503 | 1503 | |
@@ -1512,7 +1512,7 @@ discard block |
||
1512 | 1512 | '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() ) ), |
1513 | 1513 | ); |
1514 | 1514 | |
1515 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1515 | + if ( ! isset( $tooltips[$name] ) ) { |
|
1516 | 1516 | return; |
1517 | 1517 | } |
1518 | 1518 | |
@@ -1522,7 +1522,7 @@ discard block |
||
1522 | 1522 | echo ' class="frm_help"'; |
1523 | 1523 | } |
1524 | 1524 | |
1525 | - echo ' title="' . esc_attr( $tooltips[ $name ] ); |
|
1525 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
1526 | 1526 | |
1527 | 1527 | if ( 'open' != $class ) { |
1528 | 1528 | echo '"'; |
@@ -1574,13 +1574,13 @@ discard block |
||
1574 | 1574 | } |
1575 | 1575 | |
1576 | 1576 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1577 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
1577 | + if ( ! isset( $post_content[$key] ) ) { |
|
1578 | 1578 | return; |
1579 | 1579 | } |
1580 | 1580 | |
1581 | 1581 | if ( is_array( $val ) ) { |
1582 | 1582 | foreach ( $val as $k1 => $v1 ) { |
1583 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
1583 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
1584 | 1584 | unset( $k1, $v1 ); |
1585 | 1585 | } |
1586 | 1586 | } else { |
@@ -1588,7 +1588,7 @@ discard block |
||
1588 | 1588 | $val = stripslashes( $val ); |
1589 | 1589 | |
1590 | 1590 | // Add backslashes before double quotes and forward slashes only |
1591 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
1591 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
1592 | 1592 | } |
1593 | 1593 | } |
1594 | 1594 | |
@@ -1605,7 +1605,7 @@ discard block |
||
1605 | 1605 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); |
1606 | 1606 | |
1607 | 1607 | if ( empty( $settings['ID'] ) ) { |
1608 | - unset( $settings['ID']); |
|
1608 | + unset( $settings['ID'] ); |
|
1609 | 1609 | } |
1610 | 1610 | |
1611 | 1611 | // delete all caches for this group |
@@ -1639,17 +1639,17 @@ discard block |
||
1639 | 1639 | } |
1640 | 1640 | |
1641 | 1641 | public static function maybe_json_decode( $string ) { |
1642 | - if ( is_array($string) ) { |
|
1642 | + if ( is_array( $string ) ) { |
|
1643 | 1643 | return $string; |
1644 | 1644 | } |
1645 | 1645 | |
1646 | - $new_string = json_decode($string, true); |
|
1647 | - if ( function_exists('json_last_error') ) { |
|
1646 | + $new_string = json_decode( $string, true ); |
|
1647 | + if ( function_exists( 'json_last_error' ) ) { |
|
1648 | 1648 | // php 5.3+ |
1649 | 1649 | if ( json_last_error() == JSON_ERROR_NONE ) { |
1650 | 1650 | $string = $new_string; |
1651 | 1651 | } |
1652 | - } else if ( isset($new_string) ) { |
|
1652 | + } else if ( isset( $new_string ) ) { |
|
1653 | 1653 | // php < 5.3 fallback |
1654 | 1654 | $string = $new_string; |
1655 | 1655 | } |
@@ -1665,11 +1665,11 @@ discard block |
||
1665 | 1665 | public static function maybe_highlight_menu( $post_type ) { |
1666 | 1666 | global $post; |
1667 | 1667 | |
1668 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1668 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
1669 | 1669 | return; |
1670 | 1670 | } |
1671 | 1671 | |
1672 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1672 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
1673 | 1673 | return; |
1674 | 1674 | } |
1675 | 1675 | |
@@ -1768,11 +1768,11 @@ discard block |
||
1768 | 1768 | $frm_version = self::plugin_version(); |
1769 | 1769 | |
1770 | 1770 | // check if Formidable meets minimum requirements |
1771 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1771 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
1772 | 1772 | return; |
1773 | 1773 | } |
1774 | 1774 | |
1775 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1775 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
1776 | 1776 | 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">' . |
1777 | 1777 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
1778 | 1778 | '</div></td></tr>'; |
@@ -1780,38 +1780,38 @@ discard block |
||
1780 | 1780 | |
1781 | 1781 | public static function locales( $type = 'date' ) { |
1782 | 1782 | $locales = array( |
1783 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1784 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1785 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1783 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1784 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1785 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1786 | 1786 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
1787 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1788 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1787 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1788 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1789 | 1789 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
1790 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1791 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1790 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1791 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1792 | 1792 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
1793 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1793 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1794 | 1794 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
1795 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1795 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1796 | 1796 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
1797 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1797 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1798 | 1798 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
1799 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1800 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1801 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1802 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1803 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1799 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1800 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1801 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1802 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1803 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1804 | 1804 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
1805 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1805 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1806 | 1806 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
1807 | 1807 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
1808 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1808 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1809 | 1809 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
1810 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1810 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1811 | 1811 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
1812 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1813 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1814 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1812 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1813 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1814 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1815 | 1815 | ); |
1816 | 1816 | |
1817 | 1817 | if ( $type == 'captcha' ) { |
@@ -1830,8 +1830,8 @@ discard block |
||
1830 | 1830 | ); |
1831 | 1831 | } |
1832 | 1832 | |
1833 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1834 | - $locales = apply_filters('frm_locales', $locales); |
|
1833 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
1834 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
1835 | 1835 | |
1836 | 1836 | return $locales; |
1837 | 1837 | } |