@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | die; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -if( ! class_exists( '\GV\Gamajo_Template_Loader' ) ) { |
|
| 19 | +if ( ! class_exists( '\GV\Gamajo_Template_Loader' ) ) { |
|
| 20 | 20 | require( GRAVITYVIEW_DIR . 'future/lib/class-gamajo-template-loader.php' ); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | 'atts' => NULL, |
| 165 | 165 | ) ); |
| 166 | 166 | |
| 167 | - foreach ($atts as $key => $value) { |
|
| 168 | - if( is_null( $value ) ) { |
|
| 167 | + foreach ( $atts as $key => $value ) { |
|
| 168 | + if ( is_null( $value ) ) { |
|
| 169 | 169 | continue; |
| 170 | 170 | } |
| 171 | 171 | $this->{$key} = $value; |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | static function getInstance( $passed_post = NULL ) { |
| 197 | 197 | |
| 198 | - if( empty( self::$instance ) ) { |
|
| 198 | + if ( empty( self::$instance ) ) { |
|
| 199 | 199 | self::$instance = new self( $passed_post ); |
| 200 | 200 | } |
| 201 | 201 | |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | public function getCurrentField( $key = NULL ) { |
| 210 | 210 | |
| 211 | - if( !empty( $key ) ) { |
|
| 212 | - if( isset( $this->_current_field[ $key ] ) ) { |
|
| 211 | + if ( ! empty( $key ) ) { |
|
| 212 | + if ( isset( $this->_current_field[ $key ] ) ) { |
|
| 213 | 213 | return $this->_current_field[ $key ]; |
| 214 | 214 | } |
| 215 | 215 | return NULL; |
@@ -220,16 +220,16 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | public function setCurrentFieldSetting( $key, $value ) { |
| 222 | 222 | |
| 223 | - if( !empty( $this->_current_field ) ) { |
|
| 224 | - $this->_current_field['field_settings'][ $key ] = $value; |
|
| 223 | + if ( ! empty( $this->_current_field ) ) { |
|
| 224 | + $this->_current_field[ 'field_settings' ][ $key ] = $value; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | public function getCurrentFieldSetting( $key ) { |
| 230 | - $settings = $this->getCurrentField('field_settings'); |
|
| 230 | + $settings = $this->getCurrentField( 'field_settings' ); |
|
| 231 | 231 | |
| 232 | - if( $settings && !empty( $settings[ $key ] ) ) { |
|
| 232 | + if ( $settings && ! empty( $settings[ $key ] ) ) { |
|
| 233 | 233 | return $settings[ $key ]; |
| 234 | 234 | } |
| 235 | 235 | |
@@ -260,8 +260,8 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function getAtts( $key = NULL ) { |
| 262 | 262 | |
| 263 | - if( !empty( $key ) ) { |
|
| 264 | - if( isset( $this->atts[ $key ] ) ) { |
|
| 263 | + if ( ! empty( $key ) ) { |
|
| 264 | + if ( isset( $this->atts[ $key ] ) ) { |
|
| 265 | 265 | return $this->atts[ $key ]; |
| 266 | 266 | } |
| 267 | 267 | return NULL; |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | $fields = empty( $this->fields ) ? NULL : $this->fields; |
| 329 | 329 | |
| 330 | - if( $fields && !empty( $key ) ) { |
|
| 330 | + if ( $fields && ! empty( $key ) ) { |
|
| 331 | 331 | $fields = isset( $fields[ $key ] ) ? $fields[ $key ] : NULL; |
| 332 | 332 | } |
| 333 | 333 | |
@@ -345,18 +345,18 @@ discard block |
||
| 345 | 345 | */ |
| 346 | 346 | public function getContextFields( $context = '' ) { |
| 347 | 347 | |
| 348 | - if( '' === $context ) { |
|
| 348 | + if ( '' === $context ) { |
|
| 349 | 349 | $context = $this->getContext(); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | $fields = $this->getFields(); |
| 353 | 353 | |
| 354 | - foreach ( (array) $fields as $key => $context_fields ) { |
|
| 354 | + foreach ( (array)$fields as $key => $context_fields ) { |
|
| 355 | 355 | |
| 356 | 356 | // Formatted as `{context}_{template id}-{zone name}`, so we want just the $context to match against |
| 357 | 357 | $matches = explode( '_', $key ); |
| 358 | 358 | |
| 359 | - if( isset( $matches[0] ) && $matches[0] === $context ) { |
|
| 359 | + if ( isset( $matches[ 0 ] ) && $matches[ 0 ] === $context ) { |
|
| 360 | 360 | return $context_fields; |
| 361 | 361 | } |
| 362 | 362 | } |
@@ -377,8 +377,8 @@ discard block |
||
| 377 | 377 | */ |
| 378 | 378 | public function getField( $key ) { |
| 379 | 379 | |
| 380 | - if( !empty( $key ) ) { |
|
| 381 | - if( isset( $this->fields[ $key ] ) ) { |
|
| 380 | + if ( ! empty( $key ) ) { |
|
| 381 | + if ( isset( $this->fields[ $key ] ) ) { |
|
| 382 | 382 | return $this->fields[ $key ]; |
| 383 | 383 | } |
| 384 | 384 | } |
@@ -484,8 +484,8 @@ discard block |
||
| 484 | 484 | public function getPaginationCounts() { |
| 485 | 485 | |
| 486 | 486 | $paging = $this->getPaging(); |
| 487 | - $offset = $paging['offset']; |
|
| 488 | - $page_size = $paging['page_size']; |
|
| 487 | + $offset = $paging[ 'offset' ]; |
|
| 488 | + $page_size = $paging[ 'page_size' ]; |
|
| 489 | 489 | $total = $this->getTotalEntries(); |
| 490 | 490 | |
| 491 | 491 | if ( empty( $total ) ) { |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | */ |
| 507 | 507 | list( $first, $last, $total ) = apply_filters( 'gravityview_pagination_counts', array( $first, $last, $total ) ); |
| 508 | 508 | |
| 509 | - return array( 'first' => (int) $first, 'last' => (int) $last, 'total' => (int) $total ); |
|
| 509 | + return array( 'first' => (int)$first, 'last' => (int)$last, 'total' => (int)$total ); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | /** |
@@ -602,16 +602,16 @@ discard block |
||
| 602 | 602 | */ |
| 603 | 603 | public function getCurrentEntry() { |
| 604 | 604 | |
| 605 | - if( in_array( $this->getContext(), array( 'edit', 'single') ) ) { |
|
| 605 | + if ( in_array( $this->getContext(), array( 'edit', 'single' ) ) ) { |
|
| 606 | 606 | $entries = $this->getEntries(); |
| 607 | - $entry = $entries[0]; |
|
| 607 | + $entry = $entries[ 0 ]; |
|
| 608 | 608 | } else { |
| 609 | 609 | $entry = $this->_current_entry; |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | /** @since 1.16 Fixes DataTables empty entry issue */ |
| 613 | - if ( empty( $entry ) && ! empty( $this->_current_field['entry'] ) ) { |
|
| 614 | - $entry = $this->_current_field['entry']; |
|
| 613 | + if ( empty( $entry ) && ! empty( $this->_current_field[ 'entry' ] ) ) { |
|
| 614 | + $entry = $this->_current_field[ 'entry' ]; |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | return $entry; |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | public function renderZone( $zone = '', $atts = array(), $echo = true ) { |
| 652 | 652 | |
| 653 | 653 | if ( empty( $zone ) ) { |
| 654 | - gravityview()->log->error( 'No zone defined.'); |
|
| 654 | + gravityview()->log->error( 'No zone defined.' ); |
|
| 655 | 655 | return NULL; |
| 656 | 656 | } |
| 657 | 657 | |
@@ -660,16 +660,16 @@ discard block |
||
| 660 | 660 | 'context' => $this->getContext(), |
| 661 | 661 | 'entry' => $this->getCurrentEntry(), |
| 662 | 662 | 'form' => $this->getForm(), |
| 663 | - 'hide_empty' => $this->getAtts('hide_empty'), |
|
| 663 | + 'hide_empty' => $this->getAtts( 'hide_empty' ), |
|
| 664 | 664 | ); |
| 665 | 665 | |
| 666 | 666 | $final_atts = wp_parse_args( $atts, $defaults ); |
| 667 | 667 | |
| 668 | 668 | $output = ''; |
| 669 | 669 | |
| 670 | - $final_atts['zone_id'] = "{$final_atts['context']}_{$final_atts['slug']}-{$zone}"; |
|
| 670 | + $final_atts[ 'zone_id' ] = "{$final_atts[ 'context' ]}_{$final_atts[ 'slug' ]}-{$zone}"; |
|
| 671 | 671 | |
| 672 | - $fields = $this->getField( $final_atts['zone_id'] ); |
|
| 672 | + $fields = $this->getField( $final_atts[ 'zone_id' ] ); |
|
| 673 | 673 | |
| 674 | 674 | // Backward compatibility |
| 675 | 675 | if ( 'table' === $this->getTemplatePartSlug() ) { |
@@ -679,19 +679,19 @@ discard block |
||
| 679 | 679 | * @param \GravityView_View $this |
| 680 | 680 | * @deprecated Use `gravityview/template/table/fields` |
| 681 | 681 | */ |
| 682 | - $fields = apply_filters("gravityview_table_cells", $fields, $this ); |
|
| 682 | + $fields = apply_filters( "gravityview_table_cells", $fields, $this ); |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | if ( empty( $fields ) ) { |
| 686 | 686 | |
| 687 | - gravityview()->log->warning( 'Empty zone configuration for {zone_id}.', array( 'zone_id' => $final_atts['zone_id'] ) ); |
|
| 687 | + gravityview()->log->warning( 'Empty zone configuration for {zone_id}.', array( 'zone_id' => $final_atts[ 'zone_id' ] ) ); |
|
| 688 | 688 | |
| 689 | 689 | return NULL; |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | $field_output = ''; |
| 693 | 693 | foreach ( $fields as $field ) { |
| 694 | - $final_atts['field'] = $field; |
|
| 694 | + $final_atts[ 'field' ] = $field; |
|
| 695 | 695 | |
| 696 | 696 | $field_output .= gravityview_field_output( $final_atts ); |
| 697 | 697 | } |
@@ -708,17 +708,17 @@ discard block |
||
| 708 | 708 | return NULL; |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
| 712 | - $output .= '<div class="'.gravityview_sanitize_html_class( $final_atts['wrapper_class'] ).'">'; |
|
| 711 | + if ( ! empty( $final_atts[ 'wrapper_class' ] ) ) { |
|
| 712 | + $output .= '<div class="' . gravityview_sanitize_html_class( $final_atts[ 'wrapper_class' ] ) . '">'; |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | $output .= $field_output; |
| 716 | 716 | |
| 717 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
| 717 | + if ( ! empty( $final_atts[ 'wrapper_class' ] ) ) { |
|
| 718 | 718 | $output .= '</div>'; |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | - if( $echo ) { |
|
| 721 | + if ( $echo ) { |
|
| 722 | 722 | echo $output; |
| 723 | 723 | } |
| 724 | 724 | |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | */ |
| 737 | 737 | function locate_template( $template_names, $load = false, $require_once = true ) { |
| 738 | 738 | |
| 739 | - if( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
| 739 | + if ( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
| 740 | 740 | |
| 741 | 741 | $located = $this->located_templates[ $template_names ]; |
| 742 | 742 | |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | // Set $load to always false so we handle it here. |
| 746 | 746 | $located = parent::locate_template( $template_names, false, $require_once ); |
| 747 | 747 | |
| 748 | - if( is_string( $template_names ) ) { |
|
| 748 | + if ( is_string( $template_names ) ) { |
|
| 749 | 749 | $this->located_templates[ $template_names ] = $located; |
| 750 | 750 | } |
| 751 | 751 | } |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | * @return mixed|null The stored data. |
| 764 | 764 | */ |
| 765 | 765 | public function __get( $name ) { |
| 766 | - if( isset( $this->{$name} ) ) { |
|
| 766 | + if ( isset( $this->{$name} ) ) { |
|
| 767 | 767 | return $this->{$name}; |
| 768 | 768 | } else { |
| 769 | 769 | return NULL; |
@@ -792,17 +792,17 @@ discard block |
||
| 792 | 792 | $additional = array(); |
| 793 | 793 | |
| 794 | 794 | // form-19-table-body.php |
| 795 | - $additional[] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
| 795 | + $additional[ ] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
| 796 | 796 | |
| 797 | - if( $view_id = $this->getViewId() ) { |
|
| 797 | + if ( $view_id = $this->getViewId() ) { |
|
| 798 | 798 | // view-3-table-body.php |
| 799 | - $additional[] = sprintf( 'view-%d-%s-%s.php', $view_id, $slug, $name ); |
|
| 799 | + $additional[ ] = sprintf( 'view-%d-%s-%s.php', $view_id, $slug, $name ); |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - if( $this->getPostId() ) { |
|
| 802 | + if ( $this->getPostId() ) { |
|
| 803 | 803 | |
| 804 | 804 | // page-19-table-body.php |
| 805 | - $additional[] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
| 805 | + $additional[ ] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | // Combine with existing table-body.php and table.php |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | |
| 825 | 825 | gravityview()->log->debug( 'Rendering Template File: {path}', array( 'path' => $template_file ) ); |
| 826 | 826 | |
| 827 | - if( !empty( $template_file) ) { |
|
| 827 | + if ( ! empty( $template_file ) ) { |
|
| 828 | 828 | |
| 829 | 829 | if ( $require_once ) { |
| 830 | 830 | require_once( $template_file ); |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | |
| 900 | 900 | // Prevent being called twice |
| 901 | 901 | if ( did_action( "gravityview/widgets/$zone/{$view->ID}/rendered" ) ) { |
| 902 | - gravityview()->log->debug( 'Not rendering {zone}; already rendered', array( 'zone' => $zone.'_'.$view->ID.'_widgets' ) ); |
|
| 902 | + gravityview()->log->debug( 'Not rendering {zone}; already rendered', array( 'zone' => $zone . '_' . $view->ID . '_widgets' ) ); |
|
| 903 | 903 | return; |
| 904 | 904 | } |
| 905 | 905 | |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | * @param string $zone Current widget zone, either `header` or `footer` |
| 922 | 922 | * @param array $widgets Array of widget configurations for the current zone, as set by `gravityview_get_current_view_data()['widgets']` |
| 923 | 923 | */ |
| 924 | - $css_class = apply_filters('gravityview/widgets/wrapper_css_class', $default_css_class, $zone, $widgets->as_configuration() ); |
|
| 924 | + $css_class = apply_filters( 'gravityview/widgets/wrapper_css_class', $default_css_class, $zone, $widgets->as_configuration() ); |
|
| 925 | 925 | |
| 926 | 926 | $css_class = gravityview_sanitize_html_class( $css_class ); |
| 927 | 927 | |
@@ -929,15 +929,15 @@ discard block |
||
| 929 | 929 | ?> |
| 930 | 930 | <div class="<?php echo $css_class; ?>"> |
| 931 | 931 | <?php |
| 932 | - foreach( $rows as $row ) { |
|
| 933 | - foreach( $row as $col => $areas ) { |
|
| 932 | + foreach ( $rows as $row ) { |
|
| 933 | + foreach ( $row as $col => $areas ) { |
|
| 934 | 934 | $column = ( $col == '2-2' ) ? '1-2 gv-right' : "$col gv-left"; |
| 935 | 935 | ?> |
| 936 | 936 | <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
| 937 | 937 | <?php |
| 938 | 938 | if ( ! empty( $areas ) ) { |
| 939 | 939 | foreach ( $areas as $area ) { |
| 940 | - foreach ( $widgets->by_position( $zone . '_' . $area['areaid'] )->all() as $widget ) { |
|
| 940 | + foreach ( $widgets->by_position( $zone . '_' . $area[ 'areaid' ] )->all() as $widget ) { |
|
| 941 | 941 | do_action( sprintf( 'gravityview/widgets/%s/render', $widget->get_widget_id() ), $widget->configuration->all(), null, $view_id_or_context ); |
| 942 | 942 | } |
| 943 | 943 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | 'search_clear' => array( |
| 56 | 56 | 'type' => 'checkbox', |
| 57 | 57 | 'label' => __( 'Show Clear button', 'gk-gravityview' ), |
| 58 | - 'desc' => __( 'When a search is performed, display a button that removes all search values.', 'gk-gravityview'), |
|
| 58 | + 'desc' => __( 'When a search is performed, display a button that removes all search values.', 'gk-gravityview' ), |
|
| 59 | 59 | 'value' => true, |
| 60 | 60 | ), |
| 61 | 61 | 'search_fields' => array( |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | 'type' => 'radio', |
| 69 | 69 | 'full_width' => true, |
| 70 | 70 | 'label' => esc_html__( 'Search Mode', 'gk-gravityview' ), |
| 71 | - 'desc' => __('Should search results match all search fields, or any?', 'gk-gravityview'), |
|
| 71 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gk-gravityview' ), |
|
| 72 | 72 | 'value' => 'any', |
| 73 | 73 | 'class' => 'hide-if-js', |
| 74 | 74 | 'options' => array( |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | // translators: Do not translate [b], [/b], [link], or [/link]; they are placeholders for HTML and links to documentation. |
| 84 | 84 | 'desc' => strtr( |
| 85 | 85 | esc_html__( 'For fields with choices: Instead of showing all choices for each field, show only field choices that exist in submitted form entries.', 'gk-gravityview' ) . |
| 86 | - '<p><strong>⚠️ ' . esc_html__('This setting affects security.', 'gk-gravityview' ) . '</strong> ' . esc_html__( '[link]Learn about the Pre-Filter Choices setting[/link] before enabling it.', 'gk-gravityview') . '</p>', |
|
| 86 | + '<p><strong>⚠️ ' . esc_html__( 'This setting affects security.', 'gk-gravityview' ) . '</strong> ' . esc_html__( '[link]Learn about the Pre-Filter Choices setting[/link] before enabling it.', 'gk-gravityview' ) . '</p>', |
|
| 87 | 87 | array( |
| 88 | 88 | '[b]' => '<strong>', |
| 89 | 89 | '[/b]' => '</strong>', |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
| 111 | 111 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
| 112 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
| 112 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
| 113 | 113 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
| 114 | 114 | |
| 115 | 115 | // ajax - get the searchable fields |
@@ -148,19 +148,19 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function add_reserved_args( $args ) { |
| 150 | 150 | |
| 151 | - $args[] = 'gv_search'; |
|
| 152 | - $args[] = 'gv_start'; |
|
| 153 | - $args[] = 'gv_end'; |
|
| 154 | - $args[] = 'gv_id'; |
|
| 155 | - $args[] = 'gv_by'; |
|
| 156 | - $args[] = 'mode'; |
|
| 151 | + $args[ ] = 'gv_search'; |
|
| 152 | + $args[ ] = 'gv_start'; |
|
| 153 | + $args[ ] = 'gv_end'; |
|
| 154 | + $args[ ] = 'gv_id'; |
|
| 155 | + $args[ ] = 'gv_by'; |
|
| 156 | + $args[ ] = 'mode'; |
|
| 157 | 157 | |
| 158 | - $get = (array) $_GET; |
|
| 158 | + $get = (array)$_GET; |
|
| 159 | 159 | |
| 160 | 160 | // If the fields being searched as reserved; not to be considered user-passed variables |
| 161 | 161 | foreach ( $get as $key => $value ) { |
| 162 | 162 | if ( $key !== $this->convert_request_key_to_filter_key( $key ) ) { |
| 163 | - $args[] = $key; |
|
| 163 | + $args[ ] = $key; |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 285 | 285 | $script_source = empty( $script_min ) ? '/source' : ''; |
| 286 | 286 | |
| 287 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
| 287 | + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
| 288 | 288 | |
| 289 | 289 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
| 290 | 290 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
| 307 | 307 | */ |
| 308 | 308 | public function register_no_conflict( $allowed ) { |
| 309 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
| 309 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
| 310 | 310 | return $allowed; |
| 311 | 311 | } |
| 312 | 312 | |
@@ -318,24 +318,24 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | public static function get_searchable_fields() { |
| 320 | 320 | |
| 321 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 321 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 322 | 322 | exit( '0' ); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | $form = ''; |
| 326 | 326 | |
| 327 | 327 | // Fetch the form for the current View |
| 328 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
| 328 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
| 329 | 329 | |
| 330 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
| 330 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
| 331 | 331 | |
| 332 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
| 332 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
| 333 | 333 | |
| 334 | - $form = (int) $_POST['formid']; |
|
| 334 | + $form = (int)$_POST[ 'formid' ]; |
|
| 335 | 335 | |
| 336 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 336 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 337 | 337 | |
| 338 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 338 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 339 | 339 | |
| 340 | 340 | } |
| 341 | 341 | |
@@ -385,14 +385,14 @@ discard block |
||
| 385 | 385 | ); |
| 386 | 386 | |
| 387 | 387 | if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { |
| 388 | - $custom_fields['is_approved'] = array( |
|
| 388 | + $custom_fields[ 'is_approved' ] = array( |
|
| 389 | 389 | 'text' => esc_html__( 'Approval Status', 'gk-gravityview' ), |
| 390 | 390 | 'type' => 'multi', |
| 391 | 391 | ); |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 395 | - $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); |
|
| 394 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 395 | + $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] ); |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | // Get fields with sub-inputs and no parent |
@@ -414,13 +414,13 @@ discard block |
||
| 414 | 414 | |
| 415 | 415 | foreach ( $fields as $id => $field ) { |
| 416 | 416 | |
| 417 | - if ( in_array( $field['type'], $blocklist_field_types ) ) { |
|
| 417 | + if ( in_array( $field[ 'type' ], $blocklist_field_types ) ) { |
|
| 418 | 418 | continue; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
| 421 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
| 422 | 422 | |
| 423 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
| 423 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
| 444 | 444 | |
| 445 | 445 | // @todo - This needs to be improved - many fields have . including products and addresses |
| 446 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 446 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 447 | 447 | $input_type = 'boolean'; // on/off checkbox |
| 448 | 448 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
| 449 | 449 | $input_type = 'multi'; //multiselect |
@@ -489,19 +489,19 @@ discard block |
||
| 489 | 489 | $post_id = 0; |
| 490 | 490 | |
| 491 | 491 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
| 492 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
| 493 | - $post_id = absint( $widget_args['post_id'] ); |
|
| 492 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
| 493 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
| 494 | 494 | } |
| 495 | 495 | // We're in the WordPress Widget context, and the base View ID should be used |
| 496 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
| 497 | - $post_id = absint( $widget_args['view_id'] ); |
|
| 496 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
| 497 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | $args = gravityview_get_permalink_query_args( $post_id ); |
| 501 | 501 | |
| 502 | 502 | // Add hidden fields to the search form |
| 503 | 503 | foreach ( $args as $key => $value ) { |
| 504 | - $search_fields[] = array( |
|
| 504 | + $search_fields[ ] = array( |
|
| 505 | 505 | 'name' => $key, |
| 506 | 506 | 'input' => 'hidden', |
| 507 | 507 | 'value' => $value, |
@@ -540,28 +540,28 @@ discard block |
||
| 540 | 540 | /** |
| 541 | 541 | * Include the sidebar Widgets. |
| 542 | 542 | */ |
| 543 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
| 543 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
| 544 | 544 | |
| 545 | 545 | foreach ( $widgets as $widget ) { |
| 546 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
| 547 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
| 546 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
| 547 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
| 548 | 548 | foreach ( $_fields as $field ) { |
| 549 | - if ( empty( $field['form_id'] ) ) { |
|
| 550 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
| 549 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
| 550 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
| 551 | 551 | } |
| 552 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
| 552 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
| 559 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
| 559 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
| 560 | 560 | foreach ( $_fields as $field ) { |
| 561 | - if ( empty( $field['form_id'] ) ) { |
|
| 562 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
| 561 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
| 562 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
| 563 | 563 | } |
| 564 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
| 564 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | } |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | - if( 'post' === $this->search_method ) { |
|
| 610 | + if ( 'post' === $this->search_method ) { |
|
| 611 | 611 | $get = $_POST; |
| 612 | 612 | } else { |
| 613 | 613 | $get = $_GET; |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | // Make sure array key is set up |
| 633 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
| 633 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
| 634 | 634 | |
| 635 | 635 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
| 636 | 636 | $searchable_field_objects = $this->get_view_searchable_fields( $view, true ); |
@@ -650,9 +650,9 @@ discard block |
||
| 650 | 650 | $trim_search_value = apply_filters( 'gravityview/search-trim-input', true ); |
| 651 | 651 | |
| 652 | 652 | // add free search |
| 653 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
| 653 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
| 654 | 654 | |
| 655 | - $search_all_value = $trim_search_value ? trim( $get['gv_search'] ) : $get['gv_search']; |
|
| 655 | + $search_all_value = $trim_search_value ? trim( $get[ 'gv_search' ] ) : $get[ 'gv_search' ]; |
|
| 656 | 656 | |
| 657 | 657 | if ( $split_words ) { |
| 658 | 658 | // Search for a piece |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | foreach ( $words as $word ) { |
| 671 | - $search_criteria['field_filters'][] = array( |
|
| 671 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 672 | 672 | 'key' => null, // The field ID to search |
| 673 | 673 | 'value' => $word, // The value to search |
| 674 | 674 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -681,14 +681,14 @@ discard block |
||
| 681 | 681 | /** |
| 682 | 682 | * Get and normalize the dates according to the input format. |
| 683 | 683 | */ |
| 684 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
| 685 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
| 684 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
| 685 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
| 686 | 686 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
| 687 | 687 | } |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
| 691 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
| 690 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
| 691 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
| 692 | 692 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
| 693 | 693 | } |
| 694 | 694 | } |
@@ -724,22 +724,22 @@ discard block |
||
| 724 | 724 | */ |
| 725 | 725 | if ( ! empty( $curr_start ) ) { |
| 726 | 726 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
| 727 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 727 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | if ( ! empty( $curr_end ) ) { |
| 731 | 731 | // Fast-forward 24 hour on the end time |
| 732 | 732 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
| 733 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 734 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
| 735 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
| 733 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 734 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
| 735 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
| 736 | 736 | } |
| 737 | 737 | } |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | // search for a specific entry ID |
| 741 | 741 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
| 742 | - $search_criteria['field_filters'][] = array( |
|
| 742 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 743 | 743 | 'key' => 'id', |
| 744 | 744 | 'value' => absint( $get[ 'gv_id' ] ), |
| 745 | 745 | 'operator' => $this->get_operator( $get, 'gv_id', array( '=' ), '=' ), |
@@ -748,15 +748,15 @@ discard block |
||
| 748 | 748 | |
| 749 | 749 | // search for a specific Created_by ID |
| 750 | 750 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
| 751 | - $search_criteria['field_filters'][] = array( |
|
| 751 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 752 | 752 | 'key' => 'created_by', |
| 753 | - 'value' => $get['gv_by'], |
|
| 753 | + 'value' => $get[ 'gv_by' ], |
|
| 754 | 754 | 'operator' => $this->get_operator( $get, 'gv_by', array( '=' ), '=' ), |
| 755 | 755 | ); |
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | // Get search mode passed in URL |
| 759 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
| 759 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
| 760 | 760 | |
| 761 | 761 | // get the other search filters |
| 762 | 762 | foreach ( $get as $key => $value ) { |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | $value = is_array( $value ) ? array_map( 'trim', $value ) : trim( $value ); |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | - if ( gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
| 777 | + if ( gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
| 778 | 778 | /** |
| 779 | 779 | * @filter `gravityview/search/ignore-empty-values` Filter to control if empty field values should be ignored or strictly matched (default: true) |
| 780 | 780 | * @since 2.14.2.1 |
@@ -805,21 +805,21 @@ discard block |
||
| 805 | 805 | continue; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - if ( ! isset( $filter['operator'] ) ) { |
|
| 809 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
| 808 | + if ( ! isset( $filter[ 'operator' ] ) ) { |
|
| 809 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | - if ( isset( $filter[0]['value'] ) ) { |
|
| 813 | - $filter[0]['value'] = $trim_search_value ? trim( $filter[0]['value'] ) : $filter[0]['value']; |
|
| 812 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
| 813 | + $filter[ 0 ][ 'value' ] = $trim_search_value ? trim( $filter[ 0 ][ 'value' ] ) : $filter[ 0 ][ 'value' ]; |
|
| 814 | 814 | |
| 815 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
| 815 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
| 816 | 816 | |
| 817 | 817 | // if date range type, set search mode to ALL |
| 818 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 818 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 819 | 819 | $mode = 'all'; |
| 820 | 820 | } |
| 821 | - } elseif( !empty( $filter ) ) { |
|
| 822 | - $search_criteria['field_filters'][] = $filter; |
|
| 821 | + } elseif ( ! empty( $filter ) ) { |
|
| 822 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
| 823 | 823 | } |
| 824 | 824 | } |
| 825 | 825 | |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | * @since 1.5.1 |
| 829 | 829 | * @param string $mode Search mode (`any` vs `all`) |
| 830 | 830 | */ |
| 831 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 831 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 832 | 832 | |
| 833 | 833 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
| 834 | 834 | |
@@ -862,19 +862,19 @@ discard block |
||
| 862 | 862 | |
| 863 | 863 | $query_class = $view->get_query_class(); |
| 864 | 864 | |
| 865 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
| 865 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
| 866 | 866 | return; |
| 867 | 867 | } |
| 868 | 868 | |
| 869 | 869 | $widgets = $view->widgets->by_id( $this->widget_id ); |
| 870 | 870 | if ( $widgets->count() ) { |
| 871 | 871 | $widgets = $widgets->all(); |
| 872 | - $widget = $widgets[0]; |
|
| 872 | + $widget = $widgets[ 0 ]; |
|
| 873 | 873 | |
| 874 | 874 | $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ); |
| 875 | 875 | |
| 876 | - foreach ( (array) $search_fields as $search_field ) { |
|
| 877 | - if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) { |
|
| 876 | + foreach ( (array)$search_fields as $search_field ) { |
|
| 877 | + if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) { |
|
| 878 | 878 | $created_by_text_mode = true; |
| 879 | 879 | } |
| 880 | 880 | } |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | $extra_conditions = array(); |
| 884 | 884 | $mode = 'any'; |
| 885 | 885 | |
| 886 | - foreach ( $search_criteria['field_filters'] as $key => &$filter ) { |
|
| 886 | + foreach ( $search_criteria[ 'field_filters' ] as $key => &$filter ) { |
|
| 887 | 887 | if ( ! is_array( $filter ) ) { |
| 888 | 888 | if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) { |
| 889 | 889 | $mode = $filter; |
@@ -892,13 +892,13 @@ discard block |
||
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | // Construct a manual query for unapproved statuses |
| 895 | - if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) { |
|
| 896 | - $_tmp_query = new $query_class( $view->form->ID, array( |
|
| 895 | + if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) { |
|
| 896 | + $_tmp_query = new $query_class( $view->form->ID, array( |
|
| 897 | 897 | 'field_filters' => array( |
| 898 | 898 | array( |
| 899 | 899 | 'operator' => 'in', |
| 900 | 900 | 'key' => 'is_approved', |
| 901 | - 'value' => (array) $filter['value'], |
|
| 901 | + 'value' => (array)$filter[ 'value' ], |
|
| 902 | 902 | ), |
| 903 | 903 | array( |
| 904 | 904 | 'operator' => 'is', |
@@ -910,30 +910,30 @@ discard block |
||
| 910 | 910 | ) ); |
| 911 | 911 | $_tmp_query_parts = $_tmp_query->_introspect(); |
| 912 | 912 | |
| 913 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
| 913 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
| 914 | 914 | |
| 915 | 915 | $filter = false; |
| 916 | 916 | continue; |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | // Construct manual query for text mode creator search |
| 920 | - if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { |
|
| 921 | - $extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
| 920 | + if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) { |
|
| 921 | + $extra_conditions[ ] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
| 922 | 922 | $filter = false; |
| 923 | 923 | continue; |
| 924 | 924 | } |
| 925 | 925 | |
| 926 | 926 | // By default, we want searches to be wildcard for each field. |
| 927 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
| 927 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
| 928 | 928 | |
| 929 | 929 | // For multichoice, let's have an in (OR) search. |
| 930 | - if ( is_array( $filter['value'] ) ) { |
|
| 931 | - $filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
| 930 | + if ( is_array( $filter[ 'value' ] ) ) { |
|
| 931 | + $filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | // Default form with joins functionality |
| 935 | - if ( empty( $filter['form_id'] ) ) { |
|
| 936 | - $filter['form_id'] = $view->form ? $view->form->ID : 0; |
|
| 935 | + if ( empty( $filter[ 'form_id' ] ) ) { |
|
| 936 | + $filter[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | /** |
@@ -943,32 +943,32 @@ discard block |
||
| 943 | 943 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
| 944 | 944 | * @param \GV\View $view The View we're operating on. |
| 945 | 945 | */ |
| 946 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter, $view ); |
|
| 946 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter, $view ); |
|
| 947 | 947 | |
| 948 | - if ( 'is' !== $filter['operator'] && '' === $filter['value'] ) { |
|
| 949 | - unset( $search_criteria['field_filters'][ $key ] ); |
|
| 948 | + if ( 'is' !== $filter[ 'operator' ] && '' === $filter[ 'value' ] ) { |
|
| 949 | + unset( $search_criteria[ 'field_filters' ][ $key ] ); |
|
| 950 | 950 | } |
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - if ( ! empty( $search_criteria['start_date'] ) || ! empty( $search_criteria['end_date'] ) ) { |
|
| 953 | + if ( ! empty( $search_criteria[ 'start_date' ] ) || ! empty( $search_criteria[ 'end_date' ] ) ) { |
|
| 954 | 954 | $date_criteria = array(); |
| 955 | 955 | |
| 956 | - if ( isset( $search_criteria['start_date'] ) ) { |
|
| 957 | - $date_criteria['start_date'] = $search_criteria['start_date']; |
|
| 956 | + if ( isset( $search_criteria[ 'start_date' ] ) ) { |
|
| 957 | + $date_criteria[ 'start_date' ] = $search_criteria[ 'start_date' ]; |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | - if ( isset( $search_criteria['end_date'] ) ) { |
|
| 961 | - $date_criteria['end_date'] = $search_criteria['end_date']; |
|
| 960 | + if ( isset( $search_criteria[ 'end_date' ] ) ) { |
|
| 961 | + $date_criteria[ 'end_date' ] = $search_criteria[ 'end_date' ]; |
|
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | $_tmp_query = new $query_class( $view->form->ID, $date_criteria ); |
| 965 | 965 | $_tmp_query_parts = $_tmp_query->_introspect(); |
| 966 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
| 966 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | $search_conditions = array(); |
| 970 | 970 | |
| 971 | - if ( $filters = array_filter( $search_criteria['field_filters'] ) ) { |
|
| 971 | + if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) { |
|
| 972 | 972 | foreach ( $filters as &$filter ) { |
| 973 | 973 | if ( ! is_array( $filter ) ) { |
| 974 | 974 | continue; |
@@ -980,12 +980,12 @@ discard block |
||
| 980 | 980 | * code by reusing what's inside GF_Query already as they |
| 981 | 981 | * take care of many small things like forcing numeric, etc. |
| 982 | 982 | */ |
| 983 | - $_tmp_query = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
| 983 | + $_tmp_query = new $query_class( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
| 984 | 984 | $_tmp_query_parts = $_tmp_query->_introspect(); |
| 985 | - $search_condition = $_tmp_query_parts['where']; |
|
| 985 | + $search_condition = $_tmp_query_parts[ 'where' ]; |
|
| 986 | 986 | |
| 987 | - if ( empty( $filter['key'] ) && $search_condition->expressions ) { |
|
| 988 | - $search_conditions[] = $search_condition; |
|
| 987 | + if ( empty( $filter[ 'key' ] ) && $search_condition->expressions ) { |
|
| 988 | + $search_conditions[ ] = $search_condition; |
|
| 989 | 989 | } else { |
| 990 | 990 | $left = $search_condition->left; |
| 991 | 991 | |
@@ -997,8 +997,8 @@ discard block |
||
| 997 | 997 | |
| 998 | 998 | $value = $reflectionProperty->getValue( $left ); |
| 999 | 999 | |
| 1000 | - if ( ! empty( $value[0] ) && $value[0] instanceof GF_Query_Column ) { |
|
| 1001 | - $left = $value[0]; |
|
| 1000 | + if ( ! empty( $value[ 0 ] ) && $value[ 0 ] instanceof GF_Query_Column ) { |
|
| 1001 | + $left = $value[ 0 ]; |
|
| 1002 | 1002 | } else { |
| 1003 | 1003 | continue; |
| 1004 | 1004 | } |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | $on = $_join->join_on; |
| 1015 | 1015 | $join = $_join->join; |
| 1016 | 1016 | |
| 1017 | - $search_conditions[] = GF_Query_Condition::_or( |
|
| 1017 | + $search_conditions[ ] = GF_Query_Condition::_or( |
|
| 1018 | 1018 | // Join |
| 1019 | 1019 | new GF_Query_Condition( |
| 1020 | 1020 | new GF_Query_Column( GF_Query_Column::META, $join->ID, $query->_alias( GF_Query_Column::META, $join->ID, 'm' ) ), |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | ); |
| 1031 | 1031 | } |
| 1032 | 1032 | } else { |
| 1033 | - $search_conditions[] = new GF_Query_Condition( |
|
| 1033 | + $search_conditions[ ] = new GF_Query_Condition( |
|
| 1034 | 1034 | new GF_Query_Column( $left->field_id, $left->source, $alias ), |
| 1035 | 1035 | $search_condition->operator, |
| 1036 | 1036 | $search_condition->right |
@@ -1052,7 +1052,7 @@ discard block |
||
| 1052 | 1052 | /** |
| 1053 | 1053 | * Combine the parts as a new WHERE clause. |
| 1054 | 1054 | */ |
| 1055 | - $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) ); |
|
| 1055 | + $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) ); |
|
| 1056 | 1056 | $query->where( $where ); |
| 1057 | 1057 | } |
| 1058 | 1058 | |
@@ -1075,7 +1075,7 @@ discard block |
||
| 1075 | 1075 | $field_id = str_replace( array( 'filter_', 'input_' ), '', $key ); |
| 1076 | 1076 | |
| 1077 | 1077 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
| 1078 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
| 1078 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
| 1079 | 1079 | $field_id = str_replace( '_', '.', $field_id ); |
| 1080 | 1080 | } |
| 1081 | 1081 | |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | // form is in searchable fields |
| 1133 | 1133 | $found = false; |
| 1134 | 1134 | foreach ( $searchable_fields as $field ) { |
| 1135 | - if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) { |
|
| 1135 | + if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) { |
|
| 1136 | 1136 | $found = true; |
| 1137 | 1137 | break; |
| 1138 | 1138 | } |
@@ -1172,7 +1172,7 @@ discard block |
||
| 1172 | 1172 | |
| 1173 | 1173 | case 'select': |
| 1174 | 1174 | case 'radio': |
| 1175 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1175 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1176 | 1176 | break; |
| 1177 | 1177 | |
| 1178 | 1178 | case 'post_category': |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | |
| 1187 | 1187 | foreach ( $value as $val ) { |
| 1188 | 1188 | $cat = get_term( $val, 'category' ); |
| 1189 | - $filter[] = array( |
|
| 1189 | + $filter[ ] = array( |
|
| 1190 | 1190 | 'key' => $field_id, |
| 1191 | 1191 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
| 1192 | 1192 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1205,7 +1205,7 @@ discard block |
||
| 1205 | 1205 | $filter = array(); |
| 1206 | 1206 | |
| 1207 | 1207 | foreach ( $value as $val ) { |
| 1208 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
| 1208 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | 1211 | break; |
@@ -1214,9 +1214,9 @@ discard block |
||
| 1214 | 1214 | // convert checkbox on/off into the correct search filter |
| 1215 | 1215 | if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
| 1216 | 1216 | foreach ( $form_field->inputs as $k => $input ) { |
| 1217 | - if ( $input['id'] == $field_id ) { |
|
| 1218 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
| 1219 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1217 | + if ( $input[ 'id' ] == $field_id ) { |
|
| 1218 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
| 1219 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1220 | 1220 | break; |
| 1221 | 1221 | } |
| 1222 | 1222 | } |
@@ -1226,7 +1226,7 @@ discard block |
||
| 1226 | 1226 | $filter = array(); |
| 1227 | 1227 | |
| 1228 | 1228 | foreach ( $value as $val ) { |
| 1229 | - $filter[] = array( |
|
| 1229 | + $filter[ ] = array( |
|
| 1230 | 1230 | 'key' => $field_id, |
| 1231 | 1231 | 'value' => $val, |
| 1232 | 1232 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1247,9 +1247,9 @@ discard block |
||
| 1247 | 1247 | foreach ( $words as $word ) { |
| 1248 | 1248 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
| 1249 | 1249 | // Keep the same key for each filter |
| 1250 | - $filter['value'] = $word; |
|
| 1250 | + $filter[ 'value' ] = $word; |
|
| 1251 | 1251 | // Add a search for the value |
| 1252 | - $filters[] = $filter; |
|
| 1252 | + $filters[ ] = $filter; |
|
| 1253 | 1253 | } |
| 1254 | 1254 | } |
| 1255 | 1255 | |
@@ -1263,19 +1263,19 @@ discard block |
||
| 1263 | 1263 | |
| 1264 | 1264 | foreach ( $searchable_fields as $searchable_field ) { |
| 1265 | 1265 | |
| 1266 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
| 1266 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
| 1267 | 1267 | continue; |
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | 1270 | // Only exact-match dropdowns, not text search |
| 1271 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
| 1271 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
| 1272 | 1272 | continue; |
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | 1275 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
| 1276 | 1276 | |
| 1277 | 1277 | if ( 4 === $input_id ) { |
| 1278 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1278 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1279 | 1279 | }; |
| 1280 | 1280 | } |
| 1281 | 1281 | } |
@@ -1303,12 +1303,12 @@ discard block |
||
| 1303 | 1303 | * @since 1.16.3 |
| 1304 | 1304 | * Safeguard until GF implements '<=' operator |
| 1305 | 1305 | */ |
| 1306 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 1306 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 1307 | 1307 | $operator = '<'; |
| 1308 | 1308 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
| 1309 | 1309 | } |
| 1310 | 1310 | |
| 1311 | - $filter[] = array( |
|
| 1311 | + $filter[ ] = array( |
|
| 1312 | 1312 | 'key' => $field_id, |
| 1313 | 1313 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
| 1314 | 1314 | 'operator' => $this->get_operator( $get, $key, array( $operator ), $operator ), |
@@ -1316,12 +1316,12 @@ discard block |
||
| 1316 | 1316 | } |
| 1317 | 1317 | } else { |
| 1318 | 1318 | $date = $value; |
| 1319 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
| 1320 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1319 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
| 1320 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1321 | 1321 | } |
| 1322 | 1322 | |
| 1323 | - if ('payment_date' === $key) { |
|
| 1324 | - $filter['operator'] = 'contains'; |
|
| 1323 | + if ( 'payment_date' === $key ) { |
|
| 1324 | + $filter[ 'operator' ] = 'contains'; |
|
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | 1327 | break; |
@@ -1350,7 +1350,7 @@ discard block |
||
| 1350 | 1350 | 'ymd_dot' => 'Y.m.d', |
| 1351 | 1351 | ); |
| 1352 | 1352 | |
| 1353 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
| 1353 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
| 1354 | 1354 | $format = $datepicker[ $field->dateFormat ]; |
| 1355 | 1355 | } |
| 1356 | 1356 | |
@@ -1387,7 +1387,7 @@ discard block |
||
| 1387 | 1387 | public function add_template_path( $file_paths ) { |
| 1388 | 1388 | |
| 1389 | 1389 | // Index 100 is the default GravityView template path. |
| 1390 | - $file_paths[102] = self::$file . 'templates/'; |
|
| 1390 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
| 1391 | 1391 | |
| 1392 | 1392 | return $file_paths; |
| 1393 | 1393 | } |
@@ -1406,7 +1406,7 @@ discard block |
||
| 1406 | 1406 | $has_date = false; |
| 1407 | 1407 | |
| 1408 | 1408 | foreach ( $search_fields as $k => $field ) { |
| 1409 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 1409 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 1410 | 1410 | $has_date = true; |
| 1411 | 1411 | break; |
| 1412 | 1412 | } |
@@ -1435,7 +1435,7 @@ discard block |
||
| 1435 | 1435 | $view = \GV\View::by_id( $gravityview_view->view_id ); |
| 1436 | 1436 | |
| 1437 | 1437 | // get configured search fields |
| 1438 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
| 1438 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
| 1439 | 1439 | |
| 1440 | 1440 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
| 1441 | 1441 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1449,39 +1449,39 @@ discard block |
||
| 1449 | 1449 | |
| 1450 | 1450 | $updated_field = $this->get_search_filter_details( $updated_field, $context, $widget_args ); |
| 1451 | 1451 | |
| 1452 | - switch ( $field['field'] ) { |
|
| 1452 | + switch ( $field[ 'field' ] ) { |
|
| 1453 | 1453 | |
| 1454 | 1454 | case 'search_all': |
| 1455 | - $updated_field['key'] = 'search_all'; |
|
| 1456 | - $updated_field['input'] = 'search_all'; |
|
| 1457 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 1455 | + $updated_field[ 'key' ] = 'search_all'; |
|
| 1456 | + $updated_field[ 'input' ] = 'search_all'; |
|
| 1457 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 1458 | 1458 | break; |
| 1459 | 1459 | |
| 1460 | 1460 | case 'entry_date': |
| 1461 | - $updated_field['key'] = 'entry_date'; |
|
| 1462 | - $updated_field['input'] = 'entry_date'; |
|
| 1463 | - $updated_field['value'] = array( |
|
| 1461 | + $updated_field[ 'key' ] = 'entry_date'; |
|
| 1462 | + $updated_field[ 'input' ] = 'entry_date'; |
|
| 1463 | + $updated_field[ 'value' ] = array( |
|
| 1464 | 1464 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
| 1465 | 1465 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
| 1466 | 1466 | ); |
| 1467 | 1467 | break; |
| 1468 | 1468 | |
| 1469 | 1469 | case 'entry_id': |
| 1470 | - $updated_field['key'] = 'entry_id'; |
|
| 1471 | - $updated_field['input'] = 'entry_id'; |
|
| 1472 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 1470 | + $updated_field[ 'key' ] = 'entry_id'; |
|
| 1471 | + $updated_field[ 'input' ] = 'entry_id'; |
|
| 1472 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 1473 | 1473 | break; |
| 1474 | 1474 | |
| 1475 | 1475 | case 'created_by': |
| 1476 | - $updated_field['key'] = 'created_by'; |
|
| 1477 | - $updated_field['name'] = 'gv_by'; |
|
| 1478 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 1476 | + $updated_field[ 'key' ] = 'created_by'; |
|
| 1477 | + $updated_field[ 'name' ] = 'gv_by'; |
|
| 1478 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 1479 | 1479 | break; |
| 1480 | 1480 | |
| 1481 | 1481 | case 'is_approved': |
| 1482 | - $updated_field['key'] = 'is_approved'; |
|
| 1483 | - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
| 1484 | - $updated_field['choices'] = self::get_is_approved_choices(); |
|
| 1482 | + $updated_field[ 'key' ] = 'is_approved'; |
|
| 1483 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
| 1484 | + $updated_field[ 'choices' ] = self::get_is_approved_choices(); |
|
| 1485 | 1485 | break; |
| 1486 | 1486 | } |
| 1487 | 1487 | |
@@ -1502,16 +1502,16 @@ discard block |
||
| 1502 | 1502 | |
| 1503 | 1503 | $gravityview_view->permalink_fields = $this->add_no_permalink_fields( array(), $this, $widget_args ); |
| 1504 | 1504 | |
| 1505 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
| 1505 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
| 1506 | 1506 | |
| 1507 | 1507 | /** @since 1.14 */ |
| 1508 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
| 1508 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
| 1509 | 1509 | |
| 1510 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 1510 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
| 1511 | 1511 | |
| 1512 | 1512 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
| 1513 | 1513 | |
| 1514 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
| 1514 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
| 1515 | 1515 | |
| 1516 | 1516 | if ( $this->has_date_field( $search_fields ) ) { |
| 1517 | 1517 | // enqueue datepicker stuff only if needed! |
@@ -1533,10 +1533,10 @@ discard block |
||
| 1533 | 1533 | public static function get_search_class( $custom_class = '' ) { |
| 1534 | 1534 | $gravityview_view = GravityView_View::getInstance(); |
| 1535 | 1535 | |
| 1536 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
| 1536 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
| 1537 | 1537 | |
| 1538 | - if ( ! empty( $custom_class ) ) { |
|
| 1539 | - $search_class .= ' '.$custom_class; |
|
| 1538 | + if ( ! empty( $custom_class ) ) { |
|
| 1539 | + $search_class .= ' ' . $custom_class; |
|
| 1540 | 1540 | } |
| 1541 | 1541 | |
| 1542 | 1542 | /** |
@@ -1587,9 +1587,9 @@ discard block |
||
| 1587 | 1587 | |
| 1588 | 1588 | if ( ! $label ) { |
| 1589 | 1589 | |
| 1590 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
| 1590 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
| 1591 | 1591 | |
| 1592 | - switch( $field['field'] ) { |
|
| 1592 | + switch ( $field[ 'field' ] ) { |
|
| 1593 | 1593 | case 'search_all': |
| 1594 | 1594 | $label = __( 'Search Entries:', 'gk-gravityview' ); |
| 1595 | 1595 | break; |
@@ -1601,10 +1601,10 @@ discard block |
||
| 1601 | 1601 | break; |
| 1602 | 1602 | default: |
| 1603 | 1603 | // If this is a field input, not a field |
| 1604 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
| 1604 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
| 1605 | 1605 | |
| 1606 | 1606 | // Get the label for the field in question, which returns an array |
| 1607 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
| 1607 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
| 1608 | 1608 | |
| 1609 | 1609 | // Get the item with the `label` key |
| 1610 | 1610 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1648,13 +1648,13 @@ discard block |
||
| 1648 | 1648 | $form = $gravityview_view->getForm(); |
| 1649 | 1649 | |
| 1650 | 1650 | // for advanced field ids (eg, first name / last name ) |
| 1651 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
| 1651 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
| 1652 | 1652 | |
| 1653 | 1653 | // get searched value from $_GET/$_POST (string or array) |
| 1654 | 1654 | $value = $this->rgget_or_rgpost( $name ); |
| 1655 | 1655 | |
| 1656 | 1656 | // get form field details |
| 1657 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
| 1657 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
| 1658 | 1658 | |
| 1659 | 1659 | $form_field_type = \GV\Utils::get( $form_field, 'type' ); |
| 1660 | 1660 | |
@@ -1668,19 +1668,19 @@ discard block |
||
| 1668 | 1668 | ); |
| 1669 | 1669 | |
| 1670 | 1670 | // collect choices |
| 1671 | - if ( 'post_category' === $form_field_type && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
| 1672 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
| 1673 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
| 1674 | - $filter['choices'] = $form_field['choices']; |
|
| 1671 | + if ( 'post_category' === $form_field_type && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
| 1672 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
| 1673 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
| 1674 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
| 1675 | 1675 | } |
| 1676 | 1676 | |
| 1677 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
| 1678 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
| 1677 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
| 1678 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
| 1679 | 1679 | } |
| 1680 | 1680 | |
| 1681 | - if ( 'created_by' === $field['field'] ) { |
|
| 1682 | - $filter['choices'] = self::get_created_by_choices( ( isset( $context->view ) ? $context->view : null ) ); |
|
| 1683 | - $filter['type'] = 'created_by'; |
|
| 1681 | + if ( 'created_by' === $field[ 'field' ] ) { |
|
| 1682 | + $filter[ 'choices' ] = self::get_created_by_choices( ( isset( $context->view ) ? $context->view : null ) ); |
|
| 1683 | + $filter[ 'type' ] = 'created_by'; |
|
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | 1686 | /** |
@@ -1716,11 +1716,11 @@ discard block |
||
| 1716 | 1716 | } |
| 1717 | 1717 | |
| 1718 | 1718 | foreach ( $search_fields as &$filter ) { |
| 1719 | - if ( empty( $filter['choices'] ) ) { |
|
| 1719 | + if ( empty( $filter[ 'choices' ] ) ) { |
|
| 1720 | 1720 | continue; |
| 1721 | 1721 | } |
| 1722 | 1722 | |
| 1723 | - $field = gravityview_get_field( $context->view->form->form, $filter['key'] ); // @todo Support multiple forms (joins) |
|
| 1723 | + $field = gravityview_get_field( $context->view->form->form, $filter[ 'key' ] ); // @todo Support multiple forms (joins) |
|
| 1724 | 1724 | |
| 1725 | 1725 | /** |
| 1726 | 1726 | * @filter `gravityview/search/sieve_choices` Only output used choices for this field. |
@@ -1731,7 +1731,7 @@ discard block |
||
| 1731 | 1731 | * @param \GV\Context The context. |
| 1732 | 1732 | */ |
| 1733 | 1733 | if ( apply_filters( 'gravityview/search/sieve_choices', $sieve_choices, $field, $context, $widget_args ) ) { |
| 1734 | - $filter['choices'] = $this->sieve_filter_choices( $filter, $context ); |
|
| 1734 | + $filter[ 'choices' ] = $this->sieve_filter_choices( $filter, $context ); |
|
| 1735 | 1735 | } |
| 1736 | 1736 | } |
| 1737 | 1737 | |
@@ -1750,18 +1750,18 @@ discard block |
||
| 1750 | 1750 | * @return array The filter choices. |
| 1751 | 1751 | */ |
| 1752 | 1752 | private function sieve_filter_choices( $filter, $context ) { |
| 1753 | - if ( empty( $filter['key'] ) || empty( $filter['choices'] ) ) { |
|
| 1753 | + if ( empty( $filter[ 'key' ] ) || empty( $filter[ 'choices' ] ) ) { |
|
| 1754 | 1754 | return $filter; // @todo Populate plugins might give us empty choices |
| 1755 | 1755 | } |
| 1756 | 1756 | |
| 1757 | 1757 | // Allow only created_by and field-ids to be sieved. |
| 1758 | - if ( 'created_by' !== $filter['key'] && ! is_numeric( $filter['key'] ) ) { |
|
| 1758 | + if ( 'created_by' !== $filter[ 'key' ] && ! is_numeric( $filter[ 'key' ] ) ) { |
|
| 1759 | 1759 | return $filter; |
| 1760 | 1760 | } |
| 1761 | 1761 | |
| 1762 | 1762 | $form_id = $context->view->form->ID; // @todo Support multiple forms (joins) |
| 1763 | 1763 | |
| 1764 | - $cache = new GravityView_Cache( $form_id, [ 'sieve', $filter['key'], $context->view->ID ] ); |
|
| 1764 | + $cache = new GravityView_Cache( $form_id, [ 'sieve', $filter[ 'key' ], $context->view->ID ] ); |
|
| 1765 | 1765 | |
| 1766 | 1766 | $filter_choices = $cache->get(); |
| 1767 | 1767 | |
@@ -1774,13 +1774,13 @@ discard block |
||
| 1774 | 1774 | $entry_table_name = GFFormsModel::get_entry_table_name(); |
| 1775 | 1775 | $entry_meta_table_name = GFFormsModel::get_entry_meta_table_name(); |
| 1776 | 1776 | |
| 1777 | - $key_like = $wpdb->esc_like( $filter['key'] ) . '.%'; |
|
| 1777 | + $key_like = $wpdb->esc_like( $filter[ 'key' ] ) . '.%'; |
|
| 1778 | 1778 | |
| 1779 | 1779 | switch ( \GV\Utils::get( $filter, 'type' ) ) { |
| 1780 | 1780 | case 'post_category': |
| 1781 | 1781 | $choices = $wpdb->get_col( $wpdb->prepare( |
| 1782 | 1782 | "SELECT DISTINCT SUBSTRING_INDEX( `meta_value`, ':', 1) FROM $entry_meta_table_name WHERE ( `meta_key` LIKE %s OR `meta_key` = %d) AND `form_id` = %d", |
| 1783 | - $key_like, $filter['key'], $form_id |
|
| 1783 | + $key_like, $filter[ 'key' ], $form_id |
|
| 1784 | 1784 | ) ); |
| 1785 | 1785 | break; |
| 1786 | 1786 | case 'created_by': |
@@ -1792,12 +1792,12 @@ discard block |
||
| 1792 | 1792 | default: |
| 1793 | 1793 | $sql = $wpdb->prepare( |
| 1794 | 1794 | "SELECT DISTINCT `meta_value` FROM $entry_meta_table_name WHERE ( `meta_key` LIKE %s OR `meta_key` = %s ) AND `form_id` = %d", |
| 1795 | - $key_like, $filter['key'], $form_id |
|
| 1795 | + $key_like, $filter[ 'key' ], $form_id |
|
| 1796 | 1796 | ); |
| 1797 | 1797 | |
| 1798 | 1798 | $choices = $wpdb->get_col( $sql ); |
| 1799 | 1799 | |
| 1800 | - $field = gravityview_get_field( $context->view->form->form, $filter['key'] ); |
|
| 1800 | + $field = gravityview_get_field( $context->view->form->form, $filter[ 'key' ] ); |
|
| 1801 | 1801 | |
| 1802 | 1802 | if ( $field && 'json' === $field->storageType ) { |
| 1803 | 1803 | $choices = array_map( 'json_decode', $choices ); |
@@ -1806,7 +1806,7 @@ discard block |
||
| 1806 | 1806 | if ( is_array( $choice ) ) { |
| 1807 | 1807 | $_choices_array = array_merge( $_choices_array, $choice ); |
| 1808 | 1808 | } else { |
| 1809 | - $_choices_array [] = $choice; |
|
| 1809 | + $_choices_array [ ] = $choice; |
|
| 1810 | 1810 | } |
| 1811 | 1811 | } |
| 1812 | 1812 | $choices = array_unique( $_choices_array ); |
@@ -1816,9 +1816,9 @@ discard block |
||
| 1816 | 1816 | } |
| 1817 | 1817 | |
| 1818 | 1818 | $filter_choices = array(); |
| 1819 | - foreach ( $filter['choices'] as $choice ) { |
|
| 1820 | - if ( in_array( $choice['text'], $choices, true ) || in_array( $choice['value'], $choices, true ) ) { |
|
| 1821 | - $filter_choices[] = $choice; |
|
| 1819 | + foreach ( $filter[ 'choices' ] as $choice ) { |
|
| 1820 | + if ( in_array( $choice[ 'text' ], $choices, true ) || in_array( $choice[ 'value' ], $choices, true ) ) { |
|
| 1821 | + $filter_choices[ ] = $choice; |
|
| 1822 | 1822 | } |
| 1823 | 1823 | } |
| 1824 | 1824 | |
@@ -1855,7 +1855,7 @@ discard block |
||
| 1855 | 1855 | * @param \GV\View|null $view The view. |
| 1856 | 1856 | */ |
| 1857 | 1857 | $text = apply_filters( 'gravityview/search/created_by/text', $user->display_name, $user, $view ); |
| 1858 | - $choices[] = array( |
|
| 1858 | + $choices[ ] = array( |
|
| 1859 | 1859 | 'value' => $user->ID, |
| 1860 | 1860 | 'text' => $text, |
| 1861 | 1861 | ); |
@@ -1875,9 +1875,9 @@ discard block |
||
| 1875 | 1875 | |
| 1876 | 1876 | $choices = array(); |
| 1877 | 1877 | foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { |
| 1878 | - $choices[] = array( |
|
| 1879 | - 'value' => $status['value'], |
|
| 1880 | - 'text' => $status['label'], |
|
| 1878 | + $choices[ ] = array( |
|
| 1879 | + 'value' => $status[ 'value' ], |
|
| 1880 | + 'text' => $status[ 'label' ], |
|
| 1881 | 1881 | ); |
| 1882 | 1882 | } |
| 1883 | 1883 | |
@@ -1931,7 +1931,7 @@ discard block |
||
| 1931 | 1931 | */ |
| 1932 | 1932 | public function add_datepicker_js_dependency( $js_dependencies ) { |
| 1933 | 1933 | |
| 1934 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
| 1934 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
| 1935 | 1935 | |
| 1936 | 1936 | return $js_dependencies; |
| 1937 | 1937 | } |
@@ -1975,7 +1975,7 @@ discard block |
||
| 1975 | 1975 | 'isRTL' => is_rtl(), |
| 1976 | 1976 | ), $view_data ); |
| 1977 | 1977 | |
| 1978 | - $localizations['datepicker'] = $datepicker_settings; |
|
| 1978 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
| 1979 | 1979 | |
| 1980 | 1980 | return $localizations; |
| 1981 | 1981 | |
@@ -2002,7 +2002,7 @@ discard block |
||
| 2002 | 2002 | * @return void |
| 2003 | 2003 | */ |
| 2004 | 2004 | private function maybe_enqueue_flexibility() { |
| 2005 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 2005 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
| 2006 | 2006 | wp_enqueue_script( 'gv-flexibility' ); |
| 2007 | 2007 | } |
| 2008 | 2008 | } |
@@ -2024,7 +2024,7 @@ discard block |
||
| 2024 | 2024 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
| 2025 | 2025 | |
| 2026 | 2026 | $scheme = is_ssl() ? 'https://' : 'http://'; |
| 2027 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 2027 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 2028 | 2028 | |
| 2029 | 2029 | /** |
| 2030 | 2030 | * @filter `gravityview_search_datepicker_class` |
@@ -2103,7 +2103,7 @@ discard block |
||
| 2103 | 2103 | public function add_preview_inputs() { |
| 2104 | 2104 | global $wp; |
| 2105 | 2105 | |
| 2106 | - if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) { |
|
| 2106 | + if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) { |
|
| 2107 | 2107 | return; |
| 2108 | 2108 | } |
| 2109 | 2109 | |
@@ -2161,7 +2161,7 @@ discard block |
||
| 2161 | 2161 | */ |
| 2162 | 2162 | class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition { |
| 2163 | 2163 | public function __construct( $filter, $view ) { |
| 2164 | - $this->value = $filter['value']; |
|
| 2164 | + $this->value = $filter[ 'value' ]; |
|
| 2165 | 2165 | $this->view = $view; |
| 2166 | 2166 | } |
| 2167 | 2167 | |
@@ -2193,11 +2193,11 @@ discard block |
||
| 2193 | 2193 | $conditions = array(); |
| 2194 | 2194 | |
| 2195 | 2195 | foreach ( $user_fields as $user_field ) { |
| 2196 | - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
| 2196 | + $conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
| 2197 | 2197 | } |
| 2198 | 2198 | |
| 2199 | 2199 | foreach ( $user_meta_fields as $meta_field ) { |
| 2200 | - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
| 2200 | + $conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
| 2201 | 2201 | } |
| 2202 | 2202 | |
| 2203 | 2203 | $conditions = '(' . implode( ' OR ', $conditions ) . ')'; |