@@ -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,14 +54,14 @@ discard block |
||
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | 56 | public static function site_name() { |
| 57 | - return get_option('blogname'); |
|
| 57 | + return get_option( 'blogname' ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public static function make_affiliate_url( $url ) { |
| 61 | 61 | $affiliate_id = self::get_affiliate(); |
| 62 | 62 | if ( ! empty( $affiliate_id ) ) { |
| 63 | 63 | $url = str_replace( array( 'http://', 'https://' ), '', $url ); |
| 64 | - $url = 'http://www.shareasale.com/r.cfm?u='. absint( $affiliate_id ) .'&b=841990&m=64739&afftrack=plugin&urllink=' . urlencode( $url ); |
|
| 64 | + $url = 'http://www.shareasale.com/r.cfm?u=' . absint( $affiliate_id ) . '&b=841990&m=64739&afftrack=plugin&urllink=' . urlencode( $url ); |
|
| 65 | 65 | } |
| 66 | 66 | return $url; |
| 67 | 67 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public static function get_settings() { |
| 82 | 82 | global $frm_settings; |
| 83 | - if ( empty($frm_settings) ) { |
|
| 83 | + if ( empty( $frm_settings ) ) { |
|
| 84 | 84 | $frm_settings = new FrmSettings(); |
| 85 | 85 | } |
| 86 | 86 | return $frm_settings; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | public static function pro_is_installed() { |
| 112 | - return apply_filters('frm_pro_installed', false); |
|
| 112 | + return apply_filters( 'frm_pro_installed', false ); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @return boolean |
| 154 | 154 | */ |
| 155 | 155 | public static function doing_ajax() { |
| 156 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 156 | + return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page(); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @return boolean |
| 174 | 174 | */ |
| 175 | 175 | public static function is_admin() { |
| 176 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 176 | + return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @return string |
| 201 | 201 | */ |
| 202 | 202 | public static function get_server_value( $value ) { |
| 203 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 203 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -215,14 +215,14 @@ discard block |
||
| 215 | 215 | 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
| 216 | 216 | 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
| 217 | 217 | ) as $key ) { |
| 218 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 218 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
| 219 | 219 | continue; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 223 | - $ip = trim($ip); // just to be safe |
|
| 222 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
| 223 | + $ip = trim( $ip ); // just to be safe |
|
| 224 | 224 | |
| 225 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 225 | + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
|
| 226 | 226 | return $ip; |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -232,15 +232,15 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
| 235 | - if ( strpos($param, '[') ) { |
|
| 236 | - $params = explode('[', $param); |
|
| 235 | + if ( strpos( $param, '[' ) ) { |
|
| 236 | + $params = explode( '[', $param ); |
|
| 237 | 237 | $param = $params[0]; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | if ( $src == 'get' ) { |
| 241 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 242 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 243 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 241 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); |
|
| 242 | + if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { |
|
| 243 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[$param] ) ); |
|
| 244 | 244 | } |
| 245 | 245 | self::sanitize_value( $sanitize, $value ); |
| 246 | 246 | } else { |
@@ -249,12 +249,12 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 251 | 251 | foreach ( $params as $k => $p ) { |
| 252 | - if ( ! $k || ! is_array($value) ) { |
|
| 252 | + if ( ! $k || ! is_array( $value ) ) { |
|
| 253 | 253 | continue; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - $p = trim($p, ']'); |
|
| 257 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 256 | + $p = trim( $p, ']' ); |
|
| 257 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
@@ -293,16 +293,16 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | $value = $args['default']; |
| 295 | 295 | if ( $args['type'] == 'get' ) { |
| 296 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
| 297 | - $value = $_GET[ $args['param'] ]; |
|
| 296 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
| 297 | + $value = $_GET[$args['param']]; |
|
| 298 | 298 | } |
| 299 | 299 | } else if ( $args['type'] == 'post' ) { |
| 300 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
| 301 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
| 300 | + if ( isset( $_POST[$args['param']] ) ) { |
|
| 301 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
| 302 | 302 | } |
| 303 | 303 | } else { |
| 304 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
| 305 | - $value = $_REQUEST[ $args['param'] ]; |
|
| 304 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
| 305 | + $value = $_REQUEST[$args['param']]; |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | if ( is_array( $value ) ) { |
| 331 | 331 | $temp_values = $value; |
| 332 | 332 | foreach ( $temp_values as $k => $v ) { |
| 333 | - FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] ); |
|
| 333 | + FrmAppHelper::sanitize_value( $sanitize, $value[$k] ); |
|
| 334 | 334 | } |
| 335 | 335 | } else { |
| 336 | 336 | $value = call_user_func( $sanitize, $value ); |
@@ -341,8 +341,8 @@ discard block |
||
| 341 | 341 | public static function sanitize_request( $sanitize_method, &$values ) { |
| 342 | 342 | $temp_values = $values; |
| 343 | 343 | foreach ( $temp_values as $k => $val ) { |
| 344 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 345 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
| 344 | + if ( isset( $sanitize_method[$k] ) ) { |
|
| 345 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | } |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | public static function sanitize_array( &$values ) { |
| 351 | 351 | $temp_values = $values; |
| 352 | 352 | foreach ( $temp_values as $k => $val ) { |
| 353 | - $values[ $k ] = wp_kses_post( $val ); |
|
| 353 | + $values[$k] = wp_kses_post( $val ); |
|
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | |
| 374 | 374 | $allowed_html = array(); |
| 375 | 375 | foreach ( $allowed as $a ) { |
| 376 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
| 376 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | $allowed_html = apply_filters( 'frm_striphtml_allowed_tags', $allowed_html ); |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | * @since 2.0 |
| 387 | 387 | */ |
| 388 | 388 | public static function remove_get_action() { |
| 389 | - if ( ! isset($_GET) ) { |
|
| 389 | + if ( ! isset( $_GET ) ) { |
|
| 390 | 390 | return; |
| 391 | 391 | } |
| 392 | 392 | |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | global $wp_query; |
| 411 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 412 | - $value = $wp_query->query_vars[ $param ]; |
|
| 411 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
| 412 | + $value = $wp_query->query_vars[$param]; |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | return $value; |
@@ -438,19 +438,19 @@ discard block |
||
| 438 | 438 | * @return mixed $results The cache or query results |
| 439 | 439 | */ |
| 440 | 440 | public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
| 441 | - $results = wp_cache_get($cache_key, $group); |
|
| 442 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 441 | + $results = wp_cache_get( $cache_key, $group ); |
|
| 442 | + if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) { |
|
| 443 | 443 | return $results; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | if ( 'get_posts' == $type ) { |
| 447 | - $results = get_posts($query); |
|
| 447 | + $results = get_posts( $query ); |
|
| 448 | 448 | } else if ( 'get_associative_results' == $type ) { |
| 449 | 449 | global $wpdb; |
| 450 | 450 | $results = $wpdb->get_results( $query, OBJECT_K ); |
| 451 | 451 | } else { |
| 452 | 452 | global $wpdb; |
| 453 | - $results = $wpdb->{$type}($query); |
|
| 453 | + $results = $wpdb->{$type}( $query ); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | self::set_cache( $cache_key, $results, $group, $time ); |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | */ |
| 472 | 472 | public static function add_key_to_group_cache( $key, $group ) { |
| 473 | 473 | $cached = self::get_group_cached_keys( $group ); |
| 474 | - $cached[ $key ] = $key; |
|
| 474 | + $cached[$key] = $key; |
|
| 475 | 475 | wp_cache_set( 'cached_keys', $cached, $group, 300 ); |
| 476 | 476 | } |
| 477 | 477 | |
@@ -498,9 +498,9 @@ discard block |
||
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | // then check the transient |
| 501 | - $results = get_transient($cache_key); |
|
| 501 | + $results = get_transient( $cache_key ); |
|
| 502 | 502 | if ( $results ) { |
| 503 | - wp_cache_set($cache_key, $results); |
|
| 503 | + wp_cache_set( $cache_key, $results ); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | return $results; |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | * @param string $cache_key |
| 512 | 512 | */ |
| 513 | 513 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
| 514 | - delete_transient($cache_key); |
|
| 514 | + delete_transient( $cache_key ); |
|
| 515 | 515 | wp_cache_delete( $cache_key, $group ); |
| 516 | 516 | } |
| 517 | 517 | |
@@ -555,17 +555,17 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | public static function get_pages() { |
| 558 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
| 558 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
| 562 | 562 | $pages = self::get_pages(); |
| 563 | 563 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 564 | 564 | ?> |
| 565 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
| 565 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
| 566 | 566 | <option value=""> </option> |
| 567 | 567 | <?php foreach ( $pages as $page ) { ?> |
| 568 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
| 568 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
| 569 | 569 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
| 570 | 570 | </option> |
| 571 | 571 | <?php } ?> |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | public static function post_edit_link( $post_id ) { |
| 577 | - $post = get_post($post_id); |
|
| 577 | + $post = get_post( $post_id ); |
|
| 578 | 578 | if ( $post ) { |
| 579 | 579 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 580 | 580 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
@@ -584,17 +584,17 @@ discard block |
||
| 584 | 584 | |
| 585 | 585 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 586 | 586 | ?> |
| 587 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
|
| 587 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php |
|
| 588 | 588 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
| 589 | 589 | ?> class="frm_multiselect"> |
| 590 | - <?php self::roles_options($capability); ?> |
|
| 590 | + <?php self::roles_options( $capability ); ?> |
|
| 591 | 591 | </select> |
| 592 | 592 | <?php |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | public static function roles_options( $capability ) { |
| 596 | 596 | global $frm_vars; |
| 597 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 597 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
| 598 | 598 | $editable_roles = $frm_vars['editable_roles']; |
| 599 | 599 | } else { |
| 600 | 600 | $editable_roles = get_editable_roles(); |
@@ -602,10 +602,10 @@ discard block |
||
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | foreach ( $editable_roles as $role => $details ) { |
| 605 | - $name = translate_user_role($details['name'] ); ?> |
|
| 606 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
| 605 | + $name = translate_user_role( $details['name'] ); ?> |
|
| 606 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
| 607 | 607 | <?php |
| 608 | - unset($role, $details); |
|
| 608 | + unset( $role, $details ); |
|
| 609 | 609 | } |
| 610 | 610 | } |
| 611 | 611 | |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | public static function maybe_add_permissions() { |
| 662 | 662 | self::force_capability( 'frm_view_entries' ); |
| 663 | 663 | |
| 664 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 664 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
| 665 | 665 | return; |
| 666 | 666 | } |
| 667 | 667 | |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | $frm_roles = self::frm_capabilities(); |
| 671 | 671 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 672 | 672 | $user->add_cap( $frm_role ); |
| 673 | - unset($frm_role, $frm_role_description); |
|
| 673 | + unset( $frm_role, $frm_role_description ); |
|
| 674 | 674 | } |
| 675 | 675 | } |
| 676 | 676 | |
@@ -695,12 +695,12 @@ discard block |
||
| 695 | 695 | * @param string $permission |
| 696 | 696 | */ |
| 697 | 697 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 698 | - $permission_error = self::permission_nonce_error($permission); |
|
| 698 | + $permission_error = self::permission_nonce_error( $permission ); |
|
| 699 | 699 | if ( $permission_error !== false ) { |
| 700 | 700 | if ( 'hide' == $show_message ) { |
| 701 | 701 | $permission_error = ''; |
| 702 | 702 | } |
| 703 | - wp_die($permission_error); |
|
| 703 | + wp_die( $permission_error ); |
|
| 704 | 704 | } |
| 705 | 705 | } |
| 706 | 706 | |
@@ -717,11 +717,11 @@ discard block |
||
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | $error = false; |
| 720 | - if ( empty($nonce_name) ) { |
|
| 720 | + if ( empty( $nonce_name ) ) { |
|
| 721 | 721 | return $error; |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 724 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
| 725 | 725 | $frm_settings = self::get_settings(); |
| 726 | 726 | $error = $frm_settings->admin_permission; |
| 727 | 727 | } |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | } else { |
| 802 | 802 | foreach ( $value as $k => $v ) { |
| 803 | 803 | if ( ! is_array( $v ) ) { |
| 804 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
| 804 | + $value[$k] = call_user_func( $original_function, $v ); |
|
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | 807 | } |
@@ -822,11 +822,11 @@ discard block |
||
| 822 | 822 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 823 | 823 | $return = array(); |
| 824 | 824 | foreach ( $array as $key => $value ) { |
| 825 | - if ( is_array($value) ) { |
|
| 825 | + if ( is_array( $value ) ) { |
|
| 826 | 826 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 827 | 827 | } else { |
| 828 | 828 | if ( $keys == 'keep' ) { |
| 829 | - $return[ $key ] = $value; |
|
| 829 | + $return[$key] = $value; |
|
| 830 | 830 | } else { |
| 831 | 831 | $return[] = $value; |
| 832 | 832 | } |
@@ -849,8 +849,8 @@ discard block |
||
| 849 | 849 | * @since 2.0 |
| 850 | 850 | */ |
| 851 | 851 | public static function use_wpautop( $content ) { |
| 852 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 853 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 852 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
| 853 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
| 854 | 854 | } |
| 855 | 855 | return $content; |
| 856 | 856 | } |
@@ -869,7 +869,7 @@ discard block |
||
| 869 | 869 | */ |
| 870 | 870 | public static function jquery_ui_base_url() { |
| 871 | 871 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 872 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 872 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
| 873 | 873 | return $url; |
| 874 | 874 | } |
| 875 | 875 | |
@@ -883,11 +883,11 @@ discard block |
||
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | $ver = $default; |
| 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 ) && ! empty( $query->ver ) ) { |
| 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,27 +945,27 @@ 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++; |
|
| 968 | + $suffix ++; |
|
| 969 | 969 | } while ( $key_check || is_numeric( $key_check ) ); |
| 970 | 970 | $key = $alt_post_name; |
| 971 | 971 | } |
@@ -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,11 +1126,11 @@ 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 | 1136 | if ( ! isset( $values['custom_style'] ) ) { |
@@ -1138,10 +1138,10 @@ discard block |
||
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | 1140 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1141 | - if ( ! isset( $values[ $h . '_html' ] ) ) { |
|
| 1142 | - $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1141 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
| 1142 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1143 | 1143 | } |
| 1144 | - unset($h); |
|
| 1144 | + unset( $h ); |
|
| 1145 | 1145 | } |
| 1146 | 1146 | } |
| 1147 | 1147 | |
@@ -1172,9 +1172,9 @@ discard block |
||
| 1172 | 1172 | } |
| 1173 | 1173 | ?> |
| 1174 | 1174 | <li> |
| 1175 | - <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> |
|
| 1176 | - <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> |
|
| 1177 | - <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> |
|
| 1175 | + <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> |
|
| 1176 | + <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> |
|
| 1177 | + <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> |
|
| 1178 | 1178 | </li> |
| 1179 | 1179 | <?php |
| 1180 | 1180 | } |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | return ''; |
| 1193 | 1193 | } else if ( $length <= 10 ) { |
| 1194 | 1194 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1195 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1195 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
|
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | 1198 | $sub = ''; |
@@ -1201,23 +1201,23 @@ discard block |
||
| 1201 | 1201 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1202 | 1202 | |
| 1203 | 1203 | foreach ( $words as $word ) { |
| 1204 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1204 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
|
| 1205 | 1205 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1206 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1206 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
| 1207 | 1207 | break; |
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | 1210 | $sub .= $part; |
| 1211 | 1211 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1212 | 1212 | |
| 1213 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1213 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
| 1214 | 1214 | break; |
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | - unset($total_len, $word); |
|
| 1217 | + unset( $total_len, $word ); |
|
| 1218 | 1218 | } |
| 1219 | 1219 | |
| 1220 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1220 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
|
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | 1223 | public static function mb_function( $function_names, $args ) { |
@@ -1230,17 +1230,17 @@ discard block |
||
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | 1232 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1233 | - if ( empty($date) ) { |
|
| 1233 | + if ( empty( $date ) ) { |
|
| 1234 | 1234 | return $date; |
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | - if ( empty($date_format) ) { |
|
| 1238 | - $date_format = get_option('date_format'); |
|
| 1237 | + if ( empty( $date_format ) ) { |
|
| 1238 | + $date_format = get_option( 'date_format' ); |
|
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1241 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
| 1242 | 1242 | $frmpro_settings = new FrmProSettings(); |
| 1243 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1243 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | 1246 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1255,7 +1255,7 @@ discard block |
||
| 1255 | 1255 | |
| 1256 | 1256 | private static function add_time_to_date( $time_format, $date ) { |
| 1257 | 1257 | if ( empty( $time_format ) ) { |
| 1258 | - $time_format = get_option('time_format'); |
|
| 1258 | + $time_format = get_option( 'time_format' ); |
|
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | $trimmed_format = trim( $time_format ); |
@@ -1301,10 +1301,10 @@ discard block |
||
| 1301 | 1301 | $time_strings = self::get_time_strings(); |
| 1302 | 1302 | |
| 1303 | 1303 | foreach ( $time_strings as $k => $v ) { |
| 1304 | - if ( $diff[ $k ] ) { |
|
| 1305 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); |
|
| 1304 | + if ( $diff[$k] ) { |
|
| 1305 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); |
|
| 1306 | 1306 | } else { |
| 1307 | - unset( $time_strings[ $k ] ); |
|
| 1307 | + unset( $time_strings[$k] ); |
|
| 1308 | 1308 | } |
| 1309 | 1309 | } |
| 1310 | 1310 | |
@@ -1343,7 +1343,7 @@ discard block |
||
| 1343 | 1343 | */ |
| 1344 | 1344 | public static function esc_like( $term ) { |
| 1345 | 1345 | global $wpdb; |
| 1346 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1346 | + if ( method_exists( $wpdb, 'esc_like' ) ) { |
|
| 1347 | 1347 | // WP 4.0 |
| 1348 | 1348 | $term = $wpdb->esc_like( $term ); |
| 1349 | 1349 | } else { |
@@ -1357,17 +1357,17 @@ discard block |
||
| 1357 | 1357 | * @param string $order_query |
| 1358 | 1358 | */ |
| 1359 | 1359 | public static function esc_order( $order_query ) { |
| 1360 | - if ( empty($order_query) ) { |
|
| 1360 | + if ( empty( $order_query ) ) { |
|
| 1361 | 1361 | return ''; |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | 1364 | // remove ORDER BY before santizing |
| 1365 | - $order_query = strtolower($order_query); |
|
| 1366 | - if ( strpos($order_query, 'order by') !== false ) { |
|
| 1367 | - $order_query = str_replace('order by', '', $order_query); |
|
| 1365 | + $order_query = strtolower( $order_query ); |
|
| 1366 | + if ( strpos( $order_query, 'order by' ) !== false ) { |
|
| 1367 | + $order_query = str_replace( 'order by', '', $order_query ); |
|
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | - $order_query = explode(' ', trim($order_query)); |
|
| 1370 | + $order_query = explode( ' ', trim( $order_query ) ); |
|
| 1371 | 1371 | |
| 1372 | 1372 | $order_fields = array( |
| 1373 | 1373 | 'id', 'form_key', 'name', 'description', |
@@ -1375,13 +1375,13 @@ discard block |
||
| 1375 | 1375 | 'default_template', 'status', 'created_at', |
| 1376 | 1376 | ); |
| 1377 | 1377 | |
| 1378 | - $order = trim(trim(reset($order_query), ',')); |
|
| 1379 | - if ( ! in_array($order, $order_fields) ) { |
|
| 1378 | + $order = trim( trim( reset( $order_query ), ',' ) ); |
|
| 1379 | + if ( ! in_array( $order, $order_fields ) ) { |
|
| 1380 | 1380 | return ''; |
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | 1383 | $order_by = ''; |
| 1384 | - if ( count($order_query) > 1 ) { |
|
| 1384 | + if ( count( $order_query ) > 1 ) { |
|
| 1385 | 1385 | $order_by = end( $order_query ); |
| 1386 | 1386 | self::esc_order_by( $order_by ); |
| 1387 | 1387 | } |
@@ -1403,23 +1403,23 @@ discard block |
||
| 1403 | 1403 | * @param string $limit |
| 1404 | 1404 | */ |
| 1405 | 1405 | public static function esc_limit( $limit ) { |
| 1406 | - if ( empty($limit) ) { |
|
| 1406 | + if ( empty( $limit ) ) { |
|
| 1407 | 1407 | return ''; |
| 1408 | 1408 | } |
| 1409 | 1409 | |
| 1410 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1411 | - if ( is_numeric($limit) ) { |
|
| 1410 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); |
|
| 1411 | + if ( is_numeric( $limit ) ) { |
|
| 1412 | 1412 | return ' LIMIT ' . $limit; |
| 1413 | 1413 | } |
| 1414 | 1414 | |
| 1415 | - $limit = explode(',', trim($limit)); |
|
| 1415 | + $limit = explode( ',', trim( $limit ) ); |
|
| 1416 | 1416 | foreach ( $limit as $k => $l ) { |
| 1417 | 1417 | if ( is_numeric( $l ) ) { |
| 1418 | - $limit[ $k ] = $l; |
|
| 1418 | + $limit[$k] = $l; |
|
| 1419 | 1419 | } |
| 1420 | 1420 | } |
| 1421 | 1421 | |
| 1422 | - $limit = implode(',', $limit); |
|
| 1422 | + $limit = implode( ',', $limit ); |
|
| 1423 | 1423 | return ' LIMIT ' . $limit; |
| 1424 | 1424 | } |
| 1425 | 1425 | |
@@ -1428,12 +1428,12 @@ discard block |
||
| 1428 | 1428 | * @since 2.0 |
| 1429 | 1429 | */ |
| 1430 | 1430 | public static function prepare_array_values( $array, $type = '%s' ) { |
| 1431 | - $placeholders = array_fill(0, count($array), $type); |
|
| 1432 | - return implode(', ', $placeholders); |
|
| 1431 | + $placeholders = array_fill( 0, count( $array ), $type ); |
|
| 1432 | + return implode( ', ', $placeholders ); |
|
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | 1435 | public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
| 1436 | - if ( empty($where) ) { |
|
| 1436 | + if ( empty( $where ) ) { |
|
| 1437 | 1437 | return ''; |
| 1438 | 1438 | } |
| 1439 | 1439 | |
@@ -1474,19 +1474,19 @@ discard block |
||
| 1474 | 1474 | public static function json_to_array( $json_vars ) { |
| 1475 | 1475 | $vars = array(); |
| 1476 | 1476 | foreach ( $json_vars as $jv ) { |
| 1477 | - $jv_name = explode('[', $jv['name']); |
|
| 1478 | - $last = count($jv_name) - 1; |
|
| 1477 | + $jv_name = explode( '[', $jv['name'] ); |
|
| 1478 | + $last = count( $jv_name ) - 1; |
|
| 1479 | 1479 | foreach ( $jv_name as $p => $n ) { |
| 1480 | - $name = trim($n, ']'); |
|
| 1481 | - if ( ! isset($l1) ) { |
|
| 1480 | + $name = trim( $n, ']' ); |
|
| 1481 | + if ( ! isset( $l1 ) ) { |
|
| 1482 | 1482 | $l1 = $name; |
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | - if ( ! isset($l2) ) { |
|
| 1485 | + if ( ! isset( $l2 ) ) { |
|
| 1486 | 1486 | $l2 = $name; |
| 1487 | 1487 | } |
| 1488 | 1488 | |
| 1489 | - if ( ! isset($l3) ) { |
|
| 1489 | + if ( ! isset( $l3 ) ) { |
|
| 1490 | 1490 | $l3 = $name; |
| 1491 | 1491 | } |
| 1492 | 1492 | |
@@ -1500,24 +1500,24 @@ discard block |
||
| 1500 | 1500 | |
| 1501 | 1501 | case 1: |
| 1502 | 1502 | $l2 = $name; |
| 1503 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1503 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
| 1504 | 1504 | break; |
| 1505 | 1505 | |
| 1506 | 1506 | case 2: |
| 1507 | 1507 | $l3 = $name; |
| 1508 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1508 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
| 1509 | 1509 | break; |
| 1510 | 1510 | |
| 1511 | 1511 | case 3: |
| 1512 | 1512 | $l4 = $name; |
| 1513 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1513 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
| 1514 | 1514 | break; |
| 1515 | 1515 | } |
| 1516 | 1516 | |
| 1517 | - unset($this_val, $n); |
|
| 1517 | + unset( $this_val, $n ); |
|
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | - unset($last, $jv); |
|
| 1520 | + unset( $last, $jv ); |
|
| 1521 | 1521 | } |
| 1522 | 1522 | |
| 1523 | 1523 | return $vars; |
@@ -1530,8 +1530,8 @@ discard block |
||
| 1530 | 1530 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
| 1531 | 1531 | if ( $name == '' ) { |
| 1532 | 1532 | $vars[] = $val; |
| 1533 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1534 | - $vars[ $l1 ] = $val; |
|
| 1533 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
| 1534 | + $vars[$l1] = $val; |
|
| 1535 | 1535 | } |
| 1536 | 1536 | } |
| 1537 | 1537 | |
@@ -1546,7 +1546,7 @@ discard block |
||
| 1546 | 1546 | '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() ) ), |
| 1547 | 1547 | ); |
| 1548 | 1548 | |
| 1549 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1549 | + if ( ! isset( $tooltips[$name] ) ) { |
|
| 1550 | 1550 | return; |
| 1551 | 1551 | } |
| 1552 | 1552 | |
@@ -1556,7 +1556,7 @@ discard block |
||
| 1556 | 1556 | echo ' class="frm_help"'; |
| 1557 | 1557 | } |
| 1558 | 1558 | |
| 1559 | - echo ' title="' . esc_attr( $tooltips[ $name ] ); |
|
| 1559 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
| 1560 | 1560 | |
| 1561 | 1561 | if ( 'open' != $class ) { |
| 1562 | 1562 | echo '"'; |
@@ -1608,13 +1608,13 @@ discard block |
||
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | 1610 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1611 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
| 1611 | + if ( ! isset( $post_content[$key] ) ) { |
|
| 1612 | 1612 | return; |
| 1613 | 1613 | } |
| 1614 | 1614 | |
| 1615 | 1615 | if ( is_array( $val ) ) { |
| 1616 | 1616 | foreach ( $val as $k1 => $v1 ) { |
| 1617 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
| 1617 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
| 1618 | 1618 | unset( $k1, $v1 ); |
| 1619 | 1619 | } |
| 1620 | 1620 | } else { |
@@ -1622,7 +1622,7 @@ discard block |
||
| 1622 | 1622 | $val = stripslashes( $val ); |
| 1623 | 1623 | |
| 1624 | 1624 | // Add backslashes before double quotes and forward slashes only |
| 1625 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
| 1625 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
| 1626 | 1626 | } |
| 1627 | 1627 | } |
| 1628 | 1628 | |
@@ -1639,7 +1639,7 @@ discard block |
||
| 1639 | 1639 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); |
| 1640 | 1640 | |
| 1641 | 1641 | if ( empty( $settings['ID'] ) ) { |
| 1642 | - unset( $settings['ID']); |
|
| 1642 | + unset( $settings['ID'] ); |
|
| 1643 | 1643 | } |
| 1644 | 1644 | |
| 1645 | 1645 | // delete all caches for this group |
@@ -1673,17 +1673,17 @@ discard block |
||
| 1673 | 1673 | } |
| 1674 | 1674 | |
| 1675 | 1675 | public static function maybe_json_decode( $string ) { |
| 1676 | - if ( is_array($string) ) { |
|
| 1676 | + if ( is_array( $string ) ) { |
|
| 1677 | 1677 | return $string; |
| 1678 | 1678 | } |
| 1679 | 1679 | |
| 1680 | - $new_string = json_decode($string, true); |
|
| 1681 | - if ( function_exists('json_last_error') ) { |
|
| 1680 | + $new_string = json_decode( $string, true ); |
|
| 1681 | + if ( function_exists( 'json_last_error' ) ) { |
|
| 1682 | 1682 | // php 5.3+ |
| 1683 | 1683 | if ( json_last_error() == JSON_ERROR_NONE ) { |
| 1684 | 1684 | $string = $new_string; |
| 1685 | 1685 | } |
| 1686 | - } else if ( isset($new_string) ) { |
|
| 1686 | + } else if ( isset( $new_string ) ) { |
|
| 1687 | 1687 | // php < 5.3 fallback |
| 1688 | 1688 | $string = $new_string; |
| 1689 | 1689 | } |
@@ -1699,11 +1699,11 @@ discard block |
||
| 1699 | 1699 | public static function maybe_highlight_menu( $post_type ) { |
| 1700 | 1700 | global $post; |
| 1701 | 1701 | |
| 1702 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1702 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1703 | 1703 | return; |
| 1704 | 1704 | } |
| 1705 | 1705 | |
| 1706 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1706 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
| 1707 | 1707 | return; |
| 1708 | 1708 | } |
| 1709 | 1709 | |
@@ -1807,11 +1807,11 @@ discard block |
||
| 1807 | 1807 | $frm_version = self::plugin_version(); |
| 1808 | 1808 | |
| 1809 | 1809 | // check if Formidable meets minimum requirements |
| 1810 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1810 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
| 1811 | 1811 | return; |
| 1812 | 1812 | } |
| 1813 | 1813 | |
| 1814 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1814 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
| 1815 | 1815 | 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">' . |
| 1816 | 1816 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
| 1817 | 1817 | '</div></td></tr>'; |
@@ -1819,38 +1819,38 @@ discard block |
||
| 1819 | 1819 | |
| 1820 | 1820 | public static function locales( $type = 'date' ) { |
| 1821 | 1821 | $locales = array( |
| 1822 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1823 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1824 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1822 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1823 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1824 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1825 | 1825 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
| 1826 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1827 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1826 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1827 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1828 | 1828 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
| 1829 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1830 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1829 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1830 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1831 | 1831 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
| 1832 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1832 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1833 | 1833 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
| 1834 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1834 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1835 | 1835 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
| 1836 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1836 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1837 | 1837 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
| 1838 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1839 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1840 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1841 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1842 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1838 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1839 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1840 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1841 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1842 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1843 | 1843 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
| 1844 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1844 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1845 | 1845 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
| 1846 | 1846 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
| 1847 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1847 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1848 | 1848 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
| 1849 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1849 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1850 | 1850 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
| 1851 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1852 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1853 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1851 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1852 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1853 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1854 | 1854 | ); |
| 1855 | 1855 | |
| 1856 | 1856 | if ( $type == 'captcha' ) { |
@@ -1869,8 +1869,8 @@ discard block |
||
| 1869 | 1869 | ); |
| 1870 | 1870 | } |
| 1871 | 1871 | |
| 1872 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1873 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1872 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
| 1873 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
| 1874 | 1874 | |
| 1875 | 1875 | return $locales; |
| 1876 | 1876 | } |
@@ -5,59 +5,59 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | class FrmEntriesHelper { |
| 7 | 7 | |
| 8 | - public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
| 8 | + public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
| 9 | 9 | $values = array( 'name' => '', 'description' => '', 'item_key' => '' ); |
| 10 | 10 | |
| 11 | - $values['fields'] = array(); |
|
| 12 | - if ( empty($fields) ) { |
|
| 13 | - return apply_filters('frm_setup_new_entry', $values); |
|
| 14 | - } |
|
| 11 | + $values['fields'] = array(); |
|
| 12 | + if ( empty($fields) ) { |
|
| 13 | + return apply_filters('frm_setup_new_entry', $values); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - foreach ( (array) $fields as $field ) { |
|
| 16 | + foreach ( (array) $fields as $field ) { |
|
| 17 | 17 | self::prepare_field_default_value( $field ); |
| 18 | - $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); |
|
| 19 | - |
|
| 20 | - $field_array = array( |
|
| 21 | - 'id' => $field->id, |
|
| 22 | - 'value' => $new_value, |
|
| 23 | - 'default_value' => $field->default_value, |
|
| 24 | - 'name' => $field->name, |
|
| 25 | - 'description' => $field->description, |
|
| 26 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
| 27 | - 'options' => $field->options, |
|
| 28 | - 'required' => $field->required, |
|
| 29 | - 'field_key' => $field->field_key, |
|
| 30 | - 'field_order' => $field->field_order, |
|
| 31 | - 'form_id' => $field->form_id, |
|
| 18 | + $new_value = self::get_field_value_for_new_entry( $field, $reset, $args ); |
|
| 19 | + |
|
| 20 | + $field_array = array( |
|
| 21 | + 'id' => $field->id, |
|
| 22 | + 'value' => $new_value, |
|
| 23 | + 'default_value' => $field->default_value, |
|
| 24 | + 'name' => $field->name, |
|
| 25 | + 'description' => $field->description, |
|
| 26 | + 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
| 27 | + 'options' => $field->options, |
|
| 28 | + 'required' => $field->required, |
|
| 29 | + 'field_key' => $field->field_key, |
|
| 30 | + 'field_order' => $field->field_order, |
|
| 31 | + 'form_id' => $field->form_id, |
|
| 32 | 32 | 'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id, |
| 33 | - 'reset_value' => $reset, |
|
| 33 | + 'reset_value' => $reset, |
|
| 34 | 34 | 'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0', |
| 35 | - ); |
|
| 35 | + ); |
|
| 36 | 36 | |
| 37 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 38 | - $opt_defaults['required_indicator'] = ''; |
|
| 37 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 38 | + $opt_defaults['required_indicator'] = ''; |
|
| 39 | 39 | $opt_defaults['original_type'] = $field->type; |
| 40 | 40 | |
| 41 | 41 | foreach ( $opt_defaults as $opt => $default_opt ) { |
| 42 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
| 43 | - unset($opt, $default_opt); |
|
| 44 | - } |
|
| 42 | + $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
| 43 | + unset($opt, $default_opt); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - unset($opt_defaults); |
|
| 46 | + unset($opt_defaults); |
|
| 47 | 47 | |
| 48 | - if ( $field_array['custom_html'] == '' ) { |
|
| 49 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
| 50 | - } |
|
| 48 | + if ( $field_array['custom_html'] == '' ) { |
|
| 49 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
| 53 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 52 | + $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
| 53 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 54 | 54 | |
| 55 | - $values['fields'][] = $field_array; |
|
| 55 | + $values['fields'][] = $field_array; |
|
| 56 | 56 | |
| 57 | - if ( ! $form || ! isset($form->id) ) { |
|
| 58 | - $form = FrmForm::getOne($field->form_id); |
|
| 59 | - } |
|
| 60 | - } |
|
| 57 | + if ( ! $form || ! isset($form->id) ) { |
|
| 58 | + $form = FrmForm::getOne($field->form_id); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | $form->options = maybe_unserialize( $form->options ); |
| 63 | 63 | if ( is_array( $form->options ) ) { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | $values = array_merge( $form_defaults, $values ); |
| 73 | 73 | |
| 74 | 74 | return apply_filters( 'frm_setup_new_entry', $values ); |
| 75 | - } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * @since 2.05 |
@@ -87,16 +87,16 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | - * Set the value for each field |
|
| 91 | - * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
| 92 | - * |
|
| 93 | - * @since 2.0.13 |
|
| 94 | - * |
|
| 95 | - * @param object $field - this is passed by reference since it is an object |
|
| 96 | - * @param boolean $reset |
|
| 97 | - * @param array $args |
|
| 98 | - * @return string|array $new_value |
|
| 99 | - */ |
|
| 90 | + * Set the value for each field |
|
| 91 | + * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
| 92 | + * |
|
| 93 | + * @since 2.0.13 |
|
| 94 | + * |
|
| 95 | + * @param object $field - this is passed by reference since it is an object |
|
| 96 | + * @param boolean $reset |
|
| 97 | + * @param array $args |
|
| 98 | + * @return string|array $new_value |
|
| 99 | + */ |
|
| 100 | 100 | private static function get_field_value_for_new_entry( $field, $reset, $args ) { |
| 101 | 101 | $new_value = $field->default_value; |
| 102 | 102 | |
@@ -121,13 +121,13 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | - * Check if a field has a posted value |
|
| 125 | - * |
|
| 126 | - * @since 2.01.0 |
|
| 127 | - * @param object $field |
|
| 128 | - * @param array $args |
|
| 129 | - * @return boolean $value_is_posted |
|
| 130 | - */ |
|
| 124 | + * Check if a field has a posted value |
|
| 125 | + * |
|
| 126 | + * @since 2.01.0 |
|
| 127 | + * @param object $field |
|
| 128 | + * @param array $args |
|
| 129 | + * @return boolean $value_is_posted |
|
| 130 | + */ |
|
| 131 | 131 | public static function value_is_posted( $field, $args ) { |
| 132 | 132 | $value_is_posted = false; |
| 133 | 133 | if ( $_POST ) { |
@@ -145,15 +145,15 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | public static function setup_edit_vars( $values, $record ) { |
| 147 | 147 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
| 148 | - $values['form_id'] = $record->form_id; |
|
| 149 | - $values['is_draft'] = $record->is_draft; |
|
| 150 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
| 151 | - } |
|
| 148 | + $values['form_id'] = $record->form_id; |
|
| 149 | + $values['is_draft'] = $record->is_draft; |
|
| 150 | + return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - public static function get_admin_params( $form = null ) { |
|
| 153 | + public static function get_admin_params( $form = null ) { |
|
| 154 | 154 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' ); |
| 155 | 155 | return FrmForm::set_current_form( $form ); |
| 156 | - } |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | 158 | public static function set_current_form( $form_id ) { |
| 159 | 159 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' ); |
@@ -165,282 +165,282 @@ discard block |
||
| 165 | 165 | return FrmForm::get_current_form( $form_id ); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - public static function get_current_form_id() { |
|
| 168 | + public static function get_current_form_id() { |
|
| 169 | 169 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' ); |
| 170 | 170 | return FrmForm::get_current_form_id(); |
| 171 | - } |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - public static function maybe_get_entry( &$entry ) { |
|
| 173 | + public static function maybe_get_entry( &$entry ) { |
|
| 174 | 174 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' ); |
| 175 | 175 | FrmEntry::maybe_get_entry( $entry ); |
| 176 | - } |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | 178 | public static function replace_default_message( $message, $atts ) { |
| 179 | - if ( strpos($message, '[default-message') === false && |
|
| 180 | - strpos($message, '[default_message') === false && |
|
| 181 | - ! empty( $message ) ) { |
|
| 182 | - return $message; |
|
| 183 | - } |
|
| 179 | + if ( strpos($message, '[default-message') === false && |
|
| 180 | + strpos($message, '[default_message') === false && |
|
| 181 | + ! empty( $message ) ) { |
|
| 182 | + return $message; |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - if ( empty($message) ) { |
|
| 186 | - $message = '[default-message]'; |
|
| 187 | - } |
|
| 185 | + if ( empty($message) ) { |
|
| 186 | + $message = '[default-message]'; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
| 189 | + preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
| 190 | 190 | |
| 191 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 191 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 192 | 192 | $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
| 193 | 193 | if ( ! empty( $add_atts ) ) { |
| 194 | - $this_atts = array_merge($atts, $add_atts); |
|
| 195 | - } else { |
|
| 196 | - $this_atts = $atts; |
|
| 197 | - } |
|
| 194 | + $this_atts = array_merge($atts, $add_atts); |
|
| 195 | + } else { |
|
| 196 | + $this_atts = $atts; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | 199 | $default = FrmEntriesController::show_entry_shortcode( $this_atts ); |
| 200 | 200 | |
| 201 | - // Add the default message |
|
| 202 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
| 203 | - } |
|
| 201 | + // Add the default message |
|
| 202 | + $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - return $message; |
|
| 206 | - } |
|
| 205 | + return $message; |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | 208 | public static function prepare_display_value( $entry, $field, $atts ) { |
| 209 | 209 | $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
| 210 | 210 | |
| 211 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 211 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 212 | 212 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
| 213 | - } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
| 216 | - return self::display_value($field_value, $field, $atts); |
|
| 217 | - } |
|
| 215 | + if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
| 216 | + return self::display_value($field_value, $field, $atts); |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - // this is an embeded form |
|
| 220 | - $val = ''; |
|
| 219 | + // this is an embeded form |
|
| 220 | + $val = ''; |
|
| 221 | 221 | |
| 222 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
| 223 | - //this is a repeating section |
|
| 222 | + if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
| 223 | + //this is a repeating section |
|
| 224 | 224 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
| 225 | - } else { |
|
| 226 | - // get all values for this field |
|
| 227 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
| 225 | + } else { |
|
| 226 | + // get all values for this field |
|
| 227 | + $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
| 228 | 228 | |
| 229 | - if ( $child_values ) { |
|
| 230 | - $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
| 231 | - } |
|
| 232 | - } |
|
| 229 | + if ( $child_values ) { |
|
| 230 | + $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - $field_value = array(); |
|
| 234 | + $field_value = array(); |
|
| 235 | 235 | |
| 236 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
| 237 | - return $val; |
|
| 238 | - } |
|
| 236 | + if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
| 237 | + return $val; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - foreach ( $child_entries as $child_entry ) { |
|
| 241 | - $atts['item_id'] = $child_entry->id; |
|
| 242 | - $atts['post_id'] = $child_entry->post_id; |
|
| 240 | + foreach ( $child_entries as $child_entry ) { |
|
| 241 | + $atts['item_id'] = $child_entry->id; |
|
| 242 | + $atts['post_id'] = $child_entry->post_id; |
|
| 243 | 243 | |
| 244 | - // get the value for this field -- check for post values as well |
|
| 245 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
| 244 | + // get the value for this field -- check for post values as well |
|
| 245 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
| 246 | 246 | |
| 247 | - if ( $entry_val ) { |
|
| 248 | - // foreach entry get display_value |
|
| 249 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
| 250 | - } |
|
| 247 | + if ( $entry_val ) { |
|
| 248 | + // foreach entry get display_value |
|
| 249 | + $field_value[] = self::display_value($entry_val, $field, $atts); |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - unset($child_entry); |
|
| 253 | - } |
|
| 252 | + unset($child_entry); |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - $val = implode(', ', (array) $field_value ); |
|
| 255 | + $val = implode(', ', (array) $field_value ); |
|
| 256 | 256 | return FrmAppHelper::kses( $val ); |
| 257 | - } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * Prepare the saved value for display |
|
| 261 | - * @return string |
|
| 262 | - */ |
|
| 259 | + /** |
|
| 260 | + * Prepare the saved value for display |
|
| 261 | + * @return string |
|
| 262 | + */ |
|
| 263 | 263 | public static function display_value( $value, $field, $atts = array() ) { |
| 264 | 264 | |
| 265 | - $defaults = array( |
|
| 266 | - 'type' => '', 'html' => false, 'show_filename' => true, |
|
| 267 | - 'truncate' => false, 'sep' => ', ', 'post_id' => 0, |
|
| 268 | - 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, |
|
| 265 | + $defaults = array( |
|
| 266 | + 'type' => '', 'html' => false, 'show_filename' => true, |
|
| 267 | + 'truncate' => false, 'sep' => ', ', 'post_id' => 0, |
|
| 268 | + 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, |
|
| 269 | 269 | 'return_array' => false, |
| 270 | - ); |
|
| 270 | + ); |
|
| 271 | 271 | |
| 272 | - $atts = wp_parse_args( $atts, $defaults ); |
|
| 273 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
| 272 | + $atts = wp_parse_args( $atts, $defaults ); |
|
| 273 | + $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
| 274 | 274 | |
| 275 | - if ( ! isset($field->field_options['post_field']) ) { |
|
| 276 | - $field->field_options['post_field'] = ''; |
|
| 277 | - } |
|
| 275 | + if ( ! isset($field->field_options['post_field']) ) { |
|
| 276 | + $field->field_options['post_field'] = ''; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 280 | - $field->field_options['custom_field'] = ''; |
|
| 281 | - } |
|
| 279 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
| 280 | + $field->field_options['custom_field'] = ''; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
| 284 | - $atts['pre_truncate'] = $atts['truncate']; |
|
| 285 | - $atts['truncate'] = true; |
|
| 286 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
| 283 | + if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
| 284 | + $atts['pre_truncate'] = $atts['truncate']; |
|
| 285 | + $atts['truncate'] = true; |
|
| 286 | + $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
| 287 | 287 | |
| 288 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
| 289 | - $atts['truncate'] = $atts['pre_truncate']; |
|
| 290 | - } |
|
| 288 | + $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
| 289 | + $atts['truncate'] = $atts['pre_truncate']; |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - if ( $value == '' ) { |
|
| 293 | - return $value; |
|
| 294 | - } |
|
| 292 | + if ( $value == '' ) { |
|
| 293 | + return $value; |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | - $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
| 296 | + $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
| 297 | 297 | $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) ); |
| 298 | 298 | |
| 299 | - $new_value = ''; |
|
| 299 | + $new_value = ''; |
|
| 300 | 300 | |
| 301 | - if ( is_array($value) && $atts['type'] != 'file' ) { |
|
| 302 | - foreach ( $value as $val ) { |
|
| 303 | - if ( is_array($val) ) { |
|
| 301 | + if ( is_array($value) && $atts['type'] != 'file' ) { |
|
| 302 | + foreach ( $value as $val ) { |
|
| 303 | + if ( is_array($val) ) { |
|
| 304 | 304 | //TODO: add options for display (li or ,) |
| 305 | - $new_value .= implode($atts['sep'], $val); |
|
| 306 | - if ( $atts['type'] != 'data' ) { |
|
| 307 | - $new_value .= '<br/>'; |
|
| 308 | - } |
|
| 309 | - } |
|
| 310 | - unset($val); |
|
| 311 | - } |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - if ( ! empty($new_value) ) { |
|
| 315 | - $value = $new_value; |
|
| 316 | - } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
| 317 | - $value = implode($atts['sep'], $value); |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
| 321 | - $value = FrmAppHelper::truncate($value, 50); |
|
| 322 | - } |
|
| 305 | + $new_value .= implode($atts['sep'], $val); |
|
| 306 | + if ( $atts['type'] != 'data' ) { |
|
| 307 | + $new_value .= '<br/>'; |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | + unset($val); |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + if ( ! empty($new_value) ) { |
|
| 315 | + $value = $new_value; |
|
| 316 | + } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
| 317 | + $value = implode($atts['sep'], $value); |
|
| 318 | + } |
|
| 319 | + |
|
| 320 | + if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
| 321 | + $value = FrmAppHelper::truncate($value, 50); |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | 324 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
| 325 | 325 | $value = FrmAppHelper::kses( $value ); |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - return apply_filters('frm_display_value', $value, $field, $atts); |
|
| 329 | - } |
|
| 328 | + return apply_filters('frm_display_value', $value, $field, $atts); |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | 331 | public static function set_posted_value( $field, $value, $args ) { |
| 332 | - // If validating a field with "other" opt, set back to prev value now |
|
| 333 | - if ( isset( $args['other'] ) && $args['other'] ) { |
|
| 334 | - $value = $args['temp_value']; |
|
| 335 | - } |
|
| 336 | - if ( empty($args['parent_field_id']) ) { |
|
| 337 | - $_POST['item_meta'][ $field->id ] = $value; |
|
| 338 | - } else { |
|
| 339 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
| 340 | - } |
|
| 341 | - } |
|
| 332 | + // If validating a field with "other" opt, set back to prev value now |
|
| 333 | + if ( isset( $args['other'] ) && $args['other'] ) { |
|
| 334 | + $value = $args['temp_value']; |
|
| 335 | + } |
|
| 336 | + if ( empty($args['parent_field_id']) ) { |
|
| 337 | + $_POST['item_meta'][ $field->id ] = $value; |
|
| 338 | + } else { |
|
| 339 | + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | 343 | public static function get_posted_value( $field, &$value, $args ) { |
| 344 | 344 | $field_id = is_object( $field ) ? $field->id : $field; |
| 345 | 345 | |
| 346 | - if ( empty($args['parent_field_id']) ) { |
|
| 347 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
| 348 | - } else { |
|
| 349 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
| 350 | - } |
|
| 346 | + if ( empty($args['parent_field_id']) ) { |
|
| 347 | + $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
| 348 | + } else { |
|
| 349 | + $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
| 350 | + } |
|
| 351 | 351 | FrmAppHelper::sanitize_value( 'wp_kses_post', $value ); |
| 352 | 352 | $value = stripslashes_deep( $value ); |
| 353 | - } |
|
| 354 | - |
|
| 355 | - /** |
|
| 356 | - * Check if field has an "Other" option and if any other values are posted |
|
| 357 | - * |
|
| 358 | - * @since 2.0 |
|
| 359 | - * |
|
| 360 | - * @param object $field |
|
| 361 | - * @param string|array $value |
|
| 362 | - * @param array $args |
|
| 363 | - */ |
|
| 364 | - public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
| 365 | - $args['other'] = false; |
|
| 366 | - if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
| 367 | - return; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - // Get other value for fields in repeating section |
|
| 371 | - self::set_other_repeating_vals( $field, $value, $args ); |
|
| 372 | - |
|
| 373 | - // Check if there are any posted "Other" values |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + /** |
|
| 356 | + * Check if field has an "Other" option and if any other values are posted |
|
| 357 | + * |
|
| 358 | + * @since 2.0 |
|
| 359 | + * |
|
| 360 | + * @param object $field |
|
| 361 | + * @param string|array $value |
|
| 362 | + * @param array $args |
|
| 363 | + */ |
|
| 364 | + public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
| 365 | + $args['other'] = false; |
|
| 366 | + if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
| 367 | + return; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + // Get other value for fields in repeating section |
|
| 371 | + self::set_other_repeating_vals( $field, $value, $args ); |
|
| 372 | + |
|
| 373 | + // Check if there are any posted "Other" values |
|
| 374 | 374 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
| 375 | 375 | |
| 376 | - // Save original value |
|
| 377 | - $args['temp_value'] = $value; |
|
| 378 | - $args['other'] = true; |
|
| 379 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
| 380 | - |
|
| 381 | - // Set the validation value now |
|
| 382 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
| 383 | - } |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
| 388 | - * |
|
| 389 | - * @since 2.0 |
|
| 390 | - * |
|
| 391 | - * @param object $field |
|
| 392 | - * @param string|array $value |
|
| 393 | - * @param array $args |
|
| 394 | - */ |
|
| 395 | - public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
| 396 | - if ( ! $args['parent_field_id'] ) { |
|
| 397 | - return; |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - // Check if there are any other posted "other" values for this field |
|
| 376 | + // Save original value |
|
| 377 | + $args['temp_value'] = $value; |
|
| 378 | + $args['other'] = true; |
|
| 379 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
| 380 | + |
|
| 381 | + // Set the validation value now |
|
| 382 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
| 383 | + } |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
| 388 | + * |
|
| 389 | + * @since 2.0 |
|
| 390 | + * |
|
| 391 | + * @param object $field |
|
| 392 | + * @param string|array $value |
|
| 393 | + * @param array $args |
|
| 394 | + */ |
|
| 395 | + public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
| 396 | + if ( ! $args['parent_field_id'] ) { |
|
| 397 | + return; |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + // Check if there are any other posted "other" values for this field |
|
| 401 | 401 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
| 402 | - // Save original value |
|
| 403 | - $args['temp_value'] = $value; |
|
| 404 | - $args['other'] = true; |
|
| 405 | - |
|
| 406 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
| 407 | - |
|
| 408 | - // Set the validation value now |
|
| 409 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
| 410 | - } |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - /** |
|
| 414 | - * Modify value used for validation |
|
| 415 | - * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
| 416 | - * It also adds any text from the free text fields to the value |
|
| 417 | - * |
|
| 418 | - * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
| 419 | - * |
|
| 420 | - * @since 2.0 |
|
| 421 | - * |
|
| 422 | - * @param string|array $value |
|
| 423 | - * @param string|array $other_vals (usually of posted values) |
|
| 424 | - * @param object $field |
|
| 425 | - * @param array $args |
|
| 426 | - */ |
|
| 427 | - public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
| 428 | - // Checkboxes and multi-select dropdowns |
|
| 429 | - if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
| 430 | - // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
| 431 | - $value = array_merge( $value, $other_vals ); |
|
| 432 | - $value = array_filter( $value ); |
|
| 433 | - if ( count( $value ) == 0 ) { |
|
| 434 | - $value = ''; |
|
| 435 | - } |
|
| 436 | - } else { |
|
| 402 | + // Save original value |
|
| 403 | + $args['temp_value'] = $value; |
|
| 404 | + $args['other'] = true; |
|
| 405 | + |
|
| 406 | + $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
| 407 | + |
|
| 408 | + // Set the validation value now |
|
| 409 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
| 410 | + } |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * Modify value used for validation |
|
| 415 | + * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
| 416 | + * It also adds any text from the free text fields to the value |
|
| 417 | + * |
|
| 418 | + * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
| 419 | + * |
|
| 420 | + * @since 2.0 |
|
| 421 | + * |
|
| 422 | + * @param string|array $value |
|
| 423 | + * @param string|array $other_vals (usually of posted values) |
|
| 424 | + * @param object $field |
|
| 425 | + * @param array $args |
|
| 426 | + */ |
|
| 427 | + public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
| 428 | + // Checkboxes and multi-select dropdowns |
|
| 429 | + if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
| 430 | + // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
| 431 | + $value = array_merge( $value, $other_vals ); |
|
| 432 | + $value = array_filter( $value ); |
|
| 433 | + if ( count( $value ) == 0 ) { |
|
| 434 | + $value = ''; |
|
| 435 | + } |
|
| 436 | + } else { |
|
| 437 | 437 | // Radio and dropdowns |
| 438 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
| 439 | - $other_key = reset( $other_key ); |
|
| 438 | + $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
| 439 | + $other_key = reset( $other_key ); |
|
| 440 | 440 | |
| 441 | - // Multi-select dropdown |
|
| 442 | - if ( is_array( $value ) ) { |
|
| 443 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
| 441 | + // Multi-select dropdown |
|
| 442 | + if ( is_array( $value ) ) { |
|
| 443 | + $o_key = array_search( $field->options[ $other_key ], $value ); |
|
| 444 | 444 | |
| 445 | 445 | if ( $o_key !== false ) { |
| 446 | 446 | // Modify the original value so other key will be preserved |
@@ -455,20 +455,20 @@ discard block |
||
| 455 | 455 | $args['temp_value'] = $value; |
| 456 | 456 | $value[ $other_key ] = reset( $other_vals ); |
| 457 | 457 | } |
| 458 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
| 459 | - $value = $other_vals; |
|
| 460 | - } |
|
| 461 | - } |
|
| 462 | - } |
|
| 458 | + } else if ( $field->options[ $other_key ] == $value ) { |
|
| 459 | + $value = $other_vals; |
|
| 460 | + } |
|
| 461 | + } |
|
| 462 | + } |
|
| 463 | 463 | |
| 464 | 464 | public static function enqueue_scripts( $params ) { |
| 465 | 465 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' ); |
| 466 | 466 | FrmFormsController::enqueue_scripts( $params ); |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - // Add submitted values to a string for spam checking |
|
| 469 | + // Add submitted values to a string for spam checking |
|
| 470 | 470 | public static function entry_array_to_string( $values ) { |
| 471 | - $content = ''; |
|
| 471 | + $content = ''; |
|
| 472 | 472 | foreach ( $values['item_meta'] as $val ) { |
| 473 | 473 | if ( $content != '' ) { |
| 474 | 474 | $content .= "\n\n"; |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | return $content; |
| 486 | - } |
|
| 486 | + } |
|
| 487 | 487 | |
| 488 | 488 | /** |
| 489 | 489 | * Get the browser from the user agent |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -9,8 +9,8 @@ discard block |
||
| 9 | 9 | $values = array( 'name' => '', 'description' => '', 'item_key' => '' ); |
| 10 | 10 | |
| 11 | 11 | $values['fields'] = array(); |
| 12 | - if ( empty($fields) ) { |
|
| 13 | - return apply_filters('frm_setup_new_entry', $values); |
|
| 12 | + if ( empty( $fields ) ) { |
|
| 13 | + return apply_filters( 'frm_setup_new_entry', $values ); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | foreach ( (array) $fields as $field ) { |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | 'default_value' => $field->default_value, |
| 24 | 24 | 'name' => $field->name, |
| 25 | 25 | 'description' => $field->description, |
| 26 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
| 26 | + 'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ), |
|
| 27 | 27 | 'options' => $field->options, |
| 28 | 28 | 'required' => $field->required, |
| 29 | 29 | 'field_key' => $field->field_key, |
@@ -34,28 +34,28 @@ discard block |
||
| 34 | 34 | 'in_embed_form' => isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0', |
| 35 | 35 | ); |
| 36 | 36 | |
| 37 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 37 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
| 38 | 38 | $opt_defaults['required_indicator'] = ''; |
| 39 | 39 | $opt_defaults['original_type'] = $field->type; |
| 40 | 40 | |
| 41 | 41 | foreach ( $opt_defaults as $opt => $default_opt ) { |
| 42 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
| 43 | - unset($opt, $default_opt); |
|
| 42 | + $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt; |
|
| 43 | + unset( $opt, $default_opt ); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - unset($opt_defaults); |
|
| 46 | + unset( $opt_defaults ); |
|
| 47 | 47 | |
| 48 | 48 | if ( $field_array['custom_html'] == '' ) { |
| 49 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
| 49 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type ); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
| 52 | + $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args ); |
|
| 53 | 53 | $field_array = array_merge( $field->field_options, $field_array ); |
| 54 | 54 | |
| 55 | 55 | $values['fields'][] = $field_array; |
| 56 | 56 | |
| 57 | - if ( ! $form || ! isset($form->id) ) { |
|
| 58 | - $form = FrmForm::getOne($field->form_id); |
|
| 57 | + if ( ! $form || ! isset( $form->id ) ) { |
|
| 58 | + $form = FrmForm::getOne( $field->form_id ); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $form_defaults = FrmFormsHelper::get_default_opts(); |
| 68 | 68 | |
| 69 | 69 | $frm_settings = FrmAppHelper::get_settings(); |
| 70 | - $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
| 70 | + $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
| 71 | 71 | |
| 72 | 72 | $values = array_merge( $form_defaults, $values ); |
| 73 | 73 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | if ( ! is_array( $new_value ) ) { |
| 117 | - $new_value = str_replace('"', '"', $new_value); |
|
| 117 | + $new_value = str_replace( '"', '"', $new_value ); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | return $new_value; |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | if ( $_POST ) { |
| 134 | 134 | $repeating = isset( $args['repeating'] ) && $args['repeating']; |
| 135 | 135 | if ( $repeating ) { |
| 136 | - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { |
|
| 136 | + if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) { |
|
| 137 | 137 | $value_is_posted = true; |
| 138 | 138 | } |
| 139 | - } else if ( isset( $_POST['item_meta'][ $field->id ] ) ) { |
|
| 139 | + } else if ( isset( $_POST['item_meta'][$field->id] ) ) { |
|
| 140 | 140 | $value_is_posted = true; |
| 141 | 141 | } |
| 142 | 142 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
| 148 | 148 | $values['form_id'] = $record->form_id; |
| 149 | 149 | $values['is_draft'] = $record->is_draft; |
| 150 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
| 150 | + return apply_filters( 'frm_setup_edit_entry_vars', $values, $record ); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | public static function get_admin_params( $form = null ) { |
@@ -176,22 +176,22 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | public static function replace_default_message( $message, $atts ) { |
| 179 | - if ( strpos($message, '[default-message') === false && |
|
| 180 | - strpos($message, '[default_message') === false && |
|
| 179 | + if ( strpos( $message, '[default-message' ) === false && |
|
| 180 | + strpos( $message, '[default_message' ) === false && |
|
| 181 | 181 | ! empty( $message ) ) { |
| 182 | 182 | return $message; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if ( empty($message) ) { |
|
| 185 | + if ( empty( $message ) ) { |
|
| 186 | 186 | $message = '[default-message]'; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
| 189 | + preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER ); |
|
| 190 | 190 | |
| 191 | 191 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
| 192 | - $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 192 | + $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] ); |
|
| 193 | 193 | if ( ! empty( $add_atts ) ) { |
| 194 | - $this_atts = array_merge($atts, $add_atts); |
|
| 194 | + $this_atts = array_merge( $atts, $add_atts ); |
|
| 195 | 195 | } else { |
| 196 | 196 | $this_atts = $atts; |
| 197 | 197 | } |
@@ -199,32 +199,32 @@ discard block |
||
| 199 | 199 | $default = FrmEntriesController::show_entry_shortcode( $this_atts ); |
| 200 | 200 | |
| 201 | 201 | // Add the default message |
| 202 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
| 202 | + $message = str_replace( $shortcodes[0][$short_key], $default, $message ); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | return $message; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | public static function prepare_display_value( $entry, $field, $atts ) { |
| 209 | - $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
|
| 209 | + $field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false; |
|
| 210 | 210 | |
| 211 | 211 | if ( FrmAppHelper::pro_is_installed() ) { |
| 212 | 212 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
| 216 | - return self::display_value($field_value, $field, $atts); |
|
| 215 | + if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) { |
|
| 216 | + return self::display_value( $field_value, $field, $atts ); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // this is an embeded form |
| 220 | 220 | $val = ''; |
| 221 | 221 | |
| 222 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
| 222 | + if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) { |
|
| 223 | 223 | //this is a repeating section |
| 224 | 224 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
| 225 | 225 | } else { |
| 226 | 226 | // get all values for this field |
| 227 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
| 227 | + $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false; |
|
| 228 | 228 | |
| 229 | 229 | if ( $child_values ) { |
| 230 | 230 | $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | $field_value = array(); |
| 235 | 235 | |
| 236 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
| 236 | + if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
| 237 | 237 | return $val; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -242,17 +242,17 @@ discard block |
||
| 242 | 242 | $atts['post_id'] = $child_entry->post_id; |
| 243 | 243 | |
| 244 | 244 | // get the value for this field -- check for post values as well |
| 245 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
| 245 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field ); |
|
| 246 | 246 | |
| 247 | 247 | if ( $entry_val ) { |
| 248 | 248 | // foreach entry get display_value |
| 249 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
| 249 | + $field_value[] = self::display_value( $entry_val, $field, $atts ); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - unset($child_entry); |
|
| 252 | + unset( $child_entry ); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - $val = implode(', ', (array) $field_value ); |
|
| 255 | + $val = implode( ', ', (array) $field_value ); |
|
| 256 | 256 | return FrmAppHelper::kses( $val ); |
| 257 | 257 | } |
| 258 | 258 | |
@@ -270,22 +270,22 @@ discard block |
||
| 270 | 270 | ); |
| 271 | 271 | |
| 272 | 272 | $atts = wp_parse_args( $atts, $defaults ); |
| 273 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
| 273 | + $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value ); |
|
| 274 | 274 | |
| 275 | - if ( ! isset($field->field_options['post_field']) ) { |
|
| 275 | + if ( ! isset( $field->field_options['post_field'] ) ) { |
|
| 276 | 276 | $field->field_options['post_field'] = ''; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 279 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
| 280 | 280 | $field->field_options['custom_field'] = ''; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
| 284 | 284 | $atts['pre_truncate'] = $atts['truncate']; |
| 285 | 285 | $atts['truncate'] = true; |
| 286 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
| 286 | + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0; |
|
| 287 | 287 | |
| 288 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
| 288 | + $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts ); |
|
| 289 | 289 | $atts['truncate'] = $atts['pre_truncate']; |
| 290 | 290 | } |
| 291 | 291 | |
@@ -293,39 +293,39 @@ discard block |
||
| 293 | 293 | return $value; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
| 296 | + $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts ); |
|
| 297 | 297 | $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) ); |
| 298 | 298 | |
| 299 | 299 | $new_value = ''; |
| 300 | 300 | |
| 301 | - if ( is_array($value) && $atts['type'] != 'file' ) { |
|
| 301 | + if ( is_array( $value ) && $atts['type'] != 'file' ) { |
|
| 302 | 302 | foreach ( $value as $val ) { |
| 303 | - if ( is_array($val) ) { |
|
| 303 | + if ( is_array( $val ) ) { |
|
| 304 | 304 | //TODO: add options for display (li or ,) |
| 305 | - $new_value .= implode($atts['sep'], $val); |
|
| 305 | + $new_value .= implode( $atts['sep'], $val ); |
|
| 306 | 306 | if ( $atts['type'] != 'data' ) { |
| 307 | 307 | $new_value .= '<br/>'; |
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | - unset($val); |
|
| 310 | + unset( $val ); |
|
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - if ( ! empty($new_value) ) { |
|
| 314 | + if ( ! empty( $new_value ) ) { |
|
| 315 | 315 | $value = $new_value; |
| 316 | - } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
| 317 | - $value = implode($atts['sep'], $value); |
|
| 316 | + } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
| 317 | + $value = implode( $atts['sep'], $value ); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
| 321 | - $value = FrmAppHelper::truncate($value, 50); |
|
| 321 | + $value = FrmAppHelper::truncate( $value, 50 ); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
| 325 | 325 | $value = FrmAppHelper::kses( $value ); |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - return apply_filters('frm_display_value', $value, $field, $atts); |
|
| 328 | + return apply_filters( 'frm_display_value', $value, $field, $atts ); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | public static function set_posted_value( $field, $value, $args ) { |
@@ -333,20 +333,20 @@ discard block |
||
| 333 | 333 | if ( isset( $args['other'] ) && $args['other'] ) { |
| 334 | 334 | $value = $args['temp_value']; |
| 335 | 335 | } |
| 336 | - if ( empty($args['parent_field_id']) ) { |
|
| 337 | - $_POST['item_meta'][ $field->id ] = $value; |
|
| 336 | + if ( empty( $args['parent_field_id'] ) ) { |
|
| 337 | + $_POST['item_meta'][$field->id] = $value; |
|
| 338 | 338 | } else { |
| 339 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
| 339 | + $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value; |
|
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | public static function get_posted_value( $field, &$value, $args ) { |
| 344 | 344 | $field_id = is_object( $field ) ? $field->id : $field; |
| 345 | 345 | |
| 346 | - if ( empty($args['parent_field_id']) ) { |
|
| 347 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
| 346 | + if ( empty( $args['parent_field_id'] ) ) { |
|
| 347 | + $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : ''; |
|
| 348 | 348 | } else { |
| 349 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
| 349 | + $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : ''; |
|
| 350 | 350 | } |
| 351 | 351 | FrmAppHelper::sanitize_value( 'wp_kses_post', $value ); |
| 352 | 352 | $value = stripslashes_deep( $value ); |
@@ -371,12 +371,12 @@ discard block |
||
| 371 | 371 | self::set_other_repeating_vals( $field, $value, $args ); |
| 372 | 372 | |
| 373 | 373 | // Check if there are any posted "Other" values |
| 374 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
|
| 374 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) { |
|
| 375 | 375 | |
| 376 | 376 | // Save original value |
| 377 | 377 | $args['temp_value'] = $value; |
| 378 | 378 | $args['other'] = true; |
| 379 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
| 379 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] ); |
|
| 380 | 380 | |
| 381 | 381 | // Set the validation value now |
| 382 | 382 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -398,12 +398,12 @@ discard block |
||
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | // Check if there are any other posted "other" values for this field |
| 401 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
|
| 401 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) { |
|
| 402 | 402 | // Save original value |
| 403 | 403 | $args['temp_value'] = $value; |
| 404 | 404 | $args['other'] = true; |
| 405 | 405 | |
| 406 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
| 406 | + $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id]; |
|
| 407 | 407 | |
| 408 | 408 | // Set the validation value now |
| 409 | 409 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -435,27 +435,27 @@ discard block |
||
| 435 | 435 | } |
| 436 | 436 | } else { |
| 437 | 437 | // Radio and dropdowns |
| 438 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
| 438 | + $other_key = array_filter( array_keys( $field->options ), 'is_string' ); |
|
| 439 | 439 | $other_key = reset( $other_key ); |
| 440 | 440 | |
| 441 | 441 | // Multi-select dropdown |
| 442 | 442 | if ( is_array( $value ) ) { |
| 443 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
| 443 | + $o_key = array_search( $field->options[$other_key], $value ); |
|
| 444 | 444 | |
| 445 | 445 | if ( $o_key !== false ) { |
| 446 | 446 | // Modify the original value so other key will be preserved |
| 447 | - $value[ $other_key ] = $value[ $o_key ]; |
|
| 447 | + $value[$other_key] = $value[$o_key]; |
|
| 448 | 448 | |
| 449 | 449 | // By default, the array keys will be numeric for multi-select dropdowns |
| 450 | 450 | // If going backwards and forwards between pages, the array key will match the other key |
| 451 | 451 | if ( $o_key != $other_key ) { |
| 452 | - unset( $value[ $o_key ] ); |
|
| 452 | + unset( $value[$o_key] ); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | $args['temp_value'] = $value; |
| 456 | - $value[ $other_key ] = reset( $other_vals ); |
|
| 456 | + $value[$other_key] = reset( $other_vals ); |
|
| 457 | 457 | } |
| 458 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
| 458 | + } else if ( $field->options[$other_key] == $value ) { |
|
| 459 | 459 | $value = $other_vals; |
| 460 | 460 | } |
| 461 | 461 | } |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | $content .= "\n\n"; |
| 475 | 475 | } |
| 476 | 476 | |
| 477 | - if ( is_array($val) ) { |
|
| 477 | + if ( is_array( $val ) ) { |
|
| 478 | 478 | $val = FrmAppHelper::array_flatten( $val ); |
| 479 | 479 | $val = implode( ', ', $val ); |
| 480 | 480 | } |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers |
| 539 | 539 | |
| 540 | 540 | // see how many we have |
| 541 | - $i = count($matches['browser']); |
|
| 541 | + $i = count( $matches['browser'] ); |
|
| 542 | 542 | |
| 543 | 543 | if ( $i > 1 ) { |
| 544 | 544 | //we will have two since we are not using 'other' argument yet |