@@ -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 |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
231 | 231 | $script_source = empty( $script_min ) ? '/source' : ''; |
232 | 232 | |
233 | - 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 ); |
|
233 | + 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 ); |
|
234 | 234 | |
235 | 235 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
236 | 236 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
253 | 253 | */ |
254 | 254 | public function register_no_conflict( $allowed ) { |
255 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
255 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
256 | 256 | return $allowed; |
257 | 257 | } |
258 | 258 | |
@@ -265,24 +265,24 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public static function get_searchable_fields() { |
267 | 267 | |
268 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
268 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
269 | 269 | exit( '0' ); |
270 | 270 | } |
271 | 271 | |
272 | 272 | $form = ''; |
273 | 273 | |
274 | 274 | // Fetch the form for the current View |
275 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
275 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
276 | 276 | |
277 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
277 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
278 | 278 | |
279 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
279 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
280 | 280 | |
281 | - $form = (int) $_POST['formid']; |
|
281 | + $form = (int)$_POST[ 'formid' ]; |
|
282 | 282 | |
283 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
283 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
284 | 284 | |
285 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
285 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
286 | 286 | |
287 | 287 | } |
288 | 288 | |
@@ -332,14 +332,14 @@ discard block |
||
332 | 332 | ); |
333 | 333 | |
334 | 334 | if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { |
335 | - $custom_fields['is_approved'] = array( |
|
335 | + $custom_fields[ 'is_approved' ] = array( |
|
336 | 336 | 'text' => esc_html__( 'Approval Status', 'gravityview' ), |
337 | 337 | 'type' => 'multi', |
338 | 338 | ); |
339 | 339 | } |
340 | 340 | |
341 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
342 | - $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'] ); |
|
341 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
342 | + $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' ] ); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | // Get fields with sub-inputs and no parent |
@@ -361,13 +361,13 @@ discard block |
||
361 | 361 | |
362 | 362 | foreach ( $fields as $id => $field ) { |
363 | 363 | |
364 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
364 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
365 | 365 | continue; |
366 | 366 | } |
367 | 367 | |
368 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
368 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
369 | 369 | |
370 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
370 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
371 | 371 | } |
372 | 372 | } |
373 | 373 | |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
391 | 391 | |
392 | 392 | // @todo - This needs to be improved - many fields have . including products and addresses |
393 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
393 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
394 | 394 | $input_type = 'boolean'; // on/off checkbox |
395 | 395 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
396 | 396 | $input_type = 'multi'; //multiselect |
@@ -436,19 +436,19 @@ discard block |
||
436 | 436 | $post_id = 0; |
437 | 437 | |
438 | 438 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
439 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
440 | - $post_id = absint( $widget_args['post_id'] ); |
|
439 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
440 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
441 | 441 | } |
442 | 442 | // We're in the WordPress Widget context, and the base View ID should be used |
443 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
444 | - $post_id = absint( $widget_args['view_id'] ); |
|
443 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
444 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | $args = gravityview_get_permalink_query_args( $post_id ); |
448 | 448 | |
449 | 449 | // Add hidden fields to the search form |
450 | 450 | foreach ( $args as $key => $value ) { |
451 | - $search_fields[] = array( |
|
451 | + $search_fields[ ] = array( |
|
452 | 452 | 'name' => $key, |
453 | 453 | 'input' => 'hidden', |
454 | 454 | 'value' => $value, |
@@ -487,28 +487,28 @@ discard block |
||
487 | 487 | /** |
488 | 488 | * Include the sidebar Widgets. |
489 | 489 | */ |
490 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
490 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
491 | 491 | |
492 | 492 | foreach ( $widgets as $widget ) { |
493 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
494 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
493 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
494 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
495 | 495 | foreach ( $_fields as $field ) { |
496 | - if ( empty( $field['form_id'] ) ) { |
|
497 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
496 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
497 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
498 | 498 | } |
499 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
499 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | } |
503 | 503 | } |
504 | 504 | |
505 | 505 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
506 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
506 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
507 | 507 | foreach ( $_fields as $field ) { |
508 | - if ( empty( $field['form_id'] ) ) { |
|
509 | - $field['form_id'] = $view->form ? $view->form->ID : 0; |
|
508 | + if ( empty( $field[ 'form_id' ] ) ) { |
|
509 | + $field[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
510 | 510 | } |
511 | - $searchable_fields[] = $with_full_field ? $field : $field['field']; |
|
511 | + $searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | } |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
539 | 539 | } |
540 | 540 | |
541 | - if( 'post' === $this->search_method ) { |
|
541 | + if ( 'post' === $this->search_method ) { |
|
542 | 542 | $get = $_POST; |
543 | 543 | } else { |
544 | 544 | $get = $_GET; |
@@ -557,15 +557,15 @@ discard block |
||
557 | 557 | $get = gv_map_deep( $get, 'rawurldecode' ); |
558 | 558 | |
559 | 559 | // Make sure array key is set up |
560 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
560 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
561 | 561 | |
562 | 562 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
563 | 563 | $searchable_field_objects = $this->get_view_searchable_fields( $view, true ); |
564 | 564 | |
565 | 565 | // add free search |
566 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
566 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
567 | 567 | |
568 | - $search_all_value = trim( $get['gv_search'] ); |
|
568 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
569 | 569 | |
570 | 570 | /** |
571 | 571 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | } |
591 | 591 | |
592 | 592 | foreach ( $words as $word ) { |
593 | - $search_criteria['field_filters'][] = array( |
|
593 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
594 | 594 | 'key' => null, // The field ID to search |
595 | 595 | 'value' => $word, // The value to search |
596 | 596 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -603,14 +603,14 @@ discard block |
||
603 | 603 | /** |
604 | 604 | * Get and normalize the dates according to the input format. |
605 | 605 | */ |
606 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
607 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
606 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
607 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
608 | 608 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
609 | 609 | } |
610 | 610 | } |
611 | 611 | |
612 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
613 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
612 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
613 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
614 | 614 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
615 | 615 | } |
616 | 616 | } |
@@ -645,22 +645,22 @@ discard block |
||
645 | 645 | */ |
646 | 646 | if ( ! empty( $curr_start ) ) { |
647 | 647 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
648 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
648 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | if ( ! empty( $curr_end ) ) { |
652 | 652 | // Fast-forward 24 hour on the end time |
653 | 653 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
654 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
655 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
656 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
654 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
655 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
656 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 | } |
660 | 660 | |
661 | 661 | // search for a specific entry ID |
662 | 662 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
663 | - $search_criteria['field_filters'][] = array( |
|
663 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
664 | 664 | 'key' => 'id', |
665 | 665 | 'value' => absint( $get[ 'gv_id' ] ), |
666 | 666 | 'operator' => $this->get_operator( $get, 'gv_id', array( '=' ), '=' ), |
@@ -669,20 +669,20 @@ discard block |
||
669 | 669 | |
670 | 670 | // search for a specific Created_by ID |
671 | 671 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
672 | - $search_criteria['field_filters'][] = array( |
|
672 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
673 | 673 | 'key' => 'created_by', |
674 | - 'value' => $get['gv_by'], |
|
674 | + 'value' => $get[ 'gv_by' ], |
|
675 | 675 | 'operator' => $this->get_operator( $get, 'gv_by', array( '=' ), '=' ), |
676 | 676 | ); |
677 | 677 | } |
678 | 678 | |
679 | 679 | // Get search mode passed in URL |
680 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
680 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
681 | 681 | |
682 | 682 | // get the other search filters |
683 | 683 | foreach ( $get as $key => $value ) { |
684 | 684 | |
685 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
685 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
686 | 686 | continue; // Not a filter, or empty |
687 | 687 | } |
688 | 688 | |
@@ -696,19 +696,19 @@ discard block |
||
696 | 696 | continue; |
697 | 697 | } |
698 | 698 | |
699 | - if ( ! isset( $filter['operator'] ) ) { |
|
700 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
699 | + if ( ! isset( $filter[ 'operator' ] ) ) { |
|
700 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' ); |
|
701 | 701 | } |
702 | 702 | |
703 | - if ( isset( $filter[0]['value'] ) ) { |
|
704 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
703 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
704 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
705 | 705 | |
706 | 706 | // if date range type, set search mode to ALL |
707 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
707 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
708 | 708 | $mode = 'all'; |
709 | 709 | } |
710 | - } elseif( !empty( $filter ) ) { |
|
711 | - $search_criteria['field_filters'][] = $filter; |
|
710 | + } elseif ( ! empty( $filter ) ) { |
|
711 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
712 | 712 | } |
713 | 713 | } |
714 | 714 | |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | * @since 1.5.1 |
718 | 718 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
719 | 719 | */ |
720 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
720 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
721 | 721 | |
722 | 722 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
723 | 723 | |
@@ -751,19 +751,19 @@ discard block |
||
751 | 751 | |
752 | 752 | $query_class = $view->get_query_class(); |
753 | 753 | |
754 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
754 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
755 | 755 | return; |
756 | 756 | } |
757 | 757 | |
758 | 758 | $widgets = $view->widgets->by_id( $this->widget_id ); |
759 | 759 | if ( $widgets->count() ) { |
760 | 760 | $widgets = $widgets->all(); |
761 | - $widget = $widgets[0]; |
|
761 | + $widget = $widgets[ 0 ]; |
|
762 | 762 | |
763 | 763 | $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ); |
764 | 764 | |
765 | - foreach ( (array) $search_fields as $search_field ) { |
|
766 | - if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) { |
|
765 | + foreach ( (array)$search_fields as $search_field ) { |
|
766 | + if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) { |
|
767 | 767 | $created_by_text_mode = true; |
768 | 768 | } |
769 | 769 | } |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | $extra_conditions = array(); |
773 | 773 | $mode = 'any'; |
774 | 774 | |
775 | - foreach ( $search_criteria['field_filters'] as &$filter ) { |
|
775 | + foreach ( $search_criteria[ 'field_filters' ] as &$filter ) { |
|
776 | 776 | if ( ! is_array( $filter ) ) { |
777 | 777 | if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) { |
778 | 778 | $mode = $filter; |
@@ -781,13 +781,13 @@ discard block |
||
781 | 781 | } |
782 | 782 | |
783 | 783 | // Construct a manual query for unapproved statuses |
784 | - if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) { |
|
785 | - $_tmp_query = new $query_class( $view->form->ID, array( |
|
784 | + if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) { |
|
785 | + $_tmp_query = new $query_class( $view->form->ID, array( |
|
786 | 786 | 'field_filters' => array( |
787 | 787 | array( |
788 | 788 | 'operator' => 'in', |
789 | 789 | 'key' => 'is_approved', |
790 | - 'value' => (array) $filter['value'], |
|
790 | + 'value' => (array)$filter[ 'value' ], |
|
791 | 791 | ), |
792 | 792 | array( |
793 | 793 | 'operator' => 'is', |
@@ -799,30 +799,30 @@ discard block |
||
799 | 799 | ) ); |
800 | 800 | $_tmp_query_parts = $_tmp_query->_introspect(); |
801 | 801 | |
802 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
802 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
803 | 803 | |
804 | 804 | $filter = false; |
805 | 805 | continue; |
806 | 806 | } |
807 | 807 | |
808 | 808 | // Construct manual query for text mode creator search |
809 | - if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { |
|
810 | - $extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
809 | + if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) { |
|
810 | + $extra_conditions[ ] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view ); |
|
811 | 811 | $filter = false; |
812 | 812 | continue; |
813 | 813 | } |
814 | 814 | |
815 | 815 | // By default, we want searches to be wildcard for each field. |
816 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
816 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
817 | 817 | |
818 | 818 | // For multichoice, let's have an in (OR) search. |
819 | - if ( is_array( $filter['value'] ) ) { |
|
820 | - $filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
819 | + if ( is_array( $filter[ 'value' ] ) ) { |
|
820 | + $filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
821 | 821 | } |
822 | 822 | |
823 | 823 | // Default form with joins functionality |
824 | - if ( empty( $filter['form_id'] ) ) { |
|
825 | - $filter['form_id'] = $view->form ? $view->form->ID : 0; |
|
824 | + if ( empty( $filter[ 'form_id' ] ) ) { |
|
825 | + $filter[ 'form_id' ] = $view->form ? $view->form->ID : 0; |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -832,28 +832,28 @@ discard block |
||
832 | 832 | * @since develop |
833 | 833 | * @param \GV\View $view The View we're operating on. |
834 | 834 | */ |
835 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter, $view ); |
|
835 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter, $view ); |
|
836 | 836 | } |
837 | 837 | |
838 | - if ( ! empty( $search_criteria['start_date'] ) || ! empty( $search_criteria['end_date'] ) ) { |
|
838 | + if ( ! empty( $search_criteria[ 'start_date' ] ) || ! empty( $search_criteria[ 'end_date' ] ) ) { |
|
839 | 839 | $date_criteria = array(); |
840 | 840 | |
841 | - if ( isset( $search_criteria['start_date'] ) ) { |
|
842 | - $date_criteria['start_date'] = $search_criteria['start_date']; |
|
841 | + if ( isset( $search_criteria[ 'start_date' ] ) ) { |
|
842 | + $date_criteria[ 'start_date' ] = $search_criteria[ 'start_date' ]; |
|
843 | 843 | } |
844 | 844 | |
845 | - if ( isset( $search_criteria['end_date'] ) ) { |
|
846 | - $date_criteria['end_date'] = $search_criteria['end_date']; |
|
845 | + if ( isset( $search_criteria[ 'end_date' ] ) ) { |
|
846 | + $date_criteria[ 'end_date' ] = $search_criteria[ 'end_date' ]; |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | $_tmp_query = new $query_class( $view->form->ID, $date_criteria ); |
850 | 850 | $_tmp_query_parts = $_tmp_query->_introspect(); |
851 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
851 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | $search_conditions = array(); |
855 | 855 | |
856 | - if ( $filters = array_filter( $search_criteria['field_filters'] ) ) { |
|
856 | + if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) { |
|
857 | 857 | |
858 | 858 | foreach ( $filters as $filter ) { |
859 | 859 | if ( ! is_array( $filter ) ) { |
@@ -866,12 +866,12 @@ discard block |
||
866 | 866 | * code by reusing what's inside GF_Query already as they |
867 | 867 | * take care of many small things like forcing numeric, etc. |
868 | 868 | */ |
869 | - $_tmp_query = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
869 | + $_tmp_query = new $query_class( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) ); |
|
870 | 870 | $_tmp_query_parts = $_tmp_query->_introspect(); |
871 | - $search_condition = $_tmp_query_parts['where']; |
|
871 | + $search_condition = $_tmp_query_parts[ 'where' ]; |
|
872 | 872 | |
873 | - if ( empty( $filter['key'] ) && $search_condition->expressions ) { |
|
874 | - $search_conditions[] = $search_condition; |
|
873 | + if ( empty( $filter[ 'key' ] ) && $search_condition->expressions ) { |
|
874 | + $search_conditions[ ] = $search_condition; |
|
875 | 875 | } else { |
876 | 876 | $left = $search_condition->left; |
877 | 877 | $alias = $query->_alias( $left->field_id, $left->source, $left->is_entry_column() ? 't' : 'm' ); |
@@ -882,21 +882,21 @@ discard block |
||
882 | 882 | $join = $_join->join; |
883 | 883 | |
884 | 884 | // Join |
885 | - $search_conditions[] = new GF_Query_Condition( |
|
885 | + $search_conditions[ ] = new GF_Query_Condition( |
|
886 | 886 | new GF_Query_Column( GF_Query_Column::META, $join->ID, $query->_alias( GF_Query_Column::META, $join->ID, 'm' ) ), |
887 | 887 | $search_condition->operator, |
888 | 888 | $search_condition->right |
889 | 889 | ); |
890 | 890 | |
891 | 891 | // On |
892 | - $search_conditions[] = new GF_Query_Condition( |
|
892 | + $search_conditions[ ] = new GF_Query_Condition( |
|
893 | 893 | new GF_Query_Column( GF_Query_Column::META, $on->ID, $query->_alias( GF_Query_Column::META, $on->ID, 'm' ) ), |
894 | 894 | $search_condition->operator, |
895 | 895 | $search_condition->right |
896 | 896 | ); |
897 | 897 | } |
898 | 898 | } else { |
899 | - $search_conditions[] = new GF_Query_Condition( |
|
899 | + $search_conditions[ ] = new GF_Query_Condition( |
|
900 | 900 | new GF_Query_Column( $left->field_id, $left->source, $alias ), |
901 | 901 | $search_condition->operator, |
902 | 902 | $search_condition->right |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | /** |
919 | 919 | * Combine the parts as a new WHERE clause. |
920 | 920 | */ |
921 | - $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) ); |
|
921 | + $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) ); |
|
922 | 922 | $query->where( $where ); |
923 | 923 | } |
924 | 924 | |
@@ -941,7 +941,7 @@ discard block |
||
941 | 941 | $field_id = str_replace( 'filter_', '', $key ); |
942 | 942 | |
943 | 943 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
944 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
944 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
945 | 945 | $field_id = str_replace( '_', '.', $field_id ); |
946 | 946 | } |
947 | 947 | |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | // form is in searchable fields |
999 | 999 | $found = false; |
1000 | 1000 | foreach ( $searchable_fields as $field ) { |
1001 | - if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) { |
|
1001 | + if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) { |
|
1002 | 1002 | $found = true; |
1003 | 1003 | break; |
1004 | 1004 | } |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | |
1035 | 1035 | case 'select': |
1036 | 1036 | case 'radio': |
1037 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1037 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1038 | 1038 | break; |
1039 | 1039 | |
1040 | 1040 | case 'post_category': |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | |
1049 | 1049 | foreach ( $value as $val ) { |
1050 | 1050 | $cat = get_term( $val, 'category' ); |
1051 | - $filter[] = array( |
|
1051 | + $filter[ ] = array( |
|
1052 | 1052 | 'key' => $field_id, |
1053 | 1053 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
1054 | 1054 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1067,7 +1067,7 @@ discard block |
||
1067 | 1067 | $filter = array(); |
1068 | 1068 | |
1069 | 1069 | foreach ( $value as $val ) { |
1070 | - $filter[] = array( 'key' => $field_id, 'value' => $val ); |
|
1070 | + $filter[ ] = array( 'key' => $field_id, 'value' => $val ); |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | break; |
@@ -1076,9 +1076,9 @@ discard block |
||
1076 | 1076 | // convert checkbox on/off into the correct search filter |
1077 | 1077 | if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
1078 | 1078 | foreach ( $form_field->inputs as $k => $input ) { |
1079 | - if ( $input['id'] == $field_id ) { |
|
1080 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
1081 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1079 | + if ( $input[ 'id' ] == $field_id ) { |
|
1080 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
1081 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1082 | 1082 | break; |
1083 | 1083 | } |
1084 | 1084 | } |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | $filter = array(); |
1089 | 1089 | |
1090 | 1090 | foreach ( $value as $val ) { |
1091 | - $filter[] = array( |
|
1091 | + $filter[ ] = array( |
|
1092 | 1092 | 'key' => $field_id, |
1093 | 1093 | 'value' => $val, |
1094 | 1094 | 'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ), |
@@ -1109,9 +1109,9 @@ discard block |
||
1109 | 1109 | foreach ( $words as $word ) { |
1110 | 1110 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
1111 | 1111 | // Keep the same key for each filter |
1112 | - $filter['value'] = $word; |
|
1112 | + $filter[ 'value' ] = $word; |
|
1113 | 1113 | // Add a search for the value |
1114 | - $filters[] = $filter; |
|
1114 | + $filters[ ] = $filter; |
|
1115 | 1115 | } |
1116 | 1116 | } |
1117 | 1117 | |
@@ -1125,19 +1125,19 @@ discard block |
||
1125 | 1125 | |
1126 | 1126 | foreach ( $searchable_fields as $searchable_field ) { |
1127 | 1127 | |
1128 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
1128 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
1129 | 1129 | continue; |
1130 | 1130 | } |
1131 | 1131 | |
1132 | 1132 | // Only exact-match dropdowns, not text search |
1133 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
1133 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
1134 | 1134 | continue; |
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
1138 | 1138 | |
1139 | 1139 | if ( 4 === $input_id ) { |
1140 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1140 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1141 | 1141 | }; |
1142 | 1142 | } |
1143 | 1143 | } |
@@ -1164,12 +1164,12 @@ discard block |
||
1164 | 1164 | * @since 1.16.3 |
1165 | 1165 | * Safeguard until GF implements '<=' operator |
1166 | 1166 | */ |
1167 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1167 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1168 | 1168 | $operator = '<'; |
1169 | 1169 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
1170 | 1170 | } |
1171 | 1171 | |
1172 | - $filter[] = array( |
|
1172 | + $filter[ ] = array( |
|
1173 | 1173 | 'key' => $field_id, |
1174 | 1174 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
1175 | 1175 | 'operator' => $this->get_operator( $get, $key, array( $operator ), $operator ), |
@@ -1177,8 +1177,8 @@ discard block |
||
1177 | 1177 | } |
1178 | 1178 | } else { |
1179 | 1179 | $date = $value; |
1180 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1181 | - $filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1180 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1181 | + $filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' ); |
|
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | break; |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | 'ymd_dot' => 'Y.m.d', |
1210 | 1210 | ); |
1211 | 1211 | |
1212 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
1212 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
1213 | 1213 | $format = $datepicker[ $field->dateFormat ]; |
1214 | 1214 | } |
1215 | 1215 | |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | public function add_template_path( $file_paths ) { |
1247 | 1247 | |
1248 | 1248 | // Index 100 is the default GravityView template path. |
1249 | - $file_paths[102] = self::$file . 'templates/'; |
|
1249 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
1250 | 1250 | |
1251 | 1251 | return $file_paths; |
1252 | 1252 | } |
@@ -1265,7 +1265,7 @@ discard block |
||
1265 | 1265 | $has_date = false; |
1266 | 1266 | |
1267 | 1267 | foreach ( $search_fields as $k => $field ) { |
1268 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1268 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1269 | 1269 | $has_date = true; |
1270 | 1270 | break; |
1271 | 1271 | } |
@@ -1292,7 +1292,7 @@ discard block |
||
1292 | 1292 | } |
1293 | 1293 | |
1294 | 1294 | // get configured search fields |
1295 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
1295 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
1296 | 1296 | |
1297 | 1297 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
1298 | 1298 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1308,40 +1308,40 @@ discard block |
||
1308 | 1308 | |
1309 | 1309 | $updated_field = $this->get_search_filter_details( $updated_field ); |
1310 | 1310 | |
1311 | - switch ( $field['field'] ) { |
|
1311 | + switch ( $field[ 'field' ] ) { |
|
1312 | 1312 | |
1313 | 1313 | case 'search_all': |
1314 | - $updated_field['key'] = 'search_all'; |
|
1315 | - $updated_field['input'] = 'search_all'; |
|
1316 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1314 | + $updated_field[ 'key' ] = 'search_all'; |
|
1315 | + $updated_field[ 'input' ] = 'search_all'; |
|
1316 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1317 | 1317 | break; |
1318 | 1318 | |
1319 | 1319 | case 'entry_date': |
1320 | - $updated_field['key'] = 'entry_date'; |
|
1321 | - $updated_field['input'] = 'entry_date'; |
|
1322 | - $updated_field['value'] = array( |
|
1320 | + $updated_field[ 'key' ] = 'entry_date'; |
|
1321 | + $updated_field[ 'input' ] = 'entry_date'; |
|
1322 | + $updated_field[ 'value' ] = array( |
|
1323 | 1323 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
1324 | 1324 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
1325 | 1325 | ); |
1326 | 1326 | break; |
1327 | 1327 | |
1328 | 1328 | case 'entry_id': |
1329 | - $updated_field['key'] = 'entry_id'; |
|
1330 | - $updated_field['input'] = 'entry_id'; |
|
1331 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1329 | + $updated_field[ 'key' ] = 'entry_id'; |
|
1330 | + $updated_field[ 'input' ] = 'entry_id'; |
|
1331 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1332 | 1332 | break; |
1333 | 1333 | |
1334 | 1334 | case 'created_by': |
1335 | - $updated_field['key'] = 'created_by'; |
|
1336 | - $updated_field['name'] = 'gv_by'; |
|
1337 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1338 | - $updated_field['choices'] = self::get_created_by_choices( $view ); |
|
1335 | + $updated_field[ 'key' ] = 'created_by'; |
|
1336 | + $updated_field[ 'name' ] = 'gv_by'; |
|
1337 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1338 | + $updated_field[ 'choices' ] = self::get_created_by_choices( $view ); |
|
1339 | 1339 | break; |
1340 | 1340 | |
1341 | 1341 | case 'is_approved': |
1342 | - $updated_field['key'] = 'is_approved'; |
|
1343 | - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1344 | - $updated_field['choices'] = self::get_is_approved_choices(); |
|
1342 | + $updated_field[ 'key' ] = 'is_approved'; |
|
1343 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1344 | + $updated_field[ 'choices' ] = self::get_is_approved_choices(); |
|
1345 | 1345 | break; |
1346 | 1346 | } |
1347 | 1347 | |
@@ -1360,16 +1360,16 @@ discard block |
||
1360 | 1360 | */ |
1361 | 1361 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
1362 | 1362 | |
1363 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1363 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1364 | 1364 | |
1365 | 1365 | /** @since 1.14 */ |
1366 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1366 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1367 | 1367 | |
1368 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1368 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1369 | 1369 | |
1370 | 1370 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1371 | 1371 | |
1372 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1372 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1373 | 1373 | |
1374 | 1374 | if ( $this->has_date_field( $search_fields ) ) { |
1375 | 1375 | // enqueue datepicker stuff only if needed! |
@@ -1391,10 +1391,10 @@ discard block |
||
1391 | 1391 | public static function get_search_class( $custom_class = '' ) { |
1392 | 1392 | $gravityview_view = GravityView_View::getInstance(); |
1393 | 1393 | |
1394 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1394 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1395 | 1395 | |
1396 | - if ( ! empty( $custom_class ) ) { |
|
1397 | - $search_class .= ' '.$custom_class; |
|
1396 | + if ( ! empty( $custom_class ) ) { |
|
1397 | + $search_class .= ' ' . $custom_class; |
|
1398 | 1398 | } |
1399 | 1399 | |
1400 | 1400 | /** |
@@ -1438,9 +1438,9 @@ discard block |
||
1438 | 1438 | |
1439 | 1439 | if ( ! $label ) { |
1440 | 1440 | |
1441 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1441 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1442 | 1442 | |
1443 | - switch( $field['field'] ) { |
|
1443 | + switch ( $field[ 'field' ] ) { |
|
1444 | 1444 | case 'search_all': |
1445 | 1445 | $label = __( 'Search Entries:', 'gravityview' ); |
1446 | 1446 | break; |
@@ -1452,10 +1452,10 @@ discard block |
||
1452 | 1452 | break; |
1453 | 1453 | default: |
1454 | 1454 | // If this is a field input, not a field |
1455 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1455 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1456 | 1456 | |
1457 | 1457 | // Get the label for the field in question, which returns an array |
1458 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1458 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1459 | 1459 | |
1460 | 1460 | // Get the item with the `label` key |
1461 | 1461 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1494,32 +1494,32 @@ discard block |
||
1494 | 1494 | $form = $gravityview_view->getForm(); |
1495 | 1495 | |
1496 | 1496 | // for advanced field ids (eg, first name / last name ) |
1497 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1497 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1498 | 1498 | |
1499 | 1499 | // get searched value from $_GET/$_POST (string or array) |
1500 | 1500 | $value = $this->rgget_or_rgpost( $name ); |
1501 | 1501 | |
1502 | 1502 | // get form field details |
1503 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1503 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1504 | 1504 | |
1505 | 1505 | $filter = array( |
1506 | - 'key' => $field['field'], |
|
1506 | + 'key' => $field[ 'field' ], |
|
1507 | 1507 | 'name' => $name, |
1508 | 1508 | 'label' => self::get_field_label( $field, $form_field ), |
1509 | - 'input' => $field['input'], |
|
1509 | + 'input' => $field[ 'input' ], |
|
1510 | 1510 | 'value' => $value, |
1511 | - 'type' => $form_field['type'], |
|
1511 | + 'type' => $form_field[ 'type' ], |
|
1512 | 1512 | ); |
1513 | 1513 | |
1514 | 1514 | // collect choices |
1515 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1516 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1517 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1518 | - $filter['choices'] = $form_field['choices']; |
|
1515 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1516 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1517 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1518 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1519 | 1519 | } |
1520 | 1520 | |
1521 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1522 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1521 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1522 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1523 | 1523 | } |
1524 | 1524 | |
1525 | 1525 | return $filter; |
@@ -1554,7 +1554,7 @@ discard block |
||
1554 | 1554 | * @param \GV\View $view The view. |
1555 | 1555 | */ |
1556 | 1556 | $text = apply_filters( 'gravityview/search/created_by/text', $user->display_name, $user, $view ); |
1557 | - $choices[] = array( |
|
1557 | + $choices[ ] = array( |
|
1558 | 1558 | 'value' => $user->ID, |
1559 | 1559 | 'text' => $text, |
1560 | 1560 | ); |
@@ -1574,9 +1574,9 @@ discard block |
||
1574 | 1574 | |
1575 | 1575 | $choices = array(); |
1576 | 1576 | foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { |
1577 | - $choices[] = array( |
|
1578 | - 'value' => $status['value'], |
|
1579 | - 'text' => $status['label'], |
|
1577 | + $choices[ ] = array( |
|
1578 | + 'value' => $status[ 'value' ], |
|
1579 | + 'text' => $status[ 'label' ], |
|
1580 | 1580 | ); |
1581 | 1581 | } |
1582 | 1582 | |
@@ -1628,7 +1628,7 @@ discard block |
||
1628 | 1628 | */ |
1629 | 1629 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1630 | 1630 | |
1631 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1631 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1632 | 1632 | |
1633 | 1633 | return $js_dependencies; |
1634 | 1634 | } |
@@ -1672,7 +1672,7 @@ discard block |
||
1672 | 1672 | 'isRTL' => is_rtl(), |
1673 | 1673 | ), $view_data ); |
1674 | 1674 | |
1675 | - $localizations['datepicker'] = $datepicker_settings; |
|
1675 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1676 | 1676 | |
1677 | 1677 | return $localizations; |
1678 | 1678 | |
@@ -1699,7 +1699,7 @@ discard block |
||
1699 | 1699 | * @return void |
1700 | 1700 | */ |
1701 | 1701 | private function maybe_enqueue_flexibility() { |
1702 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1702 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1703 | 1703 | wp_enqueue_script( 'gv-flexibility' ); |
1704 | 1704 | } |
1705 | 1705 | } |
@@ -1721,7 +1721,7 @@ discard block |
||
1721 | 1721 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1722 | 1722 | |
1723 | 1723 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1724 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1724 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1725 | 1725 | |
1726 | 1726 | /** |
1727 | 1727 | * @filter `gravityview_search_datepicker_class` |
@@ -1800,7 +1800,7 @@ discard block |
||
1800 | 1800 | public function add_preview_inputs() { |
1801 | 1801 | global $wp; |
1802 | 1802 | |
1803 | - if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) { |
|
1803 | + if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) { |
|
1804 | 1804 | return; |
1805 | 1805 | } |
1806 | 1806 | |
@@ -1852,7 +1852,7 @@ discard block |
||
1852 | 1852 | */ |
1853 | 1853 | class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition { |
1854 | 1854 | public function __construct( $filter, $view ) { |
1855 | - $this->value = $filter['value']; |
|
1855 | + $this->value = $filter[ 'value' ]; |
|
1856 | 1856 | $this->view = $view; |
1857 | 1857 | } |
1858 | 1858 | |
@@ -1884,11 +1884,11 @@ discard block |
||
1884 | 1884 | $conditions = array(); |
1885 | 1885 | |
1886 | 1886 | foreach ( $user_fields as $user_field ) { |
1887 | - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1887 | + $conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1888 | 1888 | } |
1889 | 1889 | |
1890 | 1890 | foreach ( $user_meta_fields as $meta_field ) { |
1891 | - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1891 | + $conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
1892 | 1892 | } |
1893 | 1893 | |
1894 | 1894 | $conditions = '(' . implode( ' OR ', $conditions ) . ')'; |