Completed
Push — develop ( ae96bf...05abab )
by Zack
08:31
created
includes/widgets/search-widget/templates/search-field-single_checkbox.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@
 block discarded – undo
12 12
 ?>
13 13
 
14 14
 <div class="gv-search-box gv-search-field-single_checkbox">
15
-	<label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" class="gv-check-radio">
16
-		<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 ); ?>>
17
-			<?php if( ! gv_empty( $search_field['label'], false, false ) ) { echo esc_html(  $search_field['label'] ); } ?>
15
+	<label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" class="gv-check-radio">
16
+		<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 ); ?>>
17
+			<?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { echo esc_html( $search_field[ 'label' ] ); } ?>
18 18
 	</label>
19 19
 </div>
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
includes/widgets/search-widget/class-search-widget.php 1 patch
Spacing   +107 added lines, -107 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
@@ -519,16 +519,16 @@  discard block
 block discarded – undo
519 519
 		/**
520 520
 		 * Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries)
521 521
 		 */
522
-		if( !empty( $curr_start ) ) {
523
-			$search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
522
+		if ( ! empty( $curr_start ) ) {
523
+			$search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
524 524
 		}
525
-		if( !empty( $curr_end ) ) {
526
-			$search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
525
+		if ( ! empty( $curr_end ) ) {
526
+			$search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
527 527
 		}
528 528
 
529 529
 		// search for a specific entry ID
530 530
 		if ( ! empty( $get[ 'gv_id' ] ) ) {
531
-			$search_criteria['field_filters'][] = array(
531
+			$search_criteria[ 'field_filters' ][ ] = array(
532 532
 				'key' => 'id',
533 533
 				'value' => absint( $get[ 'gv_id' ] ),
534 534
 				'operator' => '=',
@@ -537,36 +537,36 @@  discard block
 block discarded – undo
537 537
 
538 538
 		// search for a specific Created_by ID
539 539
 		if ( ! empty( $get[ 'gv_by' ] ) ) {
540
-			$search_criteria['field_filters'][] = array(
540
+			$search_criteria[ 'field_filters' ][ ] = array(
541 541
 				'key' => 'created_by',
542
-				'value' => absint( $get['gv_by'] ),
542
+				'value' => absint( $get[ 'gv_by' ] ),
543 543
 				'operator' => '=',
544 544
 			);
545 545
 		}
546 546
 
547 547
 
548 548
 		// Get search mode passed in URL
549
-		$mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ?  $get['mode'] : 'any';
549
+		$mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any';
550 550
 
551 551
 		// get the other search filters
552 552
 		foreach ( $get as $key => $value ) {
553 553
 
554
-			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) {
554
+			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) {
555 555
 				continue;
556 556
 			}
557 557
 
558 558
 			// could return simple filter or multiple filters
559 559
 			$filter = $this->prepare_field_filter( $key, $value );
560 560
 
561
-			if ( isset( $filter[0]['value'] ) ) {
562
-				$search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter );
561
+			if ( isset( $filter[ 0 ][ 'value' ] ) ) {
562
+				$search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter );
563 563
 
564 564
 				// if date range type, set search mode to ALL
565
-				if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) {
565
+				if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) {
566 566
 					$mode = 'all';
567 567
 				}
568
-			} elseif( !empty( $filter ) ) {
569
-				$search_criteria['field_filters'][] = $filter;
568
+			} elseif ( ! empty( $filter ) ) {
569
+				$search_criteria[ 'field_filters' ][ ] = $filter;
570 570
 			}
571 571
 		}
572 572
 
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 		 * @since 1.5.1
576 576
 		 * @param[out,in] string $mode Search mode (`any` vs `all`)
577 577
 		 */
578
-		$search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode );
578
+		$search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode );
579 579
 
580 580
 		do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria );
581 581
 
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		$field_id = str_replace( 'filter_', '', $key );
602 602
 
603 603
 		// calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox )
604
-		if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) {
604
+		if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) {
605 605
 			$field_id = str_replace( '_', '.', $field_id );
606 606
 		}
607 607
 
@@ -615,11 +615,11 @@  discard block
 block discarded – undo
615 615
 			'value' => $value,
616 616
 		);
617 617
 
618
-		switch ( $form_field['type'] ) {
618
+		switch ( $form_field[ 'type' ] ) {
619 619
 
620 620
 			case 'select':
621 621
 			case 'radio':
622
-				$filter['operator'] = 'is';
622
+				$filter[ 'operator' ] = 'is';
623 623
 				break;
624 624
 
625 625
 			case 'post_category':
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 
634 634
 				foreach ( $value as $val ) {
635 635
 					$cat = get_term( $val, 'category' );
636
-					$filter[] = array(
636
+					$filter[ ] = array(
637 637
 						'key' => $field_id,
638 638
 						'value' => esc_attr( $cat->name ) . ':' . $val,
639 639
 						'operator' => 'is',
@@ -652,18 +652,18 @@  discard block
 block discarded – undo
652 652
 				$filter = array();
653 653
 
654 654
 				foreach ( $value as $val ) {
655
-					$filter[] = array( 'key' => $field_id, 'value' => $val );
655
+					$filter[ ] = array( 'key' => $field_id, 'value' => $val );
656 656
 				}
657 657
 
658 658
 				break;
659 659
 
660 660
 			case 'checkbox':
661 661
 				// convert checkbox on/off into the correct search filter
662
-				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) {
663
-					foreach ( $form_field['inputs'] as $k => $input ) {
664
-						if ( $input['id'] == $field_id ) {
665
-							$filter['value'] = $form_field['choices'][ $k ]['value'];
666
-							$filter['operator'] = 'is';
662
+				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) {
663
+					foreach ( $form_field[ 'inputs' ] as $k => $input ) {
664
+						if ( $input[ 'id' ] == $field_id ) {
665
+							$filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ];
666
+							$filter[ 'operator' ] = 'is';
667 667
 							break;
668 668
 						}
669 669
 					}
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 					$filter = array();
674 674
 
675 675
 					foreach ( $value as $val ) {
676
-						$filter[] = array(
676
+						$filter[ ] = array(
677 677
 							'key'   => $field_id,
678 678
 							'value' => $val,
679 679
 							'operator' => 'is',
@@ -694,9 +694,9 @@  discard block
 block discarded – undo
694 694
 					foreach ( $words as $word ) {
695 695
 						if ( ! empty( $word ) && strlen( $word ) > 1 ) {
696 696
 							// Keep the same key for each filter
697
-							$filter['value'] = $word;
697
+							$filter[ 'value' ] = $word;
698 698
 							// Add a search for the value
699
-							$filters[] = $filter;
699
+							$filters[ ] = $filter;
700 700
 						}
701 701
 					}
702 702
 
@@ -723,19 +723,19 @@  discard block
 block discarded – undo
723 723
 						 * @since 1.16.3
724 724
 						 * Safeguard until GF implements '<=' operator
725 725
 						 */
726
-						if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
726
+						if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
727 727
 							$operator = '<';
728 728
 							$date = date( 'Y-m-d', strtotime( $date . ' +1 day' ) );
729 729
 						}
730 730
 
731
-						$filter[] = array(
731
+						$filter[ ] = array(
732 732
 							'key' => $field_id,
733 733
 							'value' => self::get_formatted_date( $date, 'Y-m-d' ),
734 734
 							'operator' => $operator,
735 735
 						);
736 736
 					}
737 737
 				} else {
738
-					$filter['value'] = self::get_formatted_date( $value, 'Y-m-d' );
738
+					$filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' );
739 739
 				}
740 740
 
741 741
 				break;
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 			'ymd_dot' => 'Y.m.d',
767 767
 		);
768 768
 
769
-		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){
769
+		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) {
770 770
 			$format = $datepicker[ $field->dateFormat ];
771 771
 		}
772 772
 
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
 	public function add_template_path( $file_paths ) {
798 798
 
799 799
 		// Index 100 is the default GravityView template path.
800
-		$file_paths[102] = self::$file . 'templates/';
800
+		$file_paths[ 102 ] = self::$file . 'templates/';
801 801
 
802 802
 		return $file_paths;
803 803
 	}
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 		$has_date = false;
817 817
 
818 818
 		foreach ( $search_fields as $k => $field ) {
819
-			if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) {
819
+			if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) {
820 820
 				$has_date = true;
821 821
 				break;
822 822
 			}
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 		}
844 844
 
845 845
 		// get configured search fields
846
-		$search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : '';
846
+		$search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : '';
847 847
 
848 848
 		if ( empty( $search_fields ) || ! is_array( $search_fields ) ) {
849 849
 			do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args );
@@ -858,34 +858,34 @@  discard block
 block discarded – undo
858 858
 
859 859
 			$updated_field = $this->get_search_filter_details( $updated_field );
860 860
 
861
-			switch ( $field['field'] ) {
861
+			switch ( $field[ 'field' ] ) {
862 862
 
863 863
 				case 'search_all':
864
-					$updated_field['key'] = 'search_all';
865
-					$updated_field['input'] = 'search_all';
866
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' );
864
+					$updated_field[ 'key' ] = 'search_all';
865
+					$updated_field[ 'input' ] = 'search_all';
866
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' );
867 867
 					break;
868 868
 
869 869
 				case 'entry_date':
870
-					$updated_field['key'] = 'entry_date';
871
-					$updated_field['input'] = 'entry_date';
872
-					$updated_field['value'] = array(
870
+					$updated_field[ 'key' ] = 'entry_date';
871
+					$updated_field[ 'input' ] = 'entry_date';
872
+					$updated_field[ 'value' ] = array(
873 873
 						'start' => $this->rgget_or_rgpost( 'gv_start' ),
874 874
 						'end' => $this->rgget_or_rgpost( 'gv_end' ),
875 875
 					);
876 876
 					break;
877 877
 
878 878
 				case 'entry_id':
879
-					$updated_field['key'] = 'entry_id';
880
-					$updated_field['input'] = 'entry_id';
881
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' );
879
+					$updated_field[ 'key' ] = 'entry_id';
880
+					$updated_field[ 'input' ] = 'entry_id';
881
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' );
882 882
 					break;
883 883
 
884 884
 				case 'created_by':
885
-					$updated_field['key'] = 'created_by';
886
-					$updated_field['name'] = 'gv_by';
887
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' );
888
-					$updated_field['choices'] = self::get_created_by_choices();
885
+					$updated_field[ 'key' ] = 'created_by';
886
+					$updated_field[ 'name' ] = 'gv_by';
887
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' );
888
+					$updated_field[ 'choices' ] = self::get_created_by_choices();
889 889
 					break;
890 890
 			}
891 891
 
@@ -903,16 +903,16 @@  discard block
 block discarded – undo
903 903
 		 */
904 904
 		$gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args );
905 905
 
906
-		$gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal';
906
+		$gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal';
907 907
 
908 908
 		/** @since 1.14 */
909
-		$gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any';
909
+		$gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any';
910 910
 
911
-		$custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : '';
911
+		$custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : '';
912 912
 
913 913
 		$gravityview_view->search_class = self::get_search_class( $custom_class );
914 914
 
915
-		$gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false;
915
+		$gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false;
916 916
 
917 917
 		if ( $this->has_date_field( $search_fields ) ) {
918 918
 			// enqueue datepicker stuff only if needed!
@@ -934,10 +934,10 @@  discard block
 block discarded – undo
934 934
 	public static function get_search_class( $custom_class = '' ) {
935 935
 		$gravityview_view = GravityView_View::getInstance();
936 936
 
937
-		$search_class = 'gv-search-'.$gravityview_view->search_layout;
937
+		$search_class = 'gv-search-' . $gravityview_view->search_layout;
938 938
 
939
-		if ( ! empty( $custom_class )  ) {
940
-			$search_class .= ' '.$custom_class;
939
+		if ( ! empty( $custom_class ) ) {
940
+			$search_class .= ' ' . $custom_class;
941 941
 		}
942 942
 
943 943
 		/**
@@ -979,11 +979,11 @@  discard block
 block discarded – undo
979 979
 
980 980
 		$label = rgget( 'label', $field );
981 981
 
982
-		if( '' === $label ) {
982
+		if ( '' === $label ) {
983 983
 
984
-			$label = isset( $form_field['label'] ) ? $form_field['label'] : '';
984
+			$label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : '';
985 985
 
986
-			switch( $field['field'] ) {
986
+			switch ( $field[ 'field' ] ) {
987 987
 				case 'search_all':
988 988
 					$label = __( 'Search Entries:', 'gravityview' );
989 989
 					break;
@@ -995,10 +995,10 @@  discard block
 block discarded – undo
995 995
 					break;
996 996
 				default:
997 997
 					// If this is a field input, not a field
998
-					if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) {
998
+					if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) {
999 999
 
1000 1000
 						// Get the label for the field in question, which returns an array
1001
-						$items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) );
1001
+						$items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) );
1002 1002
 
1003 1003
 						// Get the item with the `label` key
1004 1004
 						$values = wp_list_pluck( $items, 'label' );
@@ -1037,32 +1037,32 @@  discard block
 block discarded – undo
1037 1037
 		$form = $gravityview_view->getForm();
1038 1038
 
1039 1039
 		// for advanced field ids (eg, first name / last name )
1040
-		$name = 'filter_' . str_replace( '.', '_', $field['field'] );
1040
+		$name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] );
1041 1041
 
1042 1042
 		// get searched value from $_GET/$_POST (string or array)
1043 1043
 		$value = $this->rgget_or_rgpost( $name );
1044 1044
 
1045 1045
 		// get form field details
1046
-		$form_field = gravityview_get_field( $form, $field['field'] );
1046
+		$form_field = gravityview_get_field( $form, $field[ 'field' ] );
1047 1047
 
1048 1048
 		$filter = array(
1049
-			'key' => $field['field'],
1049
+			'key' => $field[ 'field' ],
1050 1050
 			'name' => $name,
1051 1051
 			'label' => self::get_field_label( $field, $form_field ),
1052
-			'input' => $field['input'],
1052
+			'input' => $field[ 'input' ],
1053 1053
 			'value' => $value,
1054
-			'type' => $form_field['type'],
1054
+			'type' => $form_field[ 'type' ],
1055 1055
 		);
1056 1056
 
1057 1057
 		// collect choices
1058
-		if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) {
1059
-			$filter['choices'] = gravityview_get_terms_choices();
1060
-		} elseif ( ! empty( $form_field['choices'] ) ) {
1061
-			$filter['choices'] = $form_field['choices'];
1058
+		if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) {
1059
+			$filter[ 'choices' ] = gravityview_get_terms_choices();
1060
+		} elseif ( ! empty( $form_field[ 'choices' ] ) ) {
1061
+			$filter[ 'choices' ] = $form_field[ 'choices' ];
1062 1062
 		}
1063 1063
 
1064
-		if ( 'date_range' === $field['input'] && empty( $value ) ) {
1065
-			$filter['value'] = array( 'start' => '', 'end' => '' );
1064
+		if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) {
1065
+			$filter[ 'value' ] = array( 'start' => '', 'end' => '' );
1066 1066
 		}
1067 1067
 
1068 1068
 		return $filter;
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
 
1087 1087
 		$choices = array();
1088 1088
 		foreach ( $users as $user ) {
1089
-			$choices[] = array(
1089
+			$choices[ ] = array(
1090 1090
 				'value' => $user->ID,
1091 1091
 				'text' => $user->display_name,
1092 1092
 			);
@@ -1141,7 +1141,7 @@  discard block
 block discarded – undo
1141 1141
 	 */
1142 1142
 	public function add_datepicker_js_dependency( $js_dependencies ) {
1143 1143
 
1144
-		$js_dependencies[] = 'jquery-ui-datepicker';
1144
+		$js_dependencies[ ] = 'jquery-ui-datepicker';
1145 1145
 
1146 1146
 		return $js_dependencies;
1147 1147
 	}
@@ -1185,7 +1185,7 @@  discard block
 block discarded – undo
1185 1185
 			'isRTL'             => is_rtl(),
1186 1186
 		), $view_data );
1187 1187
 
1188
-		$localizations['datepicker'] = $datepicker_settings;
1188
+		$localizations[ 'datepicker' ] = $datepicker_settings;
1189 1189
 
1190 1190
 		return $localizations;
1191 1191
 
@@ -1214,7 +1214,7 @@  discard block
 block discarded – undo
1214 1214
 	 * @return void
1215 1215
 	 */
1216 1216
 	private function maybe_enqueue_flexibility() {
1217
-		if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) {
1217
+		if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
1218 1218
 			wp_enqueue_script( 'gv-flexibility' );
1219 1219
 		}
1220 1220
 	}
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 		add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 );
1237 1237
 
1238 1238
 		$scheme = is_ssl() ? 'https://' : 'http://';
1239
-		wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1239
+		wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1240 1240
 
1241 1241
 		/**
1242 1242
 		 * @filter `gravityview_search_datepicker_class`
Please login to merge, or discard this patch.
includes/connector-functions.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
  * @param  mixed $field_id Field ID or Field array
329 329
  * @return string field type
330 330
  */
331
-function gravityview_get_field_type(  $form = null , $field_id = '' ) {
332
-	return GVCommon::get_field_type(  $form, $field_id );
331
+function gravityview_get_field_type( $form = null, $field_id = '' ) {
332
+	return GVCommon::get_field_type( $form, $field_id );
333 333
 }
334 334
 
335 335
 
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
  * @return string HTML of the output. Empty string if $view_id is empty.
343 343
  */
344 344
 function get_gravityview( $view_id = '', $atts = array() ) {
345
-	if( !empty( $view_id ) ) {
346
-		$atts['id'] = $view_id;
345
+	if ( ! empty( $view_id ) ) {
346
+		$atts[ 'id' ] = $view_id;
347 347
 		$args = wp_parse_args( $atts, defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? \GV\View_Settings::defaults() : GravityView_View_Data::get_default_args() );
348 348
 		$GravityView_frontend = GravityView_frontend::getInstance();
349 349
 		$GravityView_frontend->setGvOutputData( GravityView_View_Data::getInstance( $view_id ) );
@@ -386,19 +386,19 @@  discard block
 block discarded – undo
386 386
  */
387 387
 function gravityview_view_has_single_checkbox_or_radio( $form, $view_fields ) {
388 388
 
389
-	if( class_exists('GFFormsModel') && $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) {
389
+	if ( class_exists( 'GFFormsModel' ) && $form_fields = GFFormsModel::get_fields_by_type( $form, array( 'checkbox', 'radio' ) ) ) {
390 390
 
391 391
 		/** @var GF_Field_Radio|GF_Field_Checkbox $form_field */
392
-		foreach( $form_fields as $form_field ) {
392
+		foreach ( $form_fields as $form_field ) {
393 393
 			$field_id = $form_field->id;
394
-			foreach( $view_fields as $zone ) {
394
+			foreach ( $view_fields as $zone ) {
395 395
 
396 396
 				// ACF compatibility; ACF-added fields aren't arrays
397 397
 				if ( ! is_array( $zone ) ) { continue; }
398 398
 
399
-				foreach( $zone as $field ) {
399
+				foreach ( $zone as $field ) {
400 400
 					// If it's an input, not the parent and the parent ID matches a checkbox or radio
401
-					if( ( strpos( $field['id'], '.' ) > 0 ) && floor( $field['id'] ) === floor( $field_id ) ) {
401
+					if ( ( strpos( $field[ 'id' ], '.' ) > 0 ) && floor( $field[ 'id' ] ) === floor( $field_id ) ) {
402 402
 						return true;
403 403
 					}
404 404
 				}
Please login to merge, or discard this patch.