@@ -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 ); |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | */ |
468 | 468 | public static function add_key_to_group_cache( $key, $group ) { |
469 | 469 | $cached = self::get_group_cached_keys( $group ); |
470 | - $cached[ $key ] = $key; |
|
470 | + $cached[$key] = $key; |
|
471 | 471 | wp_cache_set( 'cached_keys', $cached, $group, 300 ); |
472 | 472 | } |
473 | 473 | |
@@ -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 | |
@@ -548,17 +548,17 @@ discard block |
||
548 | 548 | } |
549 | 549 | |
550 | 550 | public static function get_pages() { |
551 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
551 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
555 | 555 | $pages = self::get_pages(); |
556 | 556 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
557 | 557 | ?> |
558 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
558 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
559 | 559 | <option value=""> </option> |
560 | 560 | <?php foreach ( $pages as $page ) { ?> |
561 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
561 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
562 | 562 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
563 | 563 | </option> |
564 | 564 | <?php } ?> |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | } |
568 | 568 | |
569 | 569 | public static function post_edit_link( $post_id ) { |
570 | - $post = get_post($post_id); |
|
570 | + $post = get_post( $post_id ); |
|
571 | 571 | if ( $post ) { |
572 | 572 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
573 | 573 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
@@ -577,17 +577,17 @@ discard block |
||
577 | 577 | |
578 | 578 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
579 | 579 | ?> |
580 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
|
580 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php |
|
581 | 581 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
582 | 582 | ?> class="frm_multiselect"> |
583 | - <?php self::roles_options($capability); ?> |
|
583 | + <?php self::roles_options( $capability ); ?> |
|
584 | 584 | </select> |
585 | 585 | <?php |
586 | 586 | } |
587 | 587 | |
588 | 588 | public static function roles_options( $capability ) { |
589 | 589 | global $frm_vars; |
590 | - if ( isset($frm_vars['editable_roles']) ) { |
|
590 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
591 | 591 | $editable_roles = $frm_vars['editable_roles']; |
592 | 592 | } else { |
593 | 593 | $editable_roles = get_editable_roles(); |
@@ -595,10 +595,10 @@ discard block |
||
595 | 595 | } |
596 | 596 | |
597 | 597 | foreach ( $editable_roles as $role => $details ) { |
598 | - $name = translate_user_role($details['name'] ); ?> |
|
599 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
598 | + $name = translate_user_role( $details['name'] ); ?> |
|
599 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
600 | 600 | <?php |
601 | - unset($role, $details); |
|
601 | + unset( $role, $details ); |
|
602 | 602 | } |
603 | 603 | } |
604 | 604 | |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | public static function maybe_add_permissions() { |
655 | 655 | self::force_capability( 'frm_view_entries' ); |
656 | 656 | |
657 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
657 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
658 | 658 | return; |
659 | 659 | } |
660 | 660 | |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | $frm_roles = self::frm_capabilities(); |
664 | 664 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
665 | 665 | $user->add_cap( $frm_role ); |
666 | - unset($frm_role, $frm_role_description); |
|
666 | + unset( $frm_role, $frm_role_description ); |
|
667 | 667 | } |
668 | 668 | } |
669 | 669 | |
@@ -688,12 +688,12 @@ discard block |
||
688 | 688 | * @param string $permission |
689 | 689 | */ |
690 | 690 | public static function permission_check( $permission, $show_message = 'show' ) { |
691 | - $permission_error = self::permission_nonce_error($permission); |
|
691 | + $permission_error = self::permission_nonce_error( $permission ); |
|
692 | 692 | if ( $permission_error !== false ) { |
693 | 693 | if ( 'hide' == $show_message ) { |
694 | 694 | $permission_error = ''; |
695 | 695 | } |
696 | - wp_die($permission_error); |
|
696 | + wp_die( $permission_error ); |
|
697 | 697 | } |
698 | 698 | } |
699 | 699 | |
@@ -710,11 +710,11 @@ discard block |
||
710 | 710 | } |
711 | 711 | |
712 | 712 | $error = false; |
713 | - if ( empty($nonce_name) ) { |
|
713 | + if ( empty( $nonce_name ) ) { |
|
714 | 714 | return $error; |
715 | 715 | } |
716 | 716 | |
717 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
717 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
718 | 718 | $frm_settings = self::get_settings(); |
719 | 719 | $error = $frm_settings->admin_permission; |
720 | 720 | } |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | } else { |
795 | 795 | foreach ( $value as $k => $v ) { |
796 | 796 | if ( ! is_array( $v ) ) { |
797 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
797 | + $value[$k] = call_user_func( $original_function, $v ); |
|
798 | 798 | } |
799 | 799 | } |
800 | 800 | } |
@@ -815,11 +815,11 @@ discard block |
||
815 | 815 | public static function array_flatten( $array, $keys = 'keep' ) { |
816 | 816 | $return = array(); |
817 | 817 | foreach ( $array as $key => $value ) { |
818 | - if ( is_array($value) ) { |
|
818 | + if ( is_array( $value ) ) { |
|
819 | 819 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
820 | 820 | } else { |
821 | 821 | if ( $keys == 'keep' ) { |
822 | - $return[ $key ] = $value; |
|
822 | + $return[$key] = $value; |
|
823 | 823 | } else { |
824 | 824 | $return[] = $value; |
825 | 825 | } |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | * @since 2.0 |
843 | 843 | */ |
844 | 844 | public static function use_wpautop( $content ) { |
845 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
846 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
845 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
846 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
847 | 847 | } |
848 | 848 | return $content; |
849 | 849 | } |
@@ -861,8 +861,8 @@ discard block |
||
861 | 861 | * @return string The base Google APIS url for the current version of jQuery UI |
862 | 862 | */ |
863 | 863 | public static function jquery_ui_base_url() { |
864 | - $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core'); |
|
865 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
864 | + $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' ); |
|
865 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
866 | 866 | return $url; |
867 | 867 | } |
868 | 868 | |
@@ -877,11 +877,11 @@ discard block |
||
877 | 877 | |
878 | 878 | $ver = 0; |
879 | 879 | |
880 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
880 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
881 | 881 | return $ver; |
882 | 882 | } |
883 | 883 | |
884 | - $query = $wp_scripts->registered[ $handle ]; |
|
884 | + $query = $wp_scripts->registered[$handle]; |
|
885 | 885 | if ( is_object( $query ) ) { |
886 | 886 | $ver = $query->ver; |
887 | 887 | } |
@@ -894,36 +894,36 @@ discard block |
||
894 | 894 | } |
895 | 895 | |
896 | 896 | public static function get_user_id_param( $user_id ) { |
897 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
897 | + if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
|
898 | 898 | return $user_id; |
899 | 899 | } |
900 | 900 | |
901 | 901 | if ( $user_id == 'current' ) { |
902 | 902 | $user_id = get_current_user_id(); |
903 | 903 | } else { |
904 | - if ( is_email($user_id) ) { |
|
905 | - $user = get_user_by('email', $user_id); |
|
904 | + if ( is_email( $user_id ) ) { |
|
905 | + $user = get_user_by( 'email', $user_id ); |
|
906 | 906 | } else { |
907 | - $user = get_user_by('login', $user_id); |
|
907 | + $user = get_user_by( 'login', $user_id ); |
|
908 | 908 | } |
909 | 909 | |
910 | 910 | if ( $user ) { |
911 | 911 | $user_id = $user->ID; |
912 | 912 | } |
913 | - unset($user); |
|
913 | + unset( $user ); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | return $user_id; |
917 | 917 | } |
918 | 918 | |
919 | 919 | public static function get_file_contents( $filename, $atts = array() ) { |
920 | - if ( ! is_file($filename) ) { |
|
920 | + if ( ! is_file( $filename ) ) { |
|
921 | 921 | return false; |
922 | 922 | } |
923 | 923 | |
924 | - extract($atts); |
|
924 | + extract( $atts ); |
|
925 | 925 | ob_start(); |
926 | - include($filename); |
|
926 | + include( $filename ); |
|
927 | 927 | $contents = ob_get_contents(); |
928 | 928 | ob_end_clean(); |
929 | 929 | return $contents; |
@@ -939,28 +939,28 @@ discard block |
||
939 | 939 | $key = ''; |
940 | 940 | |
941 | 941 | if ( ! empty( $name ) ) { |
942 | - $key = sanitize_key($name); |
|
942 | + $key = sanitize_key( $name ); |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | if ( empty( $key ) ) { |
946 | - $max_slug_value = pow(36, $num_chars); |
|
946 | + $max_slug_value = pow( 36, $num_chars ); |
|
947 | 947 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
948 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
948 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
949 | 949 | } |
950 | 950 | |
951 | - if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
951 | + if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
952 | 952 | $key = $key . 'a'; |
953 | 953 | } |
954 | 954 | |
955 | 955 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
956 | 956 | |
957 | - if ( $key_check || is_numeric($key_check) ) { |
|
957 | + if ( $key_check || is_numeric( $key_check ) ) { |
|
958 | 958 | $suffix = 2; |
959 | 959 | do { |
960 | 960 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
961 | 961 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
962 | - $suffix++; |
|
963 | - } while ($key_check || is_numeric($key_check)); |
|
962 | + $suffix ++; |
|
963 | + } while ( $key_check || is_numeric( $key_check ) ); |
|
964 | 964 | $key = $alt_post_name; |
965 | 965 | } |
966 | 966 | return $key; |
@@ -976,32 +976,32 @@ discard block |
||
976 | 976 | return false; |
977 | 977 | } |
978 | 978 | |
979 | - if ( empty($post_values) ) { |
|
980 | - $post_values = stripslashes_deep($_POST); |
|
979 | + if ( empty( $post_values ) ) { |
|
980 | + $post_values = stripslashes_deep( $_POST ); |
|
981 | 981 | } |
982 | 982 | |
983 | 983 | $values = array( 'id' => $record->id, 'fields' => array() ); |
984 | 984 | |
985 | 985 | foreach ( array( 'name', 'description' ) as $var ) { |
986 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
987 | - $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
988 | - unset($var, $default_val); |
|
986 | + $default_val = isset( $record->{$var}) ? $record->{$var} : ''; |
|
987 | + $values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
988 | + unset( $var, $default_val ); |
|
989 | 989 | } |
990 | 990 | |
991 | - $values['description'] = self::use_wpautop($values['description']); |
|
991 | + $values['description'] = self::use_wpautop( $values['description'] ); |
|
992 | 992 | $frm_settings = self::get_settings(); |
993 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
993 | + $is_form_builder = self::is_admin_page( 'formidable' ); |
|
994 | 994 | |
995 | 995 | foreach ( (array) $fields as $field ) { |
996 | 996 | // Make sure to filter default values (for placeholder text), but not on the form builder page |
997 | 997 | if ( ! $is_form_builder ) { |
998 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
998 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
|
999 | 999 | } |
1000 | 1000 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
1001 | - self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
1001 | + self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
1004 | + self::fill_form_opts( $record, $table, $post_values, $values ); |
|
1005 | 1005 | |
1006 | 1006 | if ( $table == 'entries' ) { |
1007 | 1007 | $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
@@ -1018,8 +1018,8 @@ discard block |
||
1018 | 1018 | if ( $args['default'] ) { |
1019 | 1019 | $meta_value = $field->default_value; |
1020 | 1020 | } else { |
1021 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1022 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
1021 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
|
1022 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
1023 | 1023 | $field->field_options['custom_field'] = ''; |
1024 | 1024 | } |
1025 | 1025 | $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 ) ); |
@@ -1028,8 +1028,8 @@ discard block |
||
1028 | 1028 | } |
1029 | 1029 | } |
1030 | 1030 | |
1031 | - $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
|
1032 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1031 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
1032 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
1033 | 1033 | |
1034 | 1034 | $field_array = array( |
1035 | 1035 | 'id' => $field->id, |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | 'default_value' => $field->default_value, |
1038 | 1038 | 'name' => $field->name, |
1039 | 1039 | 'description' => $field->description, |
1040 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1040 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), |
|
1041 | 1041 | 'options' => $field->options, |
1042 | 1042 | 'required' => $field->required, |
1043 | 1043 | 'field_key' => $field->field_key, |
@@ -1047,40 +1047,40 @@ discard block |
||
1047 | 1047 | ); |
1048 | 1048 | |
1049 | 1049 | $args['field_type'] = $field_type; |
1050 | - self::fill_field_opts($field, $field_array, $args); |
|
1050 | + self::fill_field_opts( $field, $field_array, $args ); |
|
1051 | 1051 | // Track the original field's type |
1052 | 1052 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
1053 | 1053 | |
1054 | 1054 | $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
1055 | 1055 | |
1056 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1056 | + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
|
1057 | 1057 | $field_array['unique_msg'] = ''; |
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | $field_array = array_merge( $field->field_options, $field_array ); |
1061 | 1061 | |
1062 | - $values['fields'][ $field->id ] = $field_array; |
|
1062 | + $values['fields'][$field->id] = $field_array; |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1066 | 1066 | $post_values = $args['post_values']; |
1067 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1067 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
1068 | 1068 | |
1069 | 1069 | foreach ( $opt_defaults as $opt => $default_opt ) { |
1070 | - $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 ); |
|
1071 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1072 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1073 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1070 | + $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 ); |
|
1071 | + if ( $opt == 'blank' && $field_array[$opt] == '' ) { |
|
1072 | + $field_array[$opt] = $args['frm_settings']->blank_msg; |
|
1073 | + } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { |
|
1074 | 1074 | if ( $args['field_type'] == 'captcha' ) { |
1075 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1075 | + $field_array[$opt] = $args['frm_settings']->re_msg; |
|
1076 | 1076 | } else { |
1077 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1077 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1078 | 1078 | } |
1079 | 1079 | } |
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | if ( $field_array['custom_html'] == '' ) { |
1083 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1083 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); |
|
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 | |
@@ -1099,18 +1099,18 @@ discard block |
||
1099 | 1099 | return; |
1100 | 1100 | } |
1101 | 1101 | |
1102 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1102 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
|
1103 | 1103 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1104 | 1104 | |
1105 | - if ( ! is_array($form->options) ) { |
|
1105 | + if ( ! is_array( $form->options ) ) { |
|
1106 | 1106 | return; |
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | foreach ( $form->options as $opt => $value ) { |
1110 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1110 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
1111 | 1111 | } |
1112 | 1112 | |
1113 | - self::fill_form_defaults($post_values, $values); |
|
1113 | + self::fill_form_defaults( $post_values, $values ); |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | /** |
@@ -1120,23 +1120,23 @@ discard block |
||
1120 | 1120 | $form_defaults = FrmFormsHelper::get_default_opts(); |
1121 | 1121 | |
1122 | 1122 | foreach ( $form_defaults as $opt => $default ) { |
1123 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1124 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
1123 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
1124 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
1125 | 1125 | } |
1126 | 1126 | |
1127 | - unset($opt, $defaut); |
|
1127 | + unset( $opt, $defaut ); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | - if ( ! isset($values['custom_style']) ) { |
|
1130 | + if ( ! isset( $values['custom_style'] ) ) { |
|
1131 | 1131 | $frm_settings = self::get_settings(); |
1132 | 1132 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1136 | - if ( ! isset( $values[ $h . '_html' ] ) ) { |
|
1137 | - $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1136 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
1137 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
1138 | 1138 | } |
1139 | - unset($h); |
|
1139 | + unset( $h ); |
|
1140 | 1140 | } |
1141 | 1141 | } |
1142 | 1142 | |
@@ -1152,9 +1152,9 @@ discard block |
||
1152 | 1152 | } |
1153 | 1153 | ?> |
1154 | 1154 | <li> |
1155 | - <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> |
|
1156 | - <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> |
|
1157 | - <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> |
|
1155 | + <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> |
|
1156 | + <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> |
|
1157 | + <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> |
|
1158 | 1158 | </li> |
1159 | 1159 | <?php |
1160 | 1160 | } |
@@ -1172,7 +1172,7 @@ discard block |
||
1172 | 1172 | return ''; |
1173 | 1173 | } else if ( $length <= 10 ) { |
1174 | 1174 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
1175 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
1175 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | $sub = ''; |
@@ -1181,23 +1181,23 @@ discard block |
||
1181 | 1181 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
1182 | 1182 | |
1183 | 1183 | foreach ( $words as $word ) { |
1184 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
1184 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
|
1185 | 1185 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
1186 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
1186 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
1187 | 1187 | break; |
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | $sub .= $part; |
1191 | 1191 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
1192 | 1192 | |
1193 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1193 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
1194 | 1194 | break; |
1195 | 1195 | } |
1196 | 1196 | |
1197 | - unset($total_len, $word); |
|
1197 | + unset( $total_len, $word ); |
|
1198 | 1198 | } |
1199 | 1199 | |
1200 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1200 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
|
1201 | 1201 | } |
1202 | 1202 | |
1203 | 1203 | public static function mb_function( $function_names, $args ) { |
@@ -1210,17 +1210,17 @@ discard block |
||
1210 | 1210 | } |
1211 | 1211 | |
1212 | 1212 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1213 | - if ( empty($date) ) { |
|
1213 | + if ( empty( $date ) ) { |
|
1214 | 1214 | return $date; |
1215 | 1215 | } |
1216 | 1216 | |
1217 | - if ( empty($date_format) ) { |
|
1218 | - $date_format = get_option('date_format'); |
|
1217 | + if ( empty( $date_format ) ) { |
|
1218 | + $date_format = get_option( 'date_format' ); |
|
1219 | 1219 | } |
1220 | 1220 | |
1221 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1221 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
1222 | 1222 | $frmpro_settings = new FrmProSettings(); |
1223 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1223 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
1224 | 1224 | } |
1225 | 1225 | |
1226 | 1226 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1235,7 +1235,7 @@ discard block |
||
1235 | 1235 | |
1236 | 1236 | private static function add_time_to_date( $time_format, $date ) { |
1237 | 1237 | if ( empty( $time_format ) ) { |
1238 | - $time_format = get_option('time_format'); |
|
1238 | + $time_format = get_option( 'time_format' ); |
|
1239 | 1239 | } |
1240 | 1240 | |
1241 | 1241 | $trimmed_format = trim( $time_format ); |
@@ -1281,10 +1281,10 @@ discard block |
||
1281 | 1281 | $time_strings = self::get_time_strings(); |
1282 | 1282 | |
1283 | 1283 | foreach ( $time_strings as $k => $v ) { |
1284 | - if ( $diff[ $k ] ) { |
|
1285 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); |
|
1284 | + if ( $diff[$k] ) { |
|
1285 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); |
|
1286 | 1286 | } else { |
1287 | - unset( $time_strings[ $k ] ); |
|
1287 | + unset( $time_strings[$k] ); |
|
1288 | 1288 | } |
1289 | 1289 | } |
1290 | 1290 | |
@@ -1322,7 +1322,7 @@ discard block |
||
1322 | 1322 | */ |
1323 | 1323 | public static function esc_like( $term ) { |
1324 | 1324 | global $wpdb; |
1325 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1325 | + if ( method_exists( $wpdb, 'esc_like' ) ) { |
|
1326 | 1326 | // WP 4.0 |
1327 | 1327 | $term = $wpdb->esc_like( $term ); |
1328 | 1328 | } else { |
@@ -1336,17 +1336,17 @@ discard block |
||
1336 | 1336 | * @param string $order_query |
1337 | 1337 | */ |
1338 | 1338 | public static function esc_order( $order_query ) { |
1339 | - if ( empty($order_query) ) { |
|
1339 | + if ( empty( $order_query ) ) { |
|
1340 | 1340 | return ''; |
1341 | 1341 | } |
1342 | 1342 | |
1343 | 1343 | // remove ORDER BY before santizing |
1344 | - $order_query = strtolower($order_query); |
|
1345 | - if ( strpos($order_query, 'order by') !== false ) { |
|
1346 | - $order_query = str_replace('order by', '', $order_query); |
|
1344 | + $order_query = strtolower( $order_query ); |
|
1345 | + if ( strpos( $order_query, 'order by' ) !== false ) { |
|
1346 | + $order_query = str_replace( 'order by', '', $order_query ); |
|
1347 | 1347 | } |
1348 | 1348 | |
1349 | - $order_query = explode(' ', trim($order_query)); |
|
1349 | + $order_query = explode( ' ', trim( $order_query ) ); |
|
1350 | 1350 | |
1351 | 1351 | $order_fields = array( |
1352 | 1352 | 'id', 'form_key', 'name', 'description', |
@@ -1354,13 +1354,13 @@ discard block |
||
1354 | 1354 | 'default_template', 'status', 'created_at', |
1355 | 1355 | ); |
1356 | 1356 | |
1357 | - $order = trim(trim(reset($order_query), ',')); |
|
1358 | - if ( ! in_array($order, $order_fields) ) { |
|
1357 | + $order = trim( trim( reset( $order_query ), ',' ) ); |
|
1358 | + if ( ! in_array( $order, $order_fields ) ) { |
|
1359 | 1359 | return ''; |
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | $order_by = ''; |
1363 | - if ( count($order_query) > 1 ) { |
|
1363 | + if ( count( $order_query ) > 1 ) { |
|
1364 | 1364 | $order_by = end( $order_query ); |
1365 | 1365 | self::esc_order_by( $order_by ); |
1366 | 1366 | } |
@@ -1382,23 +1382,23 @@ discard block |
||
1382 | 1382 | * @param string $limit |
1383 | 1383 | */ |
1384 | 1384 | public static function esc_limit( $limit ) { |
1385 | - if ( empty($limit) ) { |
|
1385 | + if ( empty( $limit ) ) { |
|
1386 | 1386 | return ''; |
1387 | 1387 | } |
1388 | 1388 | |
1389 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1390 | - if ( is_numeric($limit) ) { |
|
1389 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); |
|
1390 | + if ( is_numeric( $limit ) ) { |
|
1391 | 1391 | return ' LIMIT ' . $limit; |
1392 | 1392 | } |
1393 | 1393 | |
1394 | - $limit = explode(',', trim($limit)); |
|
1394 | + $limit = explode( ',', trim( $limit ) ); |
|
1395 | 1395 | foreach ( $limit as $k => $l ) { |
1396 | 1396 | if ( is_numeric( $l ) ) { |
1397 | - $limit[ $k ] = $l; |
|
1397 | + $limit[$k] = $l; |
|
1398 | 1398 | } |
1399 | 1399 | } |
1400 | 1400 | |
1401 | - $limit = implode(',', $limit); |
|
1401 | + $limit = implode( ',', $limit ); |
|
1402 | 1402 | return ' LIMIT ' . $limit; |
1403 | 1403 | } |
1404 | 1404 | |
@@ -1407,12 +1407,12 @@ discard block |
||
1407 | 1407 | * @since 2.0 |
1408 | 1408 | */ |
1409 | 1409 | public static function prepare_array_values( $array, $type = '%s' ) { |
1410 | - $placeholders = array_fill(0, count($array), $type); |
|
1411 | - return implode(', ', $placeholders); |
|
1410 | + $placeholders = array_fill( 0, count( $array ), $type ); |
|
1411 | + return implode( ', ', $placeholders ); |
|
1412 | 1412 | } |
1413 | 1413 | |
1414 | 1414 | public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
1415 | - if ( empty($where) ) { |
|
1415 | + if ( empty( $where ) ) { |
|
1416 | 1416 | return ''; |
1417 | 1417 | } |
1418 | 1418 | |
@@ -1453,19 +1453,19 @@ discard block |
||
1453 | 1453 | public static function json_to_array( $json_vars ) { |
1454 | 1454 | $vars = array(); |
1455 | 1455 | foreach ( $json_vars as $jv ) { |
1456 | - $jv_name = explode('[', $jv['name']); |
|
1457 | - $last = count($jv_name) - 1; |
|
1456 | + $jv_name = explode( '[', $jv['name'] ); |
|
1457 | + $last = count( $jv_name ) - 1; |
|
1458 | 1458 | foreach ( $jv_name as $p => $n ) { |
1459 | - $name = trim($n, ']'); |
|
1460 | - if ( ! isset($l1) ) { |
|
1459 | + $name = trim( $n, ']' ); |
|
1460 | + if ( ! isset( $l1 ) ) { |
|
1461 | 1461 | $l1 = $name; |
1462 | 1462 | } |
1463 | 1463 | |
1464 | - if ( ! isset($l2) ) { |
|
1464 | + if ( ! isset( $l2 ) ) { |
|
1465 | 1465 | $l2 = $name; |
1466 | 1466 | } |
1467 | 1467 | |
1468 | - if ( ! isset($l3) ) { |
|
1468 | + if ( ! isset( $l3 ) ) { |
|
1469 | 1469 | $l3 = $name; |
1470 | 1470 | } |
1471 | 1471 | |
@@ -1479,24 +1479,24 @@ discard block |
||
1479 | 1479 | |
1480 | 1480 | case 1: |
1481 | 1481 | $l2 = $name; |
1482 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1482 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
1483 | 1483 | break; |
1484 | 1484 | |
1485 | 1485 | case 2: |
1486 | 1486 | $l3 = $name; |
1487 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1487 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
1488 | 1488 | break; |
1489 | 1489 | |
1490 | 1490 | case 3: |
1491 | 1491 | $l4 = $name; |
1492 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1492 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
1493 | 1493 | break; |
1494 | 1494 | } |
1495 | 1495 | |
1496 | - unset($this_val, $n); |
|
1496 | + unset( $this_val, $n ); |
|
1497 | 1497 | } |
1498 | 1498 | |
1499 | - unset($last, $jv); |
|
1499 | + unset( $last, $jv ); |
|
1500 | 1500 | } |
1501 | 1501 | |
1502 | 1502 | return $vars; |
@@ -1509,8 +1509,8 @@ discard block |
||
1509 | 1509 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
1510 | 1510 | if ( $name == '' ) { |
1511 | 1511 | $vars[] = $val; |
1512 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1513 | - $vars[ $l1 ] = $val; |
|
1512 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
1513 | + $vars[$l1] = $val; |
|
1514 | 1514 | } |
1515 | 1515 | } |
1516 | 1516 | |
@@ -1525,7 +1525,7 @@ discard block |
||
1525 | 1525 | '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() ) ), |
1526 | 1526 | ); |
1527 | 1527 | |
1528 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1528 | + if ( ! isset( $tooltips[$name] ) ) { |
|
1529 | 1529 | return; |
1530 | 1530 | } |
1531 | 1531 | |
@@ -1535,7 +1535,7 @@ discard block |
||
1535 | 1535 | echo ' class="frm_help"'; |
1536 | 1536 | } |
1537 | 1537 | |
1538 | - echo ' title="' . esc_attr( $tooltips[ $name ] ); |
|
1538 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
1539 | 1539 | |
1540 | 1540 | if ( 'open' != $class ) { |
1541 | 1541 | echo '"'; |
@@ -1587,13 +1587,13 @@ discard block |
||
1587 | 1587 | } |
1588 | 1588 | |
1589 | 1589 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1590 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
1590 | + if ( ! isset( $post_content[$key] ) ) { |
|
1591 | 1591 | return; |
1592 | 1592 | } |
1593 | 1593 | |
1594 | 1594 | if ( is_array( $val ) ) { |
1595 | 1595 | foreach ( $val as $k1 => $v1 ) { |
1596 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
1596 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
1597 | 1597 | unset( $k1, $v1 ); |
1598 | 1598 | } |
1599 | 1599 | } else { |
@@ -1601,7 +1601,7 @@ discard block |
||
1601 | 1601 | $val = stripslashes( $val ); |
1602 | 1602 | |
1603 | 1603 | // Add backslashes before double quotes and forward slashes only |
1604 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
1604 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
1605 | 1605 | } |
1606 | 1606 | } |
1607 | 1607 | |
@@ -1618,7 +1618,7 @@ discard block |
||
1618 | 1618 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); |
1619 | 1619 | |
1620 | 1620 | if ( empty( $settings['ID'] ) ) { |
1621 | - unset( $settings['ID']); |
|
1621 | + unset( $settings['ID'] ); |
|
1622 | 1622 | } |
1623 | 1623 | |
1624 | 1624 | // delete all caches for this group |
@@ -1652,17 +1652,17 @@ discard block |
||
1652 | 1652 | } |
1653 | 1653 | |
1654 | 1654 | public static function maybe_json_decode( $string ) { |
1655 | - if ( is_array($string) ) { |
|
1655 | + if ( is_array( $string ) ) { |
|
1656 | 1656 | return $string; |
1657 | 1657 | } |
1658 | 1658 | |
1659 | - $new_string = json_decode($string, true); |
|
1660 | - if ( function_exists('json_last_error') ) { |
|
1659 | + $new_string = json_decode( $string, true ); |
|
1660 | + if ( function_exists( 'json_last_error' ) ) { |
|
1661 | 1661 | // php 5.3+ |
1662 | 1662 | if ( json_last_error() == JSON_ERROR_NONE ) { |
1663 | 1663 | $string = $new_string; |
1664 | 1664 | } |
1665 | - } else if ( isset($new_string) ) { |
|
1665 | + } else if ( isset( $new_string ) ) { |
|
1666 | 1666 | // php < 5.3 fallback |
1667 | 1667 | $string = $new_string; |
1668 | 1668 | } |
@@ -1678,11 +1678,11 @@ discard block |
||
1678 | 1678 | public static function maybe_highlight_menu( $post_type ) { |
1679 | 1679 | global $post; |
1680 | 1680 | |
1681 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1681 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
1682 | 1682 | return; |
1683 | 1683 | } |
1684 | 1684 | |
1685 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1685 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
1686 | 1686 | return; |
1687 | 1687 | } |
1688 | 1688 | |
@@ -1783,11 +1783,11 @@ discard block |
||
1783 | 1783 | $frm_version = self::plugin_version(); |
1784 | 1784 | |
1785 | 1785 | // check if Formidable meets minimum requirements |
1786 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1786 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
1787 | 1787 | return; |
1788 | 1788 | } |
1789 | 1789 | |
1790 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1790 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
1791 | 1791 | 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">' . |
1792 | 1792 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
1793 | 1793 | '</div></td></tr>'; |
@@ -1795,38 +1795,38 @@ discard block |
||
1795 | 1795 | |
1796 | 1796 | public static function locales( $type = 'date' ) { |
1797 | 1797 | $locales = array( |
1798 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1799 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1800 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1798 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1799 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1800 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1801 | 1801 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
1802 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1803 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1802 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1803 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1804 | 1804 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
1805 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1806 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1805 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1806 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1807 | 1807 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
1808 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1808 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1809 | 1809 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
1810 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1810 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1811 | 1811 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
1812 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1812 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1813 | 1813 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
1814 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1815 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1816 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1817 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1818 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1814 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1815 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1816 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1817 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1818 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1819 | 1819 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
1820 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1820 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1821 | 1821 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
1822 | 1822 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
1823 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1823 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1824 | 1824 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
1825 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1825 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1826 | 1826 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
1827 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1828 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1829 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1827 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1828 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1829 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1830 | 1830 | ); |
1831 | 1831 | |
1832 | 1832 | if ( $type == 'captcha' ) { |
@@ -1845,8 +1845,8 @@ discard block |
||
1845 | 1845 | ); |
1846 | 1846 | } |
1847 | 1847 | |
1848 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1849 | - $locales = apply_filters('frm_locales', $locales); |
|
1848 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
1849 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
1850 | 1850 | |
1851 | 1851 | return $locales; |
1852 | 1852 | } |