@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | parent::add_hooks(); |
35 | 35 | |
36 | - add_filter( 'gravityview/search/searchable_fields', array( $this, 'modify_search_bar_fields_dropdown'), 10, 2 ); |
|
36 | + add_filter( 'gravityview/search/searchable_fields', array( $this, 'modify_search_bar_fields_dropdown' ), 10, 2 ); |
|
37 | 37 | |
38 | 38 | add_filter( 'gravityview/admin/available_fields', array( $this, 'maybe_add_non_default_fields' ), 10, 3 ); |
39 | 39 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @return void |
54 | 54 | */ |
55 | 55 | public function clear_cache_after_workflow( $form, $entry_id, $step_id, $starting_step_id ) { |
56 | - do_action( 'gravityview_clear_form_cache', $form['id'] ); |
|
56 | + do_action( 'gravityview_clear_form_cache', $form[ 'id' ] ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public static function get_status_options( $form_id = 0, $status_key = 'workflow_final_status' ) { |
72 | 72 | |
73 | - if( empty( $form_id ) ) { |
|
73 | + if ( empty( $form_id ) ) { |
|
74 | 74 | $form_id = GravityView_View::getInstance()->getFormId(); |
75 | 75 | } |
76 | 76 | |
77 | 77 | $entry_meta = gravity_flow()->get_entry_meta( array(), $form_id ); |
78 | 78 | |
79 | - return (array) \GV\Utils::get( $entry_meta, $status_key . '/filter/choices' ); |
|
79 | + return (array)\GV\Utils::get( $entry_meta, $status_key . '/filter/choices' ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | $workflow_steps = $GFlow->get_steps(); |
100 | 100 | |
101 | - if( $workflow_steps ) { |
|
101 | + if ( $workflow_steps ) { |
|
102 | 102 | |
103 | 103 | foreach ( $workflow_steps as $step ) { |
104 | 104 | |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | ); |
111 | 111 | } |
112 | 112 | |
113 | - $fields['workflow_step'] = array( |
|
113 | + $fields[ 'workflow_step' ] = array( |
|
114 | 114 | 'label' => esc_html__( 'Workflow Step', 'gravityview' ), |
115 | 115 | 'type' => 'select', |
116 | 116 | ); |
117 | 117 | |
118 | - $fields['workflow_final_status'] = array( |
|
118 | + $fields[ 'workflow_final_status' ] = array( |
|
119 | 119 | 'label' => esc_html__( 'Workflow Status', 'gravityview' ), |
120 | 120 | 'type' => 'select', |
121 | 121 | ); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | if ( ( $insert_at = array_search( 'workflow_final_status', wp_list_pluck( $fields, 'key' ) ) ) !== false ) { |
132 | 132 | $fields_end = array_splice( $fields, $insert_at + 1 ); |
133 | 133 | |
134 | - $fields[] = array( |
|
134 | + $fields[ ] = array( |
|
135 | 135 | 'text' => __( 'Workflow Current Status Timestamp', 'gravityview' ), |
136 | 136 | 'operators' => array( '>', '<' ), |
137 | 137 | 'placeholder' => 'yyyy-mm-dd', |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | $keys_end = array_splice( $keys, $insert_at + 1 ); |
158 | 158 | $values_end = array_splice( $values, $insert_at + 1 ); |
159 | 159 | |
160 | - $keys[] = 'workflow_current_status_timestamp'; |
|
161 | - $values[] = array( |
|
160 | + $keys[ ] = 'workflow_current_status_timestamp'; |
|
161 | + $values[ ] = array( |
|
162 | 162 | 'label' => __( 'Workflow Current Status Timestamp', 'gravityview' ), |
163 | 163 | 'type' => 'workflow_current_status_timestamp', |
164 | 164 | ); |
@@ -97,7 +97,7 @@ |
||
97 | 97 | * @uses api_request() |
98 | 98 | * |
99 | 99 | * @param array $_transient_data Update array build by WordPress. |
100 | - * @return array Modified update array with custom plugin data. |
|
100 | + * @return stdClass Modified update array with custom plugin data. |
|
101 | 101 | */ |
102 | 102 | public function check_update( $_transient_data ) { |
103 | 103 |
@@ -10,7 +10,9 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
13 | +if ( ! defined( 'ABSPATH' ) ) { |
|
14 | + exit; |
|
15 | +} |
|
14 | 16 | |
15 | 17 | /** |
16 | 18 | * Allows plugins to use their own update API. |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | $this->api_data = $_api_data; |
49 | 49 | $this->name = plugin_basename( $_plugin_file ); |
50 | 50 | $this->slug = basename( $_plugin_file, '.php' ); |
51 | - $this->version = $_api_data['version']; |
|
52 | - $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false; |
|
53 | - $this->beta = ! empty( $this->api_data['beta'] ) ? true : false; |
|
54 | - $this->cache_key = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ); |
|
51 | + $this->version = $_api_data[ 'version' ]; |
|
52 | + $this->wp_override = isset( $_api_data[ 'wp_override' ] ) ? (bool)$_api_data[ 'wp_override' ] : false; |
|
53 | + $this->beta = ! empty( $this->api_data[ 'beta' ] ) ? true : false; |
|
54 | + $this->cache_key = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data[ 'license' ] . $this->beta ) ); |
|
55 | 55 | |
56 | 56 | $edd_plugin_data[ $this->slug ] = $this->api_data; |
57 | 57 | |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
173 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
173 | + if ( ! current_user_can( 'update_plugins' ) ) { |
|
174 | 174 | return; |
175 | 175 | } |
176 | 176 | |
177 | - if( ! is_multisite() ) { |
|
177 | + if ( ! is_multisite() ) { |
|
178 | 178 | return; |
179 | 179 | } |
180 | 180 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">', |
282 | 282 | esc_html( $version_info->new_version ), |
283 | 283 | '</a>', |
284 | - '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">', |
|
284 | + '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) . '">', |
|
285 | 285 | '</a>' |
286 | 286 | ); |
287 | 287 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | $_data->contributors = $this->convert_object_to_array( $_data->contributors ); |
366 | 366 | } |
367 | 367 | |
368 | - if( ! isset( $_data->plugin ) ) { |
|
368 | + if ( ! isset( $_data->plugin ) ) { |
|
369 | 369 | $_data->plugin = $this->name; |
370 | 370 | } |
371 | 371 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | |
405 | 405 | $verify_ssl = $this->verify_ssl(); |
406 | 406 | if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
407 | - $args['sslverify'] = $verify_ssl; |
|
407 | + $args[ 'sslverify' ] = $verify_ssl; |
|
408 | 408 | } |
409 | 409 | return $args; |
410 | 410 | |
@@ -432,9 +432,9 @@ discard block |
||
432 | 432 | if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) { |
433 | 433 | $test_url_parts = parse_url( $this->api_url ); |
434 | 434 | |
435 | - $scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http'; |
|
436 | - $host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : ''; |
|
437 | - $port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : ''; |
|
435 | + $scheme = ! empty( $test_url_parts[ 'scheme' ] ) ? $test_url_parts[ 'scheme' ] : 'http'; |
|
436 | + $host = ! empty( $test_url_parts[ 'host' ] ) ? $test_url_parts[ 'host' ] : ''; |
|
437 | + $port = ! empty( $test_url_parts[ 'port' ] ) ? ':' . $test_url_parts[ 'port' ] : ''; |
|
438 | 438 | |
439 | 439 | if ( empty( $host ) ) { |
440 | 440 | $edd_plugin_url_available[ $store_hash ] = false; |
@@ -451,27 +451,27 @@ discard block |
||
451 | 451 | |
452 | 452 | $data = array_merge( $this->api_data, $_data ); |
453 | 453 | |
454 | - if ( $data['slug'] != $this->slug ) { |
|
454 | + if ( $data[ 'slug' ] != $this->slug ) { |
|
455 | 455 | return; |
456 | 456 | } |
457 | 457 | |
458 | - if( $this->api_url == trailingslashit ( home_url() ) ) { |
|
458 | + if ( $this->api_url == trailingslashit( home_url() ) ) { |
|
459 | 459 | return false; // Don't allow a plugin to ping itself |
460 | 460 | } |
461 | 461 | |
462 | 462 | $api_params = array( |
463 | 463 | 'edd_action' => 'get_version', |
464 | - 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
465 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
466 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
467 | - 'version' => isset( $data['version'] ) ? $data['version'] : false, |
|
468 | - 'slug' => $data['slug'], |
|
469 | - 'author' => $data['author'], |
|
464 | + 'license' => ! empty( $data[ 'license' ] ) ? $data[ 'license' ] : '', |
|
465 | + 'item_name' => isset( $data[ 'item_name' ] ) ? $data[ 'item_name' ] : false, |
|
466 | + 'item_id' => isset( $data[ 'item_id' ] ) ? $data[ 'item_id' ] : false, |
|
467 | + 'version' => isset( $data[ 'version' ] ) ? $data[ 'version' ] : false, |
|
468 | + 'slug' => $data[ 'slug' ], |
|
469 | + 'author' => $data[ 'author' ], |
|
470 | 470 | 'url' => home_url(), |
471 | - 'beta' => ! empty( $data['beta'] ), |
|
471 | + 'beta' => ! empty( $data[ 'beta' ] ), |
|
472 | 472 | ); |
473 | 473 | |
474 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) ); |
|
474 | + $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) ); |
|
475 | 475 | |
476 | 476 | if ( ! is_wp_error( $request ) ) { |
477 | 477 | $request = json_decode( wp_remote_retrieve_body( $request ) ); |
@@ -491,9 +491,9 @@ discard block |
||
491 | 491 | $request->icons = maybe_unserialize( $request->icons ); |
492 | 492 | } |
493 | 493 | |
494 | - if( ! empty( $request->sections ) ) { |
|
495 | - foreach( $request->sections as $key => $section ) { |
|
496 | - $request->$key = (array) $section; |
|
494 | + if ( ! empty( $request->sections ) ) { |
|
495 | + foreach ( $request->sections as $key => $section ) { |
|
496 | + $request->$key = (array)$section; |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | |
@@ -507,35 +507,35 @@ discard block |
||
507 | 507 | |
508 | 508 | global $edd_plugin_data; |
509 | 509 | |
510 | - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
510 | + if ( empty( $_REQUEST[ 'edd_sl_action' ] ) || 'view_plugin_changelog' != $_REQUEST[ 'edd_sl_action' ] ) { |
|
511 | 511 | return; |
512 | 512 | } |
513 | 513 | |
514 | - if( empty( $_REQUEST['plugin'] ) ) { |
|
514 | + if ( empty( $_REQUEST[ 'plugin' ] ) ) { |
|
515 | 515 | return; |
516 | 516 | } |
517 | 517 | |
518 | - if( empty( $_REQUEST['slug'] ) ) { |
|
518 | + if ( empty( $_REQUEST[ 'slug' ] ) ) { |
|
519 | 519 | return; |
520 | 520 | } |
521 | 521 | |
522 | - if( ! current_user_can( 'update_plugins' ) ) { |
|
522 | + if ( ! current_user_can( 'update_plugins' ) ) { |
|
523 | 523 | wp_die( __( 'You do not have permission to install plugin updates', 'gravityview' ), __( 'Error', 'gravityview' ), array( 'response' => 403 ) ); |
524 | 524 | } |
525 | 525 | |
526 | - $data = $edd_plugin_data[ $_REQUEST['slug'] ]; |
|
526 | + $data = $edd_plugin_data[ $_REQUEST[ 'slug' ] ]; |
|
527 | 527 | $version_info = $this->get_cached_version_info(); |
528 | 528 | |
529 | - if( false === $version_info ) { |
|
529 | + if ( false === $version_info ) { |
|
530 | 530 | |
531 | 531 | $api_params = array( |
532 | 532 | 'edd_action' => 'get_version', |
533 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
534 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
535 | - 'slug' => $_REQUEST['slug'], |
|
536 | - 'author' => $data['author'], |
|
533 | + 'item_name' => isset( $data[ 'item_name' ] ) ? $data[ 'item_name' ] : false, |
|
534 | + 'item_id' => isset( $data[ 'item_id' ] ) ? $data[ 'item_id' ] : false, |
|
535 | + 'slug' => $_REQUEST[ 'slug' ], |
|
536 | + 'author' => $data[ 'author' ], |
|
537 | 537 | 'url' => home_url(), |
538 | - 'beta' => ! empty( $data['beta'] ) |
|
538 | + 'beta' => ! empty( $data[ 'beta' ] ) |
|
539 | 539 | ); |
540 | 540 | |
541 | 541 | $verify_ssl = $this->verify_ssl(); |
@@ -551,22 +551,22 @@ discard block |
||
551 | 551 | $version_info = false; |
552 | 552 | } |
553 | 553 | |
554 | - if( ! empty( $version_info ) ) { |
|
555 | - foreach( $version_info->sections as $key => $section ) { |
|
556 | - $version_info->$key = (array) $section; |
|
554 | + if ( ! empty( $version_info ) ) { |
|
555 | + foreach ( $version_info->sections as $key => $section ) { |
|
556 | + $version_info->$key = (array)$section; |
|
557 | 557 | } |
558 | 558 | } |
559 | 559 | |
560 | 560 | $this->set_version_info_cache( $version_info ); |
561 | 561 | |
562 | 562 | // Delete the unneeded option |
563 | - delete_option( md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $this->beta . '_version_info' ) ); |
|
563 | + delete_option( md5( 'edd_plugin_' . sanitize_key( $_REQUEST[ 'plugin' ] ) . '_' . $this->beta . '_version_info' ) ); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | if ( isset( $version_info->sections ) ) { |
567 | 567 | $sections = $this->convert_object_to_array( $version_info->sections ); |
568 | - if ( ! empty( $sections['changelog'] ) ) { |
|
569 | - echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>'; |
|
568 | + if ( ! empty( $sections[ 'changelog' ] ) ) { |
|
569 | + echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections[ 'changelog' ] ) . '</div>'; |
|
570 | 570 | } |
571 | 571 | } |
572 | 572 | |
@@ -581,25 +581,25 @@ discard block |
||
581 | 581 | */ |
582 | 582 | public function get_cached_version_info( $cache_key = '' ) { |
583 | 583 | |
584 | - if( empty( $cache_key ) ) { |
|
584 | + if ( empty( $cache_key ) ) { |
|
585 | 585 | $cache_key = $this->cache_key; |
586 | 586 | } |
587 | 587 | |
588 | 588 | $cache = get_option( $cache_key ); |
589 | 589 | |
590 | - if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) { |
|
590 | + if ( empty( $cache[ 'timeout' ] ) || time() > $cache[ 'timeout' ] ) { |
|
591 | 591 | return false; // Cache is expired |
592 | 592 | } |
593 | 593 | |
594 | 594 | // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point. |
595 | - $cache['value'] = json_decode( $cache['value'] ); |
|
596 | - if ( ! empty( $cache['value']->icons ) ) { |
|
597 | - $cache['value']->icons = (array) $cache['value']->icons; |
|
595 | + $cache[ 'value' ] = json_decode( $cache[ 'value' ] ); |
|
596 | + if ( ! empty( $cache[ 'value' ]->icons ) ) { |
|
597 | + $cache[ 'value' ]->icons = (array)$cache[ 'value' ]->icons; |
|
598 | 598 | } else { |
599 | - $cache['value']->icons = array(); |
|
599 | + $cache[ 'value' ]->icons = array(); |
|
600 | 600 | } |
601 | 601 | |
602 | - return $cache['value']; |
|
602 | + return $cache[ 'value' ]; |
|
603 | 603 | |
604 | 604 | } |
605 | 605 | |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | */ |
612 | 612 | public function set_version_info_cache( $value = '', $cache_key = '' ) { |
613 | 613 | |
614 | - if( empty( $cache_key ) ) { |
|
614 | + if ( empty( $cache_key ) ) { |
|
615 | 615 | $cache_key = $this->cache_key; |
616 | 616 | } |
617 | 617 | |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | update_option( $cache_key, $data, 'no' ); |
624 | 624 | |
625 | 625 | // Delete the duplicate option |
626 | - delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ) ); |
|
626 | + delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data[ 'license' ] . $this->beta ) ) ); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | /** |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | * @return bool |
634 | 634 | */ |
635 | 635 | private function verify_ssl() { |
636 | - return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); |
|
636 | + return (bool)apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | } |
@@ -111,7 +111,7 @@ |
||
111 | 111 | * @api |
112 | 112 | * @since |
113 | 113 | * |
114 | - * @param $view \GV\View The view! |
|
114 | + * @param View $view \GV\View The view! |
|
115 | 115 | * |
116 | 116 | * @return \GV\Field_Collection A filtered collection of \GV\Fields, filtered by visibility. |
117 | 117 | */ |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @see add_columns_sort_links |
160 | 160 | * @param string $url Single-sort URL |
161 | - * @param array $sort_args Single sorting for rules, in [ field_id, dir ] format |
|
161 | + * @param string[] $sort_args Single sorting for rules, in [ field_id, dir ] format |
|
162 | 162 | * @param \GV\Field $field The current field |
163 | 163 | * |
164 | 164 | * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * Output a field cell. |
370 | 370 | * |
371 | 371 | * @param \GV\Field $field The field to be ouput. |
372 | - * @param \GV\Field $entry The entry this field is for. |
|
372 | + * @param Entry $entry The entry this field is for. |
|
373 | 373 | * |
374 | 374 | * @return void |
375 | 375 | */ |
@@ -75,22 +75,22 @@ discard block |
||
75 | 75 | if ( is_array( $sorts ) ) { |
76 | 76 | foreach ( (array)$sorts as $key => $direction ) { |
77 | 77 | if ( $key == $field_id ) { |
78 | - $sorting['key'] = $field_id; |
|
79 | - $sorting['direction'] = strtolower( $direction ); |
|
78 | + $sorting[ 'key' ] = $field_id; |
|
79 | + $sorting[ 'direction' ] = strtolower( $direction ); |
|
80 | 80 | break; |
81 | 81 | } |
82 | 82 | } |
83 | 83 | } else { |
84 | 84 | if ( $sorts == $field_id ) { |
85 | - $sorting['key'] = $context_id; |
|
86 | - $sorting['direction'] = strtolower( Utils::_GET( 'dir', '' ) ); |
|
85 | + $sorting[ 'key' ] = $context_id; |
|
86 | + $sorting[ 'direction' ] = strtolower( Utils::_GET( 'dir', '' ) ); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | } else { |
90 | 90 | foreach ( (array)$context->view->settings->get( 'sort_field', array() ) as $i => $sort_field ) { |
91 | 91 | if ( $sort_field == $field_id ) { |
92 | - $sorting['key'] = $sort_field; |
|
93 | - $sorting['direction'] = strtolower( Utils::get( $directions, $i, '' ) ); |
|
92 | + $sorting[ 'key' ] = $sort_field; |
|
93 | + $sorting[ 'direction' ] = strtolower( Utils::get( $directions, $i, '' ) ); |
|
94 | 94 | break; // Only get the first sort |
95 | 95 | } |
96 | 96 | } |
@@ -109,21 +109,21 @@ discard block |
||
109 | 109 | ); |
110 | 110 | |
111 | 111 | // If we are already sorting by the current field... |
112 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
112 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
113 | 113 | |
114 | - switch( $sorting['direction'] ) { |
|
114 | + switch ( $sorting[ 'direction' ] ) { |
|
115 | 115 | // No sort |
116 | 116 | case '': |
117 | - $sort_args[1] = 'asc'; |
|
117 | + $sort_args[ 1 ] = 'asc'; |
|
118 | 118 | $class .= ' gv-icon-caret-up-down'; |
119 | 119 | break; |
120 | 120 | case 'desc': |
121 | - $sort_args[1] = ''; |
|
121 | + $sort_args[ 1 ] = ''; |
|
122 | 122 | $class .= ' gv-icon-sort-asc'; |
123 | 123 | break; |
124 | 124 | case 'asc': |
125 | 125 | default: |
126 | - $sort_args[1] = 'desc'; |
|
126 | + $sort_args[ 1 ] = 'desc'; |
|
127 | 127 | $class .= ' gv-icon-sort-desc'; |
128 | 128 | break; |
129 | 129 | } |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | $url = remove_query_arg( 'sort', $url ); |
137 | 137 | $multisort_url = self::_get_multisort_url( $url, $sort_args, $context->field ); |
138 | 138 | |
139 | - $url = add_query_arg( $sort_args[0], $sort_args[1], $url ); |
|
139 | + $url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $url ); |
|
140 | 140 | |
141 | - $return = '<a href="'. esc_url_raw( $url ) .'"'; |
|
141 | + $return = '<a href="' . esc_url_raw( $url ) . '"'; |
|
142 | 142 | |
143 | 143 | if ( ! empty( $multisort_url ) ) { |
144 | - $return .= ' data-multisort-href="'. esc_url_raw( $multisort_url ) . '"'; |
|
144 | + $return .= ' data-multisort-href="' . esc_url_raw( $multisort_url ) . '"'; |
|
145 | 145 | } |
146 | 146 | |
147 | - $return .= ' class="'. $class .'" ></a> '. $column_label; |
|
147 | + $return .= ' class="' . $class . '" ></a> ' . $column_label; |
|
148 | 148 | |
149 | 149 | return $return; |
150 | 150 | } |
@@ -183,19 +183,19 @@ discard block |
||
183 | 183 | if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) { |
184 | 184 | if ( count( $keys ) ) { |
185 | 185 | $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url ); |
186 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
186 | + $multisort_url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $multisort_url ); |
|
187 | 187 | } else { |
188 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
188 | + $multisort_url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $multisort_url ); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | // Otherwise, we are just updating the sort order |
192 | 192 | else { |
193 | 193 | |
194 | 194 | // Pass empty value to unset |
195 | - if( '' === $sort_args[1] ) { |
|
195 | + if ( '' === $sort_args[ 1 ] ) { |
|
196 | 196 | unset( $sorts[ $field_id ] ); |
197 | 197 | } else { |
198 | - $sorts[ $field_id ] = $sort_args[1]; |
|
198 | + $sorts[ $field_id ] = $sort_args[ 1 ]; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url ); |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() ); |
334 | 334 | |
335 | 335 | foreach ( $fields->all() as $field ) { |
336 | - if ( isset( $this->view->unions[ $entry['form_id'] ] ) ) { |
|
337 | - if ( isset( $this->view->unions[ $entry['form_id'] ][ $field->ID ] ) ) { |
|
338 | - $field = $this->view->unions[ $entry['form_id'] ][ $field->ID ]; |
|
336 | + if ( isset( $this->view->unions[ $entry[ 'form_id' ] ] ) ) { |
|
337 | + if ( isset( $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ] ) ) { |
|
338 | + $field = $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ]; |
|
339 | 339 | } else { |
340 | 340 | if ( ! $field instanceof Internal_Field ) { |
341 | 341 | $field = Internal_Field::from_configuration( array( 'id' => 'custom' ) ); |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | |
21 | 21 | /** |
22 | - * Constructor. Add filters to modify output. |
|
23 | - * |
|
22 | + * Constructor. Add filters to modify output. |
|
23 | + * |
|
24 | 24 | * @since 2.0.4 |
25 | 25 | * |
26 | 26 | * @param View $view |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function __construct( View $view, Entry_Collection $entries, Request $request ) { |
31 | 31 | |
32 | - add_filter( 'gravityview/template/field/label', array( __CLASS__, 'add_columns_sort_links' ), 100, 2 ); |
|
32 | + add_filter( 'gravityview/template/field/label', array( __CLASS__, 'add_columns_sort_links' ), 100, 2 ); |
|
33 | 33 | |
34 | 34 | parent::__construct( $view, $entries, $request ); |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | - * Add sorting links to HTML columns that support sorting |
|
39 | - * |
|
40 | - * @since 2.0.4 |
|
41 | - * @since 2.0.5 Made static |
|
42 | - * |
|
43 | - * @static |
|
44 | - * |
|
38 | + * Add sorting links to HTML columns that support sorting |
|
39 | + * |
|
40 | + * @since 2.0.4 |
|
41 | + * @since 2.0.5 Made static |
|
42 | + * |
|
43 | + * @static |
|
44 | + * |
|
45 | 45 | * @param string $column_label Label for the table column |
46 | 46 | * @param \GV\Template_Context $context |
47 | 47 | * |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $sort_columns = $context->view->settings->get( 'sort_columns' ); |
53 | 53 | |
54 | 54 | if ( empty( $sort_columns ) ) { |
55 | - return $column_label; |
|
55 | + return $column_label; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | if ( 'custom' === $context->field->type ) { |
@@ -111,22 +111,22 @@ discard block |
||
111 | 111 | // If we are already sorting by the current field... |
112 | 112 | if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
113 | 113 | |
114 | - switch( $sorting['direction'] ) { |
|
115 | - // No sort |
|
116 | - case '': |
|
117 | - $sort_args[1] = 'asc'; |
|
118 | - $class .= ' gv-icon-caret-up-down'; |
|
119 | - break; |
|
120 | - case 'desc': |
|
121 | - $sort_args[1] = ''; |
|
122 | - $class .= ' gv-icon-sort-asc'; |
|
123 | - break; |
|
124 | - case 'asc': |
|
125 | - default: |
|
126 | - $sort_args[1] = 'desc'; |
|
127 | - $class .= ' gv-icon-sort-desc'; |
|
128 | - break; |
|
129 | - } |
|
114 | + switch( $sorting['direction'] ) { |
|
115 | + // No sort |
|
116 | + case '': |
|
117 | + $sort_args[1] = 'asc'; |
|
118 | + $class .= ' gv-icon-caret-up-down'; |
|
119 | + break; |
|
120 | + case 'desc': |
|
121 | + $sort_args[1] = ''; |
|
122 | + $class .= ' gv-icon-sort-asc'; |
|
123 | + break; |
|
124 | + case 'asc': |
|
125 | + default: |
|
126 | + $sort_args[1] = 'desc'; |
|
127 | + $class .= ' gv-icon-sort-desc'; |
|
128 | + break; |
|
129 | + } |
|
130 | 130 | |
131 | 131 | } else { |
132 | 132 | $class .= ' gv-icon-caret-up-down'; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $url = remove_query_arg( 'sort', $url ); |
137 | 137 | $multisort_url = self::_get_multisort_url( $url, $sort_args, $context->field ); |
138 | 138 | |
139 | - $url = add_query_arg( $sort_args[0], $sort_args[1], $url ); |
|
139 | + $url = add_query_arg( $sort_args[0], $sort_args[1], $url ); |
|
140 | 140 | |
141 | 141 | $return = '<a href="'. esc_url_raw( $url ) .'"'; |
142 | 142 | |
@@ -150,28 +150,28 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | - * Get the multi-sort URL used in the sorting links |
|
154 | - * |
|
155 | - * @todo Consider moving to Utils? |
|
156 | - * |
|
157 | - * @since 2.3 |
|
158 | - * |
|
159 | - * @see add_columns_sort_links |
|
153 | + * Get the multi-sort URL used in the sorting links |
|
154 | + * |
|
155 | + * @todo Consider moving to Utils? |
|
156 | + * |
|
157 | + * @since 2.3 |
|
158 | + * |
|
159 | + * @see add_columns_sort_links |
|
160 | 160 | * @param string $url Single-sort URL |
161 | 161 | * @param array $sort_args Single sorting for rules, in [ field_id, dir ] format |
162 | - * @param \GV\Field $field The current field |
|
163 | - * |
|
164 | - * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url |
|
162 | + * @param \GV\Field $field The current field |
|
163 | + * |
|
164 | + * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url |
|
165 | 165 | */ |
166 | 166 | static public function _get_multisort_url( $url, $sort_args, $field ) { |
167 | 167 | |
168 | 168 | $sorts = Utils::_GET( 'sort' ); |
169 | 169 | |
170 | 170 | if ( ! is_array( $sorts ) ) { |
171 | - return $url; |
|
171 | + return $url; |
|
172 | 172 | } |
173 | 173 | |
174 | - $multisort_url = $url; |
|
174 | + $multisort_url = $url; |
|
175 | 175 | |
176 | 176 | if ( ! $field ) { |
177 | 177 | return $url; |
@@ -184,26 +184,26 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | // If the field has already been sorted by, add the field to the URL |
187 | - if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) { |
|
188 | - if ( count( $keys ) ) { |
|
189 | - $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url ); |
|
190 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
191 | - } else { |
|
192 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
193 | - } |
|
194 | - } |
|
195 | - // Otherwise, we are just updating the sort order |
|
196 | - else { |
|
197 | - |
|
198 | - // Pass empty value to unset |
|
199 | - if( '' === $sort_args[1] ) { |
|
200 | - unset( $sorts[ $field_id ] ); |
|
201 | - } else { |
|
202 | - $sorts[ $field_id ] = $sort_args[1]; |
|
203 | - } |
|
204 | - |
|
205 | - $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url ); |
|
206 | - } |
|
187 | + if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) { |
|
188 | + if ( count( $keys ) ) { |
|
189 | + $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url ); |
|
190 | + $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
191 | + } else { |
|
192 | + $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
193 | + } |
|
194 | + } |
|
195 | + // Otherwise, we are just updating the sort order |
|
196 | + else { |
|
197 | + |
|
198 | + // Pass empty value to unset |
|
199 | + if( '' === $sort_args[1] ) { |
|
200 | + unset( $sorts[ $field_id ] ); |
|
201 | + } else { |
|
202 | + $sorts[ $field_id ] = $sort_args[1]; |
|
203 | + } |
|
204 | + |
|
205 | + $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url ); |
|
206 | + } |
|
207 | 207 | |
208 | 208 | return $multisort_url; |
209 | 209 | } |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
236 | - * Returns the label for a column, with support for all deprecated filters |
|
237 | - * |
|
238 | - * @since 2.1 |
|
239 | - * |
|
236 | + * Returns the label for a column, with support for all deprecated filters |
|
237 | + * |
|
238 | + * @since 2.1 |
|
239 | + * |
|
240 | 240 | * @param \GV\Field $field |
241 | 241 | * @param \GV\Template_Context $context |
242 | 242 | */ |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $column_label = apply_filters( 'gravityview/template/field/label', $column_label, $context ); |
260 | 260 | |
261 | 261 | return $column_label; |
262 | - } |
|
262 | + } |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * Output the entry row. |
@@ -328,15 +328,15 @@ discard block |
||
328 | 328 | */ |
329 | 329 | do_action( 'gravityview/template/table/cells/before', $context ); |
330 | 330 | |
331 | - /** |
|
332 | - * @action `gravityview_table_cells_before` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
333 | - * @since 1.0.7 |
|
331 | + /** |
|
332 | + * @action `gravityview_table_cells_before` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
333 | + * @since 1.0.7 |
|
334 | 334 | * @param \GravityView_View $this Current GravityView_View object |
335 | 335 | * @deprecated Use `gravityview/template/table/cells/before` |
336 | - */ |
|
337 | - do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() ); |
|
336 | + */ |
|
337 | + do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() ); |
|
338 | 338 | |
339 | - foreach ( $fields->all() as $field ) { |
|
339 | + foreach ( $fields->all() as $field ) { |
|
340 | 340 | if ( isset( $this->view->unions[ $entry['form_id'] ] ) ) { |
341 | 341 | if ( isset( $this->view->unions[ $entry['form_id'] ][ $field->ID ] ) ) { |
342 | 342 | $field = $this->view->unions[ $entry['form_id'] ][ $field->ID ]; |
@@ -356,13 +356,13 @@ discard block |
||
356 | 356 | */ |
357 | 357 | do_action( 'gravityview/template/table/cells/after', $context ); |
358 | 358 | |
359 | - /** |
|
360 | - * @action `gravityview_table_cells_after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
361 | - * @since 1.0.7 |
|
359 | + /** |
|
360 | + * @action `gravityview_table_cells_after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
361 | + * @since 1.0.7 |
|
362 | 362 | * @param \GravityView_View $this Current GravityView_View object |
363 | 363 | * @deprecated Use `gravityview/template/table/cells/after` |
364 | - */ |
|
365 | - do_action( 'gravityview_table_cells_after', \GravityView_View::getInstance() ); |
|
364 | + */ |
|
365 | + do_action( 'gravityview_table_cells_after', \GravityView_View::getInstance() ); |
|
366 | 366 | |
367 | 367 | ?> |
368 | 368 | </tr> |
@@ -410,9 +410,9 @@ discard block |
||
410 | 410 | 'value' => $value, |
411 | 411 | 'hide_empty' => false, |
412 | 412 | 'zone_id' => 'directory_table-columns', |
413 | - 'label' => self::get_field_column_label( $field, $context ), |
|
413 | + 'label' => self::get_field_column_label( $field, $context ), |
|
414 | 414 | 'markup' => '<td id="{{ field_id }}" class="{{ class }}" data-label="{{label_value:data-label}}">{{ value }}</td>', |
415 | - 'form' => $form, |
|
415 | + 'form' => $form, |
|
416 | 416 | ); |
417 | 417 | |
418 | 418 | /** Output. */ |
@@ -437,11 +437,11 @@ discard block |
||
437 | 437 | do_action( 'gravityview/template/table/body/before', $context ); |
438 | 438 | |
439 | 439 | /** |
440 | - * @action `gravityview_table_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows. |
|
441 | - * @deprecated Use `gravityview/template/table/body/before` |
|
442 | - * @since 1.0.7 |
|
443 | - * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
444 | - */ |
|
440 | + * @action `gravityview_table_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows. |
|
441 | + * @deprecated Use `gravityview/template/table/body/before` |
|
442 | + * @since 1.0.7 |
|
443 | + * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
444 | + */ |
|
445 | 445 | do_action( 'gravityview_table_body_before', \GravityView_View::getInstance() /** ugh! */ ); |
446 | 446 | } |
447 | 447 | |
@@ -463,11 +463,11 @@ discard block |
||
463 | 463 | do_action( 'gravityview/template/table/body/after', $context ); |
464 | 464 | |
465 | 465 | /** |
466 | - * @action `gravityview_table_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows. |
|
467 | - * @deprecated Use `gravityview/template/table/body/after` |
|
468 | - * @since 1.0.7 |
|
469 | - * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
470 | - */ |
|
466 | + * @action `gravityview_table_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows. |
|
467 | + * @deprecated Use `gravityview/template/table/body/after` |
|
468 | + * @since 1.0.7 |
|
469 | + * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
470 | + */ |
|
471 | 471 | do_action( 'gravityview_table_body_after', \GravityView_View::getInstance() /** ugh! */ ); |
472 | 472 | } |
473 | 473 |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param bool $url_encode Whether to URL-encode output |
250 | 250 | * @param bool $esc_html Whether to apply `esc_html()` to output |
251 | 251 | * |
252 | - * @return mixed |
|
252 | + * @return string |
|
253 | 253 | */ |
254 | 254 | public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
255 | 255 | |
@@ -427,6 +427,9 @@ discard block |
||
427 | 427 | return apply_filters( 'gravityview_field_support_options', $options ); |
428 | 428 | } |
429 | 429 | |
430 | + /** |
|
431 | + * @param string $key |
|
432 | + */ |
|
430 | 433 | function add_field_support( $key, &$field_options ) { |
431 | 434 | |
432 | 435 | $options = $this->field_support_options(); |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | |
135 | 135 | add_filter( 'gravityview/sortable/field_blacklist', array( $this, '_filter_sortable_fields' ), 1 ); |
136 | 136 | |
137 | - if( $this->entry_meta_key ) { |
|
137 | + if ( $this->entry_meta_key ) { |
|
138 | 138 | add_filter( 'gform_entry_meta', array( $this, 'add_entry_meta' ) ); |
139 | 139 | add_filter( 'gravityview/common/sortable_fields', array( $this, 'add_sortable_field' ), 10, 2 ); |
140 | 140 | } |
141 | 141 | |
142 | - if( $this->_custom_merge_tag ) { |
|
142 | + if ( $this->_custom_merge_tag ) { |
|
143 | 143 | add_filter( 'gform_custom_merge_tags', array( $this, '_filter_gform_custom_merge_tags' ), 10, 4 ); |
144 | 144 | add_filter( 'gform_replace_merge_tags', array( $this, '_filter_gform_replace_merge_tags' ), 10, 7 ); |
145 | 145 | } |
146 | 146 | |
147 | - if( 'meta' === $this->group || '' !== $this->default_search_label ) { |
|
147 | + if ( 'meta' === $this->group || '' !== $this->default_search_label ) { |
|
148 | 148 | add_filter( 'gravityview_search_field_label', array( $this, 'set_default_search_label' ), 10, 3 ); |
149 | 149 | } |
150 | 150 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * Auto-assign label from Gravity Forms label, if exists |
153 | 153 | * @since 1.20 |
154 | 154 | */ |
155 | - if( empty( $this->label ) && ! empty( $this->_gf_field_class_name ) && class_exists( $this->_gf_field_class_name ) ) { |
|
155 | + if ( empty( $this->label ) && ! empty( $this->_gf_field_class_name ) && class_exists( $this->_gf_field_class_name ) ) { |
|
156 | 156 | $this->label = ucfirst( GF_Fields::get( $this->name )->get_form_editor_field_title() ); |
157 | 157 | } |
158 | 158 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | 'type' => $this->name |
180 | 180 | ); |
181 | 181 | |
182 | - $fields["{$this->entry_meta_key}"] = $added_field; |
|
182 | + $fields[ "{$this->entry_meta_key}" ] = $added_field; |
|
183 | 183 | |
184 | 184 | return $fields; |
185 | 185 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | */ |
200 | 200 | function set_default_search_label( $label = '', $gf_field = null, $field = array() ) { |
201 | 201 | |
202 | - if( $this->name === $field['field'] && '' === $label ) { |
|
202 | + if ( $this->name === $field[ 'field' ] && '' === $label ) { |
|
203 | 203 | $label = esc_html( $this->default_search_label ); |
204 | 204 | } |
205 | 205 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return string Original text if {_custom_merge_tag} isn't found. Otherwise, replaced text. |
222 | 222 | */ |
223 | - public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
223 | + public function _filter_gform_replace_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
224 | 224 | |
225 | 225 | // Is there is field merge tag? Strip whitespace off the ned, too. |
226 | 226 | preg_match_all( '/{' . preg_quote( $this->_custom_merge_tag ) . ':?(.*?)(?:\s)?}/ism', $text, $matches, PREG_SET_ORDER ); |
@@ -253,19 +253,19 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
255 | 255 | |
256 | - foreach( $matches as $match ) { |
|
256 | + foreach ( $matches as $match ) { |
|
257 | 257 | |
258 | - $full_tag = $match[0]; |
|
258 | + $full_tag = $match[ 0 ]; |
|
259 | 259 | |
260 | 260 | // Strip the Merge Tags |
261 | - $tag = str_replace( array( '{', '}'), '', $full_tag ); |
|
261 | + $tag = str_replace( array( '{', '}' ), '', $full_tag ); |
|
262 | 262 | |
263 | 263 | // Replace the value from the entry, if exists |
264 | - if( isset( $entry[ $tag ] ) ) { |
|
264 | + if ( isset( $entry[ $tag ] ) ) { |
|
265 | 265 | |
266 | 266 | $value = $entry[ $tag ]; |
267 | 267 | |
268 | - if( is_callable( array( $this, 'get_content') ) ) { |
|
268 | + if ( is_callable( array( $this, 'get_content' ) ) ) { |
|
269 | 269 | $value = $this->get_content( $value ); |
270 | 270 | } |
271 | 271 | |
@@ -338,8 +338,8 @@ discard block |
||
338 | 338 | */ |
339 | 339 | public function _filter_sortable_fields( $not_sortable ) { |
340 | 340 | |
341 | - if( ! $this->is_sortable ) { |
|
342 | - $not_sortable[] = $this->name; |
|
341 | + if ( ! $this->is_sortable ) { |
|
342 | + $not_sortable[ ] = $this->name; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | return $not_sortable; |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | */ |
357 | 357 | function add_entry_meta( $entry_meta ) { |
358 | 358 | |
359 | - if( ! isset( $entry_meta["{$this->entry_meta_key}"] ) ) { |
|
359 | + if ( ! isset( $entry_meta[ "{$this->entry_meta_key}" ] ) ) { |
|
360 | 360 | |
361 | 361 | $added_meta = array( |
362 | 362 | 'label' => $this->label, |
@@ -365,13 +365,13 @@ discard block |
||
365 | 365 | ); |
366 | 366 | |
367 | 367 | if ( $this->entry_meta_update_callback && is_callable( $this->entry_meta_update_callback ) ) { |
368 | - $added_meta['update_entry_meta_callback'] = $this->entry_meta_update_callback; |
|
368 | + $added_meta[ 'update_entry_meta_callback' ] = $this->entry_meta_update_callback; |
|
369 | 369 | } |
370 | 370 | |
371 | - $entry_meta["{$this->entry_meta_key}"] = $added_meta; |
|
371 | + $entry_meta[ "{$this->entry_meta_key}" ] = $added_meta; |
|
372 | 372 | |
373 | 373 | } else { |
374 | - gravityview()->log->error( 'Entry meta already set: {meta_key}', array( 'meta_key' => $this->entry_meta_key, 'data' => $entry_meta["{$this->entry_meta_key}"] ) ); |
|
374 | + gravityview()->log->error( 'Entry meta already set: {meta_key}', array( 'meta_key' => $this->entry_meta_key, 'data' => $entry_meta[ "{$this->entry_meta_key}" ] ) ); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | return $entry_meta; |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | 'date_display' => array( |
401 | 401 | 'type' => 'text', |
402 | 402 | 'label' => __( 'Override Date Format', 'gravityview' ), |
403 | - 'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview'), '<a href="https://wordpress.org/support/article/formatting-date-and-time/" rel="external">', '</a>' ), |
|
403 | + 'desc' => sprintf( __( 'Define how the date is displayed (using %sthe PHP date format%s)', 'gravityview' ), '<a href="https://wordpress.org/support/article/formatting-date-and-time/" rel="external">', '</a>' ), |
|
404 | 404 | /** |
405 | 405 | * @filter `gravityview_date_format` Override the date format with a [PHP date format](https://codex.wordpress.org/Formatting_Date_and_Time) |
406 | 406 | * @param[in,out] null|string $date_format Date Format (default: null) |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | |
427 | 427 | $options = $this->field_support_options(); |
428 | 428 | |
429 | - if( isset( $options[ $key ] ) ) { |
|
429 | + if ( isset( $options[ $key ] ) ) { |
|
430 | 430 | $field_options[ $key ] = $options[ $key ]; |
431 | 431 | } |
432 | 432 | |
@@ -490,11 +490,11 @@ discard block |
||
490 | 490 | $connected_form = \GV\Utils::_POST( 'form_id' ); |
491 | 491 | |
492 | 492 | // Otherwise, get the Form ID from the Post page |
493 | - if( empty( $connected_form ) ) { |
|
493 | + if ( empty( $connected_form ) ) { |
|
494 | 494 | $connected_form = gravityview_get_form_id( get_the_ID() ); |
495 | 495 | } |
496 | 496 | |
497 | - if( empty( $connected_form ) ) { |
|
497 | + if ( empty( $connected_form ) ) { |
|
498 | 498 | gravityview()->log->error( 'Form not found for form ID "{form_id}"', array( 'form_id' => $connected_form ) ); |
499 | 499 | return false; |
500 | 500 | } |
@@ -21,13 +21,13 @@ |
||
21 | 21 | $plugin_hooks_files = glob( $include_path . 'class-gravityview-plugin-hooks-*.php' ); |
22 | 22 | |
23 | 23 | // Load all plugin files automatically |
24 | -foreach ( (array) $plugin_hooks_files as $plugin_hooks_file ) { |
|
24 | +foreach ( (array)$plugin_hooks_files as $plugin_hooks_file ) { |
|
25 | 25 | include $plugin_hooks_file; |
26 | 26 | } |
27 | 27 | |
28 | 28 | $theme_hooks_files = glob( $include_path . 'class-gravityview-theme-hooks-*.php' ); |
29 | 29 | |
30 | 30 | // Load all theme files automatically |
31 | -foreach ( (array) $theme_hooks_files as $theme_hooks_file ) { |
|
31 | +foreach ( (array)$theme_hooks_files as $theme_hooks_file ) { |
|
32 | 32 | include $theme_hooks_file; |
33 | 33 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | add_filter( 'icl_ls_languages', array( $this, 'wpml_ls_filter' ) ); |
66 | 66 | |
67 | - add_filter( 'gravityview_directory_link', array( $this, 'filter_gravityview_back_link') ); |
|
67 | + add_filter( 'gravityview_directory_link', array( $this, 'filter_gravityview_back_link' ) ); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | function filter_gravityview_back_link( $link ) { |
85 | 85 | global $wpml_url_filters; |
86 | 86 | |
87 | - if( $wpml_url_filters ) { |
|
87 | + if ( $wpml_url_filters ) { |
|
88 | 88 | $link = $wpml_url_filters->permalink_filter( $link, GravityView_frontend::getInstance()->getPostId() ); |
89 | 89 | } |
90 | 90 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | private function remove_url_hooks() { |
102 | 102 | global $wpml_url_filters; |
103 | 103 | |
104 | - if( ! $wpml_url_filters ) { |
|
104 | + if ( ! $wpml_url_filters ) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | private function add_url_hooks() { |
130 | 130 | global $wpml_url_filters; |
131 | 131 | |
132 | - if( ! $wpml_url_filters ) { |
|
132 | + if ( ! $wpml_url_filters ) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | break; |
227 | 227 | } |
228 | 228 | |
229 | - $languages[ $lang_code ]['url'] = $entry_link; |
|
229 | + $languages[ $lang_code ][ 'url' ] = $entry_link; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | $this->add_url_hooks(); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | $is_table_layout = preg_match( '/table/ism', $template_id ); |
32 | 32 | |
33 | - if( 'field' === $field_type ) { |
|
33 | + if ( 'field' === $field_type ) { |
|
34 | 34 | |
35 | 35 | // Default options - fields |
36 | 36 | $field_options = array( |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | 'custom_class' => array( |
50 | 50 | 'type' => 'text', |
51 | 51 | 'label' => __( 'Custom CSS Class:', 'gravityview' ), |
52 | - 'desc' => __( 'This class will be added to the field container', 'gravityview'), |
|
52 | + 'desc' => __( 'This class will be added to the field container', 'gravityview' ), |
|
53 | 53 | 'value' => '', |
54 | 54 | 'merge_tags' => true, |
55 | 55 | 'tooltip' => 'gv_css_merge_tags', |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | ); |
71 | 71 | |
72 | 72 | // Match Table as well as DataTables |
73 | - if( $is_table_layout && 'directory' === $context ) { |
|
74 | - $field_options['width'] = array( |
|
73 | + if ( $is_table_layout && 'directory' === $context ) { |
|
74 | + $field_options[ 'width' ] = array( |
|
75 | 75 | 'type' => 'number', |
76 | - 'label' => __('Percent Width', 'gravityview'), |
|
77 | - 'desc' => __( 'Leave blank for column width to be based on the field content.', 'gravityview'), |
|
76 | + 'label' => __( 'Percent Width', 'gravityview' ), |
|
77 | + 'desc' => __( 'Leave blank for column width to be based on the field content.', 'gravityview' ), |
|
78 | 78 | 'class' => 'code widefat', |
79 | 79 | 'value' => '', |
80 | 80 | ); |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | 'manage_options' => __( 'Administrator', 'gravityview' ), |
130 | 130 | ); |
131 | 131 | |
132 | - if( is_multisite() ) { |
|
133 | - $select_cap_choices['manage_network'] = __('Multisite Super Admin', 'gravityview' ); |
|
132 | + if ( is_multisite() ) { |
|
133 | + $select_cap_choices[ 'manage_network' ] = __( 'Multisite Super Admin', 'gravityview' ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param string $context Optional. What context are we in? Example: `single` or `directory` |
144 | 144 | * @param string $input_type Optional. (textarea, list, select, etc.) |
145 | 145 | */ |
146 | - $select_cap_choices = apply_filters('gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type ); |
|
146 | + $select_cap_choices = apply_filters( 'gravityview_field_visibility_caps', $select_cap_choices, $template_id, $field_id, $context, $input_type ); |
|
147 | 147 | |
148 | 148 | return $select_cap_choices; |
149 | 149 | } |
@@ -170,27 +170,27 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public static function render_field_options( $form_id, $field_type, $template_id, $field_id, $field_label, $area, $input_type = NULL, $uniqid = '', $current = '', $context = 'single', $item = array() ) { |
172 | 172 | |
173 | - if( empty( $uniqid ) ) { |
|
173 | + if ( empty( $uniqid ) ) { |
|
174 | 174 | //generate a unique field id |
175 | - $uniqid = uniqid('', false); |
|
175 | + $uniqid = uniqid( '', false ); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | // get field/widget options |
179 | 179 | $options = self::get_default_field_options( $field_type, $template_id, $field_id, $context, $input_type, $form_id ); |
180 | 180 | |
181 | 181 | // two different post arrays, depending of the field type |
182 | - $name_prefix = $field_type .'s' .'['. $area .']['. $uniqid .']'; |
|
182 | + $name_prefix = $field_type . 's' . '[' . $area . '][' . $uniqid . ']'; |
|
183 | 183 | |
184 | 184 | // build output |
185 | 185 | $output = ''; |
186 | - $output .= '<input type="hidden" class="field-key" name="'. $name_prefix .'[id]" value="'. esc_attr( $field_id ) .'">'; |
|
187 | - $output .= '<input type="hidden" class="field-label" name="'. $name_prefix .'[label]" value="'. esc_attr( $field_label ) .'">'; |
|
186 | + $output .= '<input type="hidden" class="field-key" name="' . $name_prefix . '[id]" value="' . esc_attr( $field_id ) . '">'; |
|
187 | + $output .= '<input type="hidden" class="field-label" name="' . $name_prefix . '[label]" value="' . esc_attr( $field_label ) . '">'; |
|
188 | 188 | if ( $form_id ) { |
189 | - $output .= '<input type="hidden" class="field-form-id" name="'. $name_prefix .'[form_id]" value="'. esc_attr( $form_id ) .'">'; |
|
189 | + $output .= '<input type="hidden" class="field-form-id" name="' . $name_prefix . '[form_id]" value="' . esc_attr( $form_id ) . '">'; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | // If there are no options, return what we got. |
193 | - if(empty($options)) { |
|
193 | + if ( empty( $options ) ) { |
|
194 | 194 | |
195 | 195 | // This is here for checking if the output is empty in render_label() |
196 | 196 | $output .= '<!-- No Options -->'; |
@@ -198,33 +198,33 @@ discard block |
||
198 | 198 | return $output; |
199 | 199 | } |
200 | 200 | |
201 | - $output .= '<div class="gv-dialog-options" title="'. esc_attr( sprintf( __( 'Options: %s', 'gravityview' ) , strip_tags( html_entity_decode( $field_label ) ) ) ) .'">'; |
|
201 | + $output .= '<div class="gv-dialog-options" title="' . esc_attr( sprintf( __( 'Options: %s', 'gravityview' ), strip_tags( html_entity_decode( $field_label ) ) ) ) . '">'; |
|
202 | 202 | |
203 | 203 | /** |
204 | 204 | * @since 1.8 |
205 | 205 | */ |
206 | - if( !empty( $item['subtitle'] ) ) { |
|
207 | - $output .= '<div class="subtitle">' . $item['subtitle'] . '</div>'; |
|
206 | + if ( ! empty( $item[ 'subtitle' ] ) ) { |
|
207 | + $output .= '<div class="subtitle">' . $item[ 'subtitle' ] . '</div>'; |
|
208 | 208 | } |
209 | 209 | |
210 | - foreach( $options as $key => $option ) { |
|
210 | + foreach ( $options as $key => $option ) { |
|
211 | 211 | |
212 | 212 | $value = isset( $current[ $key ] ) ? $current[ $key ] : NULL; |
213 | 213 | |
214 | - $field_output = self::render_field_option( $name_prefix . '['. $key .']' , $option, $value); |
|
214 | + $field_output = self::render_field_option( $name_prefix . '[' . $key . ']', $option, $value ); |
|
215 | 215 | |
216 | 216 | // The setting is empty |
217 | - if( empty( $field_output ) ) { |
|
217 | + if ( empty( $field_output ) ) { |
|
218 | 218 | continue; |
219 | 219 | } |
220 | 220 | |
221 | - switch( $option['type'] ) { |
|
221 | + switch ( $option[ 'type' ] ) { |
|
222 | 222 | // Hide hidden fields |
223 | 223 | case 'hidden': |
224 | - $output .= '<div class="gv-setting-container gv-setting-container-'. esc_attr( $key ) . ' screen-reader-text">'. $field_output . '</div>'; |
|
224 | + $output .= '<div class="gv-setting-container gv-setting-container-' . esc_attr( $key ) . ' screen-reader-text">' . $field_output . '</div>'; |
|
225 | 225 | break; |
226 | 226 | default: |
227 | - $output .= '<div class="gv-setting-container gv-setting-container-'. esc_attr( $key ) . '">'. $field_output .'</div>'; |
|
227 | + $output .= '<div class="gv-setting-container gv-setting-container-' . esc_attr( $key ) . '">' . $field_output . '</div>'; |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
@@ -253,17 +253,17 @@ discard block |
||
253 | 253 | * @deprecated setting index 'default' was replaced by 'value' |
254 | 254 | * @see GravityView_FieldType::get_field_defaults |
255 | 255 | */ |
256 | - if( !empty( $option['default'] ) && empty( $option['value'] ) ) { |
|
257 | - $option['value'] = $option['default']; |
|
258 | - _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting '. $name .' details' ); |
|
256 | + if ( ! empty( $option[ 'default' ] ) && empty( $option[ 'value' ] ) ) { |
|
257 | + $option[ 'value' ] = $option[ 'default' ]; |
|
258 | + _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[value] instead of [default] when defining the setting ' . $name . ' details' ); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | // prepare to render option field type |
262 | - if( isset( $option['type'] ) ) { |
|
262 | + if ( isset( $option[ 'type' ] ) ) { |
|
263 | 263 | |
264 | 264 | $type_class = self::load_type_class( $option ); |
265 | 265 | |
266 | - if( class_exists( $type_class ) ) { |
|
266 | + if ( class_exists( $type_class ) ) { |
|
267 | 267 | |
268 | 268 | /** @type GravityView_FieldType $render_type */ |
269 | 269 | $render_type = new $type_class( $name, $option, $curr_value ); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @param[in,out] string $output field class name |
281 | 281 | * @param[in] array $option option field data |
282 | 282 | */ |
283 | - $output = apply_filters( "gravityview/option/output/{$option['type']}" , $output, $option ); |
|
283 | + $output = apply_filters( "gravityview/option/output/{$option[ 'type' ]}", $output, $option ); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | } // isset option[type] |
@@ -315,27 +315,27 @@ discard block |
||
315 | 315 | * @deprecated setting index 'name' was replaced by 'label' |
316 | 316 | * @see GravityView_FieldType::get_field_defaults |
317 | 317 | */ |
318 | - if( isset( $setting['name'] ) && empty( $setting['label'] ) ) { |
|
319 | - $setting['label'] = $setting['name']; |
|
320 | - _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting '. $key .' details' ); |
|
318 | + if ( isset( $setting[ 'name' ] ) && empty( $setting[ 'label' ] ) ) { |
|
319 | + $setting[ 'label' ] = $setting[ 'name' ]; |
|
320 | + _deprecated_function( 'GravityView_FieldType::get_field_defaults', '1.1.7', '[label] instead of [name] when defining the setting ' . $key . ' details' ); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | $name = esc_attr( sprintf( $name, $key ) ); |
324 | - $setting['id'] = esc_attr( sprintf( $id, $key ) ); |
|
325 | - $setting['tooltip'] = 'gv_' . $key; |
|
324 | + $setting[ 'id' ] = esc_attr( sprintf( $id, $key ) ); |
|
325 | + $setting[ 'tooltip' ] = 'gv_' . $key; |
|
326 | 326 | |
327 | 327 | // Use default if current setting isn't set. |
328 | - $curr_value = isset( $current_settings[ $key ] ) ? $current_settings[ $key ] : $setting['value']; |
|
328 | + $curr_value = isset( $current_settings[ $key ] ) ? $current_settings[ $key ] : $setting[ 'value' ]; |
|
329 | 329 | |
330 | 330 | // default setting type = text |
331 | - $setting['type'] = empty( $setting['type'] ) ? 'text' : $setting['type']; |
|
331 | + $setting[ 'type' ] = empty( $setting[ 'type' ] ) ? 'text' : $setting[ 'type' ]; |
|
332 | 332 | |
333 | 333 | // merge tags |
334 | - if( !isset( $setting['merge_tags'] ) ) { |
|
335 | - if( $setting['type'] === 'text' ) { |
|
336 | - $setting['merge_tags'] = true; |
|
334 | + if ( ! isset( $setting[ 'merge_tags' ] ) ) { |
|
335 | + if ( $setting[ 'type' ] === 'text' ) { |
|
336 | + $setting[ 'merge_tags' ] = true; |
|
337 | 337 | } else { |
338 | - $setting['merge_tags'] = false; |
|
338 | + $setting[ 'merge_tags' ] = false; |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | |
344 | 344 | // render the setting |
345 | 345 | $type_class = self::load_type_class( $setting ); |
346 | - if( class_exists( $type_class ) ) { |
|
346 | + if ( class_exists( $type_class ) ) { |
|
347 | 347 | /** @type GravityView_FieldType $render_type */ |
348 | 348 | $render_type = new $type_class( $name, $setting, $curr_value ); |
349 | 349 | ob_start(); |
@@ -352,25 +352,25 @@ discard block |
||
352 | 352 | } |
353 | 353 | |
354 | 354 | // Check if setting is specific for a template |
355 | - if( !empty( $setting['show_in_template'] ) ) { |
|
356 | - if( !is_array( $setting['show_in_template'] ) ) { |
|
357 | - $setting['show_in_template'] = array( $setting['show_in_template'] ); |
|
355 | + if ( ! empty( $setting[ 'show_in_template' ] ) ) { |
|
356 | + if ( ! is_array( $setting[ 'show_in_template' ] ) ) { |
|
357 | + $setting[ 'show_in_template' ] = array( $setting[ 'show_in_template' ] ); |
|
358 | 358 | } |
359 | - $show_if = ' data-show-if="'. implode( ' ', $setting['show_in_template'] ).'"'; |
|
359 | + $show_if = ' data-show-if="' . implode( ' ', $setting[ 'show_in_template' ] ) . '"'; |
|
360 | 360 | } else { |
361 | 361 | $show_if = ''; |
362 | 362 | } |
363 | 363 | |
364 | - if( ! empty( $setting['requires'] ) ) { |
|
365 | - $show_if .= sprintf( ' data-requires="%s"', $setting['requires'] ); |
|
364 | + if ( ! empty( $setting[ 'requires' ] ) ) { |
|
365 | + $show_if .= sprintf( ' data-requires="%s"', $setting[ 'requires' ] ); |
|
366 | 366 | } |
367 | 367 | |
368 | - if( ! empty( $setting['requires_not'] ) ) { |
|
369 | - $show_if .= sprintf( ' data-requires-not="%s"', $setting['requires_not'] ); |
|
368 | + if ( ! empty( $setting[ 'requires_not' ] ) ) { |
|
369 | + $show_if .= sprintf( ' data-requires-not="%s"', $setting[ 'requires_not' ] ); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | // output |
373 | - echo '<tr style="vertical-align: top;" '. $show_if .'>' . $output . '</tr>'; |
|
373 | + echo '<tr style="vertical-align: top;" ' . $show_if . '>' . $output . '</tr>'; |
|
374 | 374 | |
375 | 375 | } |
376 | 376 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | public static function load_type_class( $field = NULL ) { |
384 | 384 | |
385 | - if( empty( $field['type'] ) ) { |
|
385 | + if ( empty( $field[ 'type' ] ) ) { |
|
386 | 386 | return NULL; |
387 | 387 | } |
388 | 388 | |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | * @param string $class_suffix field class suffix; `GravityView_FieldType_{$class_suffix}` |
392 | 392 | * @param array $field field data |
393 | 393 | */ |
394 | - $type_class = apply_filters( "gravityview/setting/class/{$field['type']}", 'GravityView_FieldType_' . $field['type'], $field ); |
|
394 | + $type_class = apply_filters( "gravityview/setting/class/{$field[ 'type' ]}", 'GravityView_FieldType_' . $field[ 'type' ], $field ); |
|
395 | 395 | |
396 | - if( class_exists( $type_class ) ) { |
|
396 | + if ( class_exists( $type_class ) ) { |
|
397 | 397 | return $type_class; |
398 | 398 | } |
399 | 399 | |
@@ -402,9 +402,9 @@ discard block |
||
402 | 402 | * @param string $field_type_include_path field class file path |
403 | 403 | * @param array $field field data |
404 | 404 | */ |
405 | - $class_file = apply_filters( "gravityview/setting/class_file/{$field['type']}", GRAVITYVIEW_DIR . "includes/admin/field-types/type_{$field['type']}.php", $field ); |
|
405 | + $class_file = apply_filters( "gravityview/setting/class_file/{$field[ 'type' ]}", GRAVITYVIEW_DIR . "includes/admin/field-types/type_{$field[ 'type' ]}.php", $field ); |
|
406 | 406 | |
407 | - if( $class_file && file_exists( $class_file ) ) { |
|
407 | + if ( $class_file && file_exists( $class_file ) ) { |
|
408 | 408 | require_once( $class_file ); |
409 | 409 | } |
410 | 410 | |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | |
427 | 427 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_checkbox::render_input' ); |
428 | 428 | |
429 | - $output = '<input name="'. esc_attr( $name ) .'" type="hidden" value="0">'; |
|
430 | - $output .= '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="checkbox" value="1" '. checked( $current, '1', false ) .' >'; |
|
429 | + $output = '<input name="' . esc_attr( $name ) . '" type="hidden" value="0">'; |
|
430 | + $output .= '<input name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" type="checkbox" value="1" ' . checked( $current, '1', false ) . ' >'; |
|
431 | 431 | |
432 | 432 | return $output; |
433 | 433 | } |
@@ -447,22 +447,22 @@ discard block |
||
447 | 447 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_text::render_input' ); |
448 | 448 | |
449 | 449 | // Show the merge tags if the field is a list view |
450 | - $is_list = ( preg_match( '/_list-/ism', $name )); |
|
450 | + $is_list = ( preg_match( '/_list-/ism', $name ) ); |
|
451 | 451 | |
452 | 452 | // Or is a single entry view |
453 | - $is_single = ( preg_match( '/single_/ism', $name )); |
|
453 | + $is_single = ( preg_match( '/single_/ism', $name ) ); |
|
454 | 454 | $show = ( $is_single || $is_list ); |
455 | 455 | |
456 | 456 | $class = ''; |
457 | 457 | // and $add_merge_tags is not false |
458 | - if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
458 | + if ( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
459 | 459 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
460 | 460 | } |
461 | 461 | |
462 | - $class .= !empty( $args['class'] ) ? $args['class'] : 'widefat'; |
|
463 | - $type = !empty( $args['type'] ) ? $args['type'] : 'text'; |
|
462 | + $class .= ! empty( $args[ 'class' ] ) ? $args[ 'class' ] : 'widefat'; |
|
463 | + $type = ! empty( $args[ 'type' ] ) ? $args[ 'type' ] : 'text'; |
|
464 | 464 | |
465 | - return '<input name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" type="'.esc_attr($type).'" value="'. esc_attr( $current ) .'" class="'.esc_attr( $class ).'">'; |
|
465 | + return '<input name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" type="' . esc_attr( $type ) . '" value="' . esc_attr( $current ) . '" class="' . esc_attr( $class ) . '">'; |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
@@ -479,21 +479,21 @@ discard block |
||
479 | 479 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_textarea::render_input' ); |
480 | 480 | |
481 | 481 | // Show the merge tags if the field is a list view |
482 | - $is_list = ( preg_match( '/_list-/ism', $name )); |
|
482 | + $is_list = ( preg_match( '/_list-/ism', $name ) ); |
|
483 | 483 | |
484 | 484 | // Or is a single entry view |
485 | - $is_single = ( preg_match( '/single_/ism', $name )); |
|
485 | + $is_single = ( preg_match( '/single_/ism', $name ) ); |
|
486 | 486 | $show = ( $is_single || $is_list ); |
487 | 487 | |
488 | 488 | $class = ''; |
489 | 489 | // and $add_merge_tags is not false |
490 | - if( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
490 | + if ( $show && $add_merge_tags !== false || $add_merge_tags === 'force' ) { |
|
491 | 491 | $class = 'merge-tag-support mt-position-right mt-hide_all_fields '; |
492 | 492 | } |
493 | 493 | |
494 | - $class .= !empty( $args['class'] ) ? 'widefat '.$args['class'] : 'widefat'; |
|
494 | + $class .= ! empty( $args[ 'class' ] ) ? 'widefat ' . $args[ 'class' ] : 'widefat'; |
|
495 | 495 | |
496 | - return '<textarea name="'. esc_attr( $name ) .'" id="'. esc_attr( $id ) .'" class="'.esc_attr( $class ).'">'. esc_textarea( $current ) .'</textarea>'; |
|
496 | + return '<textarea name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class ) . '">' . esc_textarea( $current ) . '</textarea>'; |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /** |
@@ -509,9 +509,9 @@ discard block |
||
509 | 509 | |
510 | 510 | _deprecated_function( __METHOD__, '1.2', 'GravityView_FieldType_select::render_input' ); |
511 | 511 | |
512 | - $output = '<select name="'. $name .'" id="'. $id .'">'; |
|
513 | - foreach( $choices as $value => $label ) { |
|
514 | - $output .= '<option value="'. esc_attr( $value ) .'" '. selected( $value, $current, false ) .'>'. esc_html( $label ) .'</option>'; |
|
512 | + $output = '<select name="' . $name . '" id="' . $id . '">'; |
|
513 | + foreach ( $choices as $value => $label ) { |
|
514 | + $output .= '<option value="' . esc_attr( $value ) . '" ' . selected( $value, $current, false ) . '>' . esc_html( $label ) . '</option>'; |
|
515 | 515 | } |
516 | 516 | $output .= '</select>'; |
517 | 517 |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | continue; |
63 | 63 | } |
64 | 64 | |
65 | - $field_id = intval( floor( $search_field['key'] ) ); |
|
66 | - $input_id = gravityview_get_input_id_from_id( $search_field['key'] ); |
|
65 | + $field_id = intval( floor( $search_field[ 'key' ] ) ); |
|
66 | + $input_id = gravityview_get_input_id_from_id( $search_field[ 'key' ] ); |
|
67 | 67 | $form = GravityView_View::getInstance()->getForm(); |
68 | 68 | |
69 | 69 | /** @type GF_Field_Address $address_field */ |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $choices = array(); |
73 | 73 | |
74 | 74 | $method_name = 'get_choices_' . self::get_input_type_from_input_id( $input_id ); |
75 | - if( method_exists( $this, $method_name ) ) { |
|
75 | + if ( method_exists( $this, $method_name ) ) { |
|
76 | 76 | /** |
77 | 77 | * @uses GravityView_Field_Address::get_choices_country() |
78 | 78 | * @uses GravityView_Field_Address::get_choices_state() |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | $choices = $this->{$method_name}( $address_field, $form ); |
81 | 81 | } |
82 | 82 | |
83 | - if( ! empty( $choices ) ) { |
|
84 | - $search_field['choices'] = $choices; |
|
85 | - $search_field['type'] = \GV\Utils::get( $search_field, 'input'); |
|
83 | + if ( ! empty( $choices ) ) { |
|
84 | + $search_field[ 'choices' ] = $choices; |
|
85 | + $search_field[ 'type' ] = \GV\Utils::get( $search_field, 'input' ); |
|
86 | 86 | } else { |
87 | - $search_field['type'] = 'text'; |
|
88 | - $search_field['input'] = 'input_text'; |
|
87 | + $search_field[ 'type' ] = 'text'; |
|
88 | + $search_field[ 'input' ] = 'input_text'; |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $country_choices = array(); |
111 | 111 | |
112 | 112 | foreach ( $countries as $key => $country ) { |
113 | - $country_choices[] = array( |
|
113 | + $country_choices[ ] = array( |
|
114 | 114 | 'value' => $country, |
115 | 115 | 'text' => $country, |
116 | 116 | ); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | private function get_choices_state( $address_field, $form ) { |
137 | 137 | |
138 | - $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form['id'] ) : $address_field->addressType; |
|
138 | + $address_type = empty( $address_field->addressType ) ? $address_field->get_default_address_type( $form[ 'id' ] ) : $address_field->addressType; |
|
139 | 139 | |
140 | 140 | $state_choices = array(); |
141 | 141 | |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | $states = GFCommon::get_canadian_provinces(); |
148 | 148 | break; |
149 | 149 | default: |
150 | - $address_types = $address_field->get_address_types( $form['id'] ); |
|
151 | - $states = empty( $address_types[ $address_type ]['states'] ) ? array() : $address_types[ $address_type ]['states']; |
|
150 | + $address_types = $address_field->get_address_types( $form[ 'id' ] ); |
|
151 | + $states = empty( $address_types[ $address_type ][ 'states' ] ) ? array() : $address_types[ $address_type ][ 'states' ]; |
|
152 | 152 | break; |
153 | 153 | } |
154 | 154 | |
@@ -157,19 +157,19 @@ discard block |
||
157 | 157 | $state_subchoices = array(); |
158 | 158 | |
159 | 159 | foreach ( $state as $key => $substate ) { |
160 | - $state_subchoices[] = array( |
|
160 | + $state_subchoices[ ] = array( |
|
161 | 161 | 'value' => is_numeric( $key ) ? $substate : $key, |
162 | 162 | 'text' => $substate, |
163 | 163 | ); |
164 | 164 | } |
165 | 165 | |
166 | - $state_choices[] = array( |
|
166 | + $state_choices[ ] = array( |
|
167 | 167 | 'text' => $key, |
168 | 168 | 'value' => $state_subchoices, |
169 | 169 | ); |
170 | 170 | |
171 | 171 | } else { |
172 | - $state_choices[] = array( |
|
172 | + $state_choices[ ] = array( |
|
173 | 173 | 'value' => is_numeric( $key ) ? $state : $key, |
174 | 174 | 'text' => $state, |
175 | 175 | ); |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | // Use the same inputs as the "text" input type allows |
194 | 194 | $text_inputs = \GV\Utils::get( $input_types, 'text' ); |
195 | 195 | |
196 | - $input_types['street'] = $text_inputs; |
|
197 | - $input_types['street2'] = $text_inputs; |
|
198 | - $input_types['city'] = $text_inputs; |
|
196 | + $input_types[ 'street' ] = $text_inputs; |
|
197 | + $input_types[ 'street2' ] = $text_inputs; |
|
198 | + $input_types[ 'city' ] = $text_inputs; |
|
199 | 199 | |
200 | - $input_types['state'] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
201 | - $input_types['zip'] = array( 'input_text' ); |
|
202 | - $input_types['country'] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
200 | + $input_types[ 'state' ] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
201 | + $input_types[ 'zip' ] = array( 'input_text' ); |
|
202 | + $input_types[ 'country' ] = array( 'select', 'radio', 'link' ) + $text_inputs; |
|
203 | 203 | |
204 | 204 | return $input_types; |
205 | 205 | } |
@@ -220,12 +220,12 @@ discard block |
||
220 | 220 | // Is this search field for an input (eg: 4.2) or the whole address field (eg: 4)? |
221 | 221 | $input_id = gravityview_get_input_id_from_id( $field_id ); |
222 | 222 | |
223 | - if( 'address' !== $field_type && $input_id ) { |
|
223 | + if ( 'address' !== $field_type && $input_id ) { |
|
224 | 224 | return $input_type; |
225 | 225 | } |
226 | 226 | |
227 | 227 | // If the input ID matches an expected address input, set to that. Otherwise, keep existing input type. |
228 | - if( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { |
|
228 | + if ( $address_field_name = self::get_input_type_from_input_id( $input_id ) ) { |
|
229 | 229 | $input_type = $address_field_name; |
230 | 230 | } |
231 | 231 | |
@@ -273,20 +273,20 @@ discard block |
||
273 | 273 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
274 | 274 | |
275 | 275 | // If this is NOT the full address field, return default options. |
276 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
276 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
277 | 277 | return $field_options; |
278 | 278 | } |
279 | 279 | |
280 | - if( 'edit' === $context ) { |
|
280 | + if ( 'edit' === $context ) { |
|
281 | 281 | return $field_options; |
282 | 282 | } |
283 | 283 | |
284 | 284 | $add_options = array(); |
285 | 285 | |
286 | - $add_options['show_map_link'] = array( |
|
286 | + $add_options[ 'show_map_link' ] = array( |
|
287 | 287 | 'type' => 'checkbox', |
288 | 288 | 'label' => __( 'Show Map Link:', 'gravityview' ), |
289 | - 'desc' => __('Display a "Map It" link below the address', 'gravityview'), |
|
289 | + 'desc' => __( 'Display a "Map It" link below the address', 'gravityview' ), |
|
290 | 290 | 'value' => true, |
291 | 291 | 'merge_tags' => false, |
292 | 292 | ); |