Completed
Push — develop ( e17a4e...fa7830 )
by
unknown
17:17
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
 				/**
744 744
 				 * @filter `gravityview/search/ignore-empty-field-values` Filter to control if empty field values should be ignored or strictly matched (default: true)
745 745
 				 * @since  2.14.2.1
@@ -774,21 +774,21 @@  discard block
 block discarded – undo
774 774
 				continue;
775 775
 			}
776 776
 
777
-			if ( ! isset( $filter['operator'] ) ) {
778
-				$filter['operator'] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' );
777
+			if ( ! isset( $filter[ 'operator' ] ) ) {
778
+				$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' );
779 779
 			}
780 780
 
781
-			if ( isset( $filter[0]['value'] ) ) {
782
-				$filter[0]['value'] = $trim_search_value ? trim( $filter[0]['value'] ) : $filter[0]['value'];
781
+			if ( isset( $filter[ 0 ][ 'value' ] ) ) {
782
+				$filter[ 0 ][ 'value' ] = $trim_search_value ? trim( $filter[ 0 ][ 'value' ] ) : $filter[ 0 ][ 'value' ];
783 783
 
784
-				$search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter );
784
+				$search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter );
785 785
 
786 786
 				// if date range type, set search mode to ALL
787
-				if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) {
787
+				if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) {
788 788
 					$mode = 'all';
789 789
 				}
790
-			} elseif( !empty( $filter ) ) {
791
-				$search_criteria['field_filters'][] = $filter;
790
+			} elseif ( ! empty( $filter ) ) {
791
+				$search_criteria[ 'field_filters' ][ ] = $filter;
792 792
 			}
793 793
 		}
794 794
 
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
 		 * @since 1.5.1
798 798
 		 * @param[out,in] string $mode Search mode (`any` vs `all`)
799 799
 		 */
800
-		$search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode );
800
+		$search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode );
801 801
 
802 802
 		gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) );
803 803
 
@@ -831,19 +831,19 @@  discard block
 block discarded – undo
831 831
 
832 832
 		$query_class = $view->get_query_class();
833 833
 
834
-		if ( empty( $search_criteria['field_filters'] ) ) {
834
+		if ( empty( $search_criteria[ 'field_filters' ] ) ) {
835 835
 			return;
836 836
 		}
837 837
 
838 838
 		$widgets = $view->widgets->by_id( $this->widget_id );
839 839
 		if ( $widgets->count() ) {
840 840
 			$widgets = $widgets->all();
841
-			$widget  = $widgets[0];
841
+			$widget  = $widgets[ 0 ];
842 842
 
843 843
 			$search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true );
844 844
 
845
-			foreach ( (array) $search_fields as $search_field ) {
846
-				if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) {
845
+			foreach ( (array)$search_fields as $search_field ) {
846
+				if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) {
847 847
 					$created_by_text_mode = true;
848 848
 				}
849 849
 			}
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 		$extra_conditions = array();
853 853
 		$mode = 'any';
854 854
 
855
-		foreach ( $search_criteria['field_filters'] as $key => &$filter ) {
855
+		foreach ( $search_criteria[ 'field_filters' ] as $key => &$filter ) {
856 856
 			if ( ! is_array( $filter ) ) {
857 857
 				if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) {
858 858
 					$mode = $filter;
@@ -861,13 +861,13 @@  discard block
 block discarded – undo
861 861
 			}
862 862
 
863 863
 			// Construct a manual query for unapproved statuses
864
-			if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) {
865
-				$_tmp_query       = new $query_class( $view->form->ID, array(
864
+			if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) {
865
+				$_tmp_query = new $query_class( $view->form->ID, array(
866 866
 					'field_filters' => array(
867 867
 						array(
868 868
 							'operator' => 'in',
869 869
 							'key'      => 'is_approved',
870
-							'value'    => (array) $filter['value'],
870
+							'value'    => (array)$filter[ 'value' ],
871 871
 						),
872 872
 						array(
873 873
 							'operator' => 'is',
@@ -879,30 +879,30 @@  discard block
 block discarded – undo
879 879
 				) );
880 880
 				$_tmp_query_parts = $_tmp_query->_introspect();
881 881
 
882
-				$extra_conditions[] = $_tmp_query_parts['where'];
882
+				$extra_conditions[ ] = $_tmp_query_parts[ 'where' ];
883 883
 
884 884
 				$filter = false;
885 885
 				continue;
886 886
 			}
887 887
 
888 888
 			// Construct manual query for text mode creator search
889
-			if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) {
890
-				$extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view );
889
+			if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) {
890
+				$extra_conditions[ ] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view );
891 891
 				$filter = false;
892 892
 				continue;
893 893
 			}
894 894
 
895 895
 			// By default, we want searches to be wildcard for each field.
896
-			$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
896
+			$filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];
897 897
 
898 898
 			// For multichoice, let's have an in (OR) search.
899
-			if ( is_array( $filter['value'] ) ) {
900
-				$filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)?
899
+			if ( is_array( $filter[ 'value' ] ) ) {
900
+				$filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)?
901 901
 			}
902 902
 
903 903
 			// Default form with joins functionality
904
-			if ( empty( $filter['form_id'] ) ) {
905
-				$filter['form_id'] = $view->form ? $view->form->ID : 0;
904
+			if ( empty( $filter[ 'form_id' ] ) ) {
905
+				$filter[ 'form_id' ] = $view->form ? $view->form->ID : 0;
906 906
 			}
907 907
 
908 908
 			/**
@@ -912,32 +912,32 @@  discard block
 block discarded – undo
912 912
 			 * @param array $filter array with `key`, `value`, `operator`, `type` keys
913 913
 			 * @param \GV\View $view The View we're operating on.
914 914
 			 */
915
-			$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter, $view );
915
+			$filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter, $view );
916 916
 
917
-			if ( 'is' !== $filter['operator'] && '' === $filter['value'] ) {
918
-				unset( $search_criteria['field_filters'][ $key ] );
917
+			if ( 'is' !== $filter[ 'operator' ] && '' === $filter[ 'value' ] ) {
918
+				unset( $search_criteria[ 'field_filters' ][ $key ] );
919 919
 			}
920 920
 		}
921 921
 
922
-		if ( ! empty( $search_criteria['start_date'] ) || ! empty( $search_criteria['end_date'] ) ) {
922
+		if ( ! empty( $search_criteria[ 'start_date' ] ) || ! empty( $search_criteria[ 'end_date' ] ) ) {
923 923
 			$date_criteria = array();
924 924
 
925
-			if ( isset( $search_criteria['start_date'] ) ) {
926
-				$date_criteria['start_date'] = $search_criteria['start_date'];
925
+			if ( isset( $search_criteria[ 'start_date' ] ) ) {
926
+				$date_criteria[ 'start_date' ] = $search_criteria[ 'start_date' ];
927 927
 			}
928 928
 
929
-			if ( isset( $search_criteria['end_date'] ) ) {
930
-				$date_criteria['end_date'] = $search_criteria['end_date'];
929
+			if ( isset( $search_criteria[ 'end_date' ] ) ) {
930
+				$date_criteria[ 'end_date' ] = $search_criteria[ 'end_date' ];
931 931
 			}
932 932
 
933 933
 			$_tmp_query         = new $query_class( $view->form->ID, $date_criteria );
934 934
 			$_tmp_query_parts   = $_tmp_query->_introspect();
935
-			$extra_conditions[] = $_tmp_query_parts['where'];
935
+			$extra_conditions[ ] = $_tmp_query_parts[ 'where' ];
936 936
 		}
937 937
 
938 938
 		$search_conditions = array();
939 939
 
940
-		if ( $filters = array_filter( $search_criteria['field_filters'] ) ) {
940
+		if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) {
941 941
 			foreach ( $filters as &$filter ) {
942 942
 				if ( ! is_array( $filter ) ) {
943 943
 					continue;
@@ -949,12 +949,12 @@  discard block
 block discarded – undo
949 949
 				 * code by reusing what's inside GF_Query already as they
950 950
 				 * take care of many small things like forcing numeric, etc.
951 951
 				 */
952
-				$_tmp_query       = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) );
952
+				$_tmp_query       = new $query_class( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) );
953 953
 				$_tmp_query_parts = $_tmp_query->_introspect();
954
-				$search_condition = $_tmp_query_parts['where'];
954
+				$search_condition = $_tmp_query_parts[ 'where' ];
955 955
 
956
-				if ( empty( $filter['key'] ) && $search_condition->expressions ) {
957
-					$search_conditions[] = $search_condition;
956
+				if ( empty( $filter[ 'key' ] ) && $search_condition->expressions ) {
957
+					$search_conditions[ ] = $search_condition;
958 958
 				} else {
959 959
 					$left = $search_condition->left;
960 960
 
@@ -966,8 +966,8 @@  discard block
 block discarded – undo
966 966
 
967 967
 							$value = $reflectionProperty->getValue( $left );
968 968
 
969
-							if ( ! empty( $value[0] ) && $value[0] instanceof GF_Query_Column ) {
970
-								$left = $value[0];
969
+							if ( ! empty( $value[ 0 ] ) && $value[ 0 ] instanceof GF_Query_Column ) {
970
+								$left = $value[ 0 ];
971 971
 							} else {
972 972
 								continue;
973 973
 							}
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 							$on = $_join->join_on;
984 984
 							$join = $_join->join;
985 985
 
986
-							$search_conditions[] = GF_Query_Condition::_or(
986
+							$search_conditions[ ] = GF_Query_Condition::_or(
987 987
 								// Join
988 988
 								new GF_Query_Condition(
989 989
 									new GF_Query_Column( GF_Query_Column::META, $join->ID, $query->_alias( GF_Query_Column::META, $join->ID, 'm' ) ),
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
 							);
1000 1000
 						}
1001 1001
 					} else {
1002
-						$search_conditions[] = new GF_Query_Condition(
1002
+						$search_conditions[ ] = new GF_Query_Condition(
1003 1003
 							new GF_Query_Column( $left->field_id, $left->source, $alias ),
1004 1004
 							$search_condition->operator,
1005 1005
 							$search_condition->right
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
 		/**
1022 1022
 		 * Combine the parts as a new WHERE clause.
1023 1023
 		 */
1024
-		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) );
1024
+		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) );
1025 1025
 		$query->where( $where );
1026 1026
 	}
1027 1027
 
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 		$field_id = str_replace( 'filter_', '', $key );
1045 1045
 
1046 1046
 		// calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox )
1047
-		if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) {
1047
+		if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) {
1048 1048
 			$field_id = str_replace( '_', '.', $field_id );
1049 1049
 		}
1050 1050
 
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
 			// form is in searchable fields
1102 1102
 			$found = false;
1103 1103
 			foreach ( $searchable_fields as $field ) {
1104
-				if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) {
1104
+				if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) {
1105 1105
 					$found = true;
1106 1106
 					break;
1107 1107
 				}
@@ -1141,7 +1141,7 @@  discard block
 block discarded – undo
1141 1141
 
1142 1142
 			case 'select':
1143 1143
 			case 'radio':
1144
-				$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1144
+				$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1145 1145
 				break;
1146 1146
 
1147 1147
 			case 'post_category':
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 
1156 1156
 				foreach ( $value as $val ) {
1157 1157
 					$cat = get_term( $val, 'category' );
1158
-					$filter[] = array(
1158
+					$filter[ ] = array(
1159 1159
 						'key'      => $field_id,
1160 1160
 						'value'    => esc_attr( $cat->name ) . ':' . $val,
1161 1161
 						'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ),
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
 				$filter = array();
1175 1175
 
1176 1176
 				foreach ( $value as $val ) {
1177
-					$filter[] = array( 'key' => $field_id, 'value' => $val );
1177
+					$filter[ ] = array( 'key' => $field_id, 'value' => $val );
1178 1178
 				}
1179 1179
 
1180 1180
 				break;
@@ -1183,9 +1183,9 @@  discard block
 block discarded – undo
1183 1183
 				// convert checkbox on/off into the correct search filter
1184 1184
 				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) {
1185 1185
 					foreach ( $form_field->inputs as $k => $input ) {
1186
-						if ( $input['id'] == $field_id ) {
1187
-							$filter['value'] = $form_field->choices[ $k ]['value'];
1188
-							$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1186
+						if ( $input[ 'id' ] == $field_id ) {
1187
+							$filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ];
1188
+							$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1189 1189
 							break;
1190 1190
 						}
1191 1191
 					}
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
 					$filter = array();
1196 1196
 
1197 1197
 					foreach ( $value as $val ) {
1198
-						$filter[] = array(
1198
+						$filter[ ] = array(
1199 1199
 							'key'      => $field_id,
1200 1200
 							'value'    => $val,
1201 1201
 							'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ),
@@ -1216,9 +1216,9 @@  discard block
 block discarded – undo
1216 1216
 					foreach ( $words as $word ) {
1217 1217
 						if ( ! empty( $word ) && strlen( $word ) > 1 ) {
1218 1218
 							// Keep the same key for each filter
1219
-							$filter['value'] = $word;
1219
+							$filter[ 'value' ] = $word;
1220 1220
 							// Add a search for the value
1221
-							$filters[] = $filter;
1221
+							$filters[ ] = $filter;
1222 1222
 						}
1223 1223
 					}
1224 1224
 
@@ -1232,19 +1232,19 @@  discard block
 block discarded – undo
1232 1232
 
1233 1233
 					foreach ( $searchable_fields as $searchable_field ) {
1234 1234
 
1235
-						if( $form_field->ID !== $searchable_field['field'] ) {
1235
+						if ( $form_field->ID !== $searchable_field[ 'field' ] ) {
1236 1236
 							continue;
1237 1237
 						}
1238 1238
 
1239 1239
 						// Only exact-match dropdowns, not text search
1240
-						if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) {
1240
+						if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) {
1241 1241
 							continue;
1242 1242
 						}
1243 1243
 
1244 1244
 						$input_id = gravityview_get_input_id_from_id( $form_field->ID );
1245 1245
 
1246 1246
 						if ( 4 === $input_id ) {
1247
-							$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1247
+							$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1248 1248
 						};
1249 1249
 					}
1250 1250
 				}
@@ -1272,12 +1272,12 @@  discard block
 block discarded – undo
1272 1272
 						 * @since 1.16.3
1273 1273
 						 * Safeguard until GF implements '<=' operator
1274 1274
 						 */
1275
-						if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1275
+						if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1276 1276
 							$operator = '<';
1277 1277
 							$date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) );
1278 1278
 						}
1279 1279
 
1280
-						$filter[] = array(
1280
+						$filter[ ] = array(
1281 1281
 							'key'      => $field_id,
1282 1282
 							'value'    => self::get_formatted_date( $date, 'Y-m-d', $date_format ),
1283 1283
 							'operator' => $this->get_operator( $get, $key, array( $operator ), $operator ),
@@ -1285,12 +1285,12 @@  discard block
 block discarded – undo
1285 1285
 					}
1286 1286
 				} else {
1287 1287
 					$date = $value;
1288
-					$filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1289
-					$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1288
+					$filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1289
+					$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1290 1290
 				}
1291 1291
 
1292
-				if ('payment_date' === $key) {
1293
-					$filter['operator'] = 'contains';
1292
+				if ( 'payment_date' === $key ) {
1293
+					$filter[ 'operator' ] = 'contains';
1294 1294
 				}
1295 1295
 
1296 1296
 				break;
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
 			'ymd_dot' => 'Y.m.d',
1320 1320
 		);
1321 1321
 
1322
-		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){
1322
+		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) {
1323 1323
 			$format = $datepicker[ $field->dateFormat ];
1324 1324
 		}
1325 1325
 
@@ -1356,7 +1356,7 @@  discard block
 block discarded – undo
1356 1356
 	public function add_template_path( $file_paths ) {
1357 1357
 
1358 1358
 		// Index 100 is the default GravityView template path.
1359
-		$file_paths[102] = self::$file . 'templates/';
1359
+		$file_paths[ 102 ] = self::$file . 'templates/';
1360 1360
 
1361 1361
 		return $file_paths;
1362 1362
 	}
@@ -1375,7 +1375,7 @@  discard block
 block discarded – undo
1375 1375
 		$has_date = false;
1376 1376
 
1377 1377
 		foreach ( $search_fields as $k => $field ) {
1378
-			if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) {
1378
+			if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) {
1379 1379
 				$has_date = true;
1380 1380
 				break;
1381 1381
 			}
@@ -1404,7 +1404,7 @@  discard block
 block discarded – undo
1404 1404
 		$view = \GV\View::by_id( $gravityview_view->view_id );
1405 1405
 
1406 1406
 		// get configured search fields
1407
-		$search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : '';
1407
+		$search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : '';
1408 1408
 
1409 1409
 		if ( empty( $search_fields ) || ! is_array( $search_fields ) ) {
1410 1410
 			gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) );
@@ -1418,39 +1418,39 @@  discard block
 block discarded – undo
1418 1418
 
1419 1419
 			$updated_field = $this->get_search_filter_details( $updated_field, $context );
1420 1420
 
1421
-			switch ( $field['field'] ) {
1421
+			switch ( $field[ 'field' ] ) {
1422 1422
 
1423 1423
 				case 'search_all':
1424
-					$updated_field['key'] = 'search_all';
1425
-					$updated_field['input'] = 'search_all';
1426
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' );
1424
+					$updated_field[ 'key' ] = 'search_all';
1425
+					$updated_field[ 'input' ] = 'search_all';
1426
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' );
1427 1427
 					break;
1428 1428
 
1429 1429
 				case 'entry_date':
1430
-					$updated_field['key'] = 'entry_date';
1431
-					$updated_field['input'] = 'entry_date';
1432
-					$updated_field['value'] = array(
1430
+					$updated_field[ 'key' ] = 'entry_date';
1431
+					$updated_field[ 'input' ] = 'entry_date';
1432
+					$updated_field[ 'value' ] = array(
1433 1433
 						'start' => $this->rgget_or_rgpost( 'gv_start' ),
1434 1434
 						'end' => $this->rgget_or_rgpost( 'gv_end' ),
1435 1435
 					);
1436 1436
 					break;
1437 1437
 
1438 1438
 				case 'entry_id':
1439
-					$updated_field['key'] = 'entry_id';
1440
-					$updated_field['input'] = 'entry_id';
1441
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' );
1439
+					$updated_field[ 'key' ] = 'entry_id';
1440
+					$updated_field[ 'input' ] = 'entry_id';
1441
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' );
1442 1442
 					break;
1443 1443
 
1444 1444
 				case 'created_by':
1445
-					$updated_field['key'] = 'created_by';
1446
-					$updated_field['name'] = 'gv_by';
1447
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' );
1445
+					$updated_field[ 'key' ] = 'created_by';
1446
+					$updated_field[ 'name' ] = 'gv_by';
1447
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' );
1448 1448
 					break;
1449 1449
 
1450 1450
 				case 'is_approved':
1451
-					$updated_field['key'] = 'is_approved';
1452
-					$updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' );
1453
-					$updated_field['choices'] = self::get_is_approved_choices();
1451
+					$updated_field[ 'key' ] = 'is_approved';
1452
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' );
1453
+					$updated_field[ 'choices' ] = self::get_is_approved_choices();
1454 1454
 					break;
1455 1455
 			}
1456 1456
 
@@ -1471,16 +1471,16 @@  discard block
 block discarded – undo
1471 1471
 
1472 1472
 		$gravityview_view->permalink_fields = $this->add_no_permalink_fields( array(), $this, $widget_args );
1473 1473
 
1474
-		$gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal';
1474
+		$gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal';
1475 1475
 
1476 1476
 		/** @since 1.14 */
1477
-		$gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any';
1477
+		$gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any';
1478 1478
 
1479
-		$custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : '';
1479
+		$custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : '';
1480 1480
 
1481 1481
 		$gravityview_view->search_class = self::get_search_class( $custom_class );
1482 1482
 
1483
-		$gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false;
1483
+		$gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false;
1484 1484
 
1485 1485
 		if ( $this->has_date_field( $search_fields ) ) {
1486 1486
 			// enqueue datepicker stuff only if needed!
@@ -1502,10 +1502,10 @@  discard block
 block discarded – undo
1502 1502
 	public static function get_search_class( $custom_class = '' ) {
1503 1503
 		$gravityview_view = GravityView_View::getInstance();
1504 1504
 
1505
-		$search_class = 'gv-search-'.$gravityview_view->search_layout;
1505
+		$search_class = 'gv-search-' . $gravityview_view->search_layout;
1506 1506
 
1507
-		if ( ! empty( $custom_class )  ) {
1508
-			$search_class .= ' '.$custom_class;
1507
+		if ( ! empty( $custom_class ) ) {
1508
+			$search_class .= ' ' . $custom_class;
1509 1509
 		}
1510 1510
 
1511 1511
 		/**
@@ -1556,9 +1556,9 @@  discard block
 block discarded – undo
1556 1556
 
1557 1557
 		if ( ! $label ) {
1558 1558
 
1559
-			$label = isset( $form_field['label'] ) ? $form_field['label'] : '';
1559
+			$label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : '';
1560 1560
 
1561
-			switch( $field['field'] ) {
1561
+			switch ( $field[ 'field' ] ) {
1562 1562
 				case 'search_all':
1563 1563
 					$label = __( 'Search Entries:', 'gravityview' );
1564 1564
 					break;
@@ -1570,10 +1570,10 @@  discard block
 block discarded – undo
1570 1570
 					break;
1571 1571
 				default:
1572 1572
 					// If this is a field input, not a field
1573
-					if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) {
1573
+					if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) {
1574 1574
 
1575 1575
 						// Get the label for the field in question, which returns an array
1576
-						$items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) );
1576
+						$items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) );
1577 1577
 
1578 1578
 						// Get the item with the `label` key
1579 1579
 						$values = wp_list_pluck( $items, 'label' );
@@ -1614,13 +1614,13 @@  discard block
 block discarded – undo
1614 1614
 		$form = $gravityview_view->getForm();
1615 1615
 
1616 1616
 		// for advanced field ids (eg, first name / last name )
1617
-		$name = 'filter_' . str_replace( '.', '_', $field['field'] );
1617
+		$name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] );
1618 1618
 
1619 1619
 		// get searched value from $_GET/$_POST (string or array)
1620 1620
 		$value = $this->rgget_or_rgpost( $name );
1621 1621
 
1622 1622
 		// get form field details
1623
-		$form_field = gravityview_get_field( $form, $field['field'] );
1623
+		$form_field = gravityview_get_field( $form, $field[ 'field' ] );
1624 1624
 
1625 1625
 		$form_field_type = \GV\Utils::get( $form_field, 'type' );
1626 1626
 
@@ -1634,22 +1634,22 @@  discard block
 block discarded – undo
1634 1634
 		);
1635 1635
 
1636 1636
 		// collect choices
1637
-		if ( 'post_category' === $form_field_type && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) {
1638
-			$filter['choices'] = gravityview_get_terms_choices();
1639
-		} elseif ( ! empty( $form_field['choices'] ) ) {
1640
-			$filter['choices'] = $form_field['choices'];
1637
+		if ( 'post_category' === $form_field_type && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) {
1638
+			$filter[ 'choices' ] = gravityview_get_terms_choices();
1639
+		} elseif ( ! empty( $form_field[ 'choices' ] ) ) {
1640
+			$filter[ 'choices' ] = $form_field[ 'choices' ];
1641 1641
 		}
1642 1642
 
1643
-		if ( 'date_range' === $field['input'] && empty( $value ) ) {
1644
-			$filter['value'] = array( 'start' => '', 'end' => '' );
1643
+		if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) {
1644
+			$filter[ 'value' ] = array( 'start' => '', 'end' => '' );
1645 1645
 		}
1646 1646
 
1647
-		if ( 'created_by' === $field['field'] ) {
1648
-			$filter['choices'] = self::get_created_by_choices( $context->view );
1649
-			$filter['type'] = 'created_by';
1647
+		if ( 'created_by' === $field[ 'field' ] ) {
1648
+			$filter[ 'choices' ] = self::get_created_by_choices( $context->view );
1649
+			$filter[ 'type' ] = 'created_by';
1650 1650
 		}
1651 1651
 
1652
-		if ( ! empty( $filter['choices'] ) ) {
1652
+		if ( ! empty( $filter[ 'choices' ] ) ) {
1653 1653
 			/**
1654 1654
 			 * @filter `gravityview/search/sieve_choices` Only output used choices for this field.
1655 1655
 			 * @param[in,out] bool Yes or no.
@@ -1657,7 +1657,7 @@  discard block
 block discarded – undo
1657 1657
 			 * @param \GV\Context The context.
1658 1658
 			 */
1659 1659
 			if ( apply_filters( 'gravityview/search/sieve_choices', false, $field, $context ) ) {
1660
-				$filter['choices'] = $this->sieve_filter_choices( $filter, $context );
1660
+				$filter[ 'choices' ] = $this->sieve_filter_choices( $filter, $context );
1661 1661
 			}
1662 1662
 		}
1663 1663
 
@@ -1686,12 +1686,12 @@  discard block
 block discarded – undo
1686 1686
 	 * @return array The filter choices.
1687 1687
 	 */
1688 1688
 	private function sieve_filter_choices( $filter, $context ) {
1689
-		if ( empty( $filter['key'] ) || empty( $filter['choices'] ) ) {
1689
+		if ( empty( $filter[ 'key' ] ) || empty( $filter[ 'choices' ] ) ) {
1690 1690
 			return $filter; // @todo Populate plugins might give us empty choices
1691 1691
 		}
1692 1692
 
1693 1693
 		// Allow only created_by and field-ids to be sieved.
1694
-		if ( 'created_by' !== $filter['key'] && ! is_numeric( $filter['key'] ) ) {
1694
+		if ( 'created_by' !== $filter[ 'key' ] && ! is_numeric( $filter[ 'key' ] ) ) {
1695 1695
 			return $filter;
1696 1696
 		}
1697 1697
 
@@ -1702,13 +1702,13 @@  discard block
 block discarded – undo
1702 1702
 		$entry_table_name = GFFormsModel::get_entry_table_name();
1703 1703
 		$entry_meta_table_name = GFFormsModel::get_entry_meta_table_name();
1704 1704
 
1705
-		$key_like = $wpdb->esc_like( $filter['key'] ) . '.%';
1705
+		$key_like = $wpdb->esc_like( $filter[ 'key' ] ) . '.%';
1706 1706
 
1707 1707
 		switch ( \GV\Utils::get( $filter, 'type' ) ):
1708 1708
 			case 'post_category':
1709 1709
 				$choices = $wpdb->get_col( $wpdb->prepare(
1710 1710
 					"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",
1711
-					$key_like, $filter['key'], $form_id
1711
+					$key_like, $filter[ 'key' ], $form_id
1712 1712
 				) );
1713 1713
 				break;
1714 1714
 			case 'created_by':
@@ -1720,17 +1720,17 @@  discard block
 block discarded – undo
1720 1720
 			default:
1721 1721
 				$choices = $wpdb->get_col( $wpdb->prepare(
1722 1722
 					"SELECT DISTINCT meta_value FROM $entry_meta_table_name WHERE (meta_key LIKE %s OR meta_key = %d) AND form_id = %d",
1723
-					$key_like, $filter['key'], $form_id
1723
+					$key_like, $filter[ 'key' ], $form_id
1724 1724
 				) );
1725 1725
 
1726
-				if ( ( $field = gravityview_get_field( $form_id, $filter['key'] ) ) && 'json' === $field->storageType ) {
1726
+				if ( ( $field = gravityview_get_field( $form_id, $filter[ 'key' ] ) ) && 'json' === $field->storageType ) {
1727 1727
 					$choices = array_map( 'json_decode', $choices );
1728 1728
 					$_choices_array = array();
1729 1729
 					foreach ( $choices as $choice ) {
1730 1730
 						if ( is_array( $choice ) ) {
1731 1731
 							$_choices_array = array_merge( $_choices_array, $choice );
1732 1732
 						} else {
1733
-							$_choices_array []= $choice;
1733
+							$_choices_array [ ] = $choice;
1734 1734
 						}
1735 1735
 					}
1736 1736
 					$choices = array_unique( $_choices_array );
@@ -1740,9 +1740,9 @@  discard block
 block discarded – undo
1740 1740
 		endswitch;
1741 1741
 
1742 1742
 		$filter_choices = array();
1743
-		foreach ( $filter['choices'] as $choice ) {
1744
-			if ( in_array( $choice['text'], $choices, true ) || in_array( $choice['value'], $choices, true ) ) {
1745
-				$filter_choices[] = $choice;
1743
+		foreach ( $filter[ 'choices' ] as $choice ) {
1744
+			if ( in_array( $choice[ 'text' ], $choices, true ) || in_array( $choice[ 'value' ], $choices, true ) ) {
1745
+				$filter_choices[ ] = $choice;
1746 1746
 			}
1747 1747
 		}
1748 1748
 
@@ -1777,7 +1777,7 @@  discard block
 block discarded – undo
1777 1777
 			 * @param \GV\View $view The view.
1778 1778
 			 */
1779 1779
 			$text = apply_filters( 'gravityview/search/created_by/text', $user->display_name, $user, $view );
1780
-			$choices[] = array(
1780
+			$choices[ ] = array(
1781 1781
 				'value' => $user->ID,
1782 1782
 				'text' => $text,
1783 1783
 			);
@@ -1797,9 +1797,9 @@  discard block
 block discarded – undo
1797 1797
 
1798 1798
 		$choices = array();
1799 1799
 		foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) {
1800
-			$choices[] = array(
1801
-				'value' => $status['value'],
1802
-				'text' => $status['label'],
1800
+			$choices[ ] = array(
1801
+				'value' => $status[ 'value' ],
1802
+				'text' => $status[ 'label' ],
1803 1803
 			);
1804 1804
 		}
1805 1805
 
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
 	 */
1852 1852
 	public function add_datepicker_js_dependency( $js_dependencies ) {
1853 1853
 
1854
-		$js_dependencies[] = 'jquery-ui-datepicker';
1854
+		$js_dependencies[ ] = 'jquery-ui-datepicker';
1855 1855
 
1856 1856
 		return $js_dependencies;
1857 1857
 	}
@@ -1895,7 +1895,7 @@  discard block
 block discarded – undo
1895 1895
 			'isRTL'             => is_rtl(),
1896 1896
 		), $view_data );
1897 1897
 
1898
-		$localizations['datepicker'] = $datepicker_settings;
1898
+		$localizations[ 'datepicker' ] = $datepicker_settings;
1899 1899
 
1900 1900
 		return $localizations;
1901 1901
 
@@ -1922,7 +1922,7 @@  discard block
 block discarded – undo
1922 1922
 	 * @return void
1923 1923
 	 */
1924 1924
 	private function maybe_enqueue_flexibility() {
1925
-		if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) {
1925
+		if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
1926 1926
 			wp_enqueue_script( 'gv-flexibility' );
1927 1927
 		}
1928 1928
 	}
@@ -1944,7 +1944,7 @@  discard block
 block discarded – undo
1944 1944
 		add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 );
1945 1945
 
1946 1946
 		$scheme = is_ssl() ? 'https://' : 'http://';
1947
-		wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1947
+		wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1948 1948
 
1949 1949
 		/**
1950 1950
 		 * @filter `gravityview_search_datepicker_class`
@@ -2023,7 +2023,7 @@  discard block
 block discarded – undo
2023 2023
 	public function add_preview_inputs() {
2024 2024
 		global $wp;
2025 2025
 
2026
-		if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) {
2026
+		if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) {
2027 2027
 			return;
2028 2028
 		}
2029 2029
 
@@ -2081,7 +2081,7 @@  discard block
 block discarded – undo
2081 2081
  */
2082 2082
 class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition {
2083 2083
 	public function __construct( $filter, $view ) {
2084
-		$this->value = $filter['value'];
2084
+		$this->value = $filter[ 'value' ];
2085 2085
 		$this->view = $view;
2086 2086
 	}
2087 2087
 
@@ -2113,11 +2113,11 @@  discard block
 block discarded – undo
2113 2113
 		$conditions = array();
2114 2114
 
2115 2115
 		foreach ( $user_fields as $user_field ) {
2116
-			$conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) .  '%' );
2116
+			$conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' );
2117 2117
 		}
2118 2118
 
2119 2119
 		foreach ( $user_meta_fields as $meta_field ) {
2120
-			$conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) .  '%' );
2120
+			$conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' );
2121 2121
 		}
2122 2122
 
2123 2123
 		$conditions = '(' . implode( ' OR ', $conditions ) . ')';
Please login to merge, or discard this patch.