@@ -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 ) { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | public static function get_affiliate() { |
69 | 69 | return ''; |
70 | - $affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') ); |
|
70 | + $affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) ); |
|
71 | 71 | $affiliate_id = strtolower( $affiliate_id ); |
72 | 72 | $allowed_affiliates = array(); |
73 | 73 | if ( ! in_array( $affiliate_id, $allowed_affiliates ) ) { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public static function get_settings() { |
88 | 88 | global $frm_settings; |
89 | - if ( empty($frm_settings) ) { |
|
89 | + if ( empty( $frm_settings ) ) { |
|
90 | 90 | $frm_settings = new FrmSettings(); |
91 | 91 | } |
92 | 92 | return $frm_settings; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | public static function pro_is_installed() { |
110 | - return apply_filters('frm_pro_installed', false); |
|
110 | + return apply_filters( 'frm_pro_installed', false ); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @return boolean |
152 | 152 | */ |
153 | 153 | public static function doing_ajax() { |
154 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
154 | + return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page(); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @return boolean |
172 | 172 | */ |
173 | 173 | public static function is_admin() { |
174 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
174 | + return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @return string |
199 | 199 | */ |
200 | 200 | public static function get_server_value( $value ) { |
201 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
201 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
214 | 214 | 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
215 | 215 | ) as $key ) { |
216 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
216 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
217 | 217 | continue; |
218 | 218 | } |
219 | 219 | |
220 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
221 | - $ip = trim($ip); // just to be safe |
|
220 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
221 | + $ip = trim( $ip ); // just to be safe |
|
222 | 222 | |
223 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
223 | + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
|
224 | 224 | return $ip; |
225 | 225 | } |
226 | 226 | } |
@@ -230,15 +230,15 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
233 | - if ( strpos($param, '[') ) { |
|
234 | - $params = explode('[', $param); |
|
233 | + if ( strpos( $param, '[' ) ) { |
|
234 | + $params = explode( '[', $param ); |
|
235 | 235 | $param = $params[0]; |
236 | 236 | } |
237 | 237 | |
238 | 238 | if ( $src == 'get' ) { |
239 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
240 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
241 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
239 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); |
|
240 | + if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { |
|
241 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) ); |
|
242 | 242 | } |
243 | 243 | self::sanitize_value( $sanitize, $value ); |
244 | 244 | } else { |
@@ -247,12 +247,12 @@ discard block |
||
247 | 247 | |
248 | 248 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
249 | 249 | foreach ( $params as $k => $p ) { |
250 | - if ( ! $k || ! is_array($value) ) { |
|
250 | + if ( ! $k || ! is_array( $value ) ) { |
|
251 | 251 | continue; |
252 | 252 | } |
253 | 253 | |
254 | - $p = trim($p, ']'); |
|
255 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
254 | + $p = trim( $p, ']' ); |
|
255 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
@@ -291,16 +291,16 @@ discard block |
||
291 | 291 | |
292 | 292 | $value = $args['default']; |
293 | 293 | if ( $args['type'] == 'get' ) { |
294 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
295 | - $value = $_GET[ $args['param'] ]; |
|
294 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
295 | + $value = $_GET[$args['param']]; |
|
296 | 296 | } |
297 | 297 | } else if ( $args['type'] == 'post' ) { |
298 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
299 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
298 | + if ( isset( $_POST[$args['param']] ) ) { |
|
299 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
300 | 300 | } |
301 | 301 | } else { |
302 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
303 | - $value = $_REQUEST[ $args['param'] ]; |
|
302 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
303 | + $value = $_REQUEST[$args['param']]; |
|
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | if ( is_array( $value ) ) { |
329 | 329 | $temp_values = $value; |
330 | 330 | foreach ( $temp_values as $k => $v ) { |
331 | - FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] ); |
|
331 | + FrmAppHelper::sanitize_value( $sanitize, $value[$k] ); |
|
332 | 332 | } |
333 | 333 | } else { |
334 | 334 | $value = call_user_func( $sanitize, $value ); |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | public static function sanitize_request( $sanitize_method, &$values ) { |
340 | 340 | $temp_values = $values; |
341 | 341 | foreach ( $temp_values as $k => $val ) { |
342 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
343 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
342 | + if ( isset( $sanitize_method[$k] ) ) { |
|
343 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | public static function sanitize_array( &$values ) { |
349 | 349 | $temp_values = $values; |
350 | 350 | foreach ( $temp_values as $k => $val ) { |
351 | - $values[ $k ] = wp_kses_post( $val ); |
|
351 | + $values[$k] = wp_kses_post( $val ); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | |
372 | 372 | $allowed_html = array(); |
373 | 373 | foreach ( $allowed as $a ) { |
374 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
374 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | return wp_kses( $value, $allowed_html ); |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * @since 2.0 |
383 | 383 | */ |
384 | 384 | public static function remove_get_action() { |
385 | - if ( ! isset($_GET) ) { |
|
385 | + if ( ! isset( $_GET ) ) { |
|
386 | 386 | return; |
387 | 387 | } |
388 | 388 | |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | } |
405 | 405 | |
406 | 406 | global $wp_query; |
407 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
408 | - $value = $wp_query->query_vars[ $param ]; |
|
407 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
408 | + $value = $wp_query->query_vars[$param]; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | return $value; |
@@ -434,19 +434,19 @@ discard block |
||
434 | 434 | * @return mixed $results The cache or query results |
435 | 435 | */ |
436 | 436 | public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
437 | - $results = wp_cache_get($cache_key, $group); |
|
438 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
437 | + $results = wp_cache_get( $cache_key, $group ); |
|
438 | + if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) { |
|
439 | 439 | return $results; |
440 | 440 | } |
441 | 441 | |
442 | 442 | if ( 'get_posts' == $type ) { |
443 | - $results = get_posts($query); |
|
443 | + $results = get_posts( $query ); |
|
444 | 444 | } else if ( 'get_associative_results' == $type ) { |
445 | 445 | global $wpdb; |
446 | 446 | $results = $wpdb->get_results( $query, OBJECT_K ); |
447 | 447 | } else { |
448 | 448 | global $wpdb; |
449 | - $results = $wpdb->{$type}($query); |
|
449 | + $results = $wpdb->{$type}( $query ); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | self::set_cache( $cache_key, $results, $group, $time ); |
@@ -493,9 +493,9 @@ discard block |
||
493 | 493 | } |
494 | 494 | |
495 | 495 | // then check the transient |
496 | - $results = get_transient($cache_key); |
|
496 | + $results = get_transient( $cache_key ); |
|
497 | 497 | if ( $results ) { |
498 | - wp_cache_set($cache_key, $results); |
|
498 | + wp_cache_set( $cache_key, $results ); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | return $results; |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * @param string $cache_key |
507 | 507 | */ |
508 | 508 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
509 | - delete_transient($cache_key); |
|
509 | + delete_transient( $cache_key ); |
|
510 | 510 | wp_cache_delete( $cache_key, $group ); |
511 | 511 | } |
512 | 512 | |
@@ -525,8 +525,8 @@ discard block |
||
525 | 525 | $group => $cached_keys, |
526 | 526 | ); |
527 | 527 | |
528 | - if ( isset( $group_cache[ $group ] ) ) { |
|
529 | - foreach ( $group_cache[ $group ] as $key ) { |
|
528 | + if ( isset( $group_cache[$group] ) ) { |
|
529 | + foreach ( $group_cache[$group] as $key ) { |
|
530 | 530 | wp_cache_delete( $key, $group ); |
531 | 531 | } |
532 | 532 | } |
@@ -554,17 +554,17 @@ discard block |
||
554 | 554 | } |
555 | 555 | |
556 | 556 | public static function get_pages() { |
557 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
557 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
561 | 561 | $pages = self::get_pages(); |
562 | 562 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
563 | 563 | ?> |
564 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
564 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
565 | 565 | <option value=""> </option> |
566 | 566 | <?php foreach ( $pages as $page ) { ?> |
567 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
567 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
568 | 568 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
569 | 569 | </option> |
570 | 570 | <?php } ?> |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | } |
574 | 574 | |
575 | 575 | public static function post_edit_link( $post_id ) { |
576 | - $post = get_post($post_id); |
|
576 | + $post = get_post( $post_id ); |
|
577 | 577 | if ( $post ) { |
578 | 578 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
579 | 579 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
@@ -583,17 +583,17 @@ discard block |
||
583 | 583 | |
584 | 584 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
585 | 585 | ?> |
586 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
|
586 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php |
|
587 | 587 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
588 | 588 | ?> class="frm_multiselect"> |
589 | - <?php self::roles_options($capability); ?> |
|
589 | + <?php self::roles_options( $capability ); ?> |
|
590 | 590 | </select> |
591 | 591 | <?php |
592 | 592 | } |
593 | 593 | |
594 | 594 | public static function roles_options( $capability ) { |
595 | 595 | global $frm_vars; |
596 | - if ( isset($frm_vars['editable_roles']) ) { |
|
596 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
597 | 597 | $editable_roles = $frm_vars['editable_roles']; |
598 | 598 | } else { |
599 | 599 | $editable_roles = get_editable_roles(); |
@@ -601,10 +601,10 @@ discard block |
||
601 | 601 | } |
602 | 602 | |
603 | 603 | foreach ( $editable_roles as $role => $details ) { |
604 | - $name = translate_user_role($details['name'] ); ?> |
|
605 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
604 | + $name = translate_user_role( $details['name'] ); ?> |
|
605 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
606 | 606 | <?php |
607 | - unset($role, $details); |
|
607 | + unset( $role, $details ); |
|
608 | 608 | } |
609 | 609 | } |
610 | 610 | |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | public static function maybe_add_permissions() { |
661 | 661 | self::force_capability( 'frm_view_entries' ); |
662 | 662 | |
663 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
663 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
664 | 664 | return; |
665 | 665 | } |
666 | 666 | |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | $frm_roles = self::frm_capabilities(); |
670 | 670 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
671 | 671 | $user->add_cap( $frm_role ); |
672 | - unset($frm_role, $frm_role_description); |
|
672 | + unset( $frm_role, $frm_role_description ); |
|
673 | 673 | } |
674 | 674 | } |
675 | 675 | |
@@ -694,12 +694,12 @@ discard block |
||
694 | 694 | * @param string $permission |
695 | 695 | */ |
696 | 696 | public static function permission_check( $permission, $show_message = 'show' ) { |
697 | - $permission_error = self::permission_nonce_error($permission); |
|
697 | + $permission_error = self::permission_nonce_error( $permission ); |
|
698 | 698 | if ( $permission_error !== false ) { |
699 | 699 | if ( 'hide' == $show_message ) { |
700 | 700 | $permission_error = ''; |
701 | 701 | } |
702 | - wp_die($permission_error); |
|
702 | + wp_die( $permission_error ); |
|
703 | 703 | } |
704 | 704 | } |
705 | 705 | |
@@ -716,11 +716,11 @@ discard block |
||
716 | 716 | } |
717 | 717 | |
718 | 718 | $error = false; |
719 | - if ( empty($nonce_name) ) { |
|
719 | + if ( empty( $nonce_name ) ) { |
|
720 | 720 | return $error; |
721 | 721 | } |
722 | 722 | |
723 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
723 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
724 | 724 | $frm_settings = self::get_settings(); |
725 | 725 | $error = $frm_settings->admin_permission; |
726 | 726 | } |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | } else { |
801 | 801 | foreach ( $value as $k => $v ) { |
802 | 802 | if ( ! is_array( $v ) ) { |
803 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
803 | + $value[$k] = call_user_func( $original_function, $v ); |
|
804 | 804 | } |
805 | 805 | } |
806 | 806 | } |
@@ -821,11 +821,11 @@ discard block |
||
821 | 821 | public static function array_flatten( $array, $keys = 'keep' ) { |
822 | 822 | $return = array(); |
823 | 823 | foreach ( $array as $key => $value ) { |
824 | - if ( is_array($value) ) { |
|
824 | + if ( is_array( $value ) ) { |
|
825 | 825 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
826 | 826 | } else { |
827 | 827 | if ( $keys == 'keep' ) { |
828 | - $return[ $key ] = $value; |
|
828 | + $return[$key] = $value; |
|
829 | 829 | } else { |
830 | 830 | $return[] = $value; |
831 | 831 | } |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | * @since 2.0 |
849 | 849 | */ |
850 | 850 | public static function use_wpautop( $content ) { |
851 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
852 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
851 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
852 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
853 | 853 | } |
854 | 854 | return $content; |
855 | 855 | } |
@@ -867,8 +867,8 @@ discard block |
||
867 | 867 | * @return string The base Google APIS url for the current version of jQuery UI |
868 | 868 | */ |
869 | 869 | public static function jquery_ui_base_url() { |
870 | - $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core'); |
|
871 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
870 | + $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' ); |
|
871 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
872 | 872 | return $url; |
873 | 873 | } |
874 | 874 | |
@@ -883,11 +883,11 @@ discard block |
||
883 | 883 | |
884 | 884 | $ver = 0; |
885 | 885 | |
886 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
886 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
887 | 887 | return $ver; |
888 | 888 | } |
889 | 889 | |
890 | - $query = $wp_scripts->registered[ $handle ]; |
|
890 | + $query = $wp_scripts->registered[$handle]; |
|
891 | 891 | if ( is_object( $query ) ) { |
892 | 892 | $ver = $query->ver; |
893 | 893 | } |
@@ -900,36 +900,36 @@ discard block |
||
900 | 900 | } |
901 | 901 | |
902 | 902 | public static function get_user_id_param( $user_id ) { |
903 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
903 | + if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
|
904 | 904 | return $user_id; |
905 | 905 | } |
906 | 906 | |
907 | 907 | if ( $user_id == 'current' ) { |
908 | 908 | $user_id = get_current_user_id(); |
909 | 909 | } else { |
910 | - if ( is_email($user_id) ) { |
|
911 | - $user = get_user_by('email', $user_id); |
|
910 | + if ( is_email( $user_id ) ) { |
|
911 | + $user = get_user_by( 'email', $user_id ); |
|
912 | 912 | } else { |
913 | - $user = get_user_by('login', $user_id); |
|
913 | + $user = get_user_by( 'login', $user_id ); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | if ( $user ) { |
917 | 917 | $user_id = $user->ID; |
918 | 918 | } |
919 | - unset($user); |
|
919 | + unset( $user ); |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | return $user_id; |
923 | 923 | } |
924 | 924 | |
925 | 925 | public static function get_file_contents( $filename, $atts = array() ) { |
926 | - if ( ! is_file($filename) ) { |
|
926 | + if ( ! is_file( $filename ) ) { |
|
927 | 927 | return false; |
928 | 928 | } |
929 | 929 | |
930 | - extract($atts); |
|
930 | + extract( $atts ); |
|
931 | 931 | ob_start(); |
932 | - include($filename); |
|
932 | + include( $filename ); |
|
933 | 933 | $contents = ob_get_contents(); |
934 | 934 | ob_end_clean(); |
935 | 935 | return $contents; |
@@ -945,28 +945,28 @@ discard block |
||
945 | 945 | $key = ''; |
946 | 946 | |
947 | 947 | if ( ! empty( $name ) ) { |
948 | - $key = sanitize_key($name); |
|
948 | + $key = sanitize_key( $name ); |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | if ( empty( $key ) ) { |
952 | - $max_slug_value = pow(36, $num_chars); |
|
952 | + $max_slug_value = pow( 36, $num_chars ); |
|
953 | 953 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
954 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
954 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
955 | 955 | } |
956 | 956 | |
957 | - if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
957 | + if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
958 | 958 | $key = $key . 'a'; |
959 | 959 | } |
960 | 960 | |
961 | 961 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
962 | 962 | |
963 | - if ( $key_check || is_numeric($key_check) ) { |
|
963 | + if ( $key_check || is_numeric( $key_check ) ) { |
|
964 | 964 | $suffix = 2; |
965 | 965 | do { |
966 | 966 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
967 | 967 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
968 | - $suffix++; |
|
969 | - } while ($key_check || is_numeric($key_check)); |
|
968 | + $suffix ++; |
|
969 | + } while ( $key_check || is_numeric( $key_check ) ); |
|
970 | 970 | $key = $alt_post_name; |
971 | 971 | } |
972 | 972 | return $key; |
@@ -982,32 +982,32 @@ discard block |
||
982 | 982 | return false; |
983 | 983 | } |
984 | 984 | |
985 | - if ( empty($post_values) ) { |
|
986 | - $post_values = stripslashes_deep($_POST); |
|
985 | + if ( empty( $post_values ) ) { |
|
986 | + $post_values = stripslashes_deep( $_POST ); |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | $values = array( 'id' => $record->id, 'fields' => array() ); |
990 | 990 | |
991 | 991 | foreach ( array( 'name', 'description' ) as $var ) { |
992 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
993 | - $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
994 | - unset($var, $default_val); |
|
992 | + $default_val = isset( $record->{$var}) ? $record->{$var} : ''; |
|
993 | + $values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
994 | + unset( $var, $default_val ); |
|
995 | 995 | } |
996 | 996 | |
997 | - $values['description'] = self::use_wpautop($values['description']); |
|
997 | + $values['description'] = self::use_wpautop( $values['description'] ); |
|
998 | 998 | $frm_settings = self::get_settings(); |
999 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
999 | + $is_form_builder = self::is_admin_page( 'formidable' ); |
|
1000 | 1000 | |
1001 | 1001 | foreach ( (array) $fields as $field ) { |
1002 | 1002 | // Make sure to filter default values (for placeholder text), but not on the form builder page |
1003 | 1003 | if ( ! $is_form_builder ) { |
1004 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
1004 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
|
1005 | 1005 | } |
1006 | 1006 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
1007 | - self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
1007 | + self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
1008 | 1008 | } |
1009 | 1009 | |
1010 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
1010 | + self::fill_form_opts( $record, $table, $post_values, $values ); |
|
1011 | 1011 | |
1012 | 1012 | if ( $table == 'entries' ) { |
1013 | 1013 | $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
@@ -1024,8 +1024,8 @@ discard block |
||
1024 | 1024 | if ( $args['default'] ) { |
1025 | 1025 | $meta_value = $field->default_value; |
1026 | 1026 | } else { |
1027 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1028 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
1027 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
|
1028 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
1029 | 1029 | $field->field_options['custom_field'] = ''; |
1030 | 1030 | } |
1031 | 1031 | $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 ) ); |
@@ -1034,8 +1034,8 @@ discard block |
||
1034 | 1034 | } |
1035 | 1035 | } |
1036 | 1036 | |
1037 | - $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
|
1038 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1037 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
1038 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
1039 | 1039 | |
1040 | 1040 | $field_array = array( |
1041 | 1041 | 'id' => $field->id, |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | 'default_value' => $field->default_value, |
1044 | 1044 | 'name' => $field->name, |
1045 | 1045 | 'description' => $field->description, |
1046 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1046 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), |
|
1047 | 1047 | 'options' => $field->options, |
1048 | 1048 | 'required' => $field->required, |
1049 | 1049 | 'field_key' => $field->field_key, |
@@ -1053,40 +1053,40 @@ discard block |
||
1053 | 1053 | ); |
1054 | 1054 | |
1055 | 1055 | $args['field_type'] = $field_type; |
1056 | - self::fill_field_opts($field, $field_array, $args); |
|
1056 | + self::fill_field_opts( $field, $field_array, $args ); |
|
1057 | 1057 | // Track the original field's type |
1058 | 1058 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
1059 | 1059 | |
1060 | 1060 | $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
1061 | 1061 | |
1062 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1062 | + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
|
1063 | 1063 | $field_array['unique_msg'] = ''; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | $field_array = array_merge( $field->field_options, $field_array ); |
1067 | 1067 | |
1068 | - $values['fields'][ $field->id ] = $field_array; |
|
1068 | + $values['fields'][$field->id] = $field_array; |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1072 | 1072 | $post_values = $args['post_values']; |
1073 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1073 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
1074 | 1074 | |
1075 | 1075 | foreach ( $opt_defaults as $opt => $default_opt ) { |
1076 | - $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 ); |
|
1077 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1078 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1079 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1076 | + $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 ); |
|
1077 | + if ( $opt == 'blank' && $field_array[$opt] == '' ) { |
|
1078 | + $field_array[$opt] = $args['frm_settings']->blank_msg; |
|
1079 | + } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { |
|
1080 | 1080 | if ( $args['field_type'] == 'captcha' ) { |
1081 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1081 | + $field_array[$opt] = $args['frm_settings']->re_msg; |
|
1082 | 1082 | } else { |
1083 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1083 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | if ( $field_array['custom_html'] == '' ) { |
1089 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1089 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); |
|
1090 | 1090 | } |
1091 | 1091 | } |
1092 | 1092 | |
@@ -1105,18 +1105,18 @@ discard block |
||
1105 | 1105 | return; |
1106 | 1106 | } |
1107 | 1107 | |
1108 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1108 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
|
1109 | 1109 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1110 | 1110 | |
1111 | - if ( ! is_array($form->options) ) { |
|
1111 | + if ( ! is_array( $form->options ) ) { |
|
1112 | 1112 | return; |
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | foreach ( $form->options as $opt => $value ) { |
1116 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1116 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | - self::fill_form_defaults($post_values, $values); |
|
1119 | + self::fill_form_defaults( $post_values, $values ); |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | /** |
@@ -1126,23 +1126,23 @@ discard block |
||
1126 | 1126 | $form_defaults = FrmFormsHelper::get_default_opts(); |
1127 | 1127 | |
1128 | 1128 | foreach ( $form_defaults as $opt => $default ) { |
1129 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1130 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
1129 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
1130 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | - unset($opt, $defaut); |
|
1133 | + unset( $opt, $defaut ); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | - if ( ! isset($values['custom_style']) ) { |
|
1136 | + if ( ! isset( $values['custom_style'] ) ) { |
|
1137 | 1137 | $frm_settings = self::get_settings(); |
1138 | 1138 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1142 | - if ( ! isset( $values[ $h . '_html' ] ) ) { |
|
1143 | - $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1142 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
1143 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
1144 | 1144 | } |
1145 | - unset($h); |
|
1145 | + unset( $h ); |
|
1146 | 1146 | } |
1147 | 1147 | } |
1148 | 1148 | |
@@ -1158,9 +1158,9 @@ discard block |
||
1158 | 1158 | } |
1159 | 1159 | ?> |
1160 | 1160 | <li> |
1161 | - <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> |
|
1162 | - <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> |
|
1163 | - <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> |
|
1161 | + <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> |
|
1162 | + <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> |
|
1163 | + <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> |
|
1164 | 1164 | </li> |
1165 | 1165 | <?php |
1166 | 1166 | } |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | return ''; |
1179 | 1179 | } else if ( $length <= 10 ) { |
1180 | 1180 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
1181 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
1181 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
|
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | $sub = ''; |
@@ -1187,23 +1187,23 @@ discard block |
||
1187 | 1187 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
1188 | 1188 | |
1189 | 1189 | foreach ( $words as $word ) { |
1190 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
1190 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
|
1191 | 1191 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
1192 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
1192 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
1193 | 1193 | break; |
1194 | 1194 | } |
1195 | 1195 | |
1196 | 1196 | $sub .= $part; |
1197 | 1197 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
1198 | 1198 | |
1199 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1199 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
1200 | 1200 | break; |
1201 | 1201 | } |
1202 | 1202 | |
1203 | - unset($total_len, $word); |
|
1203 | + unset( $total_len, $word ); |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1206 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | public static function mb_function( $function_names, $args ) { |
@@ -1216,17 +1216,17 @@ discard block |
||
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1219 | - if ( empty($date) ) { |
|
1219 | + if ( empty( $date ) ) { |
|
1220 | 1220 | return $date; |
1221 | 1221 | } |
1222 | 1222 | |
1223 | - if ( empty($date_format) ) { |
|
1224 | - $date_format = get_option('date_format'); |
|
1223 | + if ( empty( $date_format ) ) { |
|
1224 | + $date_format = get_option( 'date_format' ); |
|
1225 | 1225 | } |
1226 | 1226 | |
1227 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1227 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
1228 | 1228 | $frmpro_settings = new FrmProSettings(); |
1229 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1229 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | |
1242 | 1242 | private static function add_time_to_date( $time_format, $date ) { |
1243 | 1243 | if ( empty( $time_format ) ) { |
1244 | - $time_format = get_option('time_format'); |
|
1244 | + $time_format = get_option( 'time_format' ); |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | $trimmed_format = trim( $time_format ); |
@@ -1287,10 +1287,10 @@ discard block |
||
1287 | 1287 | $time_strings = self::get_time_strings(); |
1288 | 1288 | |
1289 | 1289 | foreach ( $time_strings as $k => $v ) { |
1290 | - if ( $diff[ $k ] ) { |
|
1291 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); |
|
1290 | + if ( $diff[$k] ) { |
|
1291 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); |
|
1292 | 1292 | } else { |
1293 | - unset( $time_strings[ $k ] ); |
|
1293 | + unset( $time_strings[$k] ); |
|
1294 | 1294 | } |
1295 | 1295 | } |
1296 | 1296 | |
@@ -1328,7 +1328,7 @@ discard block |
||
1328 | 1328 | */ |
1329 | 1329 | public static function esc_like( $term ) { |
1330 | 1330 | global $wpdb; |
1331 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1331 | + if ( method_exists( $wpdb, 'esc_like' ) ) { |
|
1332 | 1332 | // WP 4.0 |
1333 | 1333 | $term = $wpdb->esc_like( $term ); |
1334 | 1334 | } else { |
@@ -1342,17 +1342,17 @@ discard block |
||
1342 | 1342 | * @param string $order_query |
1343 | 1343 | */ |
1344 | 1344 | public static function esc_order( $order_query ) { |
1345 | - if ( empty($order_query) ) { |
|
1345 | + if ( empty( $order_query ) ) { |
|
1346 | 1346 | return ''; |
1347 | 1347 | } |
1348 | 1348 | |
1349 | 1349 | // remove ORDER BY before santizing |
1350 | - $order_query = strtolower($order_query); |
|
1351 | - if ( strpos($order_query, 'order by') !== false ) { |
|
1352 | - $order_query = str_replace('order by', '', $order_query); |
|
1350 | + $order_query = strtolower( $order_query ); |
|
1351 | + if ( strpos( $order_query, 'order by' ) !== false ) { |
|
1352 | + $order_query = str_replace( 'order by', '', $order_query ); |
|
1353 | 1353 | } |
1354 | 1354 | |
1355 | - $order_query = explode(' ', trim($order_query)); |
|
1355 | + $order_query = explode( ' ', trim( $order_query ) ); |
|
1356 | 1356 | |
1357 | 1357 | $order_fields = array( |
1358 | 1358 | 'id', 'form_key', 'name', 'description', |
@@ -1360,13 +1360,13 @@ discard block |
||
1360 | 1360 | 'default_template', 'status', 'created_at', |
1361 | 1361 | ); |
1362 | 1362 | |
1363 | - $order = trim(trim(reset($order_query), ',')); |
|
1364 | - if ( ! in_array($order, $order_fields) ) { |
|
1363 | + $order = trim( trim( reset( $order_query ), ',' ) ); |
|
1364 | + if ( ! in_array( $order, $order_fields ) ) { |
|
1365 | 1365 | return ''; |
1366 | 1366 | } |
1367 | 1367 | |
1368 | 1368 | $order_by = ''; |
1369 | - if ( count($order_query) > 1 ) { |
|
1369 | + if ( count( $order_query ) > 1 ) { |
|
1370 | 1370 | $order_by = end( $order_query ); |
1371 | 1371 | self::esc_order_by( $order_by ); |
1372 | 1372 | } |
@@ -1388,23 +1388,23 @@ discard block |
||
1388 | 1388 | * @param string $limit |
1389 | 1389 | */ |
1390 | 1390 | public static function esc_limit( $limit ) { |
1391 | - if ( empty($limit) ) { |
|
1391 | + if ( empty( $limit ) ) { |
|
1392 | 1392 | return ''; |
1393 | 1393 | } |
1394 | 1394 | |
1395 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1396 | - if ( is_numeric($limit) ) { |
|
1395 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); |
|
1396 | + if ( is_numeric( $limit ) ) { |
|
1397 | 1397 | return ' LIMIT ' . $limit; |
1398 | 1398 | } |
1399 | 1399 | |
1400 | - $limit = explode(',', trim($limit)); |
|
1400 | + $limit = explode( ',', trim( $limit ) ); |
|
1401 | 1401 | foreach ( $limit as $k => $l ) { |
1402 | 1402 | if ( is_numeric( $l ) ) { |
1403 | - $limit[ $k ] = $l; |
|
1403 | + $limit[$k] = $l; |
|
1404 | 1404 | } |
1405 | 1405 | } |
1406 | 1406 | |
1407 | - $limit = implode(',', $limit); |
|
1407 | + $limit = implode( ',', $limit ); |
|
1408 | 1408 | return ' LIMIT ' . $limit; |
1409 | 1409 | } |
1410 | 1410 | |
@@ -1413,12 +1413,12 @@ discard block |
||
1413 | 1413 | * @since 2.0 |
1414 | 1414 | */ |
1415 | 1415 | public static function prepare_array_values( $array, $type = '%s' ) { |
1416 | - $placeholders = array_fill(0, count($array), $type); |
|
1417 | - return implode(', ', $placeholders); |
|
1416 | + $placeholders = array_fill( 0, count( $array ), $type ); |
|
1417 | + return implode( ', ', $placeholders ); |
|
1418 | 1418 | } |
1419 | 1419 | |
1420 | 1420 | public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
1421 | - if ( empty($where) ) { |
|
1421 | + if ( empty( $where ) ) { |
|
1422 | 1422 | return ''; |
1423 | 1423 | } |
1424 | 1424 | |
@@ -1459,19 +1459,19 @@ discard block |
||
1459 | 1459 | public static function json_to_array( $json_vars ) { |
1460 | 1460 | $vars = array(); |
1461 | 1461 | foreach ( $json_vars as $jv ) { |
1462 | - $jv_name = explode('[', $jv['name']); |
|
1463 | - $last = count($jv_name) - 1; |
|
1462 | + $jv_name = explode( '[', $jv['name'] ); |
|
1463 | + $last = count( $jv_name ) - 1; |
|
1464 | 1464 | foreach ( $jv_name as $p => $n ) { |
1465 | - $name = trim($n, ']'); |
|
1466 | - if ( ! isset($l1) ) { |
|
1465 | + $name = trim( $n, ']' ); |
|
1466 | + if ( ! isset( $l1 ) ) { |
|
1467 | 1467 | $l1 = $name; |
1468 | 1468 | } |
1469 | 1469 | |
1470 | - if ( ! isset($l2) ) { |
|
1470 | + if ( ! isset( $l2 ) ) { |
|
1471 | 1471 | $l2 = $name; |
1472 | 1472 | } |
1473 | 1473 | |
1474 | - if ( ! isset($l3) ) { |
|
1474 | + if ( ! isset( $l3 ) ) { |
|
1475 | 1475 | $l3 = $name; |
1476 | 1476 | } |
1477 | 1477 | |
@@ -1485,24 +1485,24 @@ discard block |
||
1485 | 1485 | |
1486 | 1486 | case 1: |
1487 | 1487 | $l2 = $name; |
1488 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1488 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
1489 | 1489 | break; |
1490 | 1490 | |
1491 | 1491 | case 2: |
1492 | 1492 | $l3 = $name; |
1493 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1493 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
1494 | 1494 | break; |
1495 | 1495 | |
1496 | 1496 | case 3: |
1497 | 1497 | $l4 = $name; |
1498 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1498 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
1499 | 1499 | break; |
1500 | 1500 | } |
1501 | 1501 | |
1502 | - unset($this_val, $n); |
|
1502 | + unset( $this_val, $n ); |
|
1503 | 1503 | } |
1504 | 1504 | |
1505 | - unset($last, $jv); |
|
1505 | + unset( $last, $jv ); |
|
1506 | 1506 | } |
1507 | 1507 | |
1508 | 1508 | return $vars; |
@@ -1515,8 +1515,8 @@ discard block |
||
1515 | 1515 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
1516 | 1516 | if ( $name == '' ) { |
1517 | 1517 | $vars[] = $val; |
1518 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1519 | - $vars[ $l1 ] = $val; |
|
1518 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
1519 | + $vars[$l1] = $val; |
|
1520 | 1520 | } |
1521 | 1521 | } |
1522 | 1522 | |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | '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() ) ), |
1532 | 1532 | ); |
1533 | 1533 | |
1534 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1534 | + if ( ! isset( $tooltips[$name] ) ) { |
|
1535 | 1535 | return; |
1536 | 1536 | } |
1537 | 1537 | |
@@ -1541,7 +1541,7 @@ discard block |
||
1541 | 1541 | echo ' class="frm_help"'; |
1542 | 1542 | } |
1543 | 1543 | |
1544 | - echo ' title="' . esc_attr( $tooltips[ $name ] ); |
|
1544 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
1545 | 1545 | |
1546 | 1546 | if ( 'open' != $class ) { |
1547 | 1547 | echo '"'; |
@@ -1593,13 +1593,13 @@ discard block |
||
1593 | 1593 | } |
1594 | 1594 | |
1595 | 1595 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1596 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
1596 | + if ( ! isset( $post_content[$key] ) ) { |
|
1597 | 1597 | return; |
1598 | 1598 | } |
1599 | 1599 | |
1600 | 1600 | if ( is_array( $val ) ) { |
1601 | 1601 | foreach ( $val as $k1 => $v1 ) { |
1602 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
1602 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
1603 | 1603 | unset( $k1, $v1 ); |
1604 | 1604 | } |
1605 | 1605 | } else { |
@@ -1607,7 +1607,7 @@ discard block |
||
1607 | 1607 | $val = stripslashes( $val ); |
1608 | 1608 | |
1609 | 1609 | // Add backslashes before double quotes and forward slashes only |
1610 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
1610 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
1611 | 1611 | } |
1612 | 1612 | } |
1613 | 1613 | |
@@ -1624,7 +1624,7 @@ discard block |
||
1624 | 1624 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); |
1625 | 1625 | |
1626 | 1626 | if ( empty( $settings['ID'] ) ) { |
1627 | - unset( $settings['ID']); |
|
1627 | + unset( $settings['ID'] ); |
|
1628 | 1628 | } |
1629 | 1629 | |
1630 | 1630 | // delete all caches for this group |
@@ -1658,17 +1658,17 @@ discard block |
||
1658 | 1658 | } |
1659 | 1659 | |
1660 | 1660 | public static function maybe_json_decode( $string ) { |
1661 | - if ( is_array($string) ) { |
|
1661 | + if ( is_array( $string ) ) { |
|
1662 | 1662 | return $string; |
1663 | 1663 | } |
1664 | 1664 | |
1665 | - $new_string = json_decode($string, true); |
|
1666 | - if ( function_exists('json_last_error') ) { |
|
1665 | + $new_string = json_decode( $string, true ); |
|
1666 | + if ( function_exists( 'json_last_error' ) ) { |
|
1667 | 1667 | // php 5.3+ |
1668 | 1668 | if ( json_last_error() == JSON_ERROR_NONE ) { |
1669 | 1669 | $string = $new_string; |
1670 | 1670 | } |
1671 | - } else if ( isset($new_string) ) { |
|
1671 | + } else if ( isset( $new_string ) ) { |
|
1672 | 1672 | // php < 5.3 fallback |
1673 | 1673 | $string = $new_string; |
1674 | 1674 | } |
@@ -1684,11 +1684,11 @@ discard block |
||
1684 | 1684 | public static function maybe_highlight_menu( $post_type ) { |
1685 | 1685 | global $post; |
1686 | 1686 | |
1687 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1687 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
1688 | 1688 | return; |
1689 | 1689 | } |
1690 | 1690 | |
1691 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1691 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
1692 | 1692 | return; |
1693 | 1693 | } |
1694 | 1694 | |
@@ -1789,11 +1789,11 @@ discard block |
||
1789 | 1789 | $frm_version = self::plugin_version(); |
1790 | 1790 | |
1791 | 1791 | // check if Formidable meets minimum requirements |
1792 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1792 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
1793 | 1793 | return; |
1794 | 1794 | } |
1795 | 1795 | |
1796 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1796 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
1797 | 1797 | 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">' . |
1798 | 1798 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
1799 | 1799 | '</div></td></tr>'; |
@@ -1801,38 +1801,38 @@ discard block |
||
1801 | 1801 | |
1802 | 1802 | public static function locales( $type = 'date' ) { |
1803 | 1803 | $locales = array( |
1804 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1805 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1806 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1804 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1805 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1806 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1807 | 1807 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
1808 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1809 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1808 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1809 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1810 | 1810 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
1811 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1812 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1811 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1812 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1813 | 1813 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
1814 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1814 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1815 | 1815 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
1816 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1816 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1817 | 1817 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
1818 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1818 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1819 | 1819 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
1820 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1821 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1822 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1823 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1824 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1820 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1821 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1822 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1823 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1824 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1825 | 1825 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
1826 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1826 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1827 | 1827 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
1828 | 1828 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
1829 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1829 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1830 | 1830 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
1831 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1831 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1832 | 1832 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
1833 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1834 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1835 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1833 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1834 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1835 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1836 | 1836 | ); |
1837 | 1837 | |
1838 | 1838 | if ( $type == 'captcha' ) { |
@@ -1851,8 +1851,8 @@ discard block |
||
1851 | 1851 | ); |
1852 | 1852 | } |
1853 | 1853 | |
1854 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1855 | - $locales = apply_filters('frm_locales', $locales); |
|
1854 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
1855 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
1856 | 1856 | |
1857 | 1857 | return $locales; |
1858 | 1858 | } |