Completed
Push — develop ( a3eda8...2f2ee7 )
by Gennady
17:12
created
includes/widgets/search-widget/class-search-widget.php 1 patch
Spacing   +144 added lines, -144 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
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		$script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
228 228
 		$script_source = empty( $script_min ) ? '/source' : '';
229 229
 
230
-		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 );
230
+		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 );
231 231
 
232 232
 		wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array(
233 233
 			'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ),
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	 * @return array Scripts allowed in no-conflict mode, plus the search widget script
250 250
 	 */
251 251
 	public function register_no_conflict( $allowed ) {
252
-		$allowed[] = 'gravityview_searchwidget_admin';
252
+		$allowed[ ] = 'gravityview_searchwidget_admin';
253 253
 		return $allowed;
254 254
 	}
255 255
 
@@ -262,24 +262,24 @@  discard block
 block discarded – undo
262 262
 	 */
263 263
 	public static function get_searchable_fields() {
264 264
 
265
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) {
265
+		if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) {
266 266
 			exit( '0' );
267 267
 		}
268 268
 
269 269
 		$form = '';
270 270
 
271 271
 		// Fetch the form for the current View
272
-		if ( ! empty( $_POST['view_id'] ) ) {
272
+		if ( ! empty( $_POST[ 'view_id' ] ) ) {
273 273
 
274
-			$form = gravityview_get_form_id( $_POST['view_id'] );
274
+			$form = gravityview_get_form_id( $_POST[ 'view_id' ] );
275 275
 
276
-		} elseif ( ! empty( $_POST['formid'] ) ) {
276
+		} elseif ( ! empty( $_POST[ 'formid' ] ) ) {
277 277
 
278
-			$form = (int) $_POST['formid'];
278
+			$form = (int)$_POST[ 'formid' ];
279 279
 
280
-		} elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) {
280
+		} elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) {
281 281
 
282
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
282
+			$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
283 283
 
284 284
 		}
285 285
 
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
 		);
330 330
 
331 331
 		if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) {
332
-			$custom_fields['is_approved'] = array(
332
+			$custom_fields[ 'is_approved' ] = array(
333 333
 				'text' => esc_html__( 'Is Approved', 'gravityview' ),
334 334
 				'type' => 'boolean',
335 335
 			);
336 336
 		}
337 337
 
338
-		foreach( $custom_fields as $custom_field_key => $custom_field ) {
339
-			$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'] );
338
+		foreach ( $custom_fields as $custom_field_key => $custom_field ) {
339
+			$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' ] );
340 340
 		}
341 341
 
342 342
 		// Get fields with sub-inputs and no parent
@@ -358,13 +358,13 @@  discard block
 block discarded – undo
358 358
 
359 359
 			foreach ( $fields as $id => $field ) {
360 360
 
361
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
361
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
362 362
 					continue;
363 363
 				}
364 364
 
365
-				$types = self::get_search_input_types( $id, $field['type'] );
365
+				$types = self::get_search_input_types( $id, $field[ 'type' ] );
366 366
 
367
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>';
367
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>';
368 368
 			}
369 369
 		}
370 370
 
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	public static function get_search_input_types( $field_id = '', $field_type = null ) {
388 388
 
389 389
 		// @todo - This needs to be improved - many fields have . including products and addresses
390
-		if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) {
390
+		if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) {
391 391
 			$input_type = 'boolean'; // on/off checkbox
392 392
 		} elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) {
393 393
 			$input_type = 'multi'; //multiselect
@@ -431,19 +431,19 @@  discard block
 block discarded – undo
431 431
 			$post_id = 0;
432 432
 
433 433
 			// We're in the WordPress Widget context, and an overriding post ID has been set.
434
-			if ( ! empty( $widget_args['post_id'] ) ) {
435
-				$post_id = absint( $widget_args['post_id'] );
434
+			if ( ! empty( $widget_args[ 'post_id' ] ) ) {
435
+				$post_id = absint( $widget_args[ 'post_id' ] );
436 436
 			}
437 437
 			// We're in the WordPress Widget context, and the base View ID should be used
438
-			else if ( ! empty( $widget_args['view_id'] ) ) {
439
-				$post_id = absint( $widget_args['view_id'] );
438
+			else if ( ! empty( $widget_args[ 'view_id' ] ) ) {
439
+				$post_id = absint( $widget_args[ 'view_id' ] );
440 440
 			}
441 441
 
442 442
 			$args = gravityview_get_permalink_query_args( $post_id );
443 443
 
444 444
 			// Add hidden fields to the search form
445 445
 			foreach ( $args as $key => $value ) {
446
-				$search_fields[] = array(
446
+				$search_fields[ ] = array(
447 447
 					'name'  => $key,
448 448
 					'input' => 'hidden',
449 449
 					'value' => $value,
@@ -482,22 +482,22 @@  discard block
 block discarded – undo
482 482
 		/**
483 483
 		 * Include the sidebar Widgets.
484 484
 		 */
485
-		$widgets = (array) get_option( 'widget_gravityview_search', array() );
485
+		$widgets = (array)get_option( 'widget_gravityview_search', array() );
486 486
 
487 487
 		foreach ( $widgets as $widget ) {
488
-			if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) {
489
-				if( $_fields = json_decode( $widget['search_fields'], true ) ) {
488
+			if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) {
489
+				if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) {
490 490
 					foreach ( $_fields as $field ) {
491
-						$searchable_fields [] = $with_full_field ? $field : $field['field'];
491
+						$searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ];
492 492
 					}
493 493
 				}
494 494
 			}
495 495
 		}
496 496
 
497 497
 		foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) {
498
-			if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) {
498
+			if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) {
499 499
 				foreach ( $_fields as $field ) {
500
-					$searchable_fields [] = $with_full_field ? $field : $field['field'];
500
+					$searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ];
501 501
 				}
502 502
 			}
503 503
 		}
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 			return $search_criteria; // Return the original criteria, GF_Query modification kicks in later
528 528
 		}
529 529
 
530
-		if( 'post' === $this->search_method ) {
530
+		if ( 'post' === $this->search_method ) {
531 531
 			$get = $_POST;
532 532
 		} else {
533 533
 			$get = $_GET;
@@ -546,14 +546,14 @@  discard block
 block discarded – undo
546 546
 		$get = gv_map_deep( $get, 'rawurldecode' );
547 547
 
548 548
 		// Make sure array key is set up
549
-		$search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() );
549
+		$search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() );
550 550
 
551 551
 		$searchable_fields = $this->get_view_searchable_fields( $view );
552 552
 
553 553
 		// add free search
554
-		if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) {
554
+		if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) {
555 555
 
556
-			$search_all_value = trim( $get['gv_search'] );
556
+			$search_all_value = trim( $get[ 'gv_search' ] );
557 557
 
558 558
 			/**
559 559
 			 * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase?
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 			}
579 579
 
580 580
 			foreach ( $words as $word ) {
581
-				$search_criteria['field_filters'][] = array(
581
+				$search_criteria[ 'field_filters' ][ ] = array(
582 582
 					'key' => null, // The field ID to search
583 583
 					'value' => $word, // The value to search
584 584
 					'operator' => 'contains', // What to search in. Options: `is` or `contains`
@@ -591,14 +591,14 @@  discard block
 block discarded – undo
591 591
 			/**
592 592
 			 * Get and normalize the dates according to the input format.
593 593
 			 */
594
-			if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) {
595
-				if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) {
594
+			if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) {
595
+				if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) {
596 596
 					$curr_start = $curr_start_date->format( 'Y-m-d' );
597 597
 				}
598 598
 			}
599 599
 
600
-			if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) {
601
-				if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) {
600
+			if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) {
601
+				if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) {
602 602
 					$curr_end = $curr_end_date->format( 'Y-m-d' );
603 603
 				}
604 604
 			}
@@ -633,22 +633,22 @@  discard block
 block discarded – undo
633 633
 			 */
634 634
 			if ( ! empty( $curr_start ) ) {
635 635
 				$curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) );
636
-				$search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
636
+				$search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
637 637
 			}
638 638
 
639 639
 			if ( ! empty( $curr_end ) ) {
640 640
 				// Fast-forward 24 hour on the end time
641 641
 				$curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS );
642
-				$search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
643
-				if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056
644
-					$search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 );
642
+				$search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
643
+				if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056
644
+					$search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 );
645 645
 				}
646 646
 			}
647 647
 		}
648 648
 
649 649
 		// search for a specific entry ID
650 650
 		if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) {
651
-			$search_criteria['field_filters'][] = array(
651
+			$search_criteria[ 'field_filters' ][ ] = array(
652 652
 				'key' => 'id',
653 653
 				'value' => absint( $get[ 'gv_id' ] ),
654 654
 				'operator' => '=',
@@ -657,41 +657,41 @@  discard block
 block discarded – undo
657 657
 
658 658
 		// search for a specific Created_by ID
659 659
 		if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) {
660
-			$search_criteria['field_filters'][] = array(
660
+			$search_criteria[ 'field_filters' ][ ] = array(
661 661
 				'key' => 'created_by',
662
-				'value' => $get['gv_by'],
662
+				'value' => $get[ 'gv_by' ],
663 663
 				'operator' => '=',
664 664
 			);
665 665
 		}
666 666
 
667 667
 		// Get search mode passed in URL
668
-		$mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ?  $get['mode'] : 'any';
668
+		$mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any';
669 669
 
670 670
 		// get the other search filters
671 671
 		foreach ( $get as $key => $value ) {
672 672
 
673
-			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) {
673
+			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) {
674 674
 				continue;
675 675
 			}
676 676
 
677 677
 			$filter_key = $this->convert_request_key_to_filter_key( $key );
678 678
 
679 679
 			// could return simple filter or multiple filters
680
-			if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key , $searchable_fields ) ) {
680
+			if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key, $searchable_fields ) ) {
681 681
 				continue;
682 682
 			}
683 683
 
684 684
 			$filter = $this->prepare_field_filter( $filter_key, $value, $view );
685 685
 
686
-			if ( isset( $filter[0]['value'] ) ) {
687
-				$search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter );
686
+			if ( isset( $filter[ 0 ][ 'value' ] ) ) {
687
+				$search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter );
688 688
 
689 689
 				// if date range type, set search mode to ALL
690
-				if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) {
690
+				if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) {
691 691
 					$mode = 'all';
692 692
 				}
693
-			} elseif( !empty( $filter ) ) {
694
-				$search_criteria['field_filters'][] = $filter;
693
+			} elseif ( ! empty( $filter ) ) {
694
+				$search_criteria[ 'field_filters' ][ ] = $filter;
695 695
 			}
696 696
 		}
697 697
 
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 		 * @since 1.5.1
701 701
 		 * @param[out,in] string $mode Search mode (`any` vs `all`)
702 702
 		 */
703
-		$search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode );
703
+		$search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode );
704 704
 
705 705
 		gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) );
706 706
 
@@ -725,15 +725,15 @@  discard block
 block discarded – undo
725 725
 		 */
726 726
 		$search_criteria = $this->filter_entries( array(), null, array( 'id' => $view->ID ), true /** force search_criteria */ );
727 727
 
728
-		if ( empty( $search_criteria['field_filters'] ) ) {
728
+		if ( empty( $search_criteria[ 'field_filters' ] ) ) {
729 729
 			return;
730 730
 		}
731 731
 
732 732
 		$widgets = $view->widgets->by_id( $this->widget_id );
733 733
 		if ( $widgets->count() ) {
734
-			$widget = $widgets->all()[0];
734
+			$widget = $widgets->all()[ 0 ];
735 735
 			foreach ( $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) as $search_field ) {
736
-				if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) {
736
+				if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) {
737 737
 					$created_by_text_mode = true;
738 738
 				}
739 739
 			}
@@ -741,19 +741,19 @@  discard block
 block discarded – undo
741 741
 
742 742
 		$extra_conditions = array();
743 743
 
744
-		foreach ( $search_criteria['field_filters'] as &$filter ) {
744
+		foreach ( $search_criteria[ 'field_filters' ] as &$filter ) {
745 745
 			if ( ! is_array( $filter ) ) {
746 746
 				continue;
747 747
 			}
748 748
 
749 749
 			// Construct a manual query for unapproved statuses
750
-			if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, $filter['value'] ) ) {
751
-				$_tmp_query       = new GF_Query( $view->form->ID, array(
750
+			if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, $filter[ 'value' ] ) ) {
751
+				$_tmp_query = new GF_Query( $view->form->ID, array(
752 752
 					'field_filters' => array(
753 753
 						array(
754 754
 							'operator' => 'in',
755 755
 							'key'      => 'is_approved',
756
-							'value'    => $filter['value'],
756
+							'value'    => $filter[ 'value' ],
757 757
 						),
758 758
 						array(
759 759
 							'operator' => 'is',
@@ -765,17 +765,17 @@  discard block
 block discarded – undo
765 765
 				) );
766 766
 				$_tmp_query_parts = $_tmp_query->_introspect();
767 767
 
768
-				$extra_conditions[] = $_tmp_query_parts['where'];
768
+				$extra_conditions[ ] = $_tmp_query_parts[ 'where' ];
769 769
 
770 770
 				$filter = false;
771 771
 				continue;
772 772
 			}
773 773
 
774 774
 			// Construct manual query for text mode creator search
775
-			if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) {
776
-				$extra_conditions[] = new class( $filter, $view ) extends \GF_Query_Condition {
775
+			if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) {
776
+				$extra_conditions[ ] = new class( $filter, $view ) extends \GF_Query_Condition {
777 777
 					public function __construct( $filter, $view ) {
778
-						$this->value = $filter['value'];
778
+						$this->value = $filter[ 'value' ];
779 779
 						$this->view = $view;
780 780
 					}
781 781
 
@@ -809,11 +809,11 @@  discard block
 block discarded – undo
809 809
 						$conditions = array();
810 810
 
811 811
 						foreach ( $user_fields as $user_field ) {
812
-							$conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) .  '%' );
812
+							$conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' );
813 813
 						}
814 814
 
815 815
 						foreach ( $user_meta_fields as $meta_field ) {
816
-							$conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) .  '%' );
816
+							$conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' );
817 817
 						}
818 818
 
819 819
 						$conditions = '(' . implode( ' OR ', $conditions ) . ')';
@@ -829,11 +829,11 @@  discard block
 block discarded – undo
829 829
 			}
830 830
 
831 831
 			// By default, we want searches to be wildcard for each field.
832
-			$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
832
+			$filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];
833 833
 
834 834
 			// For multichoice, let's have an in (OR) search.
835
-			if ( is_array( $filter['value'] ) ) {
836
-				$filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)?
835
+			if ( is_array( $filter[ 'value' ] ) ) {
836
+				$filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)?
837 837
 			}
838 838
 
839 839
 			/**
@@ -841,10 +841,10 @@  discard block
 block discarded – undo
841 841
 			 * @param string $operator Existing search operator
842 842
 			 * @param array $filter array with `key`, `value`, `operator`, `type` keys
843 843
 			 */
844
-			$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter );
844
+			$filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter );
845 845
 		}
846 846
 
847
-		$search_criteria['field_filters'] = array_filter( $search_criteria['field_filters'] );
847
+		$search_criteria[ 'field_filters' ] = array_filter( $search_criteria[ 'field_filters' ] );
848 848
 
849 849
 		/**
850 850
 		 * Parse the filter criteria to generate the needed
@@ -857,12 +857,12 @@  discard block
 block discarded – undo
857 857
 		/**
858 858
 		 * Grab the current clauses. We'll be combining them shortly.
859 859
 		 */
860
-		$query_parts      = $query->_introspect();
860
+		$query_parts = $query->_introspect();
861 861
 
862 862
 		/**
863 863
 		 * Combine the parts as a new WHERE clause.
864 864
 		 */
865
-		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'], $_tmp_query_parts['where'] ), $extra_conditions ) );
865
+		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ], $_tmp_query_parts[ 'where' ] ), $extra_conditions ) );
866 866
 		$query->where( $where );
867 867
 	}
868 868
 
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 		$field_id = str_replace( 'filter_', '', $key );
886 886
 
887 887
 		// calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox )
888
-		if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) {
888
+		if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) {
889 889
 			$field_id = str_replace( '_', '.', $field_id );
890 890
 		}
891 891
 
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
 
921 921
 			case 'select':
922 922
 			case 'radio':
923
-				$filter['operator'] = 'is';
923
+				$filter[ 'operator' ] = 'is';
924 924
 				break;
925 925
 
926 926
 			case 'post_category':
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 
935 935
 				foreach ( $value as $val ) {
936 936
 					$cat = get_term( $val, 'category' );
937
-					$filter[] = array(
937
+					$filter[ ] = array(
938 938
 						'key'      => $filter_key,
939 939
 						'value'    => esc_attr( $cat->name ) . ':' . $val,
940 940
 						'operator' => 'is',
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
 				$filter = array();
954 954
 
955 955
 				foreach ( $value as $val ) {
956
-					$filter[] = array( 'key' => $filter_key, 'value' => $val );
956
+					$filter[ ] = array( 'key' => $filter_key, 'value' => $val );
957 957
 				}
958 958
 
959 959
 				break;
@@ -962,9 +962,9 @@  discard block
 block discarded – undo
962 962
 				// convert checkbox on/off into the correct search filter
963 963
 				if ( false !== strpos( $filter_key, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) {
964 964
 					foreach ( $form_field->inputs as $k => $input ) {
965
-						if ( $input['id'] == $filter_key ) {
966
-							$filter['value'] = $form_field->choices[ $k ]['value'];
967
-							$filter['operator'] = 'is';
965
+						if ( $input[ 'id' ] == $filter_key ) {
966
+							$filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ];
967
+							$filter[ 'operator' ] = 'is';
968 968
 							break;
969 969
 						}
970 970
 					}
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 					$filter = array();
975 975
 
976 976
 					foreach ( $value as $val ) {
977
-						$filter[] = array(
977
+						$filter[ ] = array(
978 978
 							'key'      => $filter_key,
979 979
 							'value'    => $val,
980 980
 							'operator' => 'is',
@@ -995,9 +995,9 @@  discard block
 block discarded – undo
995 995
 					foreach ( $words as $word ) {
996 996
 						if ( ! empty( $word ) && strlen( $word ) > 1 ) {
997 997
 							// Keep the same key for each filter
998
-							$filter['value'] = $word;
998
+							$filter[ 'value' ] = $word;
999 999
 							// Add a search for the value
1000
-							$filters[] = $filter;
1000
+							$filters[ ] = $filter;
1001 1001
 						}
1002 1002
 					}
1003 1003
 
@@ -1011,19 +1011,19 @@  discard block
 block discarded – undo
1011 1011
 
1012 1012
 					foreach ( $searchable_fields as $searchable_field ) {
1013 1013
 
1014
-						if( $form_field->ID !== $searchable_field['field'] ) {
1014
+						if ( $form_field->ID !== $searchable_field[ 'field' ] ) {
1015 1015
 							continue;
1016 1016
 						}
1017 1017
 
1018 1018
 						// Only exact-match dropdowns, not text search
1019
-						if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) {
1019
+						if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) {
1020 1020
 							continue;
1021 1021
 						}
1022 1022
 
1023 1023
 						$input_id = gravityview_get_input_id_from_id( $form_field->ID );
1024 1024
 
1025 1025
 						if ( 4 === $input_id ) {
1026
-							$filter['operator'] = 'is';
1026
+							$filter[ 'operator' ] = 'is';
1027 1027
 						};
1028 1028
 					}
1029 1029
 				}
@@ -1050,12 +1050,12 @@  discard block
 block discarded – undo
1050 1050
 						 * @since 1.16.3
1051 1051
 						 * Safeguard until GF implements '<=' operator
1052 1052
 						 */
1053
-						if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1053
+						if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1054 1054
 							$operator = '<';
1055 1055
 							$date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) );
1056 1056
 						}
1057 1057
 
1058
-						$filter[] = array(
1058
+						$filter[ ] = array(
1059 1059
 							'key'      => $filter_key,
1060 1060
 							'value'    => self::get_formatted_date( $date, 'Y-m-d', $date_format ),
1061 1061
 							'operator' => $operator,
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 					}
1064 1064
 				} else {
1065 1065
 					$date = $value;
1066
-					$filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1066
+					$filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1067 1067
 				}
1068 1068
 
1069 1069
 				break;
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
 			'ymd_dot' => 'Y.m.d',
1095 1095
 		);
1096 1096
 
1097
-		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){
1097
+		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) {
1098 1098
 			$format = $datepicker[ $field->dateFormat ];
1099 1099
 		}
1100 1100
 
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
 	public function add_template_path( $file_paths ) {
1132 1132
 
1133 1133
 		// Index 100 is the default GravityView template path.
1134
-		$file_paths[102] = self::$file . 'templates/';
1134
+		$file_paths[ 102 ] = self::$file . 'templates/';
1135 1135
 
1136 1136
 		return $file_paths;
1137 1137
 	}
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 		$has_date = false;
1151 1151
 
1152 1152
 		foreach ( $search_fields as $k => $field ) {
1153
-			if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) {
1153
+			if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) {
1154 1154
 				$has_date = true;
1155 1155
 				break;
1156 1156
 			}
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 		}
1170 1170
 
1171 1171
 		// get configured search fields
1172
-		$search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : '';
1172
+		$search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : '';
1173 1173
 
1174 1174
 		if ( empty( $search_fields ) || ! is_array( $search_fields ) ) {
1175 1175
 			gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) );
@@ -1184,41 +1184,41 @@  discard block
 block discarded – undo
1184 1184
 
1185 1185
 			$updated_field = $this->get_search_filter_details( $updated_field, $context );
1186 1186
 
1187
-			switch ( $field['field'] ) {
1187
+			switch ( $field[ 'field' ] ) {
1188 1188
 
1189 1189
 				case 'search_all':
1190
-					$updated_field['key'] = 'search_all';
1191
-					$updated_field['input'] = 'search_all';
1192
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' );
1190
+					$updated_field[ 'key' ] = 'search_all';
1191
+					$updated_field[ 'input' ] = 'search_all';
1192
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' );
1193 1193
 					break;
1194 1194
 
1195 1195
 				case 'entry_date':
1196
-					$updated_field['key'] = 'entry_date';
1197
-					$updated_field['input'] = 'entry_date';
1198
-					$updated_field['value'] = array(
1196
+					$updated_field[ 'key' ] = 'entry_date';
1197
+					$updated_field[ 'input' ] = 'entry_date';
1198
+					$updated_field[ 'value' ] = array(
1199 1199
 						'start' => $this->rgget_or_rgpost( 'gv_start' ),
1200 1200
 						'end' => $this->rgget_or_rgpost( 'gv_end' ),
1201 1201
 					);
1202 1202
 					break;
1203 1203
 
1204 1204
 				case 'entry_id':
1205
-					$updated_field['key'] = 'entry_id';
1206
-					$updated_field['input'] = 'entry_id';
1207
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' );
1205
+					$updated_field[ 'key' ] = 'entry_id';
1206
+					$updated_field[ 'input' ] = 'entry_id';
1207
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' );
1208 1208
 					break;
1209 1209
 
1210 1210
 				case 'created_by':
1211
-					$updated_field['key'] = 'created_by';
1212
-					$updated_field['name'] = 'gv_by';
1213
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' );
1214
-					$updated_field['choices'] = self::get_created_by_choices();
1211
+					$updated_field[ 'key' ] = 'created_by';
1212
+					$updated_field[ 'name' ] = 'gv_by';
1213
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' );
1214
+					$updated_field[ 'choices' ] = self::get_created_by_choices();
1215 1215
 					break;
1216 1216
 				
1217 1217
 				case 'is_approved':
1218
-					$updated_field['key'] = 'is_approved';
1219
-					$updated_field['input'] = 'checkbox';
1220
-					$updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' );
1221
-					$updated_field['choices'] = self::get_is_approved_choices();
1218
+					$updated_field[ 'key' ] = 'is_approved';
1219
+					$updated_field[ 'input' ] = 'checkbox';
1220
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' );
1221
+					$updated_field[ 'choices' ] = self::get_is_approved_choices();
1222 1222
 					break;
1223 1223
 			}
1224 1224
 
@@ -1237,13 +1237,13 @@  discard block
 block discarded – undo
1237 1237
 		 */
1238 1238
 		$this->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context );
1239 1239
 
1240
-		$this->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal';
1241
-		$this->search_mode   = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any';
1240
+		$this->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal';
1241
+		$this->search_mode   = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any';
1242 1242
 
1243
-		$custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : '';
1243
+		$custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : '';
1244 1244
 		$this->search_class = self::get_search_class( $custom_class );
1245 1245
 
1246
-		$this->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false;
1246
+		$this->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false;
1247 1247
 
1248 1248
 		/**
1249 1249
 		 * @deprecated Set legacy state for old custom code that still uses it.
@@ -1297,10 +1297,10 @@  discard block
 block discarded – undo
1297 1297
 	public static function get_search_class( $custom_class = '' ) {
1298 1298
 		$gravityview_view = GravityView_View::getInstance();
1299 1299
 
1300
-		$search_class = 'gv-search-'.$gravityview_view->search_layout;
1300
+		$search_class = 'gv-search-' . $gravityview_view->search_layout;
1301 1301
 
1302
-		if ( ! empty( $custom_class )  ) {
1303
-			$search_class .= ' '.$custom_class;
1302
+		if ( ! empty( $custom_class ) ) {
1303
+			$search_class .= ' ' . $custom_class;
1304 1304
 		}
1305 1305
 
1306 1306
 		/**
@@ -1326,8 +1326,8 @@  discard block
 block discarded – undo
1326 1326
 	public function search_class( $context, $custom_class = '' ) {
1327 1327
 		$search_class = 'gv-search-' . $this->search_layout;
1328 1328
 
1329
-		if ( ! empty( $custom_class )  ) {
1330
-			$search_class .= ' '.$custom_class;
1329
+		if ( ! empty( $custom_class ) ) {
1330
+			$search_class .= ' ' . $custom_class;
1331 1331
 		}
1332 1332
 
1333 1333
 		/**
@@ -1390,9 +1390,9 @@  discard block
 block discarded – undo
1390 1390
 
1391 1391
 		if ( ! $label ) {
1392 1392
 
1393
-			$label = isset( $form_field['label'] ) ? $form_field['label'] : '';
1393
+			$label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : '';
1394 1394
 
1395
-			switch( $field['field'] ) {
1395
+			switch ( $field[ 'field' ] ) {
1396 1396
 				case 'search_all':
1397 1397
 					$label = __( 'Search Entries:', 'gravityview' );
1398 1398
 					break;
@@ -1404,10 +1404,10 @@  discard block
 block discarded – undo
1404 1404
 					break;
1405 1405
 				default:
1406 1406
 					// If this is a field input, not a field
1407
-					if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) {
1407
+					if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) {
1408 1408
 
1409 1409
 						// Get the label for the field in question, which returns an array
1410
-						$items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) );
1410
+						$items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) );
1411 1411
 
1412 1412
 						// Get the item with the `label` key
1413 1413
 						$values = wp_list_pluck( $items, 'label' );
@@ -1443,32 +1443,32 @@  discard block
 block discarded – undo
1443 1443
 		$form = $context->view->form->form;
1444 1444
 
1445 1445
 		// for advanced field ids (eg, first name / last name )
1446
-		$name = 'filter_' . str_replace( '.', '_', $field['field'] );
1446
+		$name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] );
1447 1447
 
1448 1448
 		// get searched value from $_GET/$_POST (string or array)
1449 1449
 		$value = $this->rgget_or_rgpost( $name );
1450 1450
 
1451 1451
 		// get form field details
1452
-		$form_field = gravityview_get_field( $form, $field['field'] );
1452
+		$form_field = gravityview_get_field( $form, $field[ 'field' ] );
1453 1453
 
1454 1454
 		$filter = array(
1455
-			'key' => $field['field'],
1455
+			'key' => $field[ 'field' ],
1456 1456
 			'name' => $name,
1457 1457
 			'label' => self::get_field_label( $field, $form_field ),
1458
-			'input' => $field['input'],
1458
+			'input' => $field[ 'input' ],
1459 1459
 			'value' => $value,
1460
-			'type' => $form_field['type'],
1460
+			'type' => $form_field[ 'type' ],
1461 1461
 		);
1462 1462
 
1463 1463
 		// collect choices
1464
-		if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) {
1465
-			$filter['choices'] = gravityview_get_terms_choices();
1466
-		} elseif ( ! empty( $form_field['choices'] ) ) {
1467
-			$filter['choices'] = $form_field['choices'];
1464
+		if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) {
1465
+			$filter[ 'choices' ] = gravityview_get_terms_choices();
1466
+		} elseif ( ! empty( $form_field[ 'choices' ] ) ) {
1467
+			$filter[ 'choices' ] = $form_field[ 'choices' ];
1468 1468
 		}
1469 1469
 
1470
-		if ( 'date_range' === $field['input'] && empty( $value ) ) {
1471
-			$filter['value'] = array( 'start' => '', 'end' => '' );
1470
+		if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) {
1471
+			$filter[ 'value' ] = array( 'start' => '', 'end' => '' );
1472 1472
 		}
1473 1473
 
1474 1474
 		return $filter;
@@ -1492,7 +1492,7 @@  discard block
 block discarded – undo
1492 1492
 
1493 1493
 		$choices = array();
1494 1494
 		foreach ( $users as $user ) {
1495
-			$choices[] = array(
1495
+			$choices[ ] = array(
1496 1496
 				'value' => $user->ID,
1497 1497
 				'text' => $user->display_name,
1498 1498
 			);
@@ -1512,9 +1512,9 @@  discard block
 block discarded – undo
1512 1512
 
1513 1513
 		$choices = array();
1514 1514
 		foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) {
1515
-			$choices[] = array(
1516
-				'value' => $status['value'],
1517
-				'text' => $status['label'],
1515
+			$choices[ ] = array(
1516
+				'value' => $status[ 'value' ],
1517
+				'text' => $status[ 'label' ],
1518 1518
 			);
1519 1519
 		}
1520 1520
 
@@ -1564,7 +1564,7 @@  discard block
 block discarded – undo
1564 1564
 	 */
1565 1565
 	public function add_datepicker_js_dependency( $js_dependencies ) {
1566 1566
 
1567
-		$js_dependencies[] = 'jquery-ui-datepicker';
1567
+		$js_dependencies[ ] = 'jquery-ui-datepicker';
1568 1568
 
1569 1569
 		return $js_dependencies;
1570 1570
 	}
@@ -1608,7 +1608,7 @@  discard block
 block discarded – undo
1608 1608
 			'isRTL'             => is_rtl(),
1609 1609
 		), $view_data );
1610 1610
 
1611
-		$localizations['datepicker'] = $datepicker_settings;
1611
+		$localizations[ 'datepicker' ] = $datepicker_settings;
1612 1612
 
1613 1613
 		return $localizations;
1614 1614
 
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
 	 * @return void
1636 1636
 	 */
1637 1637
 	private function maybe_enqueue_flexibility() {
1638
-		if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) {
1638
+		if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
1639 1639
 			wp_enqueue_script( 'gv-flexibility' );
1640 1640
 		}
1641 1641
 	}
@@ -1655,7 +1655,7 @@  discard block
 block discarded – undo
1655 1655
 		add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 );
1656 1656
 
1657 1657
 		$scheme = is_ssl() ? 'https://' : 'http://';
1658
-		wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1658
+		wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1659 1659
 
1660 1660
 		/**
1661 1661
 		 * @filter `gravityview_search_datepicker_class`
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/field-date_range.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
 ?>
16 16
 
17 17
 <div class="gv-search-box gv-search-date gv-search-date-range">
18
-	<?php if( ! gv_empty( $label, false, false ) ) { ?>
19
-	<label for="search-box-<?php echo esc_attr( $name ).'-start'; ?>"><?php echo esc_html( $label ); ?></label>
18
+	<?php if ( ! gv_empty( $label, false, false ) ) { ?>
19
+	<label for="search-box-<?php echo esc_attr( $name ) . '-start'; ?>"><?php echo esc_html( $label ); ?></label>
20 20
 	<?php } ?>
21 21
 	<p>
22
-		<input name="<?php echo esc_attr( $name ).'[start]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-start'; ?>" type="text" class="<?php echo esc_html( $widget->datepicker_class ); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview' ); ?>" value="<?php echo esc_attr( $value['start'] ); ?>">
23
-		<input name="<?php echo esc_attr( $name ).'[end]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-end'; ?>" type="text" class="<?php echo esc_html( $widget->datepicker_class ); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview' ); ?>" value="<?php echo esc_attr( $value['end'] ); ?>">
22
+		<input name="<?php echo esc_attr( $name ) . '[start]'; ?>" id="search-box-<?php echo esc_attr( $name ) . '-start'; ?>" type="text" class="<?php echo esc_html( $widget->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'Start date', 'gravityview' ); ?>" value="<?php echo esc_attr( $value[ 'start' ] ); ?>">
23
+		<input name="<?php echo esc_attr( $name ) . '[end]'; ?>" id="search-box-<?php echo esc_attr( $name ) . '-end'; ?>" type="text" class="<?php echo esc_html( $widget->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'End date', 'gravityview' ); ?>" value="<?php echo esc_attr( $value[ 'end' ] ); ?>">
24 24
 	</p>
25 25
 </div>
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/field-search_all.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 
18 18
 <div class="gv-search-box gv-search-field-text gv-search-field-search_all">
19 19
 	<div class="gv-search">
20
-	<?php if( ! gv_empty( $label, false, false ) ) { ?>
20
+	<?php if ( ! gv_empty( $label, false, false ) ) { ?>
21 21
 		<label for="gv_search_<?php echo $gravityview->view->ID; ?>"><?php echo esc_html( $label ); ?></label>
22 22
 	<?php } ?>
23 23
 		<p><input type="<?php echo $html_input_type; ?>" name="gv_search" id="gv_search_<?php echo $gravityview->view->ID; ?>" value="<?php echo esc_attr( $value ); ?>" /></p>
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/field-single_checkbox.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,6 +13,6 @@
 block discarded – undo
13 13
 <div class="gv-search-box gv-search-field-single_checkbox">
14 14
 	<label for="search-box-<?php echo esc_attr( $search_field->name ); ?>" class="gv-check-radio">
15 15
 		<input type="checkbox" name="<?php echo esc_attr( $search_field->name ); ?>" value="1" id="search-box-<?php echo esc_attr( $search_field->name ); ?>" <?php checked( '1', $search_field->value, true ); ?>>
16
-			<?php if( ! gv_empty( $search_field->label, false, false ) ) { echo esc_html(  $search_field->label ); } ?>
16
+			<?php if ( ! gv_empty( $search_field->label, false, false ) ) { echo esc_html( $search_field->label ); } ?>
17 17
 	</label>
18 18
 </div>
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/field-select.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,19 +24,19 @@
 block discarded – undo
24 24
  * @param \GV\Template_Context $gravityview The template context.
25 25
  * @param object               $search_field The current field.
26 26
  */
27
-$default_option = apply_filters('gravityview/extension/search/select_default', '&mdash;', 'select', $widget, $gravityview, $search_field );
27
+$default_option = apply_filters( 'gravityview/extension/search/select_default', '&mdash;', 'select', $widget, $gravityview, $search_field );
28 28
 
29 29
 ?>
30 30
 <div class="gv-search-box gv-search-field-select">
31
-	<?php if( ! gv_empty( $search_field->label, false, false ) ) { ?>
31
+	<?php if ( ! gv_empty( $search_field->label, false, false ) ) { ?>
32 32
 		<label for="search-box-<?php echo esc_attr( $search_field->name ); ?>"><?php echo esc_html( $search_field->label ); ?></label>
33 33
 	<?php } ?>
34 34
 	<p>
35 35
 		<select name="<?php echo esc_attr( $search_field->name ); ?>" id="search-box-<?php echo esc_attr( $search_field->name ); ?>">
36 36
 			<option value="" <?php gv_selected( '', $search_field->value, true ); ?>><?php echo esc_html( $default_option ); ?></option>
37 37
 			<?php
38
-			foreach( $search_field->choices as $choice ) : ?>
39
-				<option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php gv_selected( esc_attr( $choice['value'] ), esc_attr( $search_field->value ), true ); ?>><?php echo esc_html( $choice['text'] ); ?></option>
38
+			foreach ( $search_field->choices as $choice ) : ?>
39
+				<option value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" <?php gv_selected( esc_attr( $choice[ 'value' ] ), esc_attr( $search_field->value ), true ); ?>><?php echo esc_html( $choice[ 'text' ] ); ?></option>
40 40
 			<?php endforeach; ?>
41 41
 		</select>
42 42
 	</p>
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/field-multiselect.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,15 +28,15 @@
 block discarded – undo
28 28
 
29 29
 ?>
30 30
 <div class="gv-search-box gv-search-field-multiselect">
31
-	<?php if( ! gv_empty( $search_field->label, false, false ) ) { ?>
31
+	<?php if ( ! gv_empty( $search_field->label, false, false ) ) { ?>
32 32
 		<label for="search-box-<?php echo esc_attr( $search_field->name ); ?>"><?php echo esc_html( $search_field->label ); ?></label>
33 33
 	<?php } ?>
34 34
 	<p>
35 35
 		<select name="<?php echo esc_attr( $search_field->name ); ?>[]" id="search-box-<?php echo esc_attr( $search_field->name ); ?>" multiple>
36 36
 			<option value="" <?php gv_selected( '', $search_field->value, true ); ?>><?php echo esc_html( $default_option ); ?></option>
37 37
 			<?php
38
-			foreach( $search_field->choices as $choice ) : ?>
39
-				<option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php gv_selected( $choice['value'], $search_field->value, true ); ?>><?php echo esc_html( $choice['text'] ); ?></option>
38
+			foreach ( $search_field->choices as $choice ) : ?>
39
+				<option value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" <?php gv_selected( $choice[ 'value' ], $search_field->value, true ); ?>><?php echo esc_html( $choice[ 'text' ] ); ?></option>
40 40
 			<?php endforeach; ?>
41 41
 		</select>
42 42
 	</p>
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/widget.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		/**
29 29
 		 * @action `gravityview_search_widget_field_before` Before each search input is rendered (other than the submit button)
30 30
 		 * @param \GV\Widget $widget The widget.
31
-         * @param array $search_field
31
+		 * @param array $search_field
32 32
 		 * @param \GV\Template_Context $gravityview The context.
33 33
 		 */
34 34
 		do_action( 'gravityview_search_widget_field_before', $widget, $search_field, $gravityview );
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		/**
46 46
 		 * @action `gravityview_search_widget_field_after` After each search input is rendered (other than the submit button)
47 47
 		 * @param \GV\Widget $widget The widget.
48
-         * @param array $search_field
48
+		 * @param array $search_field
49 49
 		 * @param \GV\Template_Context $gravityview The context.
50 50
 		 */
51 51
 		do_action( 'gravityview_search_widget_field_after', $widget, $search_field, $gravityview );
@@ -60,6 +60,6 @@  discard block
 block discarded – undo
60 60
 
61 61
 	if ( $has_inputs ) {
62 62
 		$template->get_template_part( 'submit' );
63
-    }
63
+	}
64 64
 ?>
65 65
 </form>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,11 +34,11 @@
 block discarded – undo
34 34
 		do_action( 'gravityview_search_widget_field_before', $widget, $search_field, $gravityview );
35 35
 
36 36
 		$template->push_template_data( $search_field, 'search_field' );
37
-		$template->get_template_part( 'field', $search_field['input'] );
37
+		$template->get_template_part( 'field', $search_field[ 'input' ] );
38 38
 		$template->pop_template_data( 'search_field' );
39 39
 
40 40
 		// show/hide the search button if there are input type fields
41
-		if ( ! $has_inputs && $search_field['input'] != 'link' ) {
41
+		if ( ! $has_inputs && $search_field[ 'input' ] != 'link' ) {
42 42
 			$has_inputs = true;
43 43
 		}
44 44
 
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/field-checkbox.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@
 block discarded – undo
23 23
 	<p>
24 24
 	<?php foreach ( $search_field->choices as $choice ) { ?>
25 25
 
26
-		<label for="search-box-<?php echo sanitize_html_class( $search_field->name.$choice['value'].$choice['text'] ); ?>" class="gv-check-radio">
27
-			<input type="checkbox" name="<?php echo esc_attr( $search_field->name ); ?>[]" value="<?php echo esc_attr( $choice['value'] ); ?>" id="search-box-<?php echo sanitize_html_class( $search_field->name.$choice['value'].$choice['text'] ); ?>" <?php gv_selected( $choice['value'], $search_field->value, true, 'checked' ); ?>>
28
-			<?php echo esc_html( $choice['text'] ); ?>
26
+		<label for="search-box-<?php echo sanitize_html_class( $search_field->name . $choice[ 'value' ] . $choice[ 'text' ] ); ?>" class="gv-check-radio">
27
+			<input type="checkbox" name="<?php echo esc_attr( $search_field->name ); ?>[]" value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" id="search-box-<?php echo sanitize_html_class( $search_field->name . $choice[ 'value' ] . $choice[ 'text' ] ); ?>" <?php gv_selected( $choice[ 'value' ], $search_field->value, true, 'checked' ); ?>>
28
+			<?php echo esc_html( $choice[ 'text' ] ); ?>
29 29
 		</label>
30 30
 
31 31
 	<?php } ?>
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/field-entry_date.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
 ?>
16 16
 
17 17
 <div class="gv-search-box gv-search-date gv-search-date-range gv-search-field-entry_date">
18
-	<?php if( ! gv_empty( $label, false, false ) ) { ?>
18
+	<?php if ( ! gv_empty( $label, false, false ) ) { ?>
19 19
 	<label for="gv_start_date_<?php echo $gravityview->view->ID; ?>"><?php echo esc_html( $label ); ?></label>
20 20
 	<?php } ?>
21 21
 	<p>
22
-		<input name="gv_start" id="gv_start_date_<?php echo $gravityview->view->ID; ?>" type="text" class="<?php echo esc_attr( $widget->datepicker_class ); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview' ); ?>" value="<?php echo $value['start']; ?>">
23
-		<input name="gv_end" id="gv_end_date_<?php echo $gravityview->view->ID; ?>" type="text" class="<?php echo esc_attr( $widget->datepicker_class ); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview' ); ?>" value="<?php echo $value['end']; ?>">
22
+		<input name="gv_start" id="gv_start_date_<?php echo $gravityview->view->ID; ?>" type="text" class="<?php echo esc_attr( $widget->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'Start date', 'gravityview' ); ?>" value="<?php echo $value[ 'start' ]; ?>">
23
+		<input name="gv_end" id="gv_end_date_<?php echo $gravityview->view->ID; ?>" type="text" class="<?php echo esc_attr( $widget->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'End date', 'gravityview' ); ?>" value="<?php echo $value[ 'end' ]; ?>">
24 24
 	</p>
25 25
 </div>
Please login to merge, or discard this patch.