@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | /** |
244 | 244 | * Add admin script to the no-conflict scripts whitelist |
245 | 245 | * @param array $allowed Scripts allowed in no-conflict mode |
246 | - * @return array Scripts allowed in no-conflict mode, plus the search widget script |
|
246 | + * @return string[] Scripts allowed in no-conflict mode, plus the search widget script |
|
247 | 247 | */ |
248 | 248 | public function register_no_conflict( $allowed ) { |
249 | 249 | $allowed[] = 'gravityview_searchwidget_admin'; |
@@ -709,7 +709,6 @@ discard block |
||
709 | 709 | * Dropin for the legacy flat filters when \GF_Query is available. |
710 | 710 | * |
711 | 711 | * @param \GF_Query $query The current query object reference |
712 | - * @param \GV\View $this The current view object |
|
713 | 712 | * @param \GV\Request $request The request object |
714 | 713 | */ |
715 | 714 | public function gf_query_filter( &$query, $view, $request ) { |
@@ -1199,7 +1198,7 @@ discard block |
||
1199 | 1198 | /** |
1200 | 1199 | * Get the label for a search form field |
1201 | 1200 | * @param array $field Field setting as sent by the GV configuration - has `field`, `input` (input type), and `label` keys |
1202 | - * @param array $form_field Form field data, as fetched by `gravityview_get_field()` |
|
1201 | + * @param GF_Field|null $form_field Form field data, as fetched by `gravityview_get_field()` |
|
1203 | 1202 | * @return string Label for the search form |
1204 | 1203 | */ |
1205 | 1204 | private static function get_field_label( $field, $form_field = array() ) { |
@@ -1364,7 +1363,7 @@ discard block |
||
1364 | 1363 | /** |
1365 | 1364 | * Require the datepicker script for the frontend GV script |
1366 | 1365 | * @param array $js_dependencies Array of existing required scripts for the fe-views.js script |
1367 | - * @return array Array required scripts, with `jquery-ui-datepicker` added |
|
1366 | + * @return string[] Array required scripts, with `jquery-ui-datepicker` added |
|
1368 | 1367 | */ |
1369 | 1368 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1370 | 1369 | |
@@ -1376,7 +1375,7 @@ discard block |
||
1376 | 1375 | /** |
1377 | 1376 | * Modify the array passed to wp_localize_script() |
1378 | 1377 | * |
1379 | - * @param array $js_localization The data padded to the Javascript file |
|
1378 | + * @param array $localizations The data padded to the Javascript file |
|
1380 | 1379 | * @param array $view_data View data array with View settings |
1381 | 1380 | * |
1382 | 1381 | * @return array |
@@ -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 | } |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
521 | 521 | } |
522 | 522 | |
523 | - if( 'post' === $this->search_method ) { |
|
523 | + if ( 'post' === $this->search_method ) { |
|
524 | 524 | $get = $_POST; |
525 | 525 | } else { |
526 | 526 | $get = $_GET; |
@@ -539,14 +539,14 @@ discard block |
||
539 | 539 | $get = gv_map_deep( $get, 'rawurldecode' ); |
540 | 540 | |
541 | 541 | // Make sure array key is set up |
542 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
542 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
543 | 543 | |
544 | 544 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
545 | 545 | |
546 | 546 | // add free search |
547 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
547 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
548 | 548 | |
549 | - $search_all_value = trim( $get['gv_search'] ); |
|
549 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
550 | 550 | |
551 | 551 | /** |
552 | 552 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | } |
572 | 572 | |
573 | 573 | foreach ( $words as $word ) { |
574 | - $search_criteria['field_filters'][] = array( |
|
574 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
575 | 575 | 'key' => null, // The field ID to search |
576 | 576 | 'value' => $word, // The value to search |
577 | 577 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -584,14 +584,14 @@ discard block |
||
584 | 584 | /** |
585 | 585 | * Get and normalize the dates according to the input format. |
586 | 586 | */ |
587 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
588 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
587 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
588 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
589 | 589 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
590 | 590 | } |
591 | 591 | } |
592 | 592 | |
593 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
594 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
593 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
594 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
595 | 595 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
596 | 596 | } |
597 | 597 | } |
@@ -626,22 +626,22 @@ discard block |
||
626 | 626 | */ |
627 | 627 | if ( ! empty( $curr_start ) ) { |
628 | 628 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
629 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
629 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | if ( ! empty( $curr_end ) ) { |
633 | 633 | // Fast-forward 24 hour on the end time |
634 | 634 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
635 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
636 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
637 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
635 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
636 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
637 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
638 | 638 | } |
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
642 | 642 | // search for a specific entry ID |
643 | 643 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
644 | - $search_criteria['field_filters'][] = array( |
|
644 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
645 | 645 | 'key' => 'id', |
646 | 646 | 'value' => absint( $get[ 'gv_id' ] ), |
647 | 647 | 'operator' => '=', |
@@ -650,42 +650,42 @@ discard block |
||
650 | 650 | |
651 | 651 | // search for a specific Created_by ID |
652 | 652 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
653 | - $search_criteria['field_filters'][] = array( |
|
653 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
654 | 654 | 'key' => 'created_by', |
655 | - 'value' => absint( $get['gv_by'] ), |
|
655 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
656 | 656 | 'operator' => '=', |
657 | 657 | ); |
658 | 658 | } |
659 | 659 | |
660 | 660 | |
661 | 661 | // Get search mode passed in URL |
662 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
662 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
663 | 663 | |
664 | 664 | // get the other search filters |
665 | 665 | foreach ( $get as $key => $value ) { |
666 | 666 | |
667 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
667 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
668 | 668 | continue; |
669 | 669 | } |
670 | 670 | |
671 | 671 | $filter_key = $this->convert_request_key_to_filter_key( $key ); |
672 | 672 | |
673 | 673 | // could return simple filter or multiple filters |
674 | - if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key , $searchable_fields ) ) { |
|
674 | + if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key, $searchable_fields ) ) { |
|
675 | 675 | continue; |
676 | 676 | } |
677 | 677 | |
678 | 678 | $filter = $this->prepare_field_filter( $filter_key, $value, $view ); |
679 | 679 | |
680 | - if ( isset( $filter[0]['value'] ) ) { |
|
681 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
680 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
681 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
682 | 682 | |
683 | 683 | // if date range type, set search mode to ALL |
684 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
684 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
685 | 685 | $mode = 'all'; |
686 | 686 | } |
687 | - } elseif( !empty( $filter ) ) { |
|
688 | - $search_criteria['field_filters'][] = $filter; |
|
687 | + } elseif ( ! empty( $filter ) ) { |
|
688 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
689 | 689 | } |
690 | 690 | } |
691 | 691 | |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | * @since 1.5.1 |
695 | 695 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
696 | 696 | */ |
697 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
697 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
698 | 698 | |
699 | 699 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
700 | 700 | |
@@ -719,24 +719,24 @@ discard block |
||
719 | 719 | */ |
720 | 720 | $search_criteria = $this->filter_entries( array(), null, array( 'id' => $view->ID ), true /** force search_criteria */ ); |
721 | 721 | |
722 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
722 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
723 | 723 | return; |
724 | 724 | } |
725 | 725 | |
726 | - foreach ( $search_criteria['field_filters'] as &$filter ) { |
|
726 | + foreach ( $search_criteria[ 'field_filters' ] as &$filter ) { |
|
727 | 727 | if ( ! is_array( $filter ) ) { |
728 | 728 | continue; |
729 | 729 | } |
730 | 730 | |
731 | 731 | // By default, we want searches to be wildcard for each field. |
732 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
732 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
733 | 733 | |
734 | 734 | /** |
735 | 735 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
736 | 736 | * @param string $operator Existing search operator |
737 | 737 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
738 | 738 | */ |
739 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
739 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
@@ -750,12 +750,12 @@ discard block |
||
750 | 750 | /** |
751 | 751 | * Grab the current clauses. We'll be combining them shortly. |
752 | 752 | */ |
753 | - $query_parts = $query->_introspect(); |
|
753 | + $query_parts = $query->_introspect(); |
|
754 | 754 | |
755 | 755 | /** |
756 | 756 | * Combine the parts as a new WHERE clause. |
757 | 757 | */ |
758 | - $query->where( GF_Query_Condition::_and( $query_parts['where'], $_tmp_query_parts['where'] ) ); |
|
758 | + $query->where( GF_Query_Condition::_and( $query_parts[ 'where' ], $_tmp_query_parts[ 'where' ] ) ); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | /** |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | $field_id = str_replace( 'filter_', '', $key ); |
778 | 778 | |
779 | 779 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
780 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
780 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
781 | 781 | $field_id = str_replace( '_', '.', $field_id ); |
782 | 782 | } |
783 | 783 | |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | |
813 | 813 | case 'select': |
814 | 814 | case 'radio': |
815 | - $filter['operator'] = 'is'; |
|
815 | + $filter[ 'operator' ] = 'is'; |
|
816 | 816 | break; |
817 | 817 | |
818 | 818 | case 'post_category': |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | |
827 | 827 | foreach ( $value as $val ) { |
828 | 828 | $cat = get_term( $val, 'category' ); |
829 | - $filter[] = array( |
|
829 | + $filter[ ] = array( |
|
830 | 830 | 'key' => $filter_key, |
831 | 831 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
832 | 832 | 'operator' => 'is', |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | $filter = array(); |
846 | 846 | |
847 | 847 | foreach ( $value as $val ) { |
848 | - $filter[] = array( 'key' => $filter_key, 'value' => $val ); |
|
848 | + $filter[ ] = array( 'key' => $filter_key, 'value' => $val ); |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | break; |
@@ -854,9 +854,9 @@ discard block |
||
854 | 854 | // convert checkbox on/off into the correct search filter |
855 | 855 | if ( false !== strpos( $filter_key, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
856 | 856 | foreach ( $form_field->inputs as $k => $input ) { |
857 | - if ( $input['id'] == $filter_key ) { |
|
858 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
859 | - $filter['operator'] = 'is'; |
|
857 | + if ( $input[ 'id' ] == $filter_key ) { |
|
858 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
859 | + $filter[ 'operator' ] = 'is'; |
|
860 | 860 | break; |
861 | 861 | } |
862 | 862 | } |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | $filter = array(); |
867 | 867 | |
868 | 868 | foreach ( $value as $val ) { |
869 | - $filter[] = array( |
|
869 | + $filter[ ] = array( |
|
870 | 870 | 'key' => $filter_key, |
871 | 871 | 'value' => $val, |
872 | 872 | 'operator' => 'is', |
@@ -887,9 +887,9 @@ discard block |
||
887 | 887 | foreach ( $words as $word ) { |
888 | 888 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
889 | 889 | // Keep the same key for each filter |
890 | - $filter['value'] = $word; |
|
890 | + $filter[ 'value' ] = $word; |
|
891 | 891 | // Add a search for the value |
892 | - $filters[] = $filter; |
|
892 | + $filters[ ] = $filter; |
|
893 | 893 | } |
894 | 894 | } |
895 | 895 | |
@@ -903,19 +903,19 @@ discard block |
||
903 | 903 | |
904 | 904 | foreach ( $searchable_fields as $searchable_field ) { |
905 | 905 | |
906 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
906 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
907 | 907 | continue; |
908 | 908 | } |
909 | 909 | |
910 | 910 | // Only exact-match dropdowns, not text search |
911 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
911 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
912 | 912 | continue; |
913 | 913 | } |
914 | 914 | |
915 | 915 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
916 | 916 | |
917 | 917 | if ( 4 === $input_id ) { |
918 | - $filter['operator'] = 'is'; |
|
918 | + $filter[ 'operator' ] = 'is'; |
|
919 | 919 | }; |
920 | 920 | } |
921 | 921 | } |
@@ -942,12 +942,12 @@ discard block |
||
942 | 942 | * @since 1.16.3 |
943 | 943 | * Safeguard until GF implements '<=' operator |
944 | 944 | */ |
945 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
945 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
946 | 946 | $operator = '<'; |
947 | 947 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
948 | 948 | } |
949 | 949 | |
950 | - $filter[] = array( |
|
950 | + $filter[ ] = array( |
|
951 | 951 | 'key' => $filter_key, |
952 | 952 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
953 | 953 | 'operator' => $operator, |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | } |
956 | 956 | } else { |
957 | 957 | $date = $value; |
958 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
958 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | break; |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | 'ymd_dot' => 'Y.m.d', |
987 | 987 | ); |
988 | 988 | |
989 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
989 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
990 | 990 | $format = $datepicker[ $field->dateFormat ]; |
991 | 991 | } |
992 | 992 | |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | public function add_template_path( $file_paths ) { |
1024 | 1024 | |
1025 | 1025 | // Index 100 is the default GravityView template path. |
1026 | - $file_paths[102] = self::$file . 'templates/'; |
|
1026 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
1027 | 1027 | |
1028 | 1028 | return $file_paths; |
1029 | 1029 | } |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | $has_date = false; |
1043 | 1043 | |
1044 | 1044 | foreach ( $search_fields as $k => $field ) { |
1045 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1045 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1046 | 1046 | $has_date = true; |
1047 | 1047 | break; |
1048 | 1048 | } |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | // get configured search fields |
1072 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
1072 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
1073 | 1073 | |
1074 | 1074 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
1075 | 1075 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1084,34 +1084,34 @@ discard block |
||
1084 | 1084 | |
1085 | 1085 | $updated_field = $this->get_search_filter_details( $updated_field ); |
1086 | 1086 | |
1087 | - switch ( $field['field'] ) { |
|
1087 | + switch ( $field[ 'field' ] ) { |
|
1088 | 1088 | |
1089 | 1089 | case 'search_all': |
1090 | - $updated_field['key'] = 'search_all'; |
|
1091 | - $updated_field['input'] = 'search_all'; |
|
1092 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1090 | + $updated_field[ 'key' ] = 'search_all'; |
|
1091 | + $updated_field[ 'input' ] = 'search_all'; |
|
1092 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1093 | 1093 | break; |
1094 | 1094 | |
1095 | 1095 | case 'entry_date': |
1096 | - $updated_field['key'] = 'entry_date'; |
|
1097 | - $updated_field['input'] = 'entry_date'; |
|
1098 | - $updated_field['value'] = array( |
|
1096 | + $updated_field[ 'key' ] = 'entry_date'; |
|
1097 | + $updated_field[ 'input' ] = 'entry_date'; |
|
1098 | + $updated_field[ 'value' ] = array( |
|
1099 | 1099 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
1100 | 1100 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
1101 | 1101 | ); |
1102 | 1102 | break; |
1103 | 1103 | |
1104 | 1104 | case 'entry_id': |
1105 | - $updated_field['key'] = 'entry_id'; |
|
1106 | - $updated_field['input'] = 'entry_id'; |
|
1107 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1105 | + $updated_field[ 'key' ] = 'entry_id'; |
|
1106 | + $updated_field[ 'input' ] = 'entry_id'; |
|
1107 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1108 | 1108 | break; |
1109 | 1109 | |
1110 | 1110 | case 'created_by': |
1111 | - $updated_field['key'] = 'created_by'; |
|
1112 | - $updated_field['name'] = 'gv_by'; |
|
1113 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1114 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
1111 | + $updated_field[ 'key' ] = 'created_by'; |
|
1112 | + $updated_field[ 'name' ] = 'gv_by'; |
|
1113 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1114 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
1115 | 1115 | break; |
1116 | 1116 | } |
1117 | 1117 | |
@@ -1130,16 +1130,16 @@ discard block |
||
1130 | 1130 | */ |
1131 | 1131 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
1132 | 1132 | |
1133 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1133 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1134 | 1134 | |
1135 | 1135 | /** @since 1.14 */ |
1136 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1136 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1137 | 1137 | |
1138 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1138 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1139 | 1139 | |
1140 | 1140 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1141 | 1141 | |
1142 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1142 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1143 | 1143 | |
1144 | 1144 | if ( $this->has_date_field( $search_fields ) ) { |
1145 | 1145 | // enqueue datepicker stuff only if needed! |
@@ -1161,10 +1161,10 @@ discard block |
||
1161 | 1161 | public static function get_search_class( $custom_class = '' ) { |
1162 | 1162 | $gravityview_view = GravityView_View::getInstance(); |
1163 | 1163 | |
1164 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1164 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1165 | 1165 | |
1166 | - if ( ! empty( $custom_class ) ) { |
|
1167 | - $search_class .= ' '.$custom_class; |
|
1166 | + if ( ! empty( $custom_class ) ) { |
|
1167 | + $search_class .= ' ' . $custom_class; |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | /** |
@@ -1208,9 +1208,9 @@ discard block |
||
1208 | 1208 | |
1209 | 1209 | if ( ! $label ) { |
1210 | 1210 | |
1211 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1211 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1212 | 1212 | |
1213 | - switch( $field['field'] ) { |
|
1213 | + switch ( $field[ 'field' ] ) { |
|
1214 | 1214 | case 'search_all': |
1215 | 1215 | $label = __( 'Search Entries:', 'gravityview' ); |
1216 | 1216 | break; |
@@ -1222,10 +1222,10 @@ discard block |
||
1222 | 1222 | break; |
1223 | 1223 | default: |
1224 | 1224 | // If this is a field input, not a field |
1225 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1225 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1226 | 1226 | |
1227 | 1227 | // Get the label for the field in question, which returns an array |
1228 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1228 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1229 | 1229 | |
1230 | 1230 | // Get the item with the `label` key |
1231 | 1231 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1264,32 +1264,32 @@ discard block |
||
1264 | 1264 | $form = $gravityview_view->getForm(); |
1265 | 1265 | |
1266 | 1266 | // for advanced field ids (eg, first name / last name ) |
1267 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1267 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1268 | 1268 | |
1269 | 1269 | // get searched value from $_GET/$_POST (string or array) |
1270 | 1270 | $value = $this->rgget_or_rgpost( $name ); |
1271 | 1271 | |
1272 | 1272 | // get form field details |
1273 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1273 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1274 | 1274 | |
1275 | 1275 | $filter = array( |
1276 | - 'key' => $field['field'], |
|
1276 | + 'key' => $field[ 'field' ], |
|
1277 | 1277 | 'name' => $name, |
1278 | 1278 | 'label' => self::get_field_label( $field, $form_field ), |
1279 | - 'input' => $field['input'], |
|
1279 | + 'input' => $field[ 'input' ], |
|
1280 | 1280 | 'value' => $value, |
1281 | - 'type' => $form_field['type'], |
|
1281 | + 'type' => $form_field[ 'type' ], |
|
1282 | 1282 | ); |
1283 | 1283 | |
1284 | 1284 | // collect choices |
1285 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1286 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1287 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1288 | - $filter['choices'] = $form_field['choices']; |
|
1285 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1286 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1287 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1288 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1289 | 1289 | } |
1290 | 1290 | |
1291 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1292 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1291 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1292 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1293 | 1293 | } |
1294 | 1294 | |
1295 | 1295 | return $filter; |
@@ -1313,7 +1313,7 @@ discard block |
||
1313 | 1313 | |
1314 | 1314 | $choices = array(); |
1315 | 1315 | foreach ( $users as $user ) { |
1316 | - $choices[] = array( |
|
1316 | + $choices[ ] = array( |
|
1317 | 1317 | 'value' => $user->ID, |
1318 | 1318 | 'text' => $user->display_name, |
1319 | 1319 | ); |
@@ -1368,7 +1368,7 @@ discard block |
||
1368 | 1368 | */ |
1369 | 1369 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1370 | 1370 | |
1371 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1371 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1372 | 1372 | |
1373 | 1373 | return $js_dependencies; |
1374 | 1374 | } |
@@ -1412,7 +1412,7 @@ discard block |
||
1412 | 1412 | 'isRTL' => is_rtl(), |
1413 | 1413 | ), $view_data ); |
1414 | 1414 | |
1415 | - $localizations['datepicker'] = $datepicker_settings; |
|
1415 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1416 | 1416 | |
1417 | 1417 | return $localizations; |
1418 | 1418 | |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | * @return void |
1440 | 1440 | */ |
1441 | 1441 | private function maybe_enqueue_flexibility() { |
1442 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1442 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1443 | 1443 | wp_enqueue_script( 'gv-flexibility' ); |
1444 | 1444 | } |
1445 | 1445 | } |
@@ -1461,7 +1461,7 @@ discard block |
||
1461 | 1461 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1462 | 1462 | |
1463 | 1463 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1464 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1464 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1465 | 1465 | |
1466 | 1466 | /** |
1467 | 1467 | * @filter `gravityview_search_datepicker_class` |