Completed
Pull Request — develop (#1687)
by
unknown
16:12
created
includes/widgets/search-widget/class-search-widget.php 1 patch
Spacing   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 			'search_clear' => array(
56 56
 				'type'  => 'checkbox',
57 57
 				'label' => __( 'Show Clear button', 'gravityview' ),
58
-				'desc'  => __( 'When a search is performed, display a button that removes all search values.', 'gravityview'),
58
+				'desc'  => __( 'When a search is performed, display a button that removes all search values.', 'gravityview' ),
59 59
 				'value' => true,
60 60
 			),
61 61
 			'search_fields' => array(
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 				'type' => 'radio',
69 69
 				'full_width' => true,
70 70
 				'label' => esc_html__( 'Search Mode', 'gravityview' ),
71
-				'desc' => __('Should search results match all search fields, or any?', 'gravityview'),
71
+				'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ),
72 72
 				'value' => 'any',
73 73
 				'class' => 'hide-if-js',
74 74
 				'options' => array(
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
 			// admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999
89 89
 			add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 );
90
-			add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') );
90
+			add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) );
91 91
 			add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) );
92 92
 
93 93
 			// ajax - get the searchable fields
@@ -123,19 +123,19 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	public function add_reserved_args( $args ) {
125 125
 
126
-		$args[] = 'gv_search';
127
-		$args[] = 'gv_start';
128
-		$args[] = 'gv_end';
129
-		$args[] = 'gv_id';
130
-		$args[] = 'gv_by';
131
-		$args[] = 'mode';
126
+		$args[ ] = 'gv_search';
127
+		$args[ ] = 'gv_start';
128
+		$args[ ] = 'gv_end';
129
+		$args[ ] = 'gv_id';
130
+		$args[ ] = 'gv_by';
131
+		$args[ ] = 'mode';
132 132
 
133
-		$get = (array) $_GET;
133
+		$get = (array)$_GET;
134 134
 
135 135
 		// If the fields being searched as reserved; not to be considered user-passed variables
136 136
 		foreach ( $get as $key => $value ) {
137 137
 			if ( $key !== $this->convert_request_key_to_filter_key( $key ) ) {
138
-				$args[] = $key;
138
+				$args[ ] = $key;
139 139
 			}
140 140
 		}
141 141
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		$script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
260 260
 		$script_source = empty( $script_min ) ? '/source' : '';
261 261
 
262
-		wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version );
262
+		wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version );
263 263
 
264 264
 		wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array(
265 265
 			'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ),
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 	 * @return array Scripts allowed in no-conflict mode, plus the search widget script
282 282
 	 */
283 283
 	public function register_no_conflict( $allowed ) {
284
-		$allowed[] = 'gravityview_searchwidget_admin';
284
+		$allowed[ ] = 'gravityview_searchwidget_admin';
285 285
 		return $allowed;
286 286
 	}
287 287
 
@@ -293,24 +293,24 @@  discard block
 block discarded – undo
293 293
 	 */
294 294
 	public static function get_searchable_fields() {
295 295
 
296
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) {
296
+		if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) {
297 297
 			exit( '0' );
298 298
 		}
299 299
 
300 300
 		$form = '';
301 301
 
302 302
 		// Fetch the form for the current View
303
-		if ( ! empty( $_POST['view_id'] ) ) {
303
+		if ( ! empty( $_POST[ 'view_id' ] ) ) {
304 304
 
305
-			$form = gravityview_get_form_id( $_POST['view_id'] );
305
+			$form = gravityview_get_form_id( $_POST[ 'view_id' ] );
306 306
 
307
-		} elseif ( ! empty( $_POST['formid'] ) ) {
307
+		} elseif ( ! empty( $_POST[ 'formid' ] ) ) {
308 308
 
309
-			$form = (int) $_POST['formid'];
309
+			$form = (int)$_POST[ 'formid' ];
310 310
 
311
-		} elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) {
311
+		} elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) {
312 312
 
313
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
313
+			$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
314 314
 
315 315
 		}
316 316
 
@@ -360,14 +360,14 @@  discard block
 block discarded – undo
360 360
 		);
361 361
 
362 362
 		if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) {
363
-			$custom_fields['is_approved'] = array(
363
+			$custom_fields[ 'is_approved' ] = array(
364 364
 				'text' => esc_html__( 'Approval Status', 'gravityview' ),
365 365
 				'type' => 'multi',
366 366
 			);
367 367
 		}
368 368
 
369
-		foreach( $custom_fields as $custom_field_key => $custom_field ) {
370
-			$output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] );
369
+		foreach ( $custom_fields as $custom_field_key => $custom_field ) {
370
+			$output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] );
371 371
 		}
372 372
 
373 373
 		// Get fields with sub-inputs and no parent
@@ -389,13 +389,13 @@  discard block
 block discarded – undo
389 389
 
390 390
 			foreach ( $fields as $id => $field ) {
391 391
 
392
-				if ( in_array( $field['type'], $blocklist_field_types ) ) {
392
+				if ( in_array( $field[ 'type' ], $blocklist_field_types ) ) {
393 393
 					continue;
394 394
 				}
395 395
 
396
-				$types = self::get_search_input_types( $id, $field['type'] );
396
+				$types = self::get_search_input_types( $id, $field[ 'type' ] );
397 397
 
398
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>';
398
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>';
399 399
 			}
400 400
 		}
401 401
 
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	public static function get_search_input_types( $field_id = '', $field_type = null ) {
419 419
 
420 420
 		// @todo - This needs to be improved - many fields have . including products and addresses
421
-		if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) {
421
+		if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) {
422 422
 			$input_type = 'boolean'; // on/off checkbox
423 423
 		} elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) {
424 424
 			$input_type = 'multi'; //multiselect
@@ -464,19 +464,19 @@  discard block
 block discarded – undo
464 464
 			$post_id = 0;
465 465
 
466 466
 			// We're in the WordPress Widget context, and an overriding post ID has been set.
467
-			if ( ! empty( $widget_args['post_id'] ) ) {
468
-				$post_id = absint( $widget_args['post_id'] );
467
+			if ( ! empty( $widget_args[ 'post_id' ] ) ) {
468
+				$post_id = absint( $widget_args[ 'post_id' ] );
469 469
 			}
470 470
 			// We're in the WordPress Widget context, and the base View ID should be used
471
-			else if ( ! empty( $widget_args['view_id'] ) ) {
472
-				$post_id = absint( $widget_args['view_id'] );
471
+			else if ( ! empty( $widget_args[ 'view_id' ] ) ) {
472
+				$post_id = absint( $widget_args[ 'view_id' ] );
473 473
 			}
474 474
 
475 475
 			$args = gravityview_get_permalink_query_args( $post_id );
476 476
 
477 477
 			// Add hidden fields to the search form
478 478
 			foreach ( $args as $key => $value ) {
479
-				$search_fields[] = array(
479
+				$search_fields[ ] = array(
480 480
 					'name'  => $key,
481 481
 					'input' => 'hidden',
482 482
 					'value' => $value,
@@ -515,28 +515,28 @@  discard block
 block discarded – undo
515 515
 		/**
516 516
 		 * Include the sidebar Widgets.
517 517
 		 */
518
-		$widgets = (array) get_option( 'widget_gravityview_search', array() );
518
+		$widgets = (array)get_option( 'widget_gravityview_search', array() );
519 519
 
520 520
 		foreach ( $widgets as $widget ) {
521
-			if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) {
522
-				if( $_fields = json_decode( $widget['search_fields'], true ) ) {
521
+			if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) {
522
+				if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) {
523 523
 					foreach ( $_fields as $field ) {
524
-						if ( empty( $field['form_id'] ) ) {
525
-							$field['form_id'] = $view->form ? $view->form->ID : 0;
524
+						if ( empty( $field[ 'form_id' ] ) ) {
525
+							$field[ 'form_id' ] = $view->form ? $view->form->ID : 0;
526 526
 						}
527
-						$searchable_fields[] = $with_full_field ? $field : $field['field'];
527
+						$searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ];
528 528
 					}
529 529
 				}
530 530
 			}
531 531
 		}
532 532
 
533 533
 		foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) {
534
-			if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) {
534
+			if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) {
535 535
 				foreach ( $_fields as $field ) {
536
-					if ( empty( $field['form_id'] ) ) {
537
-						$field['form_id'] = $view->form ? $view->form->ID : 0;
536
+					if ( empty( $field[ 'form_id' ] ) ) {
537
+						$field[ 'form_id' ] = $view->form ? $view->form->ID : 0;
538 538
 					}
539
-					$searchable_fields[] = $with_full_field ? $field : $field['field'];
539
+					$searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ];
540 540
 				}
541 541
 			}
542 542
 		}
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 			return $search_criteria; // Return the original criteria, GF_Query modification kicks in later
583 583
 		}
584 584
 
585
-		if( 'post' === $this->search_method ) {
585
+		if ( 'post' === $this->search_method ) {
586 586
 			$get = $_POST;
587 587
 		} else {
588 588
 			$get = $_GET;
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		$get = gv_map_deep( $get, 'rawurldecode' );
602 602
 
603 603
 		// Make sure array key is set up
604
-		$search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() );
604
+		$search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() );
605 605
 
606 606
 		$searchable_fields = $this->get_view_searchable_fields( $view );
607 607
 		$searchable_field_objects = $this->get_view_searchable_fields( $view, true );
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
 		$trim_search_value = apply_filters( 'gravityview/search-trim-input', true );
622 622
 
623 623
 		// add free search
624
-		if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) {
624
+		if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) {
625 625
 
626
-			$search_all_value = $trim_search_value ? trim( $get['gv_search'] ) : $get['gv_search'];
626
+			$search_all_value = $trim_search_value ? trim( $get[ 'gv_search' ] ) : $get[ 'gv_search' ];
627 627
 
628 628
 			if ( $split_words ) {
629 629
 				// Search for a piece
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 			}
640 640
 
641 641
 			foreach ( $words as $word ) {
642
-				$search_criteria['field_filters'][] = array(
642
+				$search_criteria[ 'field_filters' ][ ] = array(
643 643
 					'key' => null, // The field ID to search
644 644
 					'value' => $word, // The value to search
645 645
 					'operator' => 'contains', // What to search in. Options: `is` or `contains`
@@ -652,14 +652,14 @@  discard block
 block discarded – undo
652 652
 			/**
653 653
 			 * Get and normalize the dates according to the input format.
654 654
 			 */
655
-			if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) {
656
-				if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) {
655
+			if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) {
656
+				if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) {
657 657
 					$curr_start = $curr_start_date->format( 'Y-m-d' );
658 658
 				}
659 659
 			}
660 660
 
661
-			if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) {
662
-				if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) {
661
+			if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) {
662
+				if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) {
663 663
 					$curr_end = $curr_end_date->format( 'Y-m-d' );
664 664
 				}
665 665
 			}
@@ -695,22 +695,22 @@  discard block
 block discarded – undo
695 695
 			 */
696 696
 			if ( ! empty( $curr_start ) ) {
697 697
 				$curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) );
698
-				$search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
698
+				$search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
699 699
 			}
700 700
 
701 701
 			if ( ! empty( $curr_end ) ) {
702 702
 				// Fast-forward 24 hour on the end time
703 703
 				$curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS );
704
-				$search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
705
-				if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056
706
-					$search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 );
704
+				$search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
705
+				if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056
706
+					$search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 );
707 707
 				}
708 708
 			}
709 709
 		}
710 710
 
711 711
 		// search for a specific entry ID
712 712
 		if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) {
713
-			$search_criteria['field_filters'][] = array(
713
+			$search_criteria[ 'field_filters' ][ ] = array(
714 714
 				'key' => 'id',
715 715
 				'value' => absint( $get[ 'gv_id' ] ),
716 716
 				'operator' => $this->get_operator( $get, 'gv_id', array( '=' ), '=' ),
@@ -719,15 +719,15 @@  discard block
 block discarded – undo
719 719
 
720 720
 		// search for a specific Created_by ID
721 721
 		if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) {
722
-			$search_criteria['field_filters'][] = array(
722
+			$search_criteria[ 'field_filters' ][ ] = array(
723 723
 				'key' => 'created_by',
724
-				'value' => $get['gv_by'],
724
+				'value' => $get[ 'gv_by' ],
725 725
 				'operator' => $this->get_operator( $get, 'gv_by', array( '=' ), '=' ),
726 726
 			);
727 727
 		}
728 728
 
729 729
 		// Get search mode passed in URL
730
-		$mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ?  $get['mode'] : 'any';
730
+		$mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any';
731 731
 
732 732
 		// get the other search filters
733 733
 		foreach ( $get as $key => $value ) {
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 				$value = is_array( $value ) ? array_map( 'trim', $value ) : trim( $value );
740 740
 			}
741 741
 
742
-			if ( gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) {
742
+			if ( gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) {
743 743
 				if ( is_array( $value ) ) {
744 744
 					continue;
745 745
 				}
@@ -757,21 +757,21 @@  discard block
 block discarded – undo
757 757
 				continue;
758 758
 			}
759 759
 
760
-			if ( ! isset( $filter['operator'] ) ) {
761
-				$filter['operator'] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' );
760
+			if ( ! isset( $filter[ 'operator' ] ) ) {
761
+				$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' );
762 762
 			}
763 763
 
764
-			if ( isset( $filter[0]['value'] ) ) {
765
-				$filter[0]['value'] = $trim_search_value ? trim( $filter[0]['value'] ) : $filter[0]['value'];
764
+			if ( isset( $filter[ 0 ][ 'value' ] ) ) {
765
+				$filter[ 0 ][ 'value' ] = $trim_search_value ? trim( $filter[ 0 ][ 'value' ] ) : $filter[ 0 ][ 'value' ];
766 766
 
767
-				$search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter );
767
+				$search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter );
768 768
 
769 769
 				// if date range type, set search mode to ALL
770
-				if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) {
770
+				if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) {
771 771
 					$mode = 'all';
772 772
 				}
773
-			} elseif( !empty( $filter ) ) {
774
-				$search_criteria['field_filters'][] = $filter;
773
+			} elseif ( ! empty( $filter ) ) {
774
+				$search_criteria[ 'field_filters' ][ ] = $filter;
775 775
 			}
776 776
 		}
777 777
 
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 		 * @since 1.5.1
781 781
 		 * @param[out,in] string $mode Search mode (`any` vs `all`)
782 782
 		 */
783
-		$search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode );
783
+		$search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode );
784 784
 
785 785
 		gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) );
786 786
 
@@ -814,19 +814,19 @@  discard block
 block discarded – undo
814 814
 
815 815
 		$query_class = $view->get_query_class();
816 816
 
817
-		if ( empty( $search_criteria['field_filters'] ) ) {
817
+		if ( empty( $search_criteria[ 'field_filters' ] ) ) {
818 818
 			return;
819 819
 		}
820 820
 
821 821
 		$widgets = $view->widgets->by_id( $this->widget_id );
822 822
 		if ( $widgets->count() ) {
823 823
 			$widgets = $widgets->all();
824
-			$widget  = $widgets[0];
824
+			$widget  = $widgets[ 0 ];
825 825
 
826 826
 			$search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true );
827 827
 
828
-			foreach ( (array) $search_fields as $search_field ) {
829
-				if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) {
828
+			foreach ( (array)$search_fields as $search_field ) {
829
+				if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) {
830 830
 					$created_by_text_mode = true;
831 831
 				}
832 832
 			}
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 		$extra_conditions = array();
836 836
 		$mode = 'any';
837 837
 
838
-		foreach ( $search_criteria['field_filters'] as $key => &$filter ) {
838
+		foreach ( $search_criteria[ 'field_filters' ] as $key => &$filter ) {
839 839
 			if ( ! is_array( $filter ) ) {
840 840
 				if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) {
841 841
 					$mode = $filter;
@@ -844,13 +844,13 @@  discard block
 block discarded – undo
844 844
 			}
845 845
 
846 846
 			// Construct a manual query for unapproved statuses
847
-			if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) {
848
-				$_tmp_query       = new $query_class( $view->form->ID, array(
847
+			if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) {
848
+				$_tmp_query = new $query_class( $view->form->ID, array(
849 849
 					'field_filters' => array(
850 850
 						array(
851 851
 							'operator' => 'in',
852 852
 							'key'      => 'is_approved',
853
-							'value'    => (array) $filter['value'],
853
+							'value'    => (array)$filter[ 'value' ],
854 854
 						),
855 855
 						array(
856 856
 							'operator' => 'is',
@@ -862,30 +862,30 @@  discard block
 block discarded – undo
862 862
 				) );
863 863
 				$_tmp_query_parts = $_tmp_query->_introspect();
864 864
 
865
-				$extra_conditions[] = $_tmp_query_parts['where'];
865
+				$extra_conditions[ ] = $_tmp_query_parts[ 'where' ];
866 866
 
867 867
 				$filter = false;
868 868
 				continue;
869 869
 			}
870 870
 
871 871
 			// Construct manual query for text mode creator search
872
-			if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) {
873
-				$extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view );
872
+			if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) {
873
+				$extra_conditions[ ] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view );
874 874
 				$filter = false;
875 875
 				continue;
876 876
 			}
877 877
 
878 878
 			// By default, we want searches to be wildcard for each field.
879
-			$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
879
+			$filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];
880 880
 
881 881
 			// For multichoice, let's have an in (OR) search.
882
-			if ( is_array( $filter['value'] ) ) {
883
-				$filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)?
882
+			if ( is_array( $filter[ 'value' ] ) ) {
883
+				$filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)?
884 884
 			}
885 885
 
886 886
 			// Default form with joins functionality
887
-			if ( empty( $filter['form_id'] ) ) {
888
-				$filter['form_id'] = $view->form ? $view->form->ID : 0;
887
+			if ( empty( $filter[ 'form_id' ] ) ) {
888
+				$filter[ 'form_id' ] = $view->form ? $view->form->ID : 0;
889 889
 			}
890 890
 
891 891
 			/**
@@ -895,32 +895,32 @@  discard block
 block discarded – undo
895 895
 			 * @param array $filter array with `key`, `value`, `operator`, `type` keys
896 896
 			 * @param \GV\View $view The View we're operating on.
897 897
 			 */
898
-			$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter, $view );
898
+			$filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter, $view );
899 899
 
900
-			if ( 'is' !== $filter['operator'] && '' === $filter['value'] ) {
901
-				unset( $search_criteria['field_filters'][ $key ] );
900
+			if ( 'is' !== $filter[ 'operator' ] && '' === $filter[ 'value' ] ) {
901
+				unset( $search_criteria[ 'field_filters' ][ $key ] );
902 902
 			}
903 903
 		}
904 904
 
905
-		if ( ! empty( $search_criteria['start_date'] ) || ! empty( $search_criteria['end_date'] ) ) {
905
+		if ( ! empty( $search_criteria[ 'start_date' ] ) || ! empty( $search_criteria[ 'end_date' ] ) ) {
906 906
 			$date_criteria = array();
907 907
 
908
-			if ( isset( $search_criteria['start_date'] ) ) {
909
-				$date_criteria['start_date'] = $search_criteria['start_date'];
908
+			if ( isset( $search_criteria[ 'start_date' ] ) ) {
909
+				$date_criteria[ 'start_date' ] = $search_criteria[ 'start_date' ];
910 910
 			}
911 911
 
912
-			if ( isset( $search_criteria['end_date'] ) ) {
913
-				$date_criteria['end_date'] = $search_criteria['end_date'];
912
+			if ( isset( $search_criteria[ 'end_date' ] ) ) {
913
+				$date_criteria[ 'end_date' ] = $search_criteria[ 'end_date' ];
914 914
 			}
915 915
 
916 916
 			$_tmp_query         = new $query_class( $view->form->ID, $date_criteria );
917 917
 			$_tmp_query_parts   = $_tmp_query->_introspect();
918
-			$extra_conditions[] = $_tmp_query_parts['where'];
918
+			$extra_conditions[ ] = $_tmp_query_parts[ 'where' ];
919 919
 		}
920 920
 
921 921
 		$search_conditions = array();
922 922
 
923
-		if ( $filters = array_filter( $search_criteria['field_filters'] ) ) {
923
+		if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) {
924 924
 			foreach ( $filters as &$filter ) {
925 925
 				if ( ! is_array( $filter ) ) {
926 926
 					continue;
@@ -932,12 +932,12 @@  discard block
 block discarded – undo
932 932
 				 * code by reusing what's inside GF_Query already as they
933 933
 				 * take care of many small things like forcing numeric, etc.
934 934
 				 */
935
-				$_tmp_query       = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) );
935
+				$_tmp_query       = new $query_class( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) );
936 936
 				$_tmp_query_parts = $_tmp_query->_introspect();
937
-				$search_condition = $_tmp_query_parts['where'];
937
+				$search_condition = $_tmp_query_parts[ 'where' ];
938 938
 
939
-				if ( empty( $filter['key'] ) && $search_condition->expressions ) {
940
-					$search_conditions[] = $search_condition;
939
+				if ( empty( $filter[ 'key' ] ) && $search_condition->expressions ) {
940
+					$search_conditions[ ] = $search_condition;
941 941
 				} else {
942 942
 					$left = $search_condition->left;
943 943
 
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
 
950 950
 							$value = $reflectionProperty->getValue( $left );
951 951
 
952
-							if ( ! empty( $value[0] ) && $value[0] instanceof GF_Query_Column ) {
953
-								$left = $value[0];
952
+							if ( ! empty( $value[ 0 ] ) && $value[ 0 ] instanceof GF_Query_Column ) {
953
+								$left = $value[ 0 ];
954 954
 							} else {
955 955
 								continue;
956 956
 							}
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
 							$on = $_join->join_on;
967 967
 							$join = $_join->join;
968 968
 
969
-							$search_conditions[] = GF_Query_Condition::_or(
969
+							$search_conditions[ ] = GF_Query_Condition::_or(
970 970
 								// Join
971 971
 								new GF_Query_Condition(
972 972
 									new GF_Query_Column( GF_Query_Column::META, $join->ID, $query->_alias( GF_Query_Column::META, $join->ID, 'm' ) ),
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 							);
983 983
 						}
984 984
 					} else {
985
-						$search_conditions[] = new GF_Query_Condition(
985
+						$search_conditions[ ] = new GF_Query_Condition(
986 986
 							new GF_Query_Column( $left->field_id, $left->source, $alias ),
987 987
 							$search_condition->operator,
988 988
 							$search_condition->right
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 		/**
1005 1005
 		 * Combine the parts as a new WHERE clause.
1006 1006
 		 */
1007
-		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) );
1007
+		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) );
1008 1008
 		$query->where( $where );
1009 1009
 	}
1010 1010
 
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 		$field_id = str_replace( 'filter_', '', $key );
1028 1028
 
1029 1029
 		// calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox )
1030
-		if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) {
1030
+		if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) {
1031 1031
 			$field_id = str_replace( '_', '.', $field_id );
1032 1032
 		}
1033 1033
 
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
 			// form is in searchable fields
1085 1085
 			$found = false;
1086 1086
 			foreach ( $searchable_fields as $field ) {
1087
-				if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) {
1087
+				if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) {
1088 1088
 					$found = true;
1089 1089
 					break;
1090 1090
 				}
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 
1125 1125
 			case 'select':
1126 1126
 			case 'radio':
1127
-				$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1127
+				$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1128 1128
 				break;
1129 1129
 
1130 1130
 			case 'post_category':
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
 
1139 1139
 				foreach ( $value as $val ) {
1140 1140
 					$cat = get_term( $val, 'category' );
1141
-					$filter[] = array(
1141
+					$filter[ ] = array(
1142 1142
 						'key'      => $field_id,
1143 1143
 						'value'    => esc_attr( $cat->name ) . ':' . $val,
1144 1144
 						'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ),
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 				$filter = array();
1158 1158
 
1159 1159
 				foreach ( $value as $val ) {
1160
-					$filter[] = array( 'key' => $field_id, 'value' => $val );
1160
+					$filter[ ] = array( 'key' => $field_id, 'value' => $val );
1161 1161
 				}
1162 1162
 
1163 1163
 				break;
@@ -1166,9 +1166,9 @@  discard block
 block discarded – undo
1166 1166
 				// convert checkbox on/off into the correct search filter
1167 1167
 				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) {
1168 1168
 					foreach ( $form_field->inputs as $k => $input ) {
1169
-						if ( $input['id'] == $field_id ) {
1170
-							$filter['value'] = $form_field->choices[ $k ]['value'];
1171
-							$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1169
+						if ( $input[ 'id' ] == $field_id ) {
1170
+							$filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ];
1171
+							$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1172 1172
 							break;
1173 1173
 						}
1174 1174
 					}
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
 					$filter = array();
1179 1179
 
1180 1180
 					foreach ( $value as $val ) {
1181
-						$filter[] = array(
1181
+						$filter[ ] = array(
1182 1182
 							'key'      => $field_id,
1183 1183
 							'value'    => $val,
1184 1184
 							'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ),
@@ -1199,9 +1199,9 @@  discard block
 block discarded – undo
1199 1199
 					foreach ( $words as $word ) {
1200 1200
 						if ( ! empty( $word ) && strlen( $word ) > 1 ) {
1201 1201
 							// Keep the same key for each filter
1202
-							$filter['value'] = $word;
1202
+							$filter[ 'value' ] = $word;
1203 1203
 							// Add a search for the value
1204
-							$filters[] = $filter;
1204
+							$filters[ ] = $filter;
1205 1205
 						}
1206 1206
 					}
1207 1207
 
@@ -1215,19 +1215,19 @@  discard block
 block discarded – undo
1215 1215
 
1216 1216
 					foreach ( $searchable_fields as $searchable_field ) {
1217 1217
 
1218
-						if( $form_field->ID !== $searchable_field['field'] ) {
1218
+						if ( $form_field->ID !== $searchable_field[ 'field' ] ) {
1219 1219
 							continue;
1220 1220
 						}
1221 1221
 
1222 1222
 						// Only exact-match dropdowns, not text search
1223
-						if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) {
1223
+						if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) {
1224 1224
 							continue;
1225 1225
 						}
1226 1226
 
1227 1227
 						$input_id = gravityview_get_input_id_from_id( $form_field->ID );
1228 1228
 
1229 1229
 						if ( 4 === $input_id ) {
1230
-							$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1230
+							$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1231 1231
 						};
1232 1232
 					}
1233 1233
 				}
@@ -1255,12 +1255,12 @@  discard block
 block discarded – undo
1255 1255
 						 * @since 1.16.3
1256 1256
 						 * Safeguard until GF implements '<=' operator
1257 1257
 						 */
1258
-						if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1258
+						if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1259 1259
 							$operator = '<';
1260 1260
 							$date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) );
1261 1261
 						}
1262 1262
 
1263
-						$filter[] = array(
1263
+						$filter[ ] = array(
1264 1264
 							'key'      => $field_id,
1265 1265
 							'value'    => self::get_formatted_date( $date, 'Y-m-d', $date_format ),
1266 1266
 							'operator' => $this->get_operator( $get, $key, array( $operator ), $operator ),
@@ -1268,12 +1268,12 @@  discard block
 block discarded – undo
1268 1268
 					}
1269 1269
 				} else {
1270 1270
 					$date = $value;
1271
-					$filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1272
-					$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1271
+					$filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1272
+					$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1273 1273
 				}
1274 1274
 
1275
-				if ('payment_date' === $key) {
1276
-					$filter['operator'] = 'contains';
1275
+				if ( 'payment_date' === $key ) {
1276
+					$filter[ 'operator' ] = 'contains';
1277 1277
 				}
1278 1278
 
1279 1279
 				break;
@@ -1302,7 +1302,7 @@  discard block
 block discarded – undo
1302 1302
 			'ymd_dot' => 'Y.m.d',
1303 1303
 		);
1304 1304
 
1305
-		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){
1305
+		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) {
1306 1306
 			$format = $datepicker[ $field->dateFormat ];
1307 1307
 		}
1308 1308
 
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 	public function add_template_path( $file_paths ) {
1340 1340
 
1341 1341
 		// Index 100 is the default GravityView template path.
1342
-		$file_paths[102] = self::$file . 'templates/';
1342
+		$file_paths[ 102 ] = self::$file . 'templates/';
1343 1343
 
1344 1344
 		return $file_paths;
1345 1345
 	}
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
 		$has_date = false;
1359 1359
 
1360 1360
 		foreach ( $search_fields as $k => $field ) {
1361
-			if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) {
1361
+			if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) {
1362 1362
 				$has_date = true;
1363 1363
 				break;
1364 1364
 			}
@@ -1387,7 +1387,7 @@  discard block
 block discarded – undo
1387 1387
 		$view = \GV\View::by_id( $gravityview_view->view_id );
1388 1388
 
1389 1389
 		// get configured search fields
1390
-		$search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : '';
1390
+		$search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : '';
1391 1391
 
1392 1392
 		if ( empty( $search_fields ) || ! is_array( $search_fields ) ) {
1393 1393
 			gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) );
@@ -1401,39 +1401,39 @@  discard block
 block discarded – undo
1401 1401
 
1402 1402
 			$updated_field = $this->get_search_filter_details( $updated_field, $context );
1403 1403
 
1404
-			switch ( $field['field'] ) {
1404
+			switch ( $field[ 'field' ] ) {
1405 1405
 
1406 1406
 				case 'search_all':
1407
-					$updated_field['key'] = 'search_all';
1408
-					$updated_field['input'] = 'search_all';
1409
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' );
1407
+					$updated_field[ 'key' ] = 'search_all';
1408
+					$updated_field[ 'input' ] = 'search_all';
1409
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' );
1410 1410
 					break;
1411 1411
 
1412 1412
 				case 'entry_date':
1413
-					$updated_field['key'] = 'entry_date';
1414
-					$updated_field['input'] = 'entry_date';
1415
-					$updated_field['value'] = array(
1413
+					$updated_field[ 'key' ] = 'entry_date';
1414
+					$updated_field[ 'input' ] = 'entry_date';
1415
+					$updated_field[ 'value' ] = array(
1416 1416
 						'start' => $this->rgget_or_rgpost( 'gv_start' ),
1417 1417
 						'end' => $this->rgget_or_rgpost( 'gv_end' ),
1418 1418
 					);
1419 1419
 					break;
1420 1420
 
1421 1421
 				case 'entry_id':
1422
-					$updated_field['key'] = 'entry_id';
1423
-					$updated_field['input'] = 'entry_id';
1424
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' );
1422
+					$updated_field[ 'key' ] = 'entry_id';
1423
+					$updated_field[ 'input' ] = 'entry_id';
1424
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' );
1425 1425
 					break;
1426 1426
 
1427 1427
 				case 'created_by':
1428
-					$updated_field['key'] = 'created_by';
1429
-					$updated_field['name'] = 'gv_by';
1430
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' );
1428
+					$updated_field[ 'key' ] = 'created_by';
1429
+					$updated_field[ 'name' ] = 'gv_by';
1430
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' );
1431 1431
 					break;
1432 1432
 
1433 1433
 				case 'is_approved':
1434
-					$updated_field['key'] = 'is_approved';
1435
-					$updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' );
1436
-					$updated_field['choices'] = self::get_is_approved_choices();
1434
+					$updated_field[ 'key' ] = 'is_approved';
1435
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' );
1436
+					$updated_field[ 'choices' ] = self::get_is_approved_choices();
1437 1437
 					break;
1438 1438
 			}
1439 1439
 
@@ -1454,16 +1454,16 @@  discard block
 block discarded – undo
1454 1454
 
1455 1455
 		$gravityview_view->permalink_fields = $this->add_no_permalink_fields( array(), $this, $widget_args );
1456 1456
 
1457
-		$gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal';
1457
+		$gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal';
1458 1458
 
1459 1459
 		/** @since 1.14 */
1460
-		$gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any';
1460
+		$gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any';
1461 1461
 
1462
-		$custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : '';
1462
+		$custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : '';
1463 1463
 
1464 1464
 		$gravityview_view->search_class = self::get_search_class( $custom_class );
1465 1465
 
1466
-		$gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false;
1466
+		$gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false;
1467 1467
 
1468 1468
 		if ( $this->has_date_field( $search_fields ) ) {
1469 1469
 			// enqueue datepicker stuff only if needed!
@@ -1485,10 +1485,10 @@  discard block
 block discarded – undo
1485 1485
 	public static function get_search_class( $custom_class = '' ) {
1486 1486
 		$gravityview_view = GravityView_View::getInstance();
1487 1487
 
1488
-		$search_class = 'gv-search-'.$gravityview_view->search_layout;
1488
+		$search_class = 'gv-search-' . $gravityview_view->search_layout;
1489 1489
 
1490
-		if ( ! empty( $custom_class )  ) {
1491
-			$search_class .= ' '.$custom_class;
1490
+		if ( ! empty( $custom_class ) ) {
1491
+			$search_class .= ' ' . $custom_class;
1492 1492
 		}
1493 1493
 
1494 1494
 		/**
@@ -1539,9 +1539,9 @@  discard block
 block discarded – undo
1539 1539
 
1540 1540
 		if ( ! $label ) {
1541 1541
 
1542
-			$label = isset( $form_field['label'] ) ? $form_field['label'] : '';
1542
+			$label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : '';
1543 1543
 
1544
-			switch( $field['field'] ) {
1544
+			switch ( $field[ 'field' ] ) {
1545 1545
 				case 'search_all':
1546 1546
 					$label = __( 'Search Entries:', 'gravityview' );
1547 1547
 					break;
@@ -1553,10 +1553,10 @@  discard block
 block discarded – undo
1553 1553
 					break;
1554 1554
 				default:
1555 1555
 					// If this is a field input, not a field
1556
-					if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) {
1556
+					if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) {
1557 1557
 
1558 1558
 						// Get the label for the field in question, which returns an array
1559
-						$items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) );
1559
+						$items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) );
1560 1560
 
1561 1561
 						// Get the item with the `label` key
1562 1562
 						$values = wp_list_pluck( $items, 'label' );
@@ -1597,13 +1597,13 @@  discard block
 block discarded – undo
1597 1597
 		$form = $gravityview_view->getForm();
1598 1598
 
1599 1599
 		// for advanced field ids (eg, first name / last name )
1600
-		$name = 'filter_' . str_replace( '.', '_', $field['field'] );
1600
+		$name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] );
1601 1601
 
1602 1602
 		// get searched value from $_GET/$_POST (string or array)
1603 1603
 		$value = $this->rgget_or_rgpost( $name );
1604 1604
 
1605 1605
 		// get form field details
1606
-		$form_field = gravityview_get_field( $form, $field['field'] );
1606
+		$form_field = gravityview_get_field( $form, $field[ 'field' ] );
1607 1607
 
1608 1608
 		$form_field_type = \GV\Utils::get( $form_field, 'type' );
1609 1609
 
@@ -1617,22 +1617,22 @@  discard block
 block discarded – undo
1617 1617
 		);
1618 1618
 
1619 1619
 		// collect choices
1620
-		if ( 'post_category' === $form_field_type && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) {
1621
-			$filter['choices'] = gravityview_get_terms_choices();
1622
-		} elseif ( ! empty( $form_field['choices'] ) ) {
1623
-			$filter['choices'] = $form_field['choices'];
1620
+		if ( 'post_category' === $form_field_type && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) {
1621
+			$filter[ 'choices' ] = gravityview_get_terms_choices();
1622
+		} elseif ( ! empty( $form_field[ 'choices' ] ) ) {
1623
+			$filter[ 'choices' ] = $form_field[ 'choices' ];
1624 1624
 		}
1625 1625
 
1626
-		if ( 'date_range' === $field['input'] && empty( $value ) ) {
1627
-			$filter['value'] = array( 'start' => '', 'end' => '' );
1626
+		if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) {
1627
+			$filter[ 'value' ] = array( 'start' => '', 'end' => '' );
1628 1628
 		}
1629 1629
 
1630
-		if ( 'created_by' === $field['field'] ) {
1631
-			$filter['choices'] = self::get_created_by_choices( $context->view );
1632
-			$filter['type'] = 'created_by';
1630
+		if ( 'created_by' === $field[ 'field' ] ) {
1631
+			$filter[ 'choices' ] = self::get_created_by_choices( $context->view );
1632
+			$filter[ 'type' ] = 'created_by';
1633 1633
 		}
1634 1634
 
1635
-		if ( ! empty( $filter['choices'] ) ) {
1635
+		if ( ! empty( $filter[ 'choices' ] ) ) {
1636 1636
 			/**
1637 1637
 			 * @filter `gravityview/search/sieve_choices` Only output used choices for this field.
1638 1638
 			 * @param[in,out] bool Yes or no.
@@ -1640,7 +1640,7 @@  discard block
 block discarded – undo
1640 1640
 			 * @param \GV\Context The context.
1641 1641
 			 */
1642 1642
 			if ( apply_filters( 'gravityview/search/sieve_choices', false, $field, $context ) ) {
1643
-				$filter['choices'] = $this->sieve_filter_choices( $filter, $context );
1643
+				$filter[ 'choices' ] = $this->sieve_filter_choices( $filter, $context );
1644 1644
 			}
1645 1645
 		}
1646 1646
 
@@ -1669,12 +1669,12 @@  discard block
 block discarded – undo
1669 1669
 	 * @return array The filter choices.
1670 1670
 	 */
1671 1671
 	private function sieve_filter_choices( $filter, $context ) {
1672
-		if ( empty( $filter['key'] ) || empty( $filter['choices'] ) ) {
1672
+		if ( empty( $filter[ 'key' ] ) || empty( $filter[ 'choices' ] ) ) {
1673 1673
 			return $filter; // @todo Populate plugins might give us empty choices
1674 1674
 		}
1675 1675
 
1676 1676
 		// Allow only created_by and field-ids to be sieved.
1677
-		if ( 'created_by' !== $filter['key'] && ! is_numeric( $filter['key'] ) ) {
1677
+		if ( 'created_by' !== $filter[ 'key' ] && ! is_numeric( $filter[ 'key' ] ) ) {
1678 1678
 			return $filter;
1679 1679
 		}
1680 1680
 
@@ -1685,13 +1685,13 @@  discard block
 block discarded – undo
1685 1685
 		$entry_table_name = GFFormsModel::get_entry_table_name();
1686 1686
 		$entry_meta_table_name = GFFormsModel::get_entry_meta_table_name();
1687 1687
 
1688
-		$key_like = $wpdb->esc_like( $filter['key'] ) . '.%';
1688
+		$key_like = $wpdb->esc_like( $filter[ 'key' ] ) . '.%';
1689 1689
 
1690 1690
 		switch ( \GV\Utils::get( $filter, 'type' ) ):
1691 1691
 			case 'post_category':
1692 1692
 				$choices = $wpdb->get_col( $wpdb->prepare(
1693 1693
 					"SELECT DISTINCT SUBSTRING_INDEX(meta_value, ':', 1) FROM $entry_meta_table_name WHERE (meta_key LIKE %s OR meta_key = %d) AND form_id = %d",
1694
-					$key_like, $filter['key'], $form_id
1694
+					$key_like, $filter[ 'key' ], $form_id
1695 1695
 				) );
1696 1696
 				break;
1697 1697
 			case 'created_by':
@@ -1703,17 +1703,17 @@  discard block
 block discarded – undo
1703 1703
 			default:
1704 1704
 				$choices = $wpdb->get_col( $wpdb->prepare(
1705 1705
 					"SELECT DISTINCT meta_value FROM $entry_meta_table_name WHERE (meta_key LIKE %s OR meta_key = %d) AND form_id = %d",
1706
-					$key_like, $filter['key'], $form_id
1706
+					$key_like, $filter[ 'key' ], $form_id
1707 1707
 				) );
1708 1708
 
1709
-				if ( ( $field = gravityview_get_field( $form_id, $filter['key'] ) ) && 'json' === $field->storageType ) {
1709
+				if ( ( $field = gravityview_get_field( $form_id, $filter[ 'key' ] ) ) && 'json' === $field->storageType ) {
1710 1710
 					$choices = array_map( 'json_decode', $choices );
1711 1711
 					$_choices_array = array();
1712 1712
 					foreach ( $choices as $choice ) {
1713 1713
 						if ( is_array( $choice ) ) {
1714 1714
 							$_choices_array = array_merge( $_choices_array, $choice );
1715 1715
 						} else {
1716
-							$_choices_array []= $choice;
1716
+							$_choices_array [ ] = $choice;
1717 1717
 						}
1718 1718
 					}
1719 1719
 					$choices = array_unique( $_choices_array );
@@ -1723,9 +1723,9 @@  discard block
 block discarded – undo
1723 1723
 		endswitch;
1724 1724
 
1725 1725
 		$filter_choices = array();
1726
-		foreach ( $filter['choices'] as $choice ) {
1727
-			if ( in_array( $choice['text'], $choices, true ) || in_array( $choice['value'], $choices, true ) ) {
1728
-				$filter_choices[] = $choice;
1726
+		foreach ( $filter[ 'choices' ] as $choice ) {
1727
+			if ( in_array( $choice[ 'text' ], $choices, true ) || in_array( $choice[ 'value' ], $choices, true ) ) {
1728
+				$filter_choices[ ] = $choice;
1729 1729
 			}
1730 1730
 		}
1731 1731
 
@@ -1760,7 +1760,7 @@  discard block
 block discarded – undo
1760 1760
 			 * @param \GV\View $view The view.
1761 1761
 			 */
1762 1762
 			$text = apply_filters( 'gravityview/search/created_by/text', $user->display_name, $user, $view );
1763
-			$choices[] = array(
1763
+			$choices[ ] = array(
1764 1764
 				'value' => $user->ID,
1765 1765
 				'text' => $text,
1766 1766
 			);
@@ -1780,9 +1780,9 @@  discard block
 block discarded – undo
1780 1780
 
1781 1781
 		$choices = array();
1782 1782
 		foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) {
1783
-			$choices[] = array(
1784
-				'value' => $status['value'],
1785
-				'text' => $status['label'],
1783
+			$choices[ ] = array(
1784
+				'value' => $status[ 'value' ],
1785
+				'text' => $status[ 'label' ],
1786 1786
 			);
1787 1787
 		}
1788 1788
 
@@ -1834,7 +1834,7 @@  discard block
 block discarded – undo
1834 1834
 	 */
1835 1835
 	public function add_datepicker_js_dependency( $js_dependencies ) {
1836 1836
 
1837
-		$js_dependencies[] = 'jquery-ui-datepicker';
1837
+		$js_dependencies[ ] = 'jquery-ui-datepicker';
1838 1838
 
1839 1839
 		return $js_dependencies;
1840 1840
 	}
@@ -1878,7 +1878,7 @@  discard block
 block discarded – undo
1878 1878
 			'isRTL'             => is_rtl(),
1879 1879
 		), $view_data );
1880 1880
 
1881
-		$localizations['datepicker'] = $datepicker_settings;
1881
+		$localizations[ 'datepicker' ] = $datepicker_settings;
1882 1882
 
1883 1883
 		return $localizations;
1884 1884
 
@@ -1905,7 +1905,7 @@  discard block
 block discarded – undo
1905 1905
 	 * @return void
1906 1906
 	 */
1907 1907
 	private function maybe_enqueue_flexibility() {
1908
-		if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) {
1908
+		if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
1909 1909
 			wp_enqueue_script( 'gv-flexibility' );
1910 1910
 		}
1911 1911
 	}
@@ -1927,7 +1927,7 @@  discard block
 block discarded – undo
1927 1927
 		add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 );
1928 1928
 
1929 1929
 		$scheme = is_ssl() ? 'https://' : 'http://';
1930
-		wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1930
+		wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1931 1931
 
1932 1932
 		/**
1933 1933
 		 * @filter `gravityview_search_datepicker_class`
@@ -2006,7 +2006,7 @@  discard block
 block discarded – undo
2006 2006
 	public function add_preview_inputs() {
2007 2007
 		global $wp;
2008 2008
 
2009
-		if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) {
2009
+		if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) {
2010 2010
 			return;
2011 2011
 		}
2012 2012
 
@@ -2064,7 +2064,7 @@  discard block
 block discarded – undo
2064 2064
  */
2065 2065
 class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition {
2066 2066
 	public function __construct( $filter, $view ) {
2067
-		$this->value = $filter['value'];
2067
+		$this->value = $filter[ 'value' ];
2068 2068
 		$this->view = $view;
2069 2069
 	}
2070 2070
 
@@ -2096,11 +2096,11 @@  discard block
 block discarded – undo
2096 2096
 		$conditions = array();
2097 2097
 
2098 2098
 		foreach ( $user_fields as $user_field ) {
2099
-			$conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) .  '%' );
2099
+			$conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' );
2100 2100
 		}
2101 2101
 
2102 2102
 		foreach ( $user_meta_fields as $meta_field ) {
2103
-			$conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) .  '%' );
2103
+			$conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' );
2104 2104
 		}
2105 2105
 
2106 2106
 		$conditions = '(' . implode( ' OR ', $conditions ) . ')';
Please login to merge, or discard this patch.