@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | 'search_clear' => array( |
| 56 | 56 | 'type' => 'checkbox', |
| 57 | 57 | 'label' => __( 'Show Clear button', 'gravityview' ), |
| 58 | - 'desc' => __( 'When a search is performed, display a button that removes all search values.', 'gravityview'), |
|
| 58 | + 'desc' => __( 'When a search is performed, display a button that removes all search values.', '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', 'gravityview' ), |
| 71 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
| 71 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
| 72 | 72 | 'value' => 'any', |
| 73 | 73 | 'class' => 'hide-if-js', |
| 74 | 74 | 'options' => array( |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
| 89 | 89 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
| 90 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
| 90 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
| 91 | 91 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
| 92 | 92 | |
| 93 | 93 | // ajax - get the searchable fields |
@@ -123,19 +123,19 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function add_reserved_args( $args ) { |
| 125 | 125 | |
| 126 | - $args[] = 'gv_search'; |
|
| 127 | - $args[] = 'gv_start'; |
|
| 128 | - $args[] = 'gv_end'; |
|
| 129 | - $args[] = 'gv_id'; |
|
| 130 | - $args[] = 'gv_by'; |
|
| 131 | - $args[] = 'mode'; |
|
| 126 | + $args[ ] = 'gv_search'; |
|
| 127 | + $args[ ] = 'gv_start'; |
|
| 128 | + $args[ ] = 'gv_end'; |
|
| 129 | + $args[ ] = 'gv_id'; |
|
| 130 | + $args[ ] = 'gv_by'; |
|
| 131 | + $args[ ] = 'mode'; |
|
| 132 | 132 | |
| 133 | - $get = (array) $_GET; |
|
| 133 | + $get = (array)$_GET; |
|
| 134 | 134 | |
| 135 | 135 | // If the fields being searched as reserved; not to be considered user-passed variables |
| 136 | 136 | foreach ( $get as $key => $value ) { |
| 137 | 137 | if ( $key !== $this->convert_request_key_to_filter_key( $key ) ) { |
| 138 | - $args[] = $key; |
|
| 138 | + $args[ ] = $key; |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 260 | 260 | $script_source = empty( $script_min ) ? '/source' : ''; |
| 261 | 261 | |
| 262 | - 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 ); |
|
| 262 | + 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 ); |
|
| 263 | 263 | |
| 264 | 264 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
| 265 | 265 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
| 282 | 282 | */ |
| 283 | 283 | public function register_no_conflict( $allowed ) { |
| 284 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
| 284 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
| 285 | 285 | return $allowed; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -293,24 +293,24 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | public static function get_searchable_fields() { |
| 295 | 295 | |
| 296 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 296 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 297 | 297 | exit( '0' ); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | $form = ''; |
| 301 | 301 | |
| 302 | 302 | // Fetch the form for the current View |
| 303 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
| 303 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
| 304 | 304 | |
| 305 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
| 305 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
| 306 | 306 | |
| 307 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
| 307 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
| 308 | 308 | |
| 309 | - $form = (int) $_POST['formid']; |
|
| 309 | + $form = (int)$_POST[ 'formid' ]; |
|
| 310 | 310 | |
| 311 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 311 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 312 | 312 | |
| 313 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 313 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 314 | 314 | |
| 315 | 315 | } |
| 316 | 316 | |
@@ -360,14 +360,14 @@ discard block |
||
| 360 | 360 | ); |
| 361 | 361 | |
| 362 | 362 | if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { |
| 363 | - $custom_fields['is_approved'] = array( |
|
| 363 | + $custom_fields[ 'is_approved' ] = array( |
|
| 364 | 364 | 'text' => esc_html__( 'Approval Status', 'gravityview' ), |
| 365 | 365 | 'type' => 'multi', |
| 366 | 366 | ); |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 370 | - $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'] ); |
|
| 369 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 370 | + $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' ] ); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | // Get fields with sub-inputs and no parent |
@@ -389,13 +389,13 @@ discard block |
||
| 389 | 389 | |
| 390 | 390 | foreach ( $fields as $id => $field ) { |
| 391 | 391 | |
| 392 | - if ( in_array( $field['type'], $blocklist_field_types ) ) { |
|
| 392 | + if ( in_array( $field[ 'type' ], $blocklist_field_types ) ) { |
|
| 393 | 393 | continue; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
| 396 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
| 397 | 397 | |
| 398 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
| 398 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
| 419 | 419 | |
| 420 | 420 | // @todo - This needs to be improved - many fields have . including products and addresses |
| 421 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 421 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 422 | 422 | $input_type = 'boolean'; // on/off checkbox |
| 423 | 423 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
| 424 | 424 | $input_type = 'multi'; //multiselect |
@@ -464,19 +464,19 @@ discard block |
||
| 464 | 464 | $post_id = 0; |
| 465 | 465 | |
| 466 | 466 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
| 467 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
| 468 | - $post_id = absint( $widget_args['post_id'] ); |
|
| 467 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
| 468 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
| 469 | 469 | } |
| 470 | 470 | // We're in the WordPress Widget context, and the base View ID should be used |
| 471 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
| 472 | - $post_id = absint( $widget_args['view_id'] ); |
|
| 471 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
| 472 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | $args = gravityview_get_permalink_query_args( $post_id ); |
| 476 | 476 | |
| 477 | 477 | // Add hidden fields to the search form |
| 478 | 478 | foreach ( $args as $key => $value ) { |
| 479 | - $search_fields[] = array( |
|
| 479 | + $search_fields[ ] = array( |
|
| 480 | 480 | 'name' => $key, |
| 481 | 481 | 'input' => 'hidden', |
| 482 | 482 | 'value' => $value, |
@@ -515,28 +515,28 @@ discard block |
||
| 515 | 515 | /** |
| 516 | 516 | * Include the sidebar Widgets. |
| 517 | 517 | */ |
| 518 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
| 518 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
| 519 | 519 | |
| 520 | 520 | foreach ( $widgets as $widget ) { |
| 521 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
| 522 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
| 521 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
| 522 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
| 523 | 523 | foreach ( $_fields as $field ) { |
| 524 | - if ( empty( $field['form_id'] ) ) { |
|
| 525 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
| 524 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
| 525 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
| 526 | 526 | } |
| 527 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
| 527 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
| 528 | 528 | } |
| 529 | 529 | } |
| 530 | 530 | } |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
| 534 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
| 534 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
| 535 | 535 | foreach ( $_fields as $field ) { |
| 536 | - if ( empty( $field['form_id'] ) ) { |
|
| 537 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
| 536 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
| 537 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
| 538 | 538 | } |
| 539 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
| 539 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
| 540 | 540 | } |
| 541 | 541 | } |
| 542 | 542 | } |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - if( 'post' === $this->search_method ) { |
|
| 585 | + if ( 'post' === $this->search_method ) { |
|
| 586 | 586 | $get = $_POST; |
| 587 | 587 | } else { |
| 588 | 588 | $get = $_GET; |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | $get = gv_map_deep( $get, 'rawurldecode' ); |
| 602 | 602 | |
| 603 | 603 | // Make sure array key is set up |
| 604 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
| 604 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
| 605 | 605 | |
| 606 | 606 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
| 607 | 607 | $searchable_field_objects = $this->get_view_searchable_fields( $view, true ); |
@@ -621,9 +621,9 @@ discard block |
||
| 621 | 621 | $trim_search_value = apply_filters( 'gravityview/search-trim-input', true ); |
| 622 | 622 | |
| 623 | 623 | // add free search |
| 624 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
| 624 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
| 625 | 625 | |
| 626 | - $search_all_value = $trim_search_value ? trim( $get['gv_search'] ) : $get['gv_search']; |
|
| 626 | + $search_all_value = $trim_search_value ? trim( $get[ 'gv_search' ] ) : $get[ 'gv_search' ]; |
|
| 627 | 627 | |
| 628 | 628 | if ( $split_words ) { |
| 629 | 629 | // Search for a piece |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | foreach ( $words as $word ) { |
| 642 | - $search_criteria['field_filters'][] = array( |
|
| 642 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 643 | 643 | 'key' => null, // The field ID to search |
| 644 | 644 | 'value' => $word, // The value to search |
| 645 | 645 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -652,14 +652,14 @@ discard block |
||
| 652 | 652 | /** |
| 653 | 653 | * Get and normalize the dates according to the input format. |
| 654 | 654 | */ |
| 655 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
| 656 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
| 655 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
| 656 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
| 657 | 657 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
| 658 | 658 | } |
| 659 | 659 | } |
| 660 | 660 | |
| 661 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
| 662 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
| 661 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
| 662 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
| 663 | 663 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
| 664 | 664 | } |
| 665 | 665 | } |
@@ -695,22 +695,22 @@ discard block |
||
| 695 | 695 | */ |
| 696 | 696 | if ( ! empty( $curr_start ) ) { |
| 697 | 697 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
| 698 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 698 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | if ( ! empty( $curr_end ) ) { |
| 702 | 702 | // Fast-forward 24 hour on the end time |
| 703 | 703 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
| 704 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 705 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
| 706 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
| 704 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 705 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
| 706 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
| 707 | 707 | } |
| 708 | 708 | } |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | // search for a specific entry ID |
| 712 | 712 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
| 713 | - $search_criteria['field_filters'][] = array( |
|
| 713 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 714 | 714 | 'key' => 'id', |
| 715 | 715 | 'value' => absint( $get[ 'gv_id' ] ), |
| 716 | 716 | 'operator' => $this->get_operator( $get, 'gv_id', array( '=' ), '=' ), |
@@ -719,15 +719,15 @@ discard block |
||
| 719 | 719 | |
| 720 | 720 | // search for a specific Created_by ID |
| 721 | 721 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
| 722 | - $search_criteria['field_filters'][] = array( |
|
| 722 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 723 | 723 | 'key' => 'created_by', |
| 724 | - 'value' => $get['gv_by'], |
|
| 724 | + 'value' => $get[ 'gv_by' ], |
|
| 725 | 725 | 'operator' => $this->get_operator( $get, 'gv_by', array( '=' ), '=' ), |
| 726 | 726 | ); |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | // Get search mode passed in URL |
| 730 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
| 730 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
| 731 | 731 | |
| 732 | 732 | // get the other search filters |
| 733 | 733 | foreach ( $get as $key => $value ) { |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | $value = is_array( $value ) ? array_map( 'trim', $value ) : trim( $value ); |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | - if ( gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
| 742 | + if ( gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
| 743 | 743 | if ( is_array( $value ) ) { |
| 744 | 744 | continue; |
| 745 | 745 | } |
@@ -757,21 +757,21 @@ discard block |
||
| 757 | 757 | continue; |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | - if ( ! isset( $filter['operator'] ) ) { |
|
| 761 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
| 760 | + if ( ! isset( $filter[ 'operator' ] ) ) { |
|
| 761 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | - if ( isset( $filter[0]['value'] ) ) { |
|
| 765 | - $filter[0]['value'] = $trim_search_value ? trim( $filter[0]['value'] ) : $filter[0]['value']; |
|
| 764 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
| 765 | + $filter[ 0 ][ 'value' ] = $trim_search_value ? trim( $filter[ 0 ][ 'value' ] ) : $filter[ 0 ][ 'value' ]; |
|
| 766 | 766 | |
| 767 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
| 767 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
| 768 | 768 | |
| 769 | 769 | // if date range type, set search mode to ALL |
| 770 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 770 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 771 | 771 | $mode = 'all'; |
| 772 | 772 | } |
| 773 | - } elseif( !empty( $filter ) ) { |
|
| 774 | - $search_criteria['field_filters'][] = $filter; |
|
| 773 | + } elseif ( ! empty( $filter ) ) { |
|
| 774 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
| 775 | 775 | } |
| 776 | 776 | } |
| 777 | 777 | |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | * @since 1.5.1 |
| 781 | 781 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
| 782 | 782 | */ |
| 783 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 783 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 784 | 784 | |
| 785 | 785 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
| 786 | 786 | |
@@ -814,19 +814,19 @@ discard block |
||
| 814 | 814 | |
| 815 | 815 | $query_class = $view->get_query_class(); |
| 816 | 816 | |
| 817 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
| 817 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
| 818 | 818 | return; |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | $widgets = $view->widgets->by_id( $this->widget_id ); |
| 822 | 822 | if ( $widgets->count() ) { |
| 823 | 823 | $widgets = $widgets->all(); |
| 824 | - $widget = $widgets[0]; |
|
| 824 | + $widget = $widgets[ 0 ]; |
|
| 825 | 825 | |
| 826 | 826 | $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ); |
| 827 | 827 | |
| 828 | - foreach ( (array) $search_fields as $search_field ) { |
|
| 829 | - if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) { |
|
| 828 | + foreach ( (array)$search_fields as $search_field ) { |
|
| 829 | + if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) { |
|
| 830 | 830 | $created_by_text_mode = true; |
| 831 | 831 | } |
| 832 | 832 | } |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | $extra_conditions = array(); |
| 836 | 836 | $mode = 'any'; |
| 837 | 837 | |
| 838 | - foreach ( $search_criteria['field_filters'] as $key => &$filter ) { |
|
| 838 | + foreach ( $search_criteria[ 'field_filters' ] as $key => &$filter ) { |
|
| 839 | 839 | if ( ! is_array( $filter ) ) { |
| 840 | 840 | if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) { |
| 841 | 841 | $mode = $filter; |
@@ -844,13 +844,13 @@ discard block |
||
| 844 | 844 | } |
| 845 | 845 | |
| 846 | 846 | // Construct a manual query for unapproved statuses |
| 847 | - if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) { |
|
| 848 | - $_tmp_query = new $query_class( $view->form->ID, array( |
|
| 847 | + if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) { |
|
| 848 | + $_tmp_query = new $query_class( $view->form->ID, array( |
|
| 849 | 849 | 'field_filters' => array( |
| 850 | 850 | array( |
| 851 | 851 | 'operator' => 'in', |
| 852 | 852 | 'key' => 'is_approved', |
| 853 | - 'value' => (array) $filter['value'], |
|
| 853 | + 'value' => (array)$filter[ 'value' ], |
|
| 854 | 854 | ), |
| 855 | 855 | array( |
| 856 | 856 | 'operator' => 'is', |
@@ -862,30 +862,30 @@ discard block |
||
| 862 | 862 | ) ); |
| 863 | 863 | $_tmp_query_parts = $_tmp_query->_introspect(); |
| 864 | 864 | |
| 865 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
| 865 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
| 866 | 866 | |
| 867 | 867 | $filter = false; |
| 868 | 868 | continue; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | // Construct manual query for text mode creator search |
| 872 | - if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { |
|
| 873 | - $extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
| 872 | + if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) { |
|
| 873 | + $extra_conditions[ ] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
| 874 | 874 | $filter = false; |
| 875 | 875 | continue; |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | // By default, we want searches to be wildcard for each field. |
| 879 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
| 879 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
| 880 | 880 | |
| 881 | 881 | // For multichoice, let's have an in (OR) search. |
| 882 | - if ( is_array( $filter['value'] ) ) { |
|
| 883 | - $filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
| 882 | + if ( is_array( $filter[ 'value' ] ) ) { |
|
| 883 | + $filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | // Default form with joins functionality |
| 887 | - if ( empty( $filter['form_id'] ) ) { |
|
| 888 | - $filter['form_id'] = $view->form ? $view->form->ID : 0; |
|
| 887 | + if ( empty( $filter[ 'form_id' ] ) ) { |
|
| 888 | + $filter[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | /** |
@@ -895,32 +895,32 @@ discard block |
||
| 895 | 895 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
| 896 | 896 | * @param \GV\View $view The View we're operating on. |
| 897 | 897 | */ |
| 898 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter, $view ); |
|
| 898 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter, $view ); |
|
| 899 | 899 | |
| 900 | - if ( 'is' !== $filter['operator'] && '' === $filter['value'] ) { |
|
| 901 | - unset( $search_criteria['field_filters'][ $key ] ); |
|
| 900 | + if ( 'is' !== $filter[ 'operator' ] && '' === $filter[ 'value' ] ) { |
|
| 901 | + unset( $search_criteria[ 'field_filters' ][ $key ] ); |
|
| 902 | 902 | } |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | - if ( ! empty( $search_criteria['start_date'] ) || ! empty( $search_criteria['end_date'] ) ) { |
|
| 905 | + if ( ! empty( $search_criteria[ 'start_date' ] ) || ! empty( $search_criteria[ 'end_date' ] ) ) { |
|
| 906 | 906 | $date_criteria = array(); |
| 907 | 907 | |
| 908 | - if ( isset( $search_criteria['start_date'] ) ) { |
|
| 909 | - $date_criteria['start_date'] = $search_criteria['start_date']; |
|
| 908 | + if ( isset( $search_criteria[ 'start_date' ] ) ) { |
|
| 909 | + $date_criteria[ 'start_date' ] = $search_criteria[ 'start_date' ]; |
|
| 910 | 910 | } |
| 911 | 911 | |
| 912 | - if ( isset( $search_criteria['end_date'] ) ) { |
|
| 913 | - $date_criteria['end_date'] = $search_criteria['end_date']; |
|
| 912 | + if ( isset( $search_criteria[ 'end_date' ] ) ) { |
|
| 913 | + $date_criteria[ 'end_date' ] = $search_criteria[ 'end_date' ]; |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | $_tmp_query = new $query_class( $view->form->ID, $date_criteria ); |
| 917 | 917 | $_tmp_query_parts = $_tmp_query->_introspect(); |
| 918 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
| 918 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | $search_conditions = array(); |
| 922 | 922 | |
| 923 | - if ( $filters = array_filter( $search_criteria['field_filters'] ) ) { |
|
| 923 | + if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) { |
|
| 924 | 924 | foreach ( $filters as &$filter ) { |
| 925 | 925 | if ( ! is_array( $filter ) ) { |
| 926 | 926 | continue; |
@@ -932,12 +932,12 @@ discard block |
||
| 932 | 932 | * code by reusing what's inside GF_Query already as they |
| 933 | 933 | * take care of many small things like forcing numeric, etc. |
| 934 | 934 | */ |
| 935 | - $_tmp_query = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
| 935 | + $_tmp_query = new $query_class( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
| 936 | 936 | $_tmp_query_parts = $_tmp_query->_introspect(); |
| 937 | - $search_condition = $_tmp_query_parts['where']; |
|
| 937 | + $search_condition = $_tmp_query_parts[ 'where' ]; |
|
| 938 | 938 | |
| 939 | - if ( empty( $filter['key'] ) && $search_condition->expressions ) { |
|
| 940 | - $search_conditions[] = $search_condition; |
|
| 939 | + if ( empty( $filter[ 'key' ] ) && $search_condition->expressions ) { |
|
| 940 | + $search_conditions[ ] = $search_condition; |
|
| 941 | 941 | } else { |
| 942 | 942 | $left = $search_condition->left; |
| 943 | 943 | $alias = $query->_alias( $left->field_id, $left->source, $left->is_entry_column() ? 't' : 'm' ); |
@@ -947,7 +947,7 @@ discard block |
||
| 947 | 947 | $on = $_join->join_on; |
| 948 | 948 | $join = $_join->join; |
| 949 | 949 | |
| 950 | - $search_conditions[] = GF_Query_Condition::_or( |
|
| 950 | + $search_conditions[ ] = GF_Query_Condition::_or( |
|
| 951 | 951 | // Join |
| 952 | 952 | new GF_Query_Condition( |
| 953 | 953 | new GF_Query_Column( GF_Query_Column::META, $join->ID, $query->_alias( GF_Query_Column::META, $join->ID, 'm' ) ), |
@@ -963,7 +963,7 @@ discard block |
||
| 963 | 963 | ); |
| 964 | 964 | } |
| 965 | 965 | } else { |
| 966 | - $search_conditions[] = new GF_Query_Condition( |
|
| 966 | + $search_conditions[ ] = new GF_Query_Condition( |
|
| 967 | 967 | new GF_Query_Column( $left->field_id, $left->source, $alias ), |
| 968 | 968 | $search_condition->operator, |
| 969 | 969 | $search_condition->right |
@@ -985,7 +985,7 @@ discard block |
||
| 985 | 985 | /** |
| 986 | 986 | * Combine the parts as a new WHERE clause. |
| 987 | 987 | */ |
| 988 | - $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) ); |
|
| 988 | + $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) ); |
|
| 989 | 989 | $query->where( $where ); |
| 990 | 990 | } |
| 991 | 991 | |
@@ -1008,7 +1008,7 @@ discard block |
||
| 1008 | 1008 | $field_id = str_replace( 'filter_', '', $key ); |
| 1009 | 1009 | |
| 1010 | 1010 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
| 1011 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
| 1011 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
| 1012 | 1012 | $field_id = str_replace( '_', '.', $field_id ); |
| 1013 | 1013 | } |
| 1014 | 1014 | |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | // form is in searchable fields |
| 1066 | 1066 | $found = false; |
| 1067 | 1067 | foreach ( $searchable_fields as $field ) { |
| 1068 | - if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) { |
|
| 1068 | + if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) { |
|
| 1069 | 1069 | $found = true; |
| 1070 | 1070 | break; |
| 1071 | 1071 | } |
@@ -1105,7 +1105,7 @@ discard block |
||
| 1105 | 1105 | |
| 1106 | 1106 | case 'select': |
| 1107 | 1107 | case 'radio': |
| 1108 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1108 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1109 | 1109 | break; |
| 1110 | 1110 | |
| 1111 | 1111 | case 'post_category': |
@@ -1119,7 +1119,7 @@ discard block |
||
| 1119 | 1119 | |
| 1120 | 1120 | foreach ( $value as $val ) { |
| 1121 | 1121 | $cat = get_term( $val, 'category' ); |
| 1122 | - $filter[] = array( |
|
| 1122 | + $filter[ ] = array( |
|
| 1123 | 1123 | 'key' => $field_id, |
| 1124 | 1124 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
| 1125 | 1125 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1138,7 +1138,7 @@ discard block |
||
| 1138 | 1138 | $filter = array(); |
| 1139 | 1139 | |
| 1140 | 1140 | foreach ( $value as $val ) { |
| 1141 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
| 1141 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | break; |
@@ -1147,9 +1147,9 @@ discard block |
||
| 1147 | 1147 | // convert checkbox on/off into the correct search filter |
| 1148 | 1148 | if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
| 1149 | 1149 | foreach ( $form_field->inputs as $k => $input ) { |
| 1150 | - if ( $input['id'] == $field_id ) { |
|
| 1151 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
| 1152 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1150 | + if ( $input[ 'id' ] == $field_id ) { |
|
| 1151 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
| 1152 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1153 | 1153 | break; |
| 1154 | 1154 | } |
| 1155 | 1155 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | $filter = array(); |
| 1160 | 1160 | |
| 1161 | 1161 | foreach ( $value as $val ) { |
| 1162 | - $filter[] = array( |
|
| 1162 | + $filter[ ] = array( |
|
| 1163 | 1163 | 'key' => $field_id, |
| 1164 | 1164 | 'value' => $val, |
| 1165 | 1165 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1180,9 +1180,9 @@ discard block |
||
| 1180 | 1180 | foreach ( $words as $word ) { |
| 1181 | 1181 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
| 1182 | 1182 | // Keep the same key for each filter |
| 1183 | - $filter['value'] = $word; |
|
| 1183 | + $filter[ 'value' ] = $word; |
|
| 1184 | 1184 | // Add a search for the value |
| 1185 | - $filters[] = $filter; |
|
| 1185 | + $filters[ ] = $filter; |
|
| 1186 | 1186 | } |
| 1187 | 1187 | } |
| 1188 | 1188 | |
@@ -1196,19 +1196,19 @@ discard block |
||
| 1196 | 1196 | |
| 1197 | 1197 | foreach ( $searchable_fields as $searchable_field ) { |
| 1198 | 1198 | |
| 1199 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
| 1199 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
| 1200 | 1200 | continue; |
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | 1203 | // Only exact-match dropdowns, not text search |
| 1204 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
| 1204 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
| 1205 | 1205 | continue; |
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | 1208 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
| 1209 | 1209 | |
| 1210 | 1210 | if ( 4 === $input_id ) { |
| 1211 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1211 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1212 | 1212 | }; |
| 1213 | 1213 | } |
| 1214 | 1214 | } |
@@ -1236,12 +1236,12 @@ discard block |
||
| 1236 | 1236 | * @since 1.16.3 |
| 1237 | 1237 | * Safeguard until GF implements '<=' operator |
| 1238 | 1238 | */ |
| 1239 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 1239 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 1240 | 1240 | $operator = '<'; |
| 1241 | 1241 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | - $filter[] = array( |
|
| 1244 | + $filter[ ] = array( |
|
| 1245 | 1245 | 'key' => $field_id, |
| 1246 | 1246 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
| 1247 | 1247 | 'operator' => $this->get_operator( $get, $key, array( $operator ), $operator ), |
@@ -1249,12 +1249,12 @@ discard block |
||
| 1249 | 1249 | } |
| 1250 | 1250 | } else { |
| 1251 | 1251 | $date = $value; |
| 1252 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
| 1253 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1252 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
| 1253 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | - if ('payment_date' === $key) { |
|
| 1257 | - $filter['operator'] = 'contains'; |
|
| 1256 | + if ( 'payment_date' === $key ) { |
|
| 1257 | + $filter[ 'operator' ] = 'contains'; |
|
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | 1260 | break; |
@@ -1283,7 +1283,7 @@ discard block |
||
| 1283 | 1283 | 'ymd_dot' => 'Y.m.d', |
| 1284 | 1284 | ); |
| 1285 | 1285 | |
| 1286 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
| 1286 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
| 1287 | 1287 | $format = $datepicker[ $field->dateFormat ]; |
| 1288 | 1288 | } |
| 1289 | 1289 | |
@@ -1320,7 +1320,7 @@ discard block |
||
| 1320 | 1320 | public function add_template_path( $file_paths ) { |
| 1321 | 1321 | |
| 1322 | 1322 | // Index 100 is the default GravityView template path. |
| 1323 | - $file_paths[102] = self::$file . 'templates/'; |
|
| 1323 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
| 1324 | 1324 | |
| 1325 | 1325 | return $file_paths; |
| 1326 | 1326 | } |
@@ -1339,7 +1339,7 @@ discard block |
||
| 1339 | 1339 | $has_date = false; |
| 1340 | 1340 | |
| 1341 | 1341 | foreach ( $search_fields as $k => $field ) { |
| 1342 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 1342 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 1343 | 1343 | $has_date = true; |
| 1344 | 1344 | break; |
| 1345 | 1345 | } |
@@ -1368,7 +1368,7 @@ discard block |
||
| 1368 | 1368 | $view = \GV\View::by_id( $gravityview_view->view_id ); |
| 1369 | 1369 | |
| 1370 | 1370 | // get configured search fields |
| 1371 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
| 1371 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
| 1372 | 1372 | |
| 1373 | 1373 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
| 1374 | 1374 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1382,39 +1382,39 @@ discard block |
||
| 1382 | 1382 | |
| 1383 | 1383 | $updated_field = $this->get_search_filter_details( $updated_field, $context ); |
| 1384 | 1384 | |
| 1385 | - switch ( $field['field'] ) { |
|
| 1385 | + switch ( $field[ 'field' ] ) { |
|
| 1386 | 1386 | |
| 1387 | 1387 | case 'search_all': |
| 1388 | - $updated_field['key'] = 'search_all'; |
|
| 1389 | - $updated_field['input'] = 'search_all'; |
|
| 1390 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 1388 | + $updated_field[ 'key' ] = 'search_all'; |
|
| 1389 | + $updated_field[ 'input' ] = 'search_all'; |
|
| 1390 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 1391 | 1391 | break; |
| 1392 | 1392 | |
| 1393 | 1393 | case 'entry_date': |
| 1394 | - $updated_field['key'] = 'entry_date'; |
|
| 1395 | - $updated_field['input'] = 'entry_date'; |
|
| 1396 | - $updated_field['value'] = array( |
|
| 1394 | + $updated_field[ 'key' ] = 'entry_date'; |
|
| 1395 | + $updated_field[ 'input' ] = 'entry_date'; |
|
| 1396 | + $updated_field[ 'value' ] = array( |
|
| 1397 | 1397 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
| 1398 | 1398 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
| 1399 | 1399 | ); |
| 1400 | 1400 | break; |
| 1401 | 1401 | |
| 1402 | 1402 | case 'entry_id': |
| 1403 | - $updated_field['key'] = 'entry_id'; |
|
| 1404 | - $updated_field['input'] = 'entry_id'; |
|
| 1405 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 1403 | + $updated_field[ 'key' ] = 'entry_id'; |
|
| 1404 | + $updated_field[ 'input' ] = 'entry_id'; |
|
| 1405 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 1406 | 1406 | break; |
| 1407 | 1407 | |
| 1408 | 1408 | case 'created_by': |
| 1409 | - $updated_field['key'] = 'created_by'; |
|
| 1410 | - $updated_field['name'] = 'gv_by'; |
|
| 1411 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 1409 | + $updated_field[ 'key' ] = 'created_by'; |
|
| 1410 | + $updated_field[ 'name' ] = 'gv_by'; |
|
| 1411 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 1412 | 1412 | break; |
| 1413 | 1413 | |
| 1414 | 1414 | case 'is_approved': |
| 1415 | - $updated_field['key'] = 'is_approved'; |
|
| 1416 | - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
| 1417 | - $updated_field['choices'] = self::get_is_approved_choices(); |
|
| 1415 | + $updated_field[ 'key' ] = 'is_approved'; |
|
| 1416 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
| 1417 | + $updated_field[ 'choices' ] = self::get_is_approved_choices(); |
|
| 1418 | 1418 | break; |
| 1419 | 1419 | } |
| 1420 | 1420 | |
@@ -1435,16 +1435,16 @@ discard block |
||
| 1435 | 1435 | |
| 1436 | 1436 | $gravityview_view->permalink_fields = $this->add_no_permalink_fields( array(), $this, $widget_args ); |
| 1437 | 1437 | |
| 1438 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
| 1438 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
| 1439 | 1439 | |
| 1440 | 1440 | /** @since 1.14 */ |
| 1441 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
| 1441 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
| 1442 | 1442 | |
| 1443 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 1443 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
| 1444 | 1444 | |
| 1445 | 1445 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
| 1446 | 1446 | |
| 1447 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
| 1447 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
| 1448 | 1448 | |
| 1449 | 1449 | if ( $this->has_date_field( $search_fields ) ) { |
| 1450 | 1450 | // enqueue datepicker stuff only if needed! |
@@ -1466,10 +1466,10 @@ discard block |
||
| 1466 | 1466 | public static function get_search_class( $custom_class = '' ) { |
| 1467 | 1467 | $gravityview_view = GravityView_View::getInstance(); |
| 1468 | 1468 | |
| 1469 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
| 1469 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
| 1470 | 1470 | |
| 1471 | - if ( ! empty( $custom_class ) ) { |
|
| 1472 | - $search_class .= ' '.$custom_class; |
|
| 1471 | + if ( ! empty( $custom_class ) ) { |
|
| 1472 | + $search_class .= ' ' . $custom_class; |
|
| 1473 | 1473 | } |
| 1474 | 1474 | |
| 1475 | 1475 | /** |
@@ -1520,9 +1520,9 @@ discard block |
||
| 1520 | 1520 | |
| 1521 | 1521 | if ( ! $label ) { |
| 1522 | 1522 | |
| 1523 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
| 1523 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
| 1524 | 1524 | |
| 1525 | - switch( $field['field'] ) { |
|
| 1525 | + switch ( $field[ 'field' ] ) { |
|
| 1526 | 1526 | case 'search_all': |
| 1527 | 1527 | $label = __( 'Search Entries:', 'gravityview' ); |
| 1528 | 1528 | break; |
@@ -1534,10 +1534,10 @@ discard block |
||
| 1534 | 1534 | break; |
| 1535 | 1535 | default: |
| 1536 | 1536 | // If this is a field input, not a field |
| 1537 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
| 1537 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
| 1538 | 1538 | |
| 1539 | 1539 | // Get the label for the field in question, which returns an array |
| 1540 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
| 1540 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
| 1541 | 1541 | |
| 1542 | 1542 | // Get the item with the `label` key |
| 1543 | 1543 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1578,13 +1578,13 @@ discard block |
||
| 1578 | 1578 | $form = $gravityview_view->getForm(); |
| 1579 | 1579 | |
| 1580 | 1580 | // for advanced field ids (eg, first name / last name ) |
| 1581 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
| 1581 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
| 1582 | 1582 | |
| 1583 | 1583 | // get searched value from $_GET/$_POST (string or array) |
| 1584 | 1584 | $value = $this->rgget_or_rgpost( $name ); |
| 1585 | 1585 | |
| 1586 | 1586 | // get form field details |
| 1587 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
| 1587 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
| 1588 | 1588 | |
| 1589 | 1589 | $form_field_type = \GV\Utils::get( $form_field, 'type' ); |
| 1590 | 1590 | |
@@ -1598,22 +1598,22 @@ discard block |
||
| 1598 | 1598 | ); |
| 1599 | 1599 | |
| 1600 | 1600 | // collect choices |
| 1601 | - if ( 'post_category' === $form_field_type && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
| 1602 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
| 1603 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
| 1604 | - $filter['choices'] = $form_field['choices']; |
|
| 1601 | + if ( 'post_category' === $form_field_type && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
| 1602 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
| 1603 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
| 1604 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
| 1605 | 1605 | } |
| 1606 | 1606 | |
| 1607 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
| 1608 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
| 1607 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
| 1608 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
| 1609 | 1609 | } |
| 1610 | 1610 | |
| 1611 | - if ( 'created_by' === $field['field'] ) { |
|
| 1612 | - $filter['choices'] = self::get_created_by_choices( $context->view ); |
|
| 1613 | - $filter['type'] = 'created_by'; |
|
| 1611 | + if ( 'created_by' === $field[ 'field' ] ) { |
|
| 1612 | + $filter[ 'choices' ] = self::get_created_by_choices( $context->view ); |
|
| 1613 | + $filter[ 'type' ] = 'created_by'; |
|
| 1614 | 1614 | } |
| 1615 | 1615 | |
| 1616 | - if ( ! empty( $filter['choices'] ) ) { |
|
| 1616 | + if ( ! empty( $filter[ 'choices' ] ) ) { |
|
| 1617 | 1617 | /** |
| 1618 | 1618 | * @filter `gravityview/search/sieve_choices` Only output used choices for this field. |
| 1619 | 1619 | * @param[in,out] bool Yes or no. |
@@ -1621,7 +1621,7 @@ discard block |
||
| 1621 | 1621 | * @param \GV\Context The context. |
| 1622 | 1622 | */ |
| 1623 | 1623 | if ( apply_filters( 'gravityview/search/sieve_choices', false, $field, $context ) ) { |
| 1624 | - $filter['choices'] = $this->sieve_filter_choices( $filter, $context ); |
|
| 1624 | + $filter[ 'choices' ] = $this->sieve_filter_choices( $filter, $context ); |
|
| 1625 | 1625 | } |
| 1626 | 1626 | } |
| 1627 | 1627 | |
@@ -1650,12 +1650,12 @@ discard block |
||
| 1650 | 1650 | * @return array The filter choices. |
| 1651 | 1651 | */ |
| 1652 | 1652 | private function sieve_filter_choices( $filter, $context ) { |
| 1653 | - if ( empty( $filter['key'] ) || empty( $filter['choices'] ) ) { |
|
| 1653 | + if ( empty( $filter[ 'key' ] ) || empty( $filter[ 'choices' ] ) ) { |
|
| 1654 | 1654 | return $filter; // @todo Populate plugins might give us empty choices |
| 1655 | 1655 | } |
| 1656 | 1656 | |
| 1657 | 1657 | // Allow only created_by and field-ids to be sieved. |
| 1658 | - if ( 'created_by' !== $filter['key'] && ! is_numeric( $filter['key'] ) ) { |
|
| 1658 | + if ( 'created_by' !== $filter[ 'key' ] && ! is_numeric( $filter[ 'key' ] ) ) { |
|
| 1659 | 1659 | return $filter; |
| 1660 | 1660 | } |
| 1661 | 1661 | |
@@ -1666,13 +1666,13 @@ discard block |
||
| 1666 | 1666 | $entry_table_name = GFFormsModel::get_entry_table_name(); |
| 1667 | 1667 | $entry_meta_table_name = GFFormsModel::get_entry_meta_table_name(); |
| 1668 | 1668 | |
| 1669 | - $key_like = $wpdb->esc_like( $filter['key'] ) . '.%'; |
|
| 1669 | + $key_like = $wpdb->esc_like( $filter[ 'key' ] ) . '.%'; |
|
| 1670 | 1670 | |
| 1671 | 1671 | switch ( \GV\Utils::get( $filter, 'type' ) ): |
| 1672 | 1672 | case 'post_category': |
| 1673 | 1673 | $choices = $wpdb->get_col( $wpdb->prepare( |
| 1674 | 1674 | "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", |
| 1675 | - $key_like, $filter['key'], $form_id |
|
| 1675 | + $key_like, $filter[ 'key' ], $form_id |
|
| 1676 | 1676 | ) ); |
| 1677 | 1677 | break; |
| 1678 | 1678 | case 'created_by': |
@@ -1684,17 +1684,17 @@ discard block |
||
| 1684 | 1684 | default: |
| 1685 | 1685 | $choices = $wpdb->get_col( $wpdb->prepare( |
| 1686 | 1686 | "SELECT DISTINCT meta_value FROM $entry_meta_table_name WHERE (meta_key LIKE %s OR meta_key = %d) AND form_id = %d", |
| 1687 | - $key_like, $filter['key'], $form_id |
|
| 1687 | + $key_like, $filter[ 'key' ], $form_id |
|
| 1688 | 1688 | ) ); |
| 1689 | 1689 | |
| 1690 | - if ( ( $field = gravityview_get_field( $form_id, $filter['key'] ) ) && 'json' === $field->storageType ) { |
|
| 1690 | + if ( ( $field = gravityview_get_field( $form_id, $filter[ 'key' ] ) ) && 'json' === $field->storageType ) { |
|
| 1691 | 1691 | $choices = array_map( 'json_decode', $choices ); |
| 1692 | 1692 | $_choices_array = array(); |
| 1693 | 1693 | foreach ( $choices as $choice ) { |
| 1694 | 1694 | if ( is_array( $choice ) ) { |
| 1695 | 1695 | $_choices_array = array_merge( $_choices_array, $choice ); |
| 1696 | 1696 | } else { |
| 1697 | - $_choices_array []= $choice; |
|
| 1697 | + $_choices_array [ ] = $choice; |
|
| 1698 | 1698 | } |
| 1699 | 1699 | } |
| 1700 | 1700 | $choices = array_unique( $_choices_array ); |
@@ -1704,9 +1704,9 @@ discard block |
||
| 1704 | 1704 | endswitch; |
| 1705 | 1705 | |
| 1706 | 1706 | $filter_choices = array(); |
| 1707 | - foreach ( $filter['choices'] as $choice ) { |
|
| 1708 | - if ( in_array( $choice['text'], $choices, true ) || in_array( $choice['value'], $choices, true ) ) { |
|
| 1709 | - $filter_choices[] = $choice; |
|
| 1707 | + foreach ( $filter[ 'choices' ] as $choice ) { |
|
| 1708 | + if ( in_array( $choice[ 'text' ], $choices, true ) || in_array( $choice[ 'value' ], $choices, true ) ) { |
|
| 1709 | + $filter_choices[ ] = $choice; |
|
| 1710 | 1710 | } |
| 1711 | 1711 | } |
| 1712 | 1712 | |
@@ -1741,7 +1741,7 @@ discard block |
||
| 1741 | 1741 | * @param \GV\View $view The view. |
| 1742 | 1742 | */ |
| 1743 | 1743 | $text = apply_filters( 'gravityview/search/created_by/text', $user->display_name, $user, $view ); |
| 1744 | - $choices[] = array( |
|
| 1744 | + $choices[ ] = array( |
|
| 1745 | 1745 | 'value' => $user->ID, |
| 1746 | 1746 | 'text' => $text, |
| 1747 | 1747 | ); |
@@ -1761,9 +1761,9 @@ discard block |
||
| 1761 | 1761 | |
| 1762 | 1762 | $choices = array(); |
| 1763 | 1763 | foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { |
| 1764 | - $choices[] = array( |
|
| 1765 | - 'value' => $status['value'], |
|
| 1766 | - 'text' => $status['label'], |
|
| 1764 | + $choices[ ] = array( |
|
| 1765 | + 'value' => $status[ 'value' ], |
|
| 1766 | + 'text' => $status[ 'label' ], |
|
| 1767 | 1767 | ); |
| 1768 | 1768 | } |
| 1769 | 1769 | |
@@ -1815,7 +1815,7 @@ discard block |
||
| 1815 | 1815 | */ |
| 1816 | 1816 | public function add_datepicker_js_dependency( $js_dependencies ) { |
| 1817 | 1817 | |
| 1818 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
| 1818 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
| 1819 | 1819 | |
| 1820 | 1820 | return $js_dependencies; |
| 1821 | 1821 | } |
@@ -1859,7 +1859,7 @@ discard block |
||
| 1859 | 1859 | 'isRTL' => is_rtl(), |
| 1860 | 1860 | ), $view_data ); |
| 1861 | 1861 | |
| 1862 | - $localizations['datepicker'] = $datepicker_settings; |
|
| 1862 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
| 1863 | 1863 | |
| 1864 | 1864 | return $localizations; |
| 1865 | 1865 | |
@@ -1886,7 +1886,7 @@ discard block |
||
| 1886 | 1886 | * @return void |
| 1887 | 1887 | */ |
| 1888 | 1888 | private function maybe_enqueue_flexibility() { |
| 1889 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 1889 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
| 1890 | 1890 | wp_enqueue_script( 'gv-flexibility' ); |
| 1891 | 1891 | } |
| 1892 | 1892 | } |
@@ -1908,7 +1908,7 @@ discard block |
||
| 1908 | 1908 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
| 1909 | 1909 | |
| 1910 | 1910 | $scheme = is_ssl() ? 'https://' : 'http://'; |
| 1911 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1911 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1912 | 1912 | |
| 1913 | 1913 | /** |
| 1914 | 1914 | * @filter `gravityview_search_datepicker_class` |
@@ -1987,7 +1987,7 @@ discard block |
||
| 1987 | 1987 | public function add_preview_inputs() { |
| 1988 | 1988 | global $wp; |
| 1989 | 1989 | |
| 1990 | - if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) { |
|
| 1990 | + if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) { |
|
| 1991 | 1991 | return; |
| 1992 | 1992 | } |
| 1993 | 1993 | |
@@ -2045,7 +2045,7 @@ discard block |
||
| 2045 | 2045 | */ |
| 2046 | 2046 | class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition { |
| 2047 | 2047 | public function __construct( $filter, $view ) { |
| 2048 | - $this->value = $filter['value']; |
|
| 2048 | + $this->value = $filter[ 'value' ]; |
|
| 2049 | 2049 | $this->view = $view; |
| 2050 | 2050 | } |
| 2051 | 2051 | |
@@ -2077,11 +2077,11 @@ discard block |
||
| 2077 | 2077 | $conditions = array(); |
| 2078 | 2078 | |
| 2079 | 2079 | foreach ( $user_fields as $user_field ) { |
| 2080 | - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
| 2080 | + $conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
| 2081 | 2081 | } |
| 2082 | 2082 | |
| 2083 | 2083 | foreach ( $user_meta_fields as $meta_field ) { |
| 2084 | - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
| 2084 | + $conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
| 2085 | 2085 | } |
| 2086 | 2086 | |
| 2087 | 2087 | $conditions = '(' . implode( ' OR ', $conditions ) . ')'; |