@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | 'type' => 'radio', |
| 65 | 65 | 'full_width' => true, |
| 66 | 66 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
| 67 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
| 67 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
| 68 | 68 | 'value' => 'any', |
| 69 | 69 | 'class' => 'hide-if-js', |
| 70 | 70 | 'options' => array( |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
| 88 | 88 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
| 89 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
| 89 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
| 90 | 90 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
| 91 | 91 | |
| 92 | 92 | // ajax - get the searchable fields |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 225 | 225 | $script_source = empty( $script_min ) ? '/source' : ''; |
| 226 | 226 | |
| 227 | - 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 ); |
|
| 227 | + 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 ); |
|
| 228 | 228 | |
| 229 | 229 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
| 230 | 230 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
| 247 | 247 | */ |
| 248 | 248 | public function register_no_conflict( $allowed ) { |
| 249 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
| 249 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
| 250 | 250 | return $allowed; |
| 251 | 251 | } |
| 252 | 252 | |
@@ -259,24 +259,24 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | public static function get_searchable_fields() { |
| 261 | 261 | |
| 262 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 262 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
| 263 | 263 | exit( '0' ); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | $form = ''; |
| 267 | 267 | |
| 268 | 268 | // Fetch the form for the current View |
| 269 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
| 269 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
| 270 | 270 | |
| 271 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
| 271 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
| 272 | 272 | |
| 273 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
| 273 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
| 274 | 274 | |
| 275 | - $form = (int) $_POST['formid']; |
|
| 275 | + $form = (int)$_POST[ 'formid' ]; |
|
| 276 | 276 | |
| 277 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 277 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
| 278 | 278 | |
| 279 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 279 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
| 280 | 280 | |
| 281 | 281 | } |
| 282 | 282 | |
@@ -325,8 +325,8 @@ discard block |
||
| 325 | 325 | ), |
| 326 | 326 | ); |
| 327 | 327 | |
| 328 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 329 | - $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'] ); |
|
| 328 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
| 329 | + $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' ] ); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | // Get fields with sub-inputs and no parent |
@@ -348,13 +348,13 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | foreach ( $fields as $id => $field ) { |
| 350 | 350 | |
| 351 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 351 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
| 352 | 352 | continue; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
| 355 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
| 356 | 356 | |
| 357 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
| 357 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
| 378 | 378 | |
| 379 | 379 | // @todo - This needs to be improved - many fields have . including products and addresses |
| 380 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 380 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
| 381 | 381 | $input_type = 'boolean'; // on/off checkbox |
| 382 | 382 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
| 383 | 383 | $input_type = 'multi'; //multiselect |
@@ -421,19 +421,19 @@ discard block |
||
| 421 | 421 | $post_id = 0; |
| 422 | 422 | |
| 423 | 423 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
| 424 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
| 425 | - $post_id = absint( $widget_args['post_id'] ); |
|
| 424 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
| 425 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
| 426 | 426 | } |
| 427 | 427 | // We're in the WordPress Widget context, and the base View ID should be used |
| 428 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
| 429 | - $post_id = absint( $widget_args['view_id'] ); |
|
| 428 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
| 429 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | $args = gravityview_get_permalink_query_args( $post_id ); |
| 433 | 433 | |
| 434 | 434 | // Add hidden fields to the search form |
| 435 | 435 | foreach ( $args as $key => $value ) { |
| 436 | - $search_fields[] = array( |
|
| 436 | + $search_fields[ ] = array( |
|
| 437 | 437 | 'name' => $key, |
| 438 | 438 | 'input' => 'hidden', |
| 439 | 439 | 'value' => $value, |
@@ -472,22 +472,22 @@ discard block |
||
| 472 | 472 | /** |
| 473 | 473 | * Include the sidebar Widgets. |
| 474 | 474 | */ |
| 475 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
| 475 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
| 476 | 476 | |
| 477 | 477 | foreach ( $widgets as $widget ) { |
| 478 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
| 479 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
| 478 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
| 479 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
| 480 | 480 | foreach ( $_fields as $field ) { |
| 481 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
| 481 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
| 488 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
| 488 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
| 489 | 489 | foreach ( $_fields as $field ) { |
| 490 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
| 490 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
| 491 | 491 | } |
| 492 | 492 | } |
| 493 | 493 | } |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | */ |
| 505 | 505 | public function filter_entries( $search_criteria, $form_id = null, $args = array() ) { |
| 506 | 506 | |
| 507 | - if( 'post' === $this->search_method ) { |
|
| 507 | + if ( 'post' === $this->search_method ) { |
|
| 508 | 508 | $get = $_POST; |
| 509 | 509 | } else { |
| 510 | 510 | $get = $_GET; |
@@ -523,14 +523,14 @@ discard block |
||
| 523 | 523 | $get = gv_map_deep( $get, 'rawurldecode' ); |
| 524 | 524 | |
| 525 | 525 | // Make sure array key is set up |
| 526 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
| 526 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
| 527 | 527 | |
| 528 | 528 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
| 529 | 529 | |
| 530 | 530 | // add free search |
| 531 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
| 531 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
| 532 | 532 | |
| 533 | - $search_all_value = trim( $get['gv_search'] ); |
|
| 533 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
| 534 | 534 | |
| 535 | 535 | /** |
| 536 | 536 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | foreach ( $words as $word ) { |
| 558 | - $search_criteria['field_filters'][] = array( |
|
| 558 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 559 | 559 | 'key' => null, // The field ID to search |
| 560 | 560 | 'value' => $word, // The value to search |
| 561 | 561 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -565,19 +565,19 @@ discard block |
||
| 565 | 565 | |
| 566 | 566 | // start date & end date |
| 567 | 567 | if ( in_array( 'entry_date', $searchable_fields ) ) { |
| 568 | - $curr_start = !empty( $get['gv_start'] ) ? $get['gv_start'] : ''; |
|
| 569 | - $curr_end = !empty( $get['gv_start'] ) ? $get['gv_end'] : ''; |
|
| 568 | + $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : ''; |
|
| 569 | + $curr_end = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_end' ] : ''; |
|
| 570 | 570 | |
| 571 | 571 | if ( $view ) { |
| 572 | 572 | /** |
| 573 | 573 | * Override start and end dates if View is limited to some already. |
| 574 | 574 | */ |
| 575 | - if ( $start_date =$view->settings->get( 'start_date' ) ) { |
|
| 575 | + if ( $start_date = $view->settings->get( 'start_date' ) ) { |
|
| 576 | 576 | if ( $start_timestamp = strtotime( $curr_start ) ) { |
| 577 | 577 | $curr_start = $start_timestamp < strtotime( $start_date ) ? $start_date : $curr_start; |
| 578 | 578 | } |
| 579 | 579 | } |
| 580 | - if ( $end_date =$view->settings->get( 'end_date' ) ) { |
|
| 580 | + if ( $end_date = $view->settings->get( 'end_date' ) ) { |
|
| 581 | 581 | if ( $end_timestamp = strtotime( $curr_end ) ) { |
| 582 | 582 | $curr_end = $end_timestamp > strtotime( $end_date ) ? $end_date : $curr_end; |
| 583 | 583 | } |
@@ -598,22 +598,22 @@ discard block |
||
| 598 | 598 | */ |
| 599 | 599 | if ( ! empty( $curr_start ) ) { |
| 600 | 600 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
| 601 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 601 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | if ( ! empty( $curr_end ) ) { |
| 605 | 605 | // Fast-forward 24 hour on the end time |
| 606 | 606 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
| 607 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 608 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
| 609 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
| 607 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
| 608 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
| 609 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
| 610 | 610 | } |
| 611 | 611 | } |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | // search for a specific entry ID |
| 615 | 615 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
| 616 | - $search_criteria['field_filters'][] = array( |
|
| 616 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 617 | 617 | 'key' => 'id', |
| 618 | 618 | 'value' => absint( $get[ 'gv_id' ] ), |
| 619 | 619 | 'operator' => '=', |
@@ -622,42 +622,42 @@ discard block |
||
| 622 | 622 | |
| 623 | 623 | // search for a specific Created_by ID |
| 624 | 624 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
| 625 | - $search_criteria['field_filters'][] = array( |
|
| 625 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
| 626 | 626 | 'key' => 'created_by', |
| 627 | - 'value' => absint( $get['gv_by'] ), |
|
| 627 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
| 628 | 628 | 'operator' => '=', |
| 629 | 629 | ); |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | |
| 633 | 633 | // Get search mode passed in URL |
| 634 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
| 634 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
| 635 | 635 | |
| 636 | 636 | // get the other search filters |
| 637 | 637 | foreach ( $get as $key => $value ) { |
| 638 | 638 | |
| 639 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
| 639 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
| 640 | 640 | continue; |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | $filter_key = $this->convert_request_key_to_filter_key( $key ); |
| 644 | 644 | |
| 645 | 645 | // could return simple filter or multiple filters |
| 646 | - if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key , $searchable_fields ) ) { |
|
| 646 | + if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key, $searchable_fields ) ) { |
|
| 647 | 647 | continue; |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | $filter = $this->prepare_field_filter( $filter_key, $value, $view ); |
| 651 | 651 | |
| 652 | - if ( isset( $filter[0]['value'] ) ) { |
|
| 653 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
| 652 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
| 653 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
| 654 | 654 | |
| 655 | 655 | // if date range type, set search mode to ALL |
| 656 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 656 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
| 657 | 657 | $mode = 'all'; |
| 658 | 658 | } |
| 659 | - } elseif( !empty( $filter ) ) { |
|
| 660 | - $search_criteria['field_filters'][] = $filter; |
|
| 659 | + } elseif ( ! empty( $filter ) ) { |
|
| 660 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | 663 | |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | * @since 1.5.1 |
| 667 | 667 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
| 668 | 668 | */ |
| 669 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 669 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
| 670 | 670 | |
| 671 | 671 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
| 672 | 672 | |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | $field_id = str_replace( 'filter_', '', $key ); |
| 695 | 695 | |
| 696 | 696 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
| 697 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
| 697 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
| 698 | 698 | $field_id = str_replace( '_', '.', $field_id ); |
| 699 | 699 | } |
| 700 | 700 | |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | |
| 730 | 730 | case 'select': |
| 731 | 731 | case 'radio': |
| 732 | - $filter['operator'] = 'is'; |
|
| 732 | + $filter[ 'operator' ] = 'is'; |
|
| 733 | 733 | break; |
| 734 | 734 | |
| 735 | 735 | case 'post_category': |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | |
| 744 | 744 | foreach ( $value as $val ) { |
| 745 | 745 | $cat = get_term( $val, 'category' ); |
| 746 | - $filter[] = array( |
|
| 746 | + $filter[ ] = array( |
|
| 747 | 747 | 'key' => $filter_key, |
| 748 | 748 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
| 749 | 749 | 'operator' => 'is', |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | $filter = array(); |
| 763 | 763 | |
| 764 | 764 | foreach ( $value as $val ) { |
| 765 | - $filter[] = array( 'key' => $filter_key, 'value' => $val ); |
|
| 765 | + $filter[ ] = array( 'key' => $filter_key, 'value' => $val ); |
|
| 766 | 766 | } |
| 767 | 767 | |
| 768 | 768 | break; |
@@ -771,9 +771,9 @@ discard block |
||
| 771 | 771 | // convert checkbox on/off into the correct search filter |
| 772 | 772 | if ( false !== strpos( $filter_key, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
| 773 | 773 | foreach ( $form_field->inputs as $k => $input ) { |
| 774 | - if ( $input['id'] == $filter_key ) { |
|
| 775 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
| 776 | - $filter['operator'] = 'is'; |
|
| 774 | + if ( $input[ 'id' ] == $filter_key ) { |
|
| 775 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
| 776 | + $filter[ 'operator' ] = 'is'; |
|
| 777 | 777 | break; |
| 778 | 778 | } |
| 779 | 779 | } |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | $filter = array(); |
| 784 | 784 | |
| 785 | 785 | foreach ( $value as $val ) { |
| 786 | - $filter[] = array( |
|
| 786 | + $filter[ ] = array( |
|
| 787 | 787 | 'key' => $filter_key, |
| 788 | 788 | 'value' => $val, |
| 789 | 789 | 'operator' => 'is', |
@@ -804,9 +804,9 @@ discard block |
||
| 804 | 804 | foreach ( $words as $word ) { |
| 805 | 805 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
| 806 | 806 | // Keep the same key for each filter |
| 807 | - $filter['value'] = $word; |
|
| 807 | + $filter[ 'value' ] = $word; |
|
| 808 | 808 | // Add a search for the value |
| 809 | - $filters[] = $filter; |
|
| 809 | + $filters[ ] = $filter; |
|
| 810 | 810 | } |
| 811 | 811 | } |
| 812 | 812 | |
@@ -820,19 +820,19 @@ discard block |
||
| 820 | 820 | |
| 821 | 821 | foreach ( $searchable_fields as $searchable_field ) { |
| 822 | 822 | |
| 823 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
| 823 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
| 824 | 824 | continue; |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | // Only exact-match dropdowns, not text search |
| 828 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
| 828 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
| 829 | 829 | continue; |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
| 833 | 833 | |
| 834 | 834 | if ( 4 === $input_id ) { |
| 835 | - $filter['operator'] = 'is'; |
|
| 835 | + $filter[ 'operator' ] = 'is'; |
|
| 836 | 836 | }; |
| 837 | 837 | } |
| 838 | 838 | } |
@@ -857,19 +857,19 @@ discard block |
||
| 857 | 857 | * @since 1.16.3 |
| 858 | 858 | * Safeguard until GF implements '<=' operator |
| 859 | 859 | */ |
| 860 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 860 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
| 861 | 861 | $operator = '<'; |
| 862 | 862 | $date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) ); |
| 863 | 863 | } |
| 864 | 864 | |
| 865 | - $filter[] = array( |
|
| 865 | + $filter[ ] = array( |
|
| 866 | 866 | 'key' => $filter_key, |
| 867 | 867 | 'value' => self::get_formatted_date( $date, 'Y-m-d' ), |
| 868 | 868 | 'operator' => $operator, |
| 869 | 869 | ); |
| 870 | 870 | } |
| 871 | 871 | } else { |
| 872 | - $filter['value'] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 872 | + $filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' ); |
|
| 873 | 873 | } |
| 874 | 874 | |
| 875 | 875 | break; |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | 'ymd_dot' => 'Y.m.d', |
| 901 | 901 | ); |
| 902 | 902 | |
| 903 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
| 903 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
| 904 | 904 | $format = $datepicker[ $field->dateFormat ]; |
| 905 | 905 | } |
| 906 | 906 | |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | public function add_template_path( $file_paths ) { |
| 932 | 932 | |
| 933 | 933 | // Index 100 is the default GravityView template path. |
| 934 | - $file_paths[102] = self::$file . 'templates/'; |
|
| 934 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
| 935 | 935 | |
| 936 | 936 | return $file_paths; |
| 937 | 937 | } |
@@ -950,7 +950,7 @@ discard block |
||
| 950 | 950 | $has_date = false; |
| 951 | 951 | |
| 952 | 952 | foreach ( $search_fields as $k => $field ) { |
| 953 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 953 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
| 954 | 954 | $has_date = true; |
| 955 | 955 | break; |
| 956 | 956 | } |
@@ -977,7 +977,7 @@ discard block |
||
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | // get configured search fields |
| 980 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
| 980 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
| 981 | 981 | |
| 982 | 982 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
| 983 | 983 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -992,34 +992,34 @@ discard block |
||
| 992 | 992 | |
| 993 | 993 | $updated_field = $this->get_search_filter_details( $updated_field ); |
| 994 | 994 | |
| 995 | - switch ( $field['field'] ) { |
|
| 995 | + switch ( $field[ 'field' ] ) { |
|
| 996 | 996 | |
| 997 | 997 | case 'search_all': |
| 998 | - $updated_field['key'] = 'search_all'; |
|
| 999 | - $updated_field['input'] = 'search_all'; |
|
| 1000 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 998 | + $updated_field[ 'key' ] = 'search_all'; |
|
| 999 | + $updated_field[ 'input' ] = 'search_all'; |
|
| 1000 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
| 1001 | 1001 | break; |
| 1002 | 1002 | |
| 1003 | 1003 | case 'entry_date': |
| 1004 | - $updated_field['key'] = 'entry_date'; |
|
| 1005 | - $updated_field['input'] = 'entry_date'; |
|
| 1006 | - $updated_field['value'] = array( |
|
| 1004 | + $updated_field[ 'key' ] = 'entry_date'; |
|
| 1005 | + $updated_field[ 'input' ] = 'entry_date'; |
|
| 1006 | + $updated_field[ 'value' ] = array( |
|
| 1007 | 1007 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
| 1008 | 1008 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
| 1009 | 1009 | ); |
| 1010 | 1010 | break; |
| 1011 | 1011 | |
| 1012 | 1012 | case 'entry_id': |
| 1013 | - $updated_field['key'] = 'entry_id'; |
|
| 1014 | - $updated_field['input'] = 'entry_id'; |
|
| 1015 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 1013 | + $updated_field[ 'key' ] = 'entry_id'; |
|
| 1014 | + $updated_field[ 'input' ] = 'entry_id'; |
|
| 1015 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
| 1016 | 1016 | break; |
| 1017 | 1017 | |
| 1018 | 1018 | case 'created_by': |
| 1019 | - $updated_field['key'] = 'created_by'; |
|
| 1020 | - $updated_field['name'] = 'gv_by'; |
|
| 1021 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 1022 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
| 1019 | + $updated_field[ 'key' ] = 'created_by'; |
|
| 1020 | + $updated_field[ 'name' ] = 'gv_by'; |
|
| 1021 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
| 1022 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
| 1023 | 1023 | break; |
| 1024 | 1024 | } |
| 1025 | 1025 | |
@@ -1038,16 +1038,16 @@ discard block |
||
| 1038 | 1038 | */ |
| 1039 | 1039 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
| 1040 | 1040 | |
| 1041 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
| 1041 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
| 1042 | 1042 | |
| 1043 | 1043 | /** @since 1.14 */ |
| 1044 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
| 1044 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
| 1045 | 1045 | |
| 1046 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
| 1046 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
| 1047 | 1047 | |
| 1048 | 1048 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
| 1049 | 1049 | |
| 1050 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
| 1050 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
| 1051 | 1051 | |
| 1052 | 1052 | if ( $this->has_date_field( $search_fields ) ) { |
| 1053 | 1053 | // enqueue datepicker stuff only if needed! |
@@ -1069,10 +1069,10 @@ discard block |
||
| 1069 | 1069 | public static function get_search_class( $custom_class = '' ) { |
| 1070 | 1070 | $gravityview_view = GravityView_View::getInstance(); |
| 1071 | 1071 | |
| 1072 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
| 1072 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
| 1073 | 1073 | |
| 1074 | - if ( ! empty( $custom_class ) ) { |
|
| 1075 | - $search_class .= ' '.$custom_class; |
|
| 1074 | + if ( ! empty( $custom_class ) ) { |
|
| 1075 | + $search_class .= ' ' . $custom_class; |
|
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | /** |
@@ -1116,9 +1116,9 @@ discard block |
||
| 1116 | 1116 | |
| 1117 | 1117 | if ( ! $label ) { |
| 1118 | 1118 | |
| 1119 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
| 1119 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
| 1120 | 1120 | |
| 1121 | - switch( $field['field'] ) { |
|
| 1121 | + switch ( $field[ 'field' ] ) { |
|
| 1122 | 1122 | case 'search_all': |
| 1123 | 1123 | $label = __( 'Search Entries:', 'gravityview' ); |
| 1124 | 1124 | break; |
@@ -1130,10 +1130,10 @@ discard block |
||
| 1130 | 1130 | break; |
| 1131 | 1131 | default: |
| 1132 | 1132 | // If this is a field input, not a field |
| 1133 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
| 1133 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
| 1134 | 1134 | |
| 1135 | 1135 | // Get the label for the field in question, which returns an array |
| 1136 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
| 1136 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
| 1137 | 1137 | |
| 1138 | 1138 | // Get the item with the `label` key |
| 1139 | 1139 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1172,32 +1172,32 @@ discard block |
||
| 1172 | 1172 | $form = $gravityview_view->getForm(); |
| 1173 | 1173 | |
| 1174 | 1174 | // for advanced field ids (eg, first name / last name ) |
| 1175 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
| 1175 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
| 1176 | 1176 | |
| 1177 | 1177 | // get searched value from $_GET/$_POST (string or array) |
| 1178 | 1178 | $value = $this->rgget_or_rgpost( $name ); |
| 1179 | 1179 | |
| 1180 | 1180 | // get form field details |
| 1181 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
| 1181 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
| 1182 | 1182 | |
| 1183 | 1183 | $filter = array( |
| 1184 | - 'key' => $field['field'], |
|
| 1184 | + 'key' => $field[ 'field' ], |
|
| 1185 | 1185 | 'name' => $name, |
| 1186 | 1186 | 'label' => self::get_field_label( $field, $form_field ), |
| 1187 | - 'input' => $field['input'], |
|
| 1187 | + 'input' => $field[ 'input' ], |
|
| 1188 | 1188 | 'value' => $value, |
| 1189 | - 'type' => $form_field['type'], |
|
| 1189 | + 'type' => $form_field[ 'type' ], |
|
| 1190 | 1190 | ); |
| 1191 | 1191 | |
| 1192 | 1192 | // collect choices |
| 1193 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
| 1194 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
| 1195 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
| 1196 | - $filter['choices'] = $form_field['choices']; |
|
| 1193 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
| 1194 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
| 1195 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
| 1196 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
| 1200 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
| 1199 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
| 1200 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | 1203 | return $filter; |
@@ -1221,7 +1221,7 @@ discard block |
||
| 1221 | 1221 | |
| 1222 | 1222 | $choices = array(); |
| 1223 | 1223 | foreach ( $users as $user ) { |
| 1224 | - $choices[] = array( |
|
| 1224 | + $choices[ ] = array( |
|
| 1225 | 1225 | 'value' => $user->ID, |
| 1226 | 1226 | 'text' => $user->display_name, |
| 1227 | 1227 | ); |
@@ -1276,7 +1276,7 @@ discard block |
||
| 1276 | 1276 | */ |
| 1277 | 1277 | public function add_datepicker_js_dependency( $js_dependencies ) { |
| 1278 | 1278 | |
| 1279 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
| 1279 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
| 1280 | 1280 | |
| 1281 | 1281 | return $js_dependencies; |
| 1282 | 1282 | } |
@@ -1320,7 +1320,7 @@ discard block |
||
| 1320 | 1320 | 'isRTL' => is_rtl(), |
| 1321 | 1321 | ), $view_data ); |
| 1322 | 1322 | |
| 1323 | - $localizations['datepicker'] = $datepicker_settings; |
|
| 1323 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
| 1324 | 1324 | |
| 1325 | 1325 | return $localizations; |
| 1326 | 1326 | |
@@ -1347,7 +1347,7 @@ discard block |
||
| 1347 | 1347 | * @return void |
| 1348 | 1348 | */ |
| 1349 | 1349 | private function maybe_enqueue_flexibility() { |
| 1350 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 1350 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
| 1351 | 1351 | wp_enqueue_script( 'gv-flexibility' ); |
| 1352 | 1352 | } |
| 1353 | 1353 | } |
@@ -1369,7 +1369,7 @@ discard block |
||
| 1369 | 1369 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
| 1370 | 1370 | |
| 1371 | 1371 | $scheme = is_ssl() ? 'https://' : 'http://'; |
| 1372 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1372 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
| 1373 | 1373 | |
| 1374 | 1374 | /** |
| 1375 | 1375 | * @filter `gravityview_search_datepicker_class` |