Completed
Push — develop ( 230664...40034c )
by Gennady
10:46
created
includes/widgets/search-widget/class-search-widget.php 1 patch
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 				'type' => 'radio',
64 64
 				'full_width' => true,
65 65
 				'label' => esc_html__( 'Search Mode', 'gravityview' ),
66
-				'desc' => __('Should search results match all search fields, or any?', 'gravityview'),
66
+				'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ),
67 67
 				'value' => 'any',
68 68
 				'class' => 'hide-if-js',
69 69
 				'options' => array(
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 		// admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999
87 87
 		add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 );
88
-		add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') );
88
+		add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) );
89 89
 		add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) );
90 90
 
91 91
 		// ajax - get the searchable fields
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		$script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
222 222
 		$script_source = empty( $script_min ) ? '/source' : '';
223 223
 
224
-		wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version );
224
+		wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version );
225 225
 
226 226
 		wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array(
227 227
 			'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ),
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @return array Scripts allowed in no-conflict mode, plus the search widget script
244 244
 	 */
245 245
 	public function register_no_conflict( $allowed ) {
246
-		$allowed[] = 'gravityview_searchwidget_admin';
246
+		$allowed[ ] = 'gravityview_searchwidget_admin';
247 247
 		return $allowed;
248 248
 	}
249 249
 
@@ -256,24 +256,24 @@  discard block
 block discarded – undo
256 256
 	 */
257 257
 	public static function get_searchable_fields() {
258 258
 
259
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) {
259
+		if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) {
260 260
 			exit( '0' );
261 261
 		}
262 262
 
263 263
 		$form = '';
264 264
 
265 265
 		// Fetch the form for the current View
266
-		if ( ! empty( $_POST['view_id'] ) ) {
266
+		if ( ! empty( $_POST[ 'view_id' ] ) ) {
267 267
 
268
-			$form = gravityview_get_form_id( $_POST['view_id'] );
268
+			$form = gravityview_get_form_id( $_POST[ 'view_id' ] );
269 269
 
270
-		} elseif ( ! empty( $_POST['formid'] ) ) {
270
+		} elseif ( ! empty( $_POST[ 'formid' ] ) ) {
271 271
 
272
-			$form = (int) $_POST['formid'];
272
+			$form = (int)$_POST[ 'formid' ];
273 273
 
274
-		} elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) {
274
+		} elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) {
275 275
 
276
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
276
+			$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
277 277
 
278 278
 		}
279 279
 
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 			)
319 319
 		);
320 320
 
321
-		foreach( $custom_fields as $custom_field_key => $custom_field ) {
322
-			$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'] );
321
+		foreach ( $custom_fields as $custom_field_key => $custom_field ) {
322
+			$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' ] );
323 323
 		}
324 324
 
325 325
 		// Get fields with sub-inputs and no parent
@@ -341,13 +341,13 @@  discard block
 block discarded – undo
341 341
 
342 342
 			foreach ( $fields as $id => $field ) {
343 343
 
344
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
344
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
345 345
 					continue;
346 346
 				}
347 347
 
348
-				$types = self::get_search_input_types( $id, $field['type'] );
348
+				$types = self::get_search_input_types( $id, $field[ 'type' ] );
349 349
 
350
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>';
350
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>';
351 351
 			}
352 352
 		}
353 353
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 	public static function get_search_input_types( $field_id = '', $field_type = null ) {
371 371
 
372 372
 		// @todo - This needs to be improved - many fields have . including products and addresses
373
-		if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) {
373
+		if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) {
374 374
 			$input_type = 'boolean'; // on/off checkbox
375 375
 		} elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) {
376 376
 			$input_type = 'multi'; //multiselect
@@ -414,19 +414,19 @@  discard block
 block discarded – undo
414 414
 			$post_id = 0;
415 415
 
416 416
 			// We're in the WordPress Widget context, and an overriding post ID has been set.
417
-			if ( ! empty( $widget_args['post_id'] ) ) {
418
-				$post_id = absint( $widget_args['post_id'] );
417
+			if ( ! empty( $widget_args[ 'post_id' ] ) ) {
418
+				$post_id = absint( $widget_args[ 'post_id' ] );
419 419
 			}
420 420
 			// We're in the WordPress Widget context, and the base View ID should be used
421
-			else if ( ! empty( $widget_args['view_id'] ) ) {
422
-				$post_id = absint( $widget_args['view_id'] );
421
+			else if ( ! empty( $widget_args[ 'view_id' ] ) ) {
422
+				$post_id = absint( $widget_args[ 'view_id' ] );
423 423
 			}
424 424
 
425 425
 			$args = gravityview_get_permalink_query_args( $post_id );
426 426
 
427 427
 			// Add hidden fields to the search form
428 428
 			foreach ( $args as $key => $value ) {
429
-				$search_fields[] = array(
429
+				$search_fields[ ] = array(
430 430
 					'name'  => $key,
431 431
 					'input' => 'hidden',
432 432
 					'value' => $value,
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 	 */
448 448
 	public function filter_entries( $search_criteria ) {
449 449
 
450
-		if( 'post' === $this->search_method ) {
450
+		if ( 'post' === $this->search_method ) {
451 451
 			$get = $_POST;
452 452
 		} else {
453 453
 			$get = $_GET;
@@ -464,12 +464,12 @@  discard block
 block discarded – undo
464 464
 		$get = gv_map_deep( $get, 'rawurldecode' );
465 465
 
466 466
 		// Make sure array key is set up
467
-		$search_criteria['field_filters'] = rgar( $search_criteria, 'field_filters', array() );
467
+		$search_criteria[ 'field_filters' ] = rgar( $search_criteria, 'field_filters', array() );
468 468
 
469 469
 		// add free search
470
-		if ( ! empty( $get['gv_search'] ) ) {
470
+		if ( ! empty( $get[ 'gv_search' ] ) ) {
471 471
 
472
-			$search_all_value = trim( $get['gv_search'] );
472
+			$search_all_value = trim( $get[ 'gv_search' ] );
473 473
 
474 474
 			/**
475 475
 			 * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase?
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 			 */
479 479
 			$split_words = apply_filters( 'gravityview/search-all-split-words', true );
480 480
 
481
-			if( $split_words ) {
481
+			if ( $split_words ) {
482 482
 
483 483
 				// Search for a piece
484 484
 				$words = explode( ' ', $search_all_value );
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 			}
495 495
 
496 496
 			foreach ( $words as $word ) {
497
-				$search_criteria['field_filters'][] = array(
497
+				$search_criteria[ 'field_filters' ][ ] = array(
498 498
 					'key' => null, // The field ID to search
499 499
 					'value' => $word, // The value to search
500 500
 					'operator' => 'contains', // What to search in. Options: `is` or `contains`
@@ -503,8 +503,8 @@  discard block
 block discarded – undo
503 503
 		}
504 504
 
505 505
 		//start date & end date
506
-		$curr_start = !empty( $get['gv_start'] ) ? $get['gv_start'] : '';
507
-		$curr_end = !empty( $get['gv_start'] ) ? $get['gv_end'] : '';
506
+		$curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '';
507
+		$curr_end = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_end' ] : '';
508 508
 
509 509
 		/**
510 510
 		 * @filter `gravityview_date_created_adjust_timezone` Whether to adjust the timezone for entries. \n
@@ -520,18 +520,18 @@  discard block
 block discarded – undo
520 520
 		 */
521 521
 		if ( ! empty( $curr_start ) ) {
522 522
 			$curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) );
523
-			$search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
523
+			$search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
524 524
 		}
525 525
 
526 526
 		if ( ! empty( $curr_end ) ) {
527 527
 			// Fast-forward 24 hour on the end time
528 528
 			$curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS );
529
-			$search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
529
+			$search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
530 530
 		}
531 531
 
532 532
 		// search for a specific entry ID
533 533
 		if ( ! empty( $get[ 'gv_id' ] ) ) {
534
-			$search_criteria['field_filters'][] = array(
534
+			$search_criteria[ 'field_filters' ][ ] = array(
535 535
 				'key' => 'id',
536 536
 				'value' => absint( $get[ 'gv_id' ] ),
537 537
 				'operator' => '=',
@@ -540,36 +540,36 @@  discard block
 block discarded – undo
540 540
 
541 541
 		// search for a specific Created_by ID
542 542
 		if ( ! empty( $get[ 'gv_by' ] ) ) {
543
-			$search_criteria['field_filters'][] = array(
543
+			$search_criteria[ 'field_filters' ][ ] = array(
544 544
 				'key' => 'created_by',
545
-				'value' => absint( $get['gv_by'] ),
545
+				'value' => absint( $get[ 'gv_by' ] ),
546 546
 				'operator' => '=',
547 547
 			);
548 548
 		}
549 549
 
550 550
 
551 551
 		// Get search mode passed in URL
552
-		$mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ?  $get['mode'] : 'any';
552
+		$mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any';
553 553
 
554 554
 		// get the other search filters
555 555
 		foreach ( $get as $key => $value ) {
556 556
 
557
-			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) {
557
+			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) {
558 558
 				continue;
559 559
 			}
560 560
 
561 561
 			// could return simple filter or multiple filters
562 562
 			$filter = $this->prepare_field_filter( $key, $value );
563 563
 
564
-			if ( isset( $filter[0]['value'] ) ) {
565
-				$search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter );
564
+			if ( isset( $filter[ 0 ][ 'value' ] ) ) {
565
+				$search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter );
566 566
 
567 567
 				// if date range type, set search mode to ALL
568
-				if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) {
568
+				if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) {
569 569
 					$mode = 'all';
570 570
 				}
571
-			} elseif( !empty( $filter ) ) {
572
-				$search_criteria['field_filters'][] = $filter;
571
+			} elseif ( ! empty( $filter ) ) {
572
+				$search_criteria[ 'field_filters' ][ ] = $filter;
573 573
 			}
574 574
 		}
575 575
 
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 		 * @since 1.5.1
579 579
 		 * @param[out,in] string $mode Search mode (`any` vs `all`)
580 580
 		 */
581
-		$search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode );
581
+		$search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode );
582 582
 
583 583
 		do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria );
584 584
 
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 		$field_id = str_replace( 'filter_', '', $key );
605 605
 
606 606
 		// calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox )
607
-		if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) {
607
+		if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) {
608 608
 			$field_id = str_replace( '_', '.', $field_id );
609 609
 		}
610 610
 
@@ -618,11 +618,11 @@  discard block
 block discarded – undo
618 618
 			'value' => $value,
619 619
 		);
620 620
 
621
-		switch ( $form_field['type'] ) {
621
+		switch ( $form_field[ 'type' ] ) {
622 622
 
623 623
 			case 'select':
624 624
 			case 'radio':
625
-				$filter['operator'] = 'is';
625
+				$filter[ 'operator' ] = 'is';
626 626
 				break;
627 627
 
628 628
 			case 'post_category':
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 
637 637
 				foreach ( $value as $val ) {
638 638
 					$cat = get_term( $val, 'category' );
639
-					$filter[] = array(
639
+					$filter[ ] = array(
640 640
 						'key' => $field_id,
641 641
 						'value' => esc_attr( $cat->name ) . ':' . $val,
642 642
 						'operator' => 'is',
@@ -655,18 +655,18 @@  discard block
 block discarded – undo
655 655
 				$filter = array();
656 656
 
657 657
 				foreach ( $value as $val ) {
658
-					$filter[] = array( 'key' => $field_id, 'value' => $val );
658
+					$filter[ ] = array( 'key' => $field_id, 'value' => $val );
659 659
 				}
660 660
 
661 661
 				break;
662 662
 
663 663
 			case 'checkbox':
664 664
 				// convert checkbox on/off into the correct search filter
665
-				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) {
666
-					foreach ( $form_field['inputs'] as $k => $input ) {
667
-						if ( $input['id'] == $field_id ) {
668
-							$filter['value'] = $form_field['choices'][ $k ]['value'];
669
-							$filter['operator'] = 'is';
665
+				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) {
666
+					foreach ( $form_field[ 'inputs' ] as $k => $input ) {
667
+						if ( $input[ 'id' ] == $field_id ) {
668
+							$filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ];
669
+							$filter[ 'operator' ] = 'is';
670 670
 							break;
671 671
 						}
672 672
 					}
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 					$filter = array();
677 677
 
678 678
 					foreach ( $value as $val ) {
679
-						$filter[] = array(
679
+						$filter[ ] = array(
680 680
 							'key'   => $field_id,
681 681
 							'value' => $val,
682 682
 							'operator' => 'is',
@@ -697,9 +697,9 @@  discard block
 block discarded – undo
697 697
 					foreach ( $words as $word ) {
698 698
 						if ( ! empty( $word ) && strlen( $word ) > 1 ) {
699 699
 							// Keep the same key for each filter
700
-							$filter['value'] = $word;
700
+							$filter[ 'value' ] = $word;
701 701
 							// Add a search for the value
702
-							$filters[] = $filter;
702
+							$filters[ ] = $filter;
703 703
 						}
704 704
 					}
705 705
 
@@ -726,19 +726,19 @@  discard block
 block discarded – undo
726 726
 						 * @since 1.16.3
727 727
 						 * Safeguard until GF implements '<=' operator
728 728
 						 */
729
-						if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
729
+						if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
730 730
 							$operator = '<';
731 731
 							$date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) );
732 732
 						}
733 733
 
734
-						$filter[] = array(
734
+						$filter[ ] = array(
735 735
 							'key' => $field_id,
736 736
 							'value' => self::get_formatted_date( $date, 'Y-m-d' ),
737 737
 							'operator' => $operator,
738 738
 						);
739 739
 					}
740 740
 				} else {
741
-					$filter['value'] = self::get_formatted_date( $value, 'Y-m-d' );
741
+					$filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' );
742 742
 				}
743 743
 
744 744
 				break;
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 			'ymd_dot' => 'Y.m.d',
770 770
 		);
771 771
 
772
-		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){
772
+		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) {
773 773
 			$format = $datepicker[ $field->dateFormat ];
774 774
 		}
775 775
 
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 	public function add_template_path( $file_paths ) {
801 801
 
802 802
 		// Index 100 is the default GravityView template path.
803
-		$file_paths[102] = self::$file . 'templates/';
803
+		$file_paths[ 102 ] = self::$file . 'templates/';
804 804
 
805 805
 		return $file_paths;
806 806
 	}
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 		$has_date = false;
820 820
 
821 821
 		foreach ( $search_fields as $k => $field ) {
822
-			if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) {
822
+			if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) {
823 823
 				$has_date = true;
824 824
 				break;
825 825
 			}
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 		}
847 847
 
848 848
 		// get configured search fields
849
-		$search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : '';
849
+		$search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : '';
850 850
 
851 851
 		if ( empty( $search_fields ) || ! is_array( $search_fields ) ) {
852 852
 			do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args );
@@ -861,34 +861,34 @@  discard block
 block discarded – undo
861 861
 
862 862
 			$updated_field = $this->get_search_filter_details( $updated_field );
863 863
 
864
-			switch ( $field['field'] ) {
864
+			switch ( $field[ 'field' ] ) {
865 865
 
866 866
 				case 'search_all':
867
-					$updated_field['key'] = 'search_all';
868
-					$updated_field['input'] = 'search_all';
869
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' );
867
+					$updated_field[ 'key' ] = 'search_all';
868
+					$updated_field[ 'input' ] = 'search_all';
869
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' );
870 870
 					break;
871 871
 
872 872
 				case 'entry_date':
873
-					$updated_field['key'] = 'entry_date';
874
-					$updated_field['input'] = 'entry_date';
875
-					$updated_field['value'] = array(
873
+					$updated_field[ 'key' ] = 'entry_date';
874
+					$updated_field[ 'input' ] = 'entry_date';
875
+					$updated_field[ 'value' ] = array(
876 876
 						'start' => $this->rgget_or_rgpost( 'gv_start' ),
877 877
 						'end' => $this->rgget_or_rgpost( 'gv_end' ),
878 878
 					);
879 879
 					break;
880 880
 
881 881
 				case 'entry_id':
882
-					$updated_field['key'] = 'entry_id';
883
-					$updated_field['input'] = 'entry_id';
884
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' );
882
+					$updated_field[ 'key' ] = 'entry_id';
883
+					$updated_field[ 'input' ] = 'entry_id';
884
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' );
885 885
 					break;
886 886
 
887 887
 				case 'created_by':
888
-					$updated_field['key'] = 'created_by';
889
-					$updated_field['name'] = 'gv_by';
890
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' );
891
-					$updated_field['choices'] = self::get_created_by_choices();
888
+					$updated_field[ 'key' ] = 'created_by';
889
+					$updated_field[ 'name' ] = 'gv_by';
890
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' );
891
+					$updated_field[ 'choices' ] = self::get_created_by_choices();
892 892
 					break;
893 893
 			}
894 894
 
@@ -906,16 +906,16 @@  discard block
 block discarded – undo
906 906
 		 */
907 907
 		$gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args );
908 908
 
909
-		$gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal';
909
+		$gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal';
910 910
 
911 911
 		/** @since 1.14 */
912
-		$gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any';
912
+		$gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any';
913 913
 
914
-		$custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : '';
914
+		$custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : '';
915 915
 
916 916
 		$gravityview_view->search_class = self::get_search_class( $custom_class );
917 917
 
918
-		$gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false;
918
+		$gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false;
919 919
 
920 920
 		if ( $this->has_date_field( $search_fields ) ) {
921 921
 			// enqueue datepicker stuff only if needed!
@@ -937,10 +937,10 @@  discard block
 block discarded – undo
937 937
 	public static function get_search_class( $custom_class = '' ) {
938 938
 		$gravityview_view = GravityView_View::getInstance();
939 939
 
940
-		$search_class = 'gv-search-'.$gravityview_view->search_layout;
940
+		$search_class = 'gv-search-' . $gravityview_view->search_layout;
941 941
 
942
-		if ( ! empty( $custom_class )  ) {
943
-			$search_class .= ' '.$custom_class;
942
+		if ( ! empty( $custom_class ) ) {
943
+			$search_class .= ' ' . $custom_class;
944 944
 		}
945 945
 
946 946
 		/**
@@ -982,11 +982,11 @@  discard block
 block discarded – undo
982 982
 
983 983
 		$label = rgget( 'label', $field );
984 984
 
985
-		if( '' === $label ) {
985
+		if ( '' === $label ) {
986 986
 
987
-			$label = isset( $form_field['label'] ) ? $form_field['label'] : '';
987
+			$label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : '';
988 988
 
989
-			switch( $field['field'] ) {
989
+			switch ( $field[ 'field' ] ) {
990 990
 				case 'search_all':
991 991
 					$label = __( 'Search Entries:', 'gravityview' );
992 992
 					break;
@@ -998,10 +998,10 @@  discard block
 block discarded – undo
998 998
 					break;
999 999
 				default:
1000 1000
 					// If this is a field input, not a field
1001
-					if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) {
1001
+					if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) {
1002 1002
 
1003 1003
 						// Get the label for the field in question, which returns an array
1004
-						$items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) );
1004
+						$items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) );
1005 1005
 
1006 1006
 						// Get the item with the `label` key
1007 1007
 						$values = wp_list_pluck( $items, 'label' );
@@ -1040,32 +1040,32 @@  discard block
 block discarded – undo
1040 1040
 		$form = $gravityview_view->getForm();
1041 1041
 
1042 1042
 		// for advanced field ids (eg, first name / last name )
1043
-		$name = 'filter_' . str_replace( '.', '_', $field['field'] );
1043
+		$name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] );
1044 1044
 
1045 1045
 		// get searched value from $_GET/$_POST (string or array)
1046 1046
 		$value = $this->rgget_or_rgpost( $name );
1047 1047
 
1048 1048
 		// get form field details
1049
-		$form_field = gravityview_get_field( $form, $field['field'] );
1049
+		$form_field = gravityview_get_field( $form, $field[ 'field' ] );
1050 1050
 
1051 1051
 		$filter = array(
1052
-			'key' => $field['field'],
1052
+			'key' => $field[ 'field' ],
1053 1053
 			'name' => $name,
1054 1054
 			'label' => self::get_field_label( $field, $form_field ),
1055
-			'input' => $field['input'],
1055
+			'input' => $field[ 'input' ],
1056 1056
 			'value' => $value,
1057
-			'type' => $form_field['type'],
1057
+			'type' => $form_field[ 'type' ],
1058 1058
 		);
1059 1059
 
1060 1060
 		// collect choices
1061
-		if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) {
1062
-			$filter['choices'] = gravityview_get_terms_choices();
1063
-		} elseif ( ! empty( $form_field['choices'] ) ) {
1064
-			$filter['choices'] = $form_field['choices'];
1061
+		if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) {
1062
+			$filter[ 'choices' ] = gravityview_get_terms_choices();
1063
+		} elseif ( ! empty( $form_field[ 'choices' ] ) ) {
1064
+			$filter[ 'choices' ] = $form_field[ 'choices' ];
1065 1065
 		}
1066 1066
 
1067
-		if ( 'date_range' === $field['input'] && empty( $value ) ) {
1068
-			$filter['value'] = array( 'start' => '', 'end' => '' );
1067
+		if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) {
1068
+			$filter[ 'value' ] = array( 'start' => '', 'end' => '' );
1069 1069
 		}
1070 1070
 
1071 1071
 		return $filter;
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 
1090 1090
 		$choices = array();
1091 1091
 		foreach ( $users as $user ) {
1092
-			$choices[] = array(
1092
+			$choices[ ] = array(
1093 1093
 				'value' => $user->ID,
1094 1094
 				'text' => $user->display_name,
1095 1095
 			);
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 	 */
1145 1145
 	public function add_datepicker_js_dependency( $js_dependencies ) {
1146 1146
 
1147
-		$js_dependencies[] = 'jquery-ui-datepicker';
1147
+		$js_dependencies[ ] = 'jquery-ui-datepicker';
1148 1148
 
1149 1149
 		return $js_dependencies;
1150 1150
 	}
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
 			'isRTL'             => is_rtl(),
1189 1189
 		), $view_data );
1190 1190
 
1191
-		$localizations['datepicker'] = $datepicker_settings;
1191
+		$localizations[ 'datepicker' ] = $datepicker_settings;
1192 1192
 
1193 1193
 		return $localizations;
1194 1194
 
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
 	 * @return void
1218 1218
 	 */
1219 1219
 	private function maybe_enqueue_flexibility() {
1220
-		if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) {
1220
+		if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
1221 1221
 			wp_enqueue_script( 'gv-flexibility' );
1222 1222
 		}
1223 1223
 	}
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
 		add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 );
1240 1240
 
1241 1241
 		$scheme = is_ssl() ? 'https://' : 'http://';
1242
-		wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1242
+		wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1243 1243
 
1244 1244
 		/**
1245 1245
 		 * @filter `gravityview_search_datepicker_class`
Please login to merge, or discard this patch.