Completed
Pull Request — develop (#636)
by Zack
03:47
created
includes/class-frontend-views.php 1 patch
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	private function __construct() {}
86 86
 
87 87
 	private function initialize() {
88
-		add_action( 'wp', array( $this, 'parse_content'), 11 );
89
-		add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 );
88
+		add_action( 'wp', array( $this, 'parse_content' ), 11 );
89
+		add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 );
90 90
 
91 91
 		// Enqueue scripts and styles after GravityView_Template::register_styles()
92 92
 		add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 );
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 
234 234
 			$this->context_view_id = $view_id;
235 235
 
236
-		} elseif ( isset( $_GET['gvid'] ) && $this->getGvOutputData()->has_multiple_views() ) {
236
+		} elseif ( isset( $_GET[ 'gvid' ] ) && $this->getGvOutputData()->has_multiple_views() ) {
237 237
 			/**
238 238
 			 * used on a has_multiple_views context
239 239
 			 * @see GravityView_API::entry_link
240 240
 			 * @see GravityView_View_Data::getInstance()->has_multiple_views()
241 241
 			 */
242
-			$this->context_view_id = $_GET['gvid'];
242
+			$this->context_view_id = $_GET[ 'gvid' ];
243 243
 
244
-		} elseif ( ! $this->getGvOutputData()->has_multiple_views() )  {
244
+		} elseif ( ! $this->getGvOutputData()->has_multiple_views() ) {
245 245
 			$array_keys = array_keys( $this->getGvOutputData()->get_views() );
246 246
 			$this->context_view_id = array_pop( $array_keys );
247 247
 			unset( $array_keys );
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		global $post;
270 270
 
271 271
 		// If in admin and NOT AJAX request, get outta here.
272
-		if ( GravityView_Plugin::is_admin() )  {
272
+		if ( GravityView_Plugin::is_admin() ) {
273 273
 			return;
274 274
 		}
275 275
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
 		$this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' );
283 283
 
284
-		$post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null );
284
+		$post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null );
285 285
 		$this->setPostId( $post_id );
286 286
 		$post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false;
287 287
 		$this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) );
@@ -365,20 +365,20 @@  discard block
 block discarded – undo
365 365
 		 * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop
366 366
 		 * @param array $entry Current entry
367 367
 		 */
368
-		$apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry );
368
+		$apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry );
369 369
 
370 370
 		if ( ! $apply_outside_loop ) {
371 371
 			return $title;
372 372
 		}
373 373
 
374 374
 		// User reported WooCommerce doesn't pass two args.
375
-		if ( empty( $passed_post_id ) )  {
375
+		if ( empty( $passed_post_id ) ) {
376 376
 			return $title;
377 377
 		}
378 378
 
379 379
 		// Don't modify the title for anything other than the current view/post.
380 380
 		// This is true for embedded shortcodes and Views.
381
-		if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) {
381
+		if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) {
382 382
 			return $title;
383 383
 		}
384 384
 
@@ -388,19 +388,19 @@  discard block
 block discarded – undo
388 388
 			$view_meta = $this->getGvOutputData()->get_view( $context_view_id );
389 389
 		} else {
390 390
 			foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) {
391
-				if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) {
391
+				if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) {
392 392
 					$view_meta = $view_data;
393 393
 					break;
394 394
 				}
395 395
 			}
396 396
 		}
397 397
 
398
-		if ( ! empty( $view_meta['atts']['single_title'] ) ) {
398
+		if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) {
399 399
 
400
-			$title = $view_meta['atts']['single_title'];
400
+			$title = $view_meta[ 'atts' ][ 'single_title' ];
401 401
 
402 402
 			// We are allowing HTML in the fields, so no escaping the output
403
-			$title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry );
403
+			$title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry );
404 404
 
405 405
 			$title = do_shortcode( $title );
406 406
 		}
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 	public function render_view( $passed_args ) {
502 502
 
503 503
 		// validate attributes
504
-		if ( empty( $passed_args['id'] ) ) {
504
+		if ( empty( $passed_args[ 'id' ] ) ) {
505 505
 			do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args );
506 506
 			return null;
507 507
 		}
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 			return null;
524 524
 		}
525 525
 
526
-		$view_id = $passed_args['id'];
526
+		$view_id = $passed_args[ 'id' ];
527 527
 
528 528
 		$view_data = $this->getGvOutputData()->get_view( $view_id, $passed_args );
529 529
 
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 		$passed_args = array_filter( $passed_args, 'strlen' );
537 537
 
538 538
 		//Override shortcode args over View template settings
539
-		$atts = wp_parse_args( $passed_args, $view_data['atts'] );
539
+		$atts = wp_parse_args( $passed_args, $view_data[ 'atts' ] );
540 540
 
541 541
 		do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts );
542 542
 
@@ -558,11 +558,11 @@  discard block
 block discarded – undo
558 558
 		 * Don't render View if user isn't allowed to see it
559 559
 		 * @since 1.15
560 560
 		 */
561
-		if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
561
+		if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
562 562
 			return null;
563 563
 		}
564 564
 
565
-		if( $this->isGravityviewPostType() ) {
565
+		if ( $this->isGravityviewPostType() ) {
566 566
 
567 567
 			/**
568 568
 			 * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode?
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
 			 */
575 575
 			$direct_access = apply_filters( 'gravityview_direct_access', true, $view_id );
576 576
 
577
-			$embed_only = ! empty( $atts['embed_only'] );
577
+			$embed_only = ! empty( $atts[ 'embed_only' ] );
578 578
 
579
-			if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) {
579
+			if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) {
580 580
 				return __( 'You are not allowed to view this content.', 'gravityview' );
581 581
 			}
582 582
 		}
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 
592 592
 		$gravityview_view = new GravityView_View( $view_data );
593 593
 
594
-		$post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : $this->getPostId();
594
+		$post_id = ! empty( $atts[ 'post_id' ] ) ? intval( $atts[ 'post_id' ] ) : $this->getPostId();
595 595
 
596 596
 		$gravityview_view->setPostId( $post_id );
597 597
 
@@ -601,20 +601,20 @@  discard block
 block discarded – undo
601 601
 			do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' );
602 602
 
603 603
 			//fetch template and slug
604
-			$view_slug = apply_filters( 'gravityview_template_slug_'. $view_data['template_id'], 'table', 'directory' );
604
+			$view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'directory' );
605 605
 
606 606
 			do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug );
607 607
 
608 608
 			/**
609 609
 			 * Disable fetching initial entries for views that don't need it (DataTables)
610 610
 			 */
611
-			$get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true );
611
+			$get_entries = apply_filters( 'gravityview_get_view_entries_' . $view_slug, true );
612 612
 
613 613
 			/**
614 614
 			 * Hide View data until search is performed
615 615
 			 * @since 1.5.4
616 616
 			 */
617
-			if ( ! empty( $atts['hide_until_searched'] ) && ! $this->isSearch() ) {
617
+			if ( ! empty( $atts[ 'hide_until_searched' ] ) && ! $this->isSearch() ) {
618 618
 				$gravityview_view->setHideUntilSearched( true );
619 619
 				$get_entries = false;
620 620
 			}
@@ -622,23 +622,23 @@  discard block
 block discarded – undo
622 622
 
623 623
 			if ( $get_entries ) {
624 624
 
625
-				if ( ! empty( $atts['sort_columns'] ) ) {
625
+				if ( ! empty( $atts[ 'sort_columns' ] ) ) {
626 626
 					// add filter to enable column sorting
627
-					add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 );
627
+					add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ), 100, 3 );
628 628
 				}
629 629
 
630
-				$view_entries = self::get_view_entries( $atts, $view_data['form_id'] );
630
+				$view_entries = self::get_view_entries( $atts, $view_data[ 'form_id' ] );
631 631
 
632
-				do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) );
632
+				do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries[ 'count' ], sizeof( $view_entries[ 'entries' ] ) ) );
633 633
 
634 634
 			} else {
635 635
 
636 636
 				$view_entries = array( 'count' => null, 'entries' => null, 'paging' => null );
637 637
 
638
-				do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' );
638
+				do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_' . $view_slug . '` is false' );
639 639
 			}
640 640
 
641
-			$gravityview_view->setPaging( $view_entries['paging'] );
641
+			$gravityview_view->setPaging( $view_entries[ 'paging' ] );
642 642
 			$gravityview_view->setContext( 'directory' );
643 643
 			$sections = array( 'header', 'body', 'footer' );
644 644
 
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 			// user requested Single Entry View
648 648
 			do_action( 'gravityview_log_debug', '[render_view] Executing Single View' );
649 649
 
650
-			do_action( 'gravityview_render_entry_'.$view_data['id'] );
650
+			do_action( 'gravityview_render_entry_' . $view_data[ 'id' ] );
651 651
 
652 652
 			$entry = $this->getEntry();
653 653
 
@@ -674,20 +674,20 @@  discard block
 block discarded – undo
674 674
 			// We're in single view, but the view being processed is not the same view the single entry belongs to.
675 675
 			// important: do not remove this as it prevents fake attempts of displaying entries from other views/forms
676 676
 			if ( $this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id() ) {
677
-				do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '. $view_id );
677
+				do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: ' . $view_id );
678 678
 				return null;
679 679
 			}
680 680
 
681 681
 			//fetch template and slug
682
-			$view_slug = apply_filters( 'gravityview_template_slug_' . $view_data['template_id'], 'table', 'single' );
682
+			$view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'single' );
683 683
 			do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug );
684 684
 
685 685
 			//fetch entry detail
686
-			$view_entries['count'] = 1;
687
-			$view_entries['entries'][] = $entry;
688
-			do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] );
686
+			$view_entries[ 'count' ] = 1;
687
+			$view_entries[ 'entries' ][ ] = $entry;
688
+			do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries[ 'entries' ] );
689 689
 
690
-			$back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null;
690
+			$back_link_label = isset( $atts[ 'back_link_label' ] ) ? $atts[ 'back_link_label' ] : null;
691 691
 
692 692
 			// set back link label
693 693
 			$gravityview_view->setBackLinkLabel( $back_link_label );
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
 		}
698 698
 
699 699
 		// add template style
700
-		self::add_style( $view_data['template_id'] );
700
+		self::add_style( $view_data[ 'template_id' ] );
701 701
 
702 702
 		// Prepare to render view and set vars
703
-		$gravityview_view->setEntries( $view_entries['entries'] );
704
-		$gravityview_view->setTotalEntries( $view_entries['count'] );
703
+		$gravityview_view->setEntries( $view_entries[ 'entries' ] );
704
+		$gravityview_view->setTotalEntries( $view_entries[ 'count' ] );
705 705
 
706 706
 		// If Edit
707 707
 		if ( 'edit' === gravityview_get_context() ) {
@@ -714,11 +714,11 @@  discard block
 block discarded – undo
714 714
 
715 715
 		} else {
716 716
 			// finaly we'll render some html
717
-			$sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data['template_id'] );
717
+			$sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data[ 'template_id' ] );
718 718
 
719 719
 			do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections );
720 720
 			foreach ( $sections as $section ) {
721
-				do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' );
721
+				do_action( 'gravityview_log_debug', '[render_view] Rendering ' . $section . ' section.' );
722 722
 				$gravityview_view->render( $view_slug, $section, false );
723 723
 			}
724 724
 		}
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 				$datetime_format = 'Y-m-d H:i:s';
773 773
 				$search_is_outside_view_bounds = false;
774 774
 
775
-				if( ! empty( $search_criteria[ $key ] ) ) {
775
+				if ( ! empty( $search_criteria[ $key ] ) ) {
776 776
 
777 777
 					$search_date = strtotime( $search_criteria[ $key ] );
778 778
 
@@ -800,14 +800,14 @@  discard block
 block discarded – undo
800 800
 				if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) {
801 801
 
802 802
 					// Then we override the search and re-set the start date
803
-					$return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true );
803
+					$return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true );
804 804
 				}
805 805
 			}
806 806
 		}
807 807
 
808
-		if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) {
808
+		if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) {
809 809
 			// The start date is AFTER the end date. This will result in no results, but let's not force the issue.
810
-			if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) {
810
+			if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) {
811 811
 				do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria );
812 812
 			}
813 813
 		}
@@ -825,9 +825,9 @@  discard block
 block discarded – undo
825 825
 	 */
826 826
 	public static function process_search_only_approved( $args, $search_criteria ) {
827 827
 
828
-		if ( ! empty( $args['show_only_approved'] ) ) {
829
-			$search_criteria['field_filters'][] = array( 'key' => 'is_approved', 'value' => 'Approved' );
830
-			$search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met
828
+		if ( ! empty( $args[ 'show_only_approved' ] ) ) {
829
+			$search_criteria[ 'field_filters' ][ ] = array( 'key' => 'is_approved', 'value' => 'Approved' );
830
+			$search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met
831 831
 
832 832
 			do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria );
833 833
 		}
@@ -851,12 +851,12 @@  discard block
 block discarded – undo
851 851
 	 */
852 852
 	public static function is_entry_approved( $entry, $args = array() ) {
853 853
 
854
-		if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) {
854
+		if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) {
855 855
 			// is implicitly approved if entry is null or View settings doesn't require to check for approval
856 856
 			return true;
857 857
 		}
858 858
 
859
-		$is_approved = gform_get_meta( $entry['id'], 'is_approved' );
859
+		$is_approved = gform_get_meta( $entry[ 'id' ], 'is_approved' );
860 860
 
861 861
 		if ( $is_approved ) {
862 862
 			return true;
@@ -889,26 +889,26 @@  discard block
 block discarded – undo
889 889
 		do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria );
890 890
 
891 891
 		// implicity search
892
-		if ( ! empty( $args['search_value'] ) ) {
892
+		if ( ! empty( $args[ 'search_value' ] ) ) {
893 893
 
894 894
 			// Search operator options. Options: `is` or `contains`
895
-			$operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains';
895
+			$operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains';
896 896
 
897
-			$search_criteria['field_filters'][] = array(
897
+			$search_criteria[ 'field_filters' ][ ] = array(
898 898
 				'key' => rgget( 'search_field', $args ), // The field ID to search
899
-				'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes.
899
+				'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes.
900 900
 				'operator' => $operator,
901 901
 			);
902 902
 		}
903 903
 
904
-		if( $search_criteria !== $original_search_criteria ) {
904
+		if ( $search_criteria !== $original_search_criteria ) {
905 905
 			do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria );
906 906
 		}
907 907
 
908 908
 		// Handle setting date range
909 909
 		$search_criteria = self::process_search_dates( $args, $search_criteria );
910 910
 
911
-		if( $search_criteria !== $original_search_criteria ) {
911
+		if ( $search_criteria !== $original_search_criteria ) {
912 912
 			do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria );
913 913
 		}
914 914
 
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 		 * @filter `gravityview_status` Modify entry status requirements to be included in search results.
920 920
 		 * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash`
921 921
 		 */
922
-		$search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args );
922
+		$search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args );
923 923
 
924 924
 		return $search_criteria;
925 925
 	}
@@ -965,16 +965,16 @@  discard block
 block discarded – undo
965 965
 		$search_criteria = self::get_search_criteria( $args, $form_id );
966 966
 
967 967
 		// Paging & offset
968
-		$page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : apply_filters( 'gravityview_default_page_size', 25 );
968
+		$page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : apply_filters( 'gravityview_default_page_size', 25 );
969 969
 
970 970
 		if ( -1 === $page_size ) {
971 971
 			$page_size = PHP_INT_MAX;
972 972
 		}
973 973
 
974
-		if ( isset( $args['offset'] ) ) {
975
-			$offset = intval( $args['offset'] );
974
+		if ( isset( $args[ 'offset' ] ) ) {
975
+			$offset = intval( $args[ 'offset' ] );
976 976
 		} else {
977
-			$curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] );
977
+			$curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] );
978 978
 			$offset = ( $curr_page - 1 ) * $page_size;
979 979
 		}
980 980
 
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 			'search_criteria' => $search_criteria,
993 993
 			'sorting' => $sorting,
994 994
 			'paging' => $paging,
995
-			'cache' => isset( $args['cache'] ) ? $args['cache'] : true,
995
+			'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true,
996 996
 		);
997 997
 
998 998
 		/**
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
 		 * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys.
1018 1018
 		 * @param array $args View configuration args.
1019 1019
 		 */
1020
-		$parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id );
1020
+		$parameters = apply_filters( 'gravityview_get_entries_' . $args[ 'id' ], $parameters, $args, $form_id );
1021 1021
 
1022 1022
 		do_action( 'gravityview_log_debug', '[get_view_entries] $parameters passed to gravityview_get_entries(): ', $parameters );
1023 1023
 
@@ -1057,8 +1057,8 @@  discard block
 block discarded – undo
1057 1057
 	 */
1058 1058
 	public static function updateViewSorting( $args, $form_id ) {
1059 1059
 		$sorting = array();
1060
-		$sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' );
1061
-		$sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' );
1060
+		$sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : rgar( $args, 'sort_field' );
1061
+		$sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : rgar( $args, 'sort_direction' );
1062 1062
 
1063 1063
 		$sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id );
1064 1064
 
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 
1099 1099
 		$sort_field = GFFormsModel::get_field( $form, $sort_field_id );
1100 1100
 
1101
-		switch ( $sort_field['type'] ) {
1101
+		switch ( $sort_field[ 'type' ] ) {
1102 1102
 
1103 1103
 			case 'address':
1104 1104
 				// Sorting by full address
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 					 */
1116 1116
 					$address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id );
1117 1117
 
1118
-					switch( strtolower( $address_part ) ){
1118
+					switch ( strtolower( $address_part ) ) {
1119 1119
 						case 'street':
1120 1120
 							$sort_field_id .= '.1';
1121 1121
 							break;
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
 		 */
1196 1196
 		$single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry );
1197 1197
 
1198
-		if ( empty( $single_entry ) ){
1198
+		if ( empty( $single_entry ) ) {
1199 1199
 			return false;
1200 1200
 		} else {
1201 1201
 			return $single_entry;
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 				 * Don't enqueue the scripts or styles if it's not going to be displayed.
1223 1223
 				 * @since 1.15
1224 1224
 				 */
1225
-				if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
1225
+				if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
1226 1226
 					continue;
1227 1227
 				}
1228 1228
 
@@ -1231,19 +1231,19 @@  discard block
 block discarded – undo
1231 1231
 				$css_dependencies = array();
1232 1232
 
1233 1233
 				// If the thickbox is enqueued, add dependencies
1234
-				if ( ! empty( $data['atts']['lightbox'] ) ) {
1234
+				if ( ! empty( $data[ 'atts' ][ 'lightbox' ] ) ) {
1235 1235
 
1236 1236
 					/**
1237 1237
 					 * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox`
1238 1238
 					 * @param string $script_slug If you want to use a different lightbox script, return the name of it here.
1239 1239
 					 */
1240
-					$js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' );
1240
+					$js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' );
1241 1241
 
1242 1242
 					/**
1243 1243
 					 * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox`
1244 1244
 					 * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here.
1245 1245
 					 */
1246
-					$css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' );
1246
+					$css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' );
1247 1247
 				}
1248 1248
 
1249 1249
 				/**
@@ -1251,25 +1251,25 @@  discard block
 block discarded – undo
1251 1251
 				 * @see https://github.com/katzwebservices/GravityView/issues/536
1252 1252
 				 * @since 1.15
1253 1253
 				 */
1254
-				if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) {
1255
-					$css_dependencies[] = 'dashicons';
1254
+				if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) {
1255
+					$css_dependencies[ ] = 'dashicons';
1256 1256
 				}
1257 1257
 
1258 1258
 				wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true );
1259 1259
 
1260 1260
 				$script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
1261 1261
 
1262
-				wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true );
1262
+				wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ), GravityView_Plugin::version, true );
1263 1263
 
1264 1264
 				wp_enqueue_script( 'gravityview-fe-view' );
1265 1265
 
1266
-				if ( ! empty( $data['atts']['sort_columns'] ) ) {
1266
+				if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) {
1267 1267
 					wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' );
1268 1268
 				}
1269 1269
 
1270 1270
 				wp_enqueue_style( 'gravityview_default_style', plugins_url( 'templates/css/gv-default-styles.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' );
1271 1271
 
1272
-				self::add_style( $data['template_id'] );
1272
+				self::add_style( $data[ 'template_id' ] );
1273 1273
 
1274 1274
 			}
1275 1275
 
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 		} elseif ( empty( $template_id ) ) {
1306 1306
 			do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' );
1307 1307
 		} else {
1308
-			do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) );
1308
+			do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_' . $template_id ) );
1309 1309
 		}
1310 1310
 
1311 1311
 	}
@@ -1330,11 +1330,11 @@  discard block
 block discarded – undo
1330 1330
 		 * Not a table-based template; don't add sort icons
1331 1331
 		 * @since 1.12
1332 1332
 		 */
1333
-		if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) {
1333
+		if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) {
1334 1334
 			return $label;
1335 1335
 		}
1336 1336
 
1337
-		if ( ! $this->is_field_sortable( $field['id'], $form ) ) {
1337
+		if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) {
1338 1338
 			return $label;
1339 1339
 		}
1340 1340
 
@@ -1342,29 +1342,29 @@  discard block
 block discarded – undo
1342 1342
 
1343 1343
 		$class = 'gv-sort';
1344 1344
 
1345
-		$sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] );
1345
+		$sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] );
1346 1346
 
1347 1347
 		$sort_args = array(
1348
-			'sort' => $field['id'],
1348
+			'sort' => $field[ 'id' ],
1349 1349
 			'dir' => 'asc',
1350 1350
 		);
1351 1351
 
1352
-		if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) {
1352
+		if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) {
1353 1353
 			//toggle sorting direction.
1354
-			if ( 'asc' === $sorting['direction'] ) {
1355
-				$sort_args['dir'] = 'desc';
1354
+			if ( 'asc' === $sorting[ 'direction' ] ) {
1355
+				$sort_args[ 'dir' ] = 'desc';
1356 1356
 				$class .= ' gv-icon-sort-desc';
1357 1357
 			} else {
1358
-				$sort_args['dir'] = 'asc';
1358
+				$sort_args[ 'dir' ] = 'asc';
1359 1359
 				$class .= ' gv-icon-sort-asc';
1360 1360
 			}
1361 1361
 		} else {
1362 1362
 			$class .= ' gv-icon-caret-up-down';
1363 1363
 		}
1364 1364
 
1365
-		$url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) );
1365
+		$url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) );
1366 1366
 
1367
-		return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a>&nbsp;'. $label;
1367
+		return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a>&nbsp;' . $label;
1368 1368
 
1369 1369
 	}
1370 1370
 
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
 
1383 1383
 		$field_type = $field_id;
1384 1384
 
1385
-		if( is_numeric( $field_id ) ) {
1385
+		if ( is_numeric( $field_id ) ) {
1386 1386
 			$field = GFFormsModel::get_field( $form, $field_id );
1387 1387
 			$field_type = $field->type;
1388 1388
 		}
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
 			return false;
1406 1406
 		}
1407 1407
 
1408
-		return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) );
1408
+		return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) );
1409 1409
 
1410 1410
 	}
1411 1411
 
Please login to merge, or discard this patch.
includes/widgets/search-widget/class-search-widget.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 				'type' => 'radio',
57 57
 				'full_width' => true,
58 58
 				'label' => esc_html__( 'Search Mode', 'gravityview' ),
59
-				'desc' => __('Should search results match all search fields, or any?', 'gravityview'),
59
+				'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ),
60 60
 				'value' => 'any',
61 61
 				'class' => 'hide-if-js',
62 62
 				'options' => array(
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
112 112
 		$script_source = empty( $script_min ) ? '/source' : '';
113 113
 
114
-		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 );
114
+		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 );
115 115
 
116 116
 
117 117
 		/**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * Add admin script to the whitelist
164 164
 	 */
165 165
 	public function register_no_conflict( $required ) {
166
-		$required[] = 'gravityview_searchwidget_admin';
166
+		$required[ ] = 'gravityview_searchwidget_admin';
167 167
 		return $required;
168 168
 	}
169 169
 
@@ -176,24 +176,24 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	public static function get_searchable_fields() {
178 178
 
179
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) {
179
+		if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) {
180 180
 			exit( '0' );
181 181
 		}
182 182
 
183 183
 		$form = '';
184 184
 
185 185
 		// Fetch the form for the current View
186
-		if ( ! empty( $_POST['view_id'] ) ) {
186
+		if ( ! empty( $_POST[ 'view_id' ] ) ) {
187 187
 
188
-			$form = gravityview_get_form_id( $_POST['view_id'] );
188
+			$form = gravityview_get_form_id( $_POST[ 'view_id' ] );
189 189
 
190
-		} elseif ( ! empty( $_POST['formid'] ) ) {
190
+		} elseif ( ! empty( $_POST[ 'formid' ] ) ) {
191 191
 
192
-			$form = (int) $_POST['formid'];
192
+			$form = (int)$_POST[ 'formid' ];
193 193
 
194
-		} elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) {
194
+		} elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) {
195 195
 
196
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
196
+			$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
197 197
 
198 198
 		}
199 199
 
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 			)
242 242
 		);
243 243
 
244
-		foreach( $custom_fields as $custom_field_key => $custom_field ) {
245
-			$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'] );
244
+		foreach ( $custom_fields as $custom_field_key => $custom_field ) {
245
+			$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' ] );
246 246
 		}
247 247
 
248 248
 		if ( ! empty( $fields ) ) {
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
 
252 252
 			foreach ( $fields as $id => $field ) {
253 253
 
254
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
254
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
255 255
 					continue;
256 256
 				}
257 257
 
258
-				$types = self::get_search_input_types( $id, $field['type'] );
258
+				$types = self::get_search_input_types( $id, $field[ 'type' ] );
259 259
 
260
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>';
260
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>';
261 261
 			}
262 262
 		}
263 263
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	public static function get_search_input_types( $id = '', $field_type = null ) {
280 280
 
281 281
 		// @todo - This needs to be improved - many fields have . including products and addresses
282
-		if ( false !== strpos( (string) $id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) {
282
+		if ( false !== strpos( (string)$id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) {
283 283
 			$input_type = 'boolean'; // on/off checkbox
284 284
 		} elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) {
285 285
 			$input_type = 'multi'; //multiselect
@@ -321,19 +321,19 @@  discard block
 block discarded – undo
321 321
 			$post_id = 0;
322 322
 
323 323
 			// We're in the WordPress Widget context, and an overriding post ID has been set.
324
-			if ( ! empty( $widget_args['post_id'] ) ) {
325
-				$post_id = absint( $widget_args['post_id'] );
324
+			if ( ! empty( $widget_args[ 'post_id' ] ) ) {
325
+				$post_id = absint( $widget_args[ 'post_id' ] );
326 326
 			}
327 327
 			// We're in the WordPress Widget context, and the base View ID should be used
328
-			else if ( ! empty( $widget_args['view_id'] ) ) {
329
-				$post_id = absint( $widget_args['view_id'] );
328
+			else if ( ! empty( $widget_args[ 'view_id' ] ) ) {
329
+				$post_id = absint( $widget_args[ 'view_id' ] );
330 330
 			}
331 331
 
332 332
 			$args = gravityview_get_permalink_query_args( $post_id );
333 333
 
334 334
 			// Add hidden fields to the search form
335 335
 			foreach ( $args as $key => $value ) {
336
-				$search_fields[] = array(
336
+				$search_fields[ ] = array(
337 337
 					'name'  => $key,
338 338
 					'input' => 'hidden',
339 339
 					'value' => $value,
@@ -365,15 +365,15 @@  discard block
 block discarded – undo
365 365
 		$get = array_map( 'urldecode', $get );
366 366
 
367 367
 		// add free search
368
-		if ( ! empty( $get['gv_search'] ) ) {
368
+		if ( ! empty( $get[ 'gv_search' ] ) ) {
369 369
 
370 370
 			// Search for a piece
371
-			$words = explode( ' ', $get['gv_search'] );
371
+			$words = explode( ' ', $get[ 'gv_search' ] );
372 372
 
373 373
 			$words = array_filter( $words );
374 374
 
375 375
 			foreach ( $words as $word ) {
376
-				$search_criteria['field_filters'][] = array(
376
+				$search_criteria[ 'field_filters' ][ ] = array(
377 377
 					'key' => null, // The field ID to search
378 378
 					'value' => $word, // The value to search
379 379
 					'operator' => 'contains', // What to search in. Options: `is` or `contains`
@@ -398,16 +398,16 @@  discard block
 block discarded – undo
398 398
 		/**
399 399
 		 * Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries)
400 400
 		 */
401
-		if( !empty( $curr_start ) ) {
402
-			$search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
401
+		if ( ! empty( $curr_start ) ) {
402
+			$search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
403 403
 		}
404
-		if( !empty( $curr_end ) ) {
405
-			$search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
404
+		if ( ! empty( $curr_end ) ) {
405
+			$search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
406 406
 		}
407 407
 
408 408
 		// search for a specific entry ID
409 409
 		if ( ! empty( $get[ 'gv_id' ] ) ) {
410
-			$search_criteria['field_filters'][] = array(
410
+			$search_criteria[ 'field_filters' ][ ] = array(
411 411
 				'key' => 'id',
412 412
 				'value' => absint( $get[ 'gv_id' ] ),
413 413
 				'operator' => '=',
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
 
417 417
 		// search for a specific Created_by ID
418 418
 		if ( ! empty( $get[ 'gv_by' ] ) ) {
419
-			$search_criteria['field_filters'][] = array(
419
+			$search_criteria[ 'field_filters' ][ ] = array(
420 420
 				'key' => 'created_by',
421
-				'value' => absint( $get['gv_by'] ),
421
+				'value' => absint( $get[ 'gv_by' ] ),
422 422
 				'operator' => '=',
423 423
 			);
424 424
 		}
@@ -430,22 +430,22 @@  discard block
 block discarded – undo
430 430
 		// get the other search filters
431 431
 		foreach ( $get as $key => $value ) {
432 432
 
433
-			if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) {
433
+			if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[ 0 ] ) ) ) {
434 434
 				continue;
435 435
 			}
436 436
 
437 437
 			// could return simple filter or multiple filters
438 438
 			$filter = $this->prepare_field_filter( $key, $value );
439 439
 
440
-			if ( isset( $filter[0]['value'] ) ) {
441
-				$search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter );
440
+			if ( isset( $filter[ 0 ][ 'value' ] ) ) {
441
+				$search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter );
442 442
 
443 443
 				// if date range type, set search mode to ALL
444
-				if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>', '<' ) ) ) {
444
+				if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>', '<' ) ) ) {
445 445
 					$mode = 'all';
446 446
 				}
447
-			} elseif( !empty( $filter ) ) {
448
-				$search_criteria['field_filters'][] = $filter;
447
+			} elseif ( ! empty( $filter ) ) {
448
+				$search_criteria[ 'field_filters' ][ ] = $filter;
449 449
 			}
450 450
 		}
451 451
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 		 * @since 1.5.1
455 455
 		 * @param[out,in] string $mode Search mode (`any` vs `all`)
456 456
 		 */
457
-		$search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode );
457
+		$search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode );
458 458
 
459 459
 		do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria );
460 460
 
@@ -490,11 +490,11 @@  discard block
 block discarded – undo
490 490
 			'value' => _wp_specialchars( $value ), // Gravity Forms encodes ampersands but not quotes
491 491
 		);
492 492
 
493
-		switch ( $form_field['type'] ) {
493
+		switch ( $form_field[ 'type' ] ) {
494 494
 
495 495
 			case 'select':
496 496
 			case 'radio':
497
-				$filter['operator'] = 'is';
497
+				$filter[ 'operator' ] = 'is';
498 498
 				break;
499 499
 
500 500
 			case 'post_category':
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 
509 509
 				foreach ( $value as $val ) {
510 510
 					$cat = get_term( $val, 'category' );
511
-					$filter[] = array(
511
+					$filter[ ] = array(
512 512
 						'key' => $field_id,
513 513
 						'value' => esc_attr( $cat->name ) . ':' . $val,
514 514
 						'operator' => 'is',
@@ -527,18 +527,18 @@  discard block
 block discarded – undo
527 527
 				$filter = array();
528 528
 
529 529
 				foreach ( $value as $val ) {
530
-					$filter[] = array( 'key' => $field_id, 'value' => $val );
530
+					$filter[ ] = array( 'key' => $field_id, 'value' => $val );
531 531
 				}
532 532
 
533 533
 				break;
534 534
 
535 535
 			case 'checkbox':
536 536
 				// convert checkbox on/off into the correct search filter
537
-				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) {
538
-					foreach ( $form_field['inputs'] as $k => $input ) {
539
-						if ( $input['id'] == $field_id ) {
540
-							$filter['value'] = $form_field['choices'][ $k ]['value'];
541
-							$filter['operator'] = 'is';
537
+				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) {
538
+					foreach ( $form_field[ 'inputs' ] as $k => $input ) {
539
+						if ( $input[ 'id' ] == $field_id ) {
540
+							$filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ];
541
+							$filter[ 'operator' ] = 'is';
542 542
 							break;
543 543
 						}
544 544
 					}
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 					$filter = array();
549 549
 
550 550
 					foreach ( $value as $val ) {
551
-						$filter[] = array(
551
+						$filter[ ] = array(
552 552
 								'key'   => $field_id,
553 553
 								'value' => $val,
554 554
 								'operator' => 'is',
@@ -569,9 +569,9 @@  discard block
 block discarded – undo
569 569
 					foreach ( $words as $word ) {
570 570
 						if ( ! empty( $word ) && strlen( $word ) > 1 ) {
571 571
 							// Keep the same key for each filter
572
-							$filter['value'] = $word;
572
+							$filter[ 'value' ] = $word;
573 573
 							// Add a search for the value
574
-							$filters[] = $filter;
574
+							$filters[ ] = $filter;
575 575
 						}
576 576
 					}
577 577
 
@@ -593,14 +593,14 @@  discard block
 block discarded – undo
593 593
 						}
594 594
 						$operator = 'start' === $k ? '>' : '<';
595 595
 
596
-						$filter[] = array(
596
+						$filter[ ] = array(
597 597
 							'key' => $field_id,
598 598
 							'value' => self::get_formatted_date( $date, 'Y-m-d' ),
599 599
 							'operator' => $operator,
600 600
 						);
601 601
 					}
602 602
 				} else {
603
-					$filter['value'] = self::get_formatted_date( $value, 'Y-m-d' );
603
+					$filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' );
604 604
 				}
605 605
 
606 606
 				break;
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 			'ymd_dot' => 'Y.m.d',
632 632
 		);
633 633
 
634
-		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){
634
+		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) {
635 635
 			$format = $datepicker[ $field->dateFormat ];
636 636
 		}
637 637
 
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	public function add_template_path( $file_paths ) {
663 663
 
664 664
 		// Index 100 is the default GravityView template path.
665
-		$file_paths[102] = self::$file . 'templates/';
665
+		$file_paths[ 102 ] = self::$file . 'templates/';
666 666
 
667 667
 		return $file_paths;
668 668
 	}
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 		}
685 685
 
686 686
 		// get configured search fields
687
-		$search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : '';
687
+		$search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : '';
688 688
 
689 689
 		if ( empty( $search_fields ) || ! is_array( $search_fields ) ) {
690 690
 			do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args );
@@ -698,24 +698,24 @@  discard block
 block discarded – undo
698 698
 
699 699
 			$updated_field = $field;
700 700
 
701
-			if ( in_array( $field['input'], array( 'date', 'date_range' ) ) ) {
701
+			if ( in_array( $field[ 'input' ], array( 'date', 'date_range' ) ) ) {
702 702
 				$has_date = true;
703 703
 			}
704 704
 
705 705
 			$updated_field = $this->get_search_filter_details( $updated_field );
706 706
 
707
-			switch ( $field['field'] ) {
707
+			switch ( $field[ 'field' ] ) {
708 708
 
709 709
 				case 'search_all':
710
-					$updated_field['key'] = 'search_all';
711
-					$updated_field['input'] = 'search_all';
712
-					$updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_search' ) ) );
710
+					$updated_field[ 'key' ] = 'search_all';
711
+					$updated_field[ 'input' ] = 'search_all';
712
+					$updated_field[ 'value' ] = esc_attr( stripslashes_deep( rgget( 'gv_search' ) ) );
713 713
 					break;
714 714
 
715 715
 				case 'entry_date':
716
-					$updated_field['key'] = 'entry_date';
717
-					$updated_field['input'] = 'entry_date';
718
-					$updated_field['value'] = array(
716
+					$updated_field[ 'key' ] = 'entry_date';
717
+					$updated_field[ 'input' ] = 'entry_date';
718
+					$updated_field[ 'value' ] = array(
719 719
 						'start' => esc_attr( stripslashes_deep( rgget( 'gv_start' ) ) ),
720 720
 						'end' => esc_attr( stripslashes_deep( rgget( 'gv_end' ) ) ),
721 721
 					);
@@ -723,16 +723,16 @@  discard block
 block discarded – undo
723 723
 					break;
724 724
 
725 725
 				case 'entry_id':
726
-					$updated_field['key'] = 'entry_id';
727
-					$updated_field['input'] = 'entry_id';
728
-					$updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_id' ) ) );
726
+					$updated_field[ 'key' ] = 'entry_id';
727
+					$updated_field[ 'input' ] = 'entry_id';
728
+					$updated_field[ 'value' ] = esc_attr( stripslashes_deep( rgget( 'gv_id' ) ) );
729 729
 					break;
730 730
 
731 731
 				case 'created_by':
732
-					$updated_field['key'] = 'created_by';
733
-					$updated_field['name'] = 'gv_by';
734
-					$updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_by' ) ) );
735
-					$updated_field['choices'] = self::get_created_by_choices();
732
+					$updated_field[ 'key' ] = 'created_by';
733
+					$updated_field[ 'name' ] = 'gv_by';
734
+					$updated_field[ 'value' ] = esc_attr( stripslashes_deep( rgget( 'gv_by' ) ) );
735
+					$updated_field[ 'choices' ] = self::get_created_by_choices();
736 736
 					break;
737 737
 			}
738 738
 
@@ -750,16 +750,16 @@  discard block
 block discarded – undo
750 750
 		 */
751 751
 		$gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args );
752 752
 
753
-		$gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal';
753
+		$gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal';
754 754
 
755 755
 		/** @since 1.14 */
756
-		$gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any';
756
+		$gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any';
757 757
 
758
-		$custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : '';
758
+		$custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : '';
759 759
 
760 760
 		$gravityview_view->search_class = self::get_search_class( $custom_class );
761 761
 
762
-		$gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false;
762
+		$gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false;
763 763
 
764 764
 		if ( $has_date ) {
765 765
 			// enqueue datepicker stuff only if needed!
@@ -779,10 +779,10 @@  discard block
 block discarded – undo
779 779
 	public static function get_search_class( $custom_class = '' ) {
780 780
 		$gravityview_view = GravityView_View::getInstance();
781 781
 
782
-		$search_class = 'gv-search-'.$gravityview_view->search_layout;
782
+		$search_class = 'gv-search-' . $gravityview_view->search_layout;
783 783
 
784
-		if ( ! empty( $custom_class )  ) {
785
-			$search_class .= ' '.$custom_class;
784
+		if ( ! empty( $custom_class ) ) {
785
+			$search_class .= ' ' . $custom_class;
786 786
 		}
787 787
 
788 788
 		/**
@@ -825,11 +825,11 @@  discard block
 block discarded – undo
825 825
 
826 826
 		$label = rgget( 'label', $field );
827 827
 
828
-		if( '' === $label ) {
828
+		if ( '' === $label ) {
829 829
 
830
-			$label = isset( $form_field['label'] ) ? $form_field['label'] : '';
830
+			$label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : '';
831 831
 
832
-			switch( $field['field'] ) {
832
+			switch ( $field[ 'field' ] ) {
833 833
 				case 'search_all':
834 834
 					$label = __( 'Search Entries:', 'gravityview' );
835 835
 					break;
@@ -847,10 +847,10 @@  discard block
 block discarded – undo
847 847
 					break;
848 848
 				default:
849 849
 					// If this is a field input, not a field
850
-					if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) {
850
+					if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) {
851 851
 
852 852
 						// Get the label for the field in question, which returns an array
853
-						$items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) );
853
+						$items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) );
854 854
 
855 855
 						// Get the item with the `label` key
856 856
 						$values = wp_list_pluck( $items, 'label' );
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 		$form = $gravityview_view->getForm();
888 888
 
889 889
 		// for advanced field ids (eg, first name / last name )
890
-		$name = 'filter_' . str_replace( '.', '_', $field['field'] );
890
+		$name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] );
891 891
 
892 892
 		// get searched value from $_GET (string or array)
893 893
 		$value = rgget( $name );
@@ -897,26 +897,26 @@  discard block
 block discarded – undo
897 897
 		$value = is_array( $value ) ? array_map( 'urldecode', $value ) : urldecode( $value );
898 898
 
899 899
 		// get form field details
900
-		$form_field = gravityview_get_field( $form, $field['field'] );
900
+		$form_field = gravityview_get_field( $form, $field[ 'field' ] );
901 901
 
902 902
 		$filter = array(
903
-			'key' => $field['field'],
903
+			'key' => $field[ 'field' ],
904 904
 			'name' => $name,
905 905
 			'label' => self::get_field_label( $field, $form_field ),
906
-			'input' => $field['input'],
906
+			'input' => $field[ 'input' ],
907 907
 			'value' => _wp_specialchars( $value ),
908
-			'type' => $form_field['type'],
908
+			'type' => $form_field[ 'type' ],
909 909
 		);
910 910
 
911 911
 		// collect choices
912
-		if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) {
913
-			$filter['choices'] = gravityview_get_terms_choices();
914
-		} elseif ( ! empty( $form_field['choices'] ) ) {
915
-			$filter['choices'] = $form_field['choices'];
912
+		if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) {
913
+			$filter[ 'choices' ] = gravityview_get_terms_choices();
914
+		} elseif ( ! empty( $form_field[ 'choices' ] ) ) {
915
+			$filter[ 'choices' ] = $form_field[ 'choices' ];
916 916
 		}
917 917
 
918
-		if ( 'date_range' === $field['input'] && empty( $value ) ) {
919
-			$filter['value'] = array( 'start' => '', 'end' => '' );
918
+		if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) {
919
+			$filter[ 'value' ] = array( 'start' => '', 'end' => '' );
920 920
 		}
921 921
 
922 922
 		return $filter;
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 
941 941
 		$choices = array();
942 942
 		foreach ( $users as $user ) {
943
-			$choices[] = array(
943
+			$choices[ ] = array(
944 944
 				'value' => $user->ID,
945 945
 				'text' => $user->display_name,
946 946
 			);
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 	 */
975 975
 	public function add_datepicker_js_dependency( $js_dependencies ) {
976 976
 
977
-		$js_dependencies[] = 'jquery-ui-datepicker';
977
+		$js_dependencies[ ] = 'jquery-ui-datepicker';
978 978
 
979 979
 		return $js_dependencies;
980 980
 	}
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
 			'isRTL'             => is_rtl(),
1019 1019
 		), $view_data );
1020 1020
 
1021
-		$localizations['datepicker'] = $datepicker_settings;
1021
+		$localizations[ 'datepicker' ] = $datepicker_settings;
1022 1022
 
1023 1023
 		return $localizations;
1024 1024
 
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 		add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 );
1042 1042
 
1043 1043
 		$scheme = is_ssl() ? 'https://' : 'http://';
1044
-		wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1044
+		wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1045 1045
 
1046 1046
 		/**
1047 1047
 		 * @filter `gravityview_search_datepicker_class`
Please login to merge, or discard this patch.