Completed
Push — develop ( 918969...60c622 )
by Zack
06:57
created
includes/class-frontend-views.php 1 patch
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -85,9 +85,9 @@  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 );
88
+		add_action( 'wp', array( $this, 'parse_content' ), 11 );
89 89
 		add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 );
90
-		add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 );
90
+		add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 );
91 91
 
92 92
 		// Enqueue scripts and styles after GravityView_Template::register_styles()
93 93
 		add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 );
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 
237 237
 			$this->context_view_id = $view_id;
238 238
 
239
-		} elseif ( isset( $_GET['gvid'] ) && $multiple_views ) {
239
+		} elseif ( isset( $_GET[ 'gvid' ] ) && $multiple_views ) {
240 240
 			/**
241 241
 			 * used on a has_multiple_views context
242 242
 			 * @see GravityView_API::entry_link
243 243
 			 */
244
-			$this->context_view_id = $_GET['gvid'];
244
+			$this->context_view_id = $_GET[ 'gvid' ];
245 245
 
246 246
 		} elseif ( ! $multiple_views ) {
247 247
 			$array_keys = array_keys( $this->getGvOutputData()->get_views() );
@@ -278,25 +278,25 @@  discard block
 block discarded – undo
278 278
 		global $wp_rewrite;
279 279
 
280 280
 		$is_front_page = ( $query->is_home || $query->is_page );
281
-		$show_on_front = ( 'page' === get_option('show_on_front') );
282
-		$front_page_id = get_option('page_on_front');
281
+		$show_on_front = ( 'page' === get_option( 'show_on_front' ) );
282
+		$front_page_id = get_option( 'page_on_front' );
283 283
 
284
-		if (  $is_front_page && $show_on_front && $front_page_id ) {
284
+		if ( $is_front_page && $show_on_front && $front_page_id ) {
285 285
 
286 286
 			// Force to be an array, potentially a query string ( entry=16 )
287 287
 			$_query = wp_parse_args( $query->query );
288 288
 
289 289
 			// pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename.
290
-			if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) {
291
-				unset( $_query['pagename'] );
290
+			if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) {
291
+				unset( $_query[ 'pagename' ] );
292 292
 			}
293 293
 
294 294
 			// this is where will break from core wordpress
295 295
 			/** @internal Don't use this filter; it will be unnecessary soon - it's just a patch for specific use case */
296 296
 			$ignore = apply_filters( 'gravityview/internal/ignored_endpoints', array( 'preview', 'page', 'paged', 'cpage' ), $query );
297 297
 			$endpoints = \GV\Utils::get( $wp_rewrite, 'endpoints' );
298
-			foreach ( (array) $endpoints as $endpoint ) {
299
-				$ignore[] = $endpoint[1];
298
+			foreach ( (array)$endpoints as $endpoint ) {
299
+				$ignore[ ] = $endpoint[ 1 ];
300 300
 			}
301 301
 			unset( $endpoints );
302 302
 
@@ -306,21 +306,21 @@  discard block
 block discarded – undo
306 306
 			// - The query includes keys that are associated with registered endpoints. `entry`, for example.
307 307
 			if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) {
308 308
 
309
-				$qv =& $query->query_vars;
309
+				$qv = & $query->query_vars;
310 310
 
311 311
 				// Prevent redirect when on the single entry endpoint
312
-				if( self::is_single_entry() ) {
312
+				if ( self::is_single_entry() ) {
313 313
 					add_filter( 'redirect_canonical', '__return_false' );
314 314
 				}
315 315
 
316 316
 				$query->is_page = true;
317 317
 				$query->is_home = false;
318
-				$qv['page_id']  = $front_page_id;
318
+				$qv[ 'page_id' ]  = $front_page_id;
319 319
 
320 320
 				// Correct <!--nextpage--> for page_on_front
321
-				if ( ! empty( $qv['paged'] ) ) {
322
-					$qv['page'] = $qv['paged'];
323
-					unset( $qv['paged'] );
321
+				if ( ! empty( $qv[ 'paged' ] ) ) {
322
+					$qv[ 'page' ] = $qv[ 'paged' ];
323
+					unset( $qv[ 'paged' ] );
324 324
 				}
325 325
 			}
326 326
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 
351 351
 		$this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' );
352 352
 
353
-		$post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null );
353
+		$post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null );
354 354
 		$this->setPostId( $post_id );
355 355
 		$post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false;
356 356
 		$this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) );
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 
387 387
 		$search_method = GravityView_Widget_Search::getInstance()->get_search_method();
388 388
 
389
-		if( 'post' === $search_method ) {
389
+		if ( 'post' === $search_method ) {
390 390
 			$get = $_POST;
391 391
 		} else {
392 392
 			$get = $_GET;
@@ -443,20 +443,20 @@  discard block
 block discarded – undo
443 443
 		 * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop
444 444
 		 * @param array $entry Current entry
445 445
 		 */
446
-		$apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry );
446
+		$apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry );
447 447
 
448 448
 		if ( ! $apply_outside_loop ) {
449 449
 			return $title;
450 450
 		}
451 451
 
452 452
 		// User reported WooCommerce doesn't pass two args.
453
-		if ( empty( $passed_post_id ) )  {
453
+		if ( empty( $passed_post_id ) ) {
454 454
 			return $title;
455 455
 		}
456 456
 
457 457
 		// Don't modify the title for anything other than the current view/post.
458 458
 		// This is true for embedded shortcodes and Views.
459
-		if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) {
459
+		if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) {
460 460
 			return $title;
461 461
 		}
462 462
 
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
 			foreach ( $views as $view_id => $view_data ) {
473 473
 
474 474
 				$entry_form_id = \GV\Utils::get( $entry, 'form_id' );
475
-				$view_form_id = $view_data['form_id'];
475
+				$view_form_id = $view_data[ 'form_id' ];
476 476
 
477
-				if ( (int) $view_form_id === (int) $entry_form_id ) {
477
+				if ( (int)$view_form_id === (int)$entry_form_id ) {
478 478
 					$view_meta = $view_data;
479 479
 					break;
480 480
 				}
@@ -482,12 +482,12 @@  discard block
 block discarded – undo
482 482
 		}
483 483
 
484 484
 		/** Deprecated stuff in the future. See the branch above. */
485
-		if ( ! empty( $view_meta['atts']['single_title'] ) ) {
485
+		if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) {
486 486
 
487
-			$title = $view_meta['atts']['single_title'];
487
+			$title = $view_meta[ 'atts' ][ 'single_title' ];
488 488
 
489 489
 			// We are allowing HTML in the fields, so no escaping the output
490
-			$title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry );
490
+			$title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry );
491 491
 
492 492
 			$title = do_shortcode( $title );
493 493
 		}
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 
558 558
 		$context = GravityView_View::getInstance()->getContext();
559 559
 
560
-		switch( $context ) {
560
+		switch ( $context ) {
561 561
 			case 'directory':
562 562
 				$tab = __( 'Multiple Entries', 'gravityview' );
563 563
 				break;
@@ -571,12 +571,12 @@  discard block
 block discarded – undo
571 571
 		}
572 572
 
573 573
 
574
-		$title = sprintf( esc_html_x('The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab );
574
+		$title = sprintf( esc_html_x( 'The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab );
575 575
 		$edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $view_id, $context ) );
576
-		$action_text = sprintf( esc_html__('Add fields to %s', 'gravityview' ), $tab );
576
+		$action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab );
577 577
 		$message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' );
578 578
 
579
-		$image =  sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url(plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) );
579
+		$image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) );
580 580
 		$output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message );
581 581
 
582 582
 		echo GVCommon::generate_notice( $output . $image, 'gv-error error', 'edit_gravityview', $view_id );
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 		$direct_access = apply_filters( 'gravityview_direct_access', true, $view->ID );
625 625
 		$embed_only = $view->settings->get( 'embed_only' );
626 626
 
627
-		if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) {
627
+		if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) {
628 628
 			return __( 'You are not allowed to view this content.', 'gravityview' );
629 629
 		}
630 630
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 				$datetime_format = 'Y-m-d H:i:s';
672 672
 				$search_is_outside_view_bounds = false;
673 673
 
674
-				if( ! empty( $search_criteria[ $key ] ) ) {
674
+				if ( ! empty( $search_criteria[ $key ] ) ) {
675 675
 
676 676
 					$search_date = strtotime( $search_criteria[ $key ] );
677 677
 
@@ -699,14 +699,14 @@  discard block
 block discarded – undo
699 699
 				if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) {
700 700
 
701 701
 					// Then we override the search and re-set the start date
702
-					$return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true );
702
+					$return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true );
703 703
 				}
704 704
 			}
705 705
 		}
706 706
 
707
-		if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) {
707
+		if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) {
708 708
 			// The start date is AFTER the end date. This will result in no results, but let's not force the issue.
709
-			if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) {
709
+			if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) {
710 710
 				gravityview()->log->error( 'Invalid search: the start date is after the end date.', array( 'data' => $return_search_criteria ) );
711 711
 			}
712 712
 		}
@@ -725,19 +725,19 @@  discard block
 block discarded – undo
725 725
 	public static function process_search_only_approved( $args, $search_criteria ) {
726 726
 
727 727
 		/** @since 1.19 */
728
-		if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) {
728
+		if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) {
729 729
 			gravityview()->log->debug( 'User can moderate entries; showing all approval statuses' );
730 730
 			return $search_criteria;
731 731
 		}
732 732
 
733
-		if ( ! empty( $args['show_only_approved'] ) ) {
733
+		if ( ! empty( $args[ 'show_only_approved' ] ) ) {
734 734
 
735
-			$search_criteria['field_filters'][] = array(
735
+			$search_criteria[ 'field_filters' ][ ] = array(
736 736
 				'key' => GravityView_Entry_Approval::meta_key,
737 737
 				'value' => GravityView_Entry_Approval_Status::APPROVED
738 738
 			);
739 739
 
740
-			$search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met
740
+			$search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met
741 741
 
742 742
 			gravityview()->log->debug( '[process_search_only_approved] Search Criteria if show only approved: ', array( 'data' => $search_criteria ) );
743 743
 		}
@@ -764,18 +764,18 @@  discard block
 block discarded – undo
764 764
 	 */
765 765
 	public static function is_entry_approved( $entry, $args = array() ) {
766 766
 
767
-		if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) {
767
+		if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) {
768 768
 			// is implicitly approved if entry is null or View settings doesn't require to check for approval
769 769
 			return true;
770 770
 		}
771 771
 
772 772
 		/** @since 1.19 */
773
-		if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) {
773
+		if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) {
774 774
 			gravityview()->log->debug( 'User can moderate entries, so entry is approved for viewing' );
775 775
 			return true;
776 776
 		}
777 777
 
778
-		$is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key );
778
+		$is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key );
779 779
 
780 780
 		return GravityView_Entry_Approval_Status::is_approved( $is_approved );
781 781
 	}
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 		 * Compatibility with filters hooking in `gravityview_search_criteria` instead of `gravityview_fe_search_criteria`.
800 800
 		 */
801 801
 		$criteria = apply_filters( 'gravityview_search_criteria', array(), array( $form_id ), \GV\Utils::get( $args, 'id' ) );
802
-		$search_criteria = isset( $criteria['search_criteria'] ) ? $criteria['search_criteria'] : array( 'field_filters' => array() );
802
+		$search_criteria = isset( $criteria[ 'search_criteria' ] ) ? $criteria[ 'search_criteria' ] : array( 'field_filters' => array() );
803 803
 
804 804
 		/**
805 805
 		 * @filter `gravityview_fe_search_criteria` Modify the search criteria
@@ -819,29 +819,29 @@  discard block
 block discarded – undo
819 819
 		gravityview()->log->debug( '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', array( 'data' =>$search_criteria ) );
820 820
 
821 821
 		// implicity search
822
-		if ( ! empty( $args['search_value'] ) ) {
822
+		if ( ! empty( $args[ 'search_value' ] ) ) {
823 823
 
824 824
 			// Search operator options. Options: `is` or `contains`
825
-			$operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains';
825
+			$operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains';
826 826
 
827
-			$search_criteria['field_filters'][] = array(
827
+			$search_criteria[ 'field_filters' ][ ] = array(
828 828
 				'key' => \GV\Utils::_GET( 'search_field', \GV\Utils::get( $args, 'search_field' ) ), // The field ID to search
829
-				'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes.
829
+				'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes.
830 830
 				'operator' => $operator,
831 831
 			);
832 832
 
833 833
 			// Lock search mode to "all" with implicit presearch filter.
834
-			$search_criteria['field_filters']['mode'] = 'all';
834
+			$search_criteria[ 'field_filters' ][ 'mode' ] = 'all';
835 835
 		}
836 836
 
837
-		if( $search_criteria !== $original_search_criteria ) {
837
+		if ( $search_criteria !== $original_search_criteria ) {
838 838
 			gravityview()->log->debug( '[get_search_criteria] Search Criteria after implicity search: ', array( 'data' => $search_criteria ) );
839 839
 		}
840 840
 
841 841
 		// Handle setting date range
842 842
 		$search_criteria = self::process_search_dates( $args, $search_criteria );
843 843
 
844
-		if( $search_criteria !== $original_search_criteria ) {
844
+		if ( $search_criteria !== $original_search_criteria ) {
845 845
 			gravityview()->log->debug( '[get_search_criteria] Search Criteria after date params: ', array( 'data' => $search_criteria ) );
846 846
 		}
847 847
 
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 		 * @filter `gravityview_status` Modify entry status requirements to be included in search results.
853 853
 		 * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash`
854 854
 		 */
855
-		$search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args );
855
+		$search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args );
856 856
 
857 857
 		return $search_criteria;
858 858
 	}
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 			'search_criteria' => $search_criteria,
966 966
 			'sorting' => self::updateViewSorting( $args, $form_id ),
967 967
 			'paging' => $paging,
968
-			'cache' => isset( $args['cache'] ) ? $args['cache'] : true,
968
+			'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true,
969 969
 		);
970 970
 
971 971
 		/**
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
 		 * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys.
991 991
 		 * @param array $args View configuration args.
992 992
 		 */
993
-		$parameters = apply_filters( 'gravityview_get_entries_'.\GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id );
993
+		$parameters = apply_filters( 'gravityview_get_entries_' . \GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id );
994 994
 
995 995
 		gravityview()->log->debug( '$parameters passed to gravityview_get_entries(): ', array( 'data' => $parameters ) );
996 996
 
@@ -1015,17 +1015,17 @@  discard block
 block discarded – undo
1015 1015
 		$default_page_size = apply_filters( 'gravityview_default_page_size', 25 );
1016 1016
 
1017 1017
 		// Paging & offset
1018
-		$page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : $default_page_size;
1018
+		$page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : $default_page_size;
1019 1019
 
1020 1020
 		if ( -1 === $page_size ) {
1021 1021
 			$page_size = PHP_INT_MAX;
1022 1022
 		}
1023 1023
 
1024
-		$curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] );
1024
+		$curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] );
1025 1025
 		$offset = ( $curr_page - 1 ) * $page_size;
1026 1026
 
1027
-		if ( ! empty( $args['offset'] ) ) {
1028
-			$offset += intval( $args['offset'] );
1027
+		if ( ! empty( $args[ 'offset' ] ) ) {
1028
+			$offset += intval( $args[ 'offset' ] );
1029 1029
 		}
1030 1030
 
1031 1031
 		$paging = array(
@@ -1050,11 +1050,11 @@  discard block
 block discarded – undo
1050 1050
 	public static function updateViewSorting( $args, $form_id ) {
1051 1051
 		$sorting = array();
1052 1052
 
1053
-		$has_values = isset( $_GET['sort'] );
1053
+		$has_values = isset( $_GET[ 'sort' ] );
1054 1054
 
1055
-		if ( $has_values && is_array( $_GET['sort'] ) ) {
1056
-			$sorts = array_keys( $_GET['sort'] );
1057
-			$dirs  = array_values( $_GET['sort'] );
1055
+		if ( $has_values && is_array( $_GET[ 'sort' ] ) ) {
1056
+			$sorts = array_keys( $_GET[ 'sort' ] );
1057
+			$dirs  = array_values( $_GET[ 'sort' ] );
1058 1058
 
1059 1059
 			if ( $has_values = array_filter( $dirs ) ) {
1060 1060
 				$sort_field_id = end( $sorts );
@@ -1063,11 +1063,11 @@  discard block
 block discarded – undo
1063 1063
 		}
1064 1064
 
1065 1065
 		if ( ! isset( $sort_field_id ) ) {
1066
-			$sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : \GV\Utils::get( $args, 'sort_field' );
1066
+			$sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : \GV\Utils::get( $args, 'sort_field' );
1067 1067
 		}
1068 1068
 
1069 1069
 		if ( ! isset( $sort_direction ) ) {
1070
-			$sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : \GV\Utils::get( $args, 'sort_direction' );
1070
+			$sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : \GV\Utils::get( $args, 'sort_direction' );
1071 1071
 		}
1072 1072
 
1073 1073
 		if ( is_array( $sort_field_id ) ) {
@@ -1099,10 +1099,10 @@  discard block
 block discarded – undo
1099 1099
 				$form = GFAPI::get_form( $form_id );
1100 1100
 
1101 1101
 				// Get the first GF_Field field ID, set as the key for entry randomization
1102
-				if ( ! empty( $form['fields'] ) ) {
1102
+				if ( ! empty( $form[ 'fields' ] ) ) {
1103 1103
 
1104 1104
 					/** @var GF_Field $field */
1105
-					foreach ( $form['fields'] as $field ) {
1105
+					foreach ( $form[ 'fields' ] as $field ) {
1106 1106
 						if ( ! is_a( $field, 'GF_Field' ) ) {
1107 1107
 							continue;
1108 1108
 						}
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 		if ( is_array( $sort_field_id ) ) {
1148 1148
 			$modified_ids = array();
1149 1149
 			foreach ( $sort_field_id as $_sort_field_id ) {
1150
-				$modified_ids []= self::_override_sorting_id_by_field_type( $_sort_field_id, $form_id );
1150
+				$modified_ids [ ] = self::_override_sorting_id_by_field_type( $_sort_field_id, $form_id );
1151 1151
 			}
1152 1152
 			return $modified_ids;
1153 1153
 		}
@@ -1156,11 +1156,11 @@  discard block
 block discarded – undo
1156 1156
 
1157 1157
 		$sort_field = GFFormsModel::get_field( $form, $sort_field_id );
1158 1158
 
1159
-		if( ! $sort_field ) {
1159
+		if ( ! $sort_field ) {
1160 1160
 			return $sort_field_id;
1161 1161
 		}
1162 1162
 
1163
-		switch ( $sort_field['type'] ) {
1163
+		switch ( $sort_field[ 'type' ] ) {
1164 1164
 
1165 1165
 			case 'address':
1166 1166
 				// Sorting by full address
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 					 */
1178 1178
 					$address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id );
1179 1179
 
1180
-					switch( strtolower( $address_part ) ){
1180
+					switch ( strtolower( $address_part ) ) {
1181 1181
 						case 'street':
1182 1182
 							$sort_field_id .= '.1';
1183 1183
 							break;
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 		if ( ! class_exists( '\GV\Entry' ) ) {
1251 1251
 
1252 1252
 			// Not using gravityview()->log->error(), since that may not exist yet either!
1253
-			do_action( 'gravityview_log_error', '\GV\Entry not defined yet. Backtrace: ' . wp_debug_backtrace_summary()  );
1253
+			do_action( 'gravityview_log_error', '\GV\Entry not defined yet. Backtrace: ' . wp_debug_backtrace_summary() );
1254 1254
 
1255 1255
 			return null;
1256 1256
 		}
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 		 */
1268 1268
 		$single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry );
1269 1269
 
1270
-		if ( empty( $single_entry ) ){
1270
+		if ( empty( $single_entry ) ) {
1271 1271
 			return false;
1272 1272
 		} else {
1273 1273
 			return $single_entry;
@@ -1289,7 +1289,7 @@  discard block
 block discarded – undo
1289 1289
 			$views = $this->getGvOutputData()->get_views();
1290 1290
 
1291 1291
 			foreach ( $views as $view_id => $data ) {
1292
-				$view = \GV\View::by_id( $data['id'] );
1292
+				$view = \GV\View::by_id( $data[ 'id' ] );
1293 1293
 				$view_id = $view->ID;
1294 1294
 				$template_id = gravityview_get_template_id( $view->ID );
1295 1295
 				$data = $view->as_data();
@@ -1298,7 +1298,7 @@  discard block
 block discarded – undo
1298 1298
 				 * Don't enqueue the scripts or styles if it's not going to be displayed.
1299 1299
 				 * @since 1.15
1300 1300
 				 */
1301
-				if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
1301
+				if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
1302 1302
 					continue;
1303 1303
 				}
1304 1304
 
@@ -1331,7 +1331,7 @@  discard block
 block discarded – undo
1331 1331
 					 * @param \GV\View The View.
1332 1332
 					 */
1333 1333
 					apply_filters( 'gravityview_lightbox_script', $js_dependency, $view );
1334
-					$js_dependencies[] = $js_dependency;
1334
+					$js_dependencies[ ] = $js_dependency;
1335 1335
 
1336 1336
 					if ( ! empty( $wp_filter[ 'gravity_view_lightbox_style' ] ) ) {
1337 1337
 						gravityview()->log->warning( 'gravity_view_lightbox_style filter is deprecated use gravityview_lightbox_style instead' );
@@ -1351,7 +1351,7 @@  discard block
 block discarded – undo
1351 1351
 					 * @param \GV\View The View.
1352 1352
 					 */
1353 1353
 					$css_dependency = apply_filters( 'gravityview_lightbox_style', $css_dependency, $view );
1354
-					$css_dependencies[] = $css_dependency;
1354
+					$css_dependencies[ ] = $css_dependency;
1355 1355
 				}
1356 1356
 
1357 1357
 				/**
@@ -1359,19 +1359,19 @@  discard block
 block discarded – undo
1359 1359
 				 * @see https://github.com/katzwebservices/GravityView/issues/536
1360 1360
 				 * @since 1.15
1361 1361
 				 */
1362
-				if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) {
1363
-					$css_dependencies[] = 'dashicons';
1362
+				if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) {
1363
+					$css_dependencies[ ] = 'dashicons';
1364 1364
 				}
1365 1365
 
1366 1366
 				wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true );
1367 1367
 
1368 1368
 				$script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
1369 1369
 
1370
-				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 );
1370
+				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 );
1371 1371
 
1372 1372
 				wp_enqueue_script( 'gravityview-fe-view' );
1373 1373
 
1374
-				if ( ! empty( $data['atts']['sort_columns'] ) ) {
1374
+				if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) {
1375 1375
 					wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' );
1376 1376
 				}
1377 1377
 
@@ -1434,7 +1434,7 @@  discard block
 block discarded – undo
1434 1434
 	public static function add_style( $template_id ) {
1435 1435
 
1436 1436
 		if ( ! empty( $template_id ) && wp_style_is( 'gravityview_style_' . $template_id, 'registered' ) ) {
1437
-			gravityview()->log->debug(  'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) );
1437
+			gravityview()->log->debug( 'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) );
1438 1438
 			wp_enqueue_style( 'gravityview_style_' . $template_id );
1439 1439
 		} elseif ( empty( $template_id ) ) {
1440 1440
 			gravityview()->log->error( 'Cannot add template style; template_id is empty' );
@@ -1465,11 +1465,11 @@  discard block
 block discarded – undo
1465 1465
 		 * Not a table-based template; don't add sort icons
1466 1466
 		 * @since 1.12
1467 1467
 		 */
1468
-		if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) {
1468
+		if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) {
1469 1469
 			return $label;
1470 1470
 		}
1471 1471
 
1472
-		if ( ! $this->is_field_sortable( $field['id'], $form ) ) {
1472
+		if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) {
1473 1473
 			return $label;
1474 1474
 		}
1475 1475
 
@@ -1477,29 +1477,29 @@  discard block
 block discarded – undo
1477 1477
 
1478 1478
 		$class = 'gv-sort';
1479 1479
 
1480
-		$sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] );
1480
+		$sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] );
1481 1481
 
1482 1482
 		$sort_args = array(
1483
-			'sort' => $field['id'],
1483
+			'sort' => $field[ 'id' ],
1484 1484
 			'dir' => 'asc',
1485 1485
 		);
1486 1486
 
1487
-		if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) {
1487
+		if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) {
1488 1488
 			//toggle sorting direction.
1489
-			if ( 'asc' === $sorting['direction'] ) {
1490
-				$sort_args['dir'] = 'desc';
1489
+			if ( 'asc' === $sorting[ 'direction' ] ) {
1490
+				$sort_args[ 'dir' ] = 'desc';
1491 1491
 				$class .= ' gv-icon-sort-desc';
1492 1492
 			} else {
1493
-				$sort_args['dir'] = 'asc';
1493
+				$sort_args[ 'dir' ] = 'asc';
1494 1494
 				$class .= ' gv-icon-sort-asc';
1495 1495
 			}
1496 1496
 		} else {
1497 1497
 			$class .= ' gv-icon-caret-up-down';
1498 1498
 		}
1499 1499
 
1500
-		$url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) );
1500
+		$url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) );
1501 1501
 
1502
-		return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a>&nbsp;'. $label;
1502
+		return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a>&nbsp;' . $label;
1503 1503
 
1504 1504
 	}
1505 1505
 
@@ -1517,7 +1517,7 @@  discard block
 block discarded – undo
1517 1517
 
1518 1518
 		$field_type = $field_id;
1519 1519
 
1520
-		if( is_numeric( $field_id ) ) {
1520
+		if ( is_numeric( $field_id ) ) {
1521 1521
 			$field = GFFormsModel::get_field( $form, $field_id );
1522 1522
 			$field_type = $field ? $field->type : $field_id;
1523 1523
 		}
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
 			return false;
1541 1541
 		}
1542 1542
 
1543
-		return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) );
1543
+		return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) );
1544 1544
 
1545 1545
 	}
1546 1546
 
Please login to merge, or discard this patch.
includes/widgets/search-widget/class-search-widget.php 1 patch
Spacing   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 				'type' => 'radio',
65 65
 				'full_width' => true,
66 66
 				'label' => esc_html__( 'Search Mode', 'gravityview' ),
67
-				'desc' => __('Should search results match all search fields, or any?', 'gravityview'),
67
+				'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ),
68 68
 				'value' => 'any',
69 69
 				'class' => 'hide-if-js',
70 70
 				'options' => array(
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
 			// admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999
85 85
 			add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 );
86
-			add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') );
86
+			add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) );
87 87
 			add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) );
88 88
 
89 89
 			// 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__( 'Approval Status', 'gravityview' ),
334 334
 				'type' => 'multi',
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
@@ -433,19 +433,19 @@  discard block
 block discarded – undo
433 433
 			$post_id = 0;
434 434
 
435 435
 			// We're in the WordPress Widget context, and an overriding post ID has been set.
436
-			if ( ! empty( $widget_args['post_id'] ) ) {
437
-				$post_id = absint( $widget_args['post_id'] );
436
+			if ( ! empty( $widget_args[ 'post_id' ] ) ) {
437
+				$post_id = absint( $widget_args[ 'post_id' ] );
438 438
 			}
439 439
 			// We're in the WordPress Widget context, and the base View ID should be used
440
-			else if ( ! empty( $widget_args['view_id'] ) ) {
441
-				$post_id = absint( $widget_args['view_id'] );
440
+			else if ( ! empty( $widget_args[ 'view_id' ] ) ) {
441
+				$post_id = absint( $widget_args[ 'view_id' ] );
442 442
 			}
443 443
 
444 444
 			$args = gravityview_get_permalink_query_args( $post_id );
445 445
 
446 446
 			// Add hidden fields to the search form
447 447
 			foreach ( $args as $key => $value ) {
448
-				$search_fields[] = array(
448
+				$search_fields[ ] = array(
449 449
 					'name'  => $key,
450 450
 					'input' => 'hidden',
451 451
 					'value' => $value,
@@ -484,28 +484,28 @@  discard block
 block discarded – undo
484 484
 		/**
485 485
 		 * Include the sidebar Widgets.
486 486
 		 */
487
-		$widgets = (array) get_option( 'widget_gravityview_search', array() );
487
+		$widgets = (array)get_option( 'widget_gravityview_search', array() );
488 488
 
489 489
 		foreach ( $widgets as $widget ) {
490
-			if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) {
491
-				if( $_fields = json_decode( $widget['search_fields'], true ) ) {
490
+			if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) {
491
+				if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) {
492 492
 					foreach ( $_fields as $field ) {
493
-						if ( empty( $field['form_id'] ) ) {
494
-							$field['form_id'] = $view->form ? $view->form->ID : 0;
493
+						if ( empty( $field[ 'form_id' ] ) ) {
494
+							$field[ 'form_id' ] = $view->form ? $view->form->ID : 0;
495 495
 						}
496
-						$searchable_fields[] = $with_full_field ? $field : $field['field'];
496
+						$searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ];
497 497
 					}
498 498
 				}
499 499
 			}
500 500
 		}
501 501
 
502 502
 		foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) {
503
-			if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) {
503
+			if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) {
504 504
 				foreach ( $_fields as $field ) {
505
-					if ( empty( $field['form_id'] ) ) {
506
-						$field['form_id'] = $view->form ? $view->form->ID : 0;
505
+					if ( empty( $field[ 'form_id' ] ) ) {
506
+						$field[ 'form_id' ] = $view->form ? $view->form->ID : 0;
507 507
 					}
508
-					$searchable_fields[] = $with_full_field ? $field : $field['field'];
508
+					$searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ];
509 509
 				}
510 510
 			}
511 511
 		}
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 			return $search_criteria; // Return the original criteria, GF_Query modification kicks in later
544 544
 		}
545 545
 
546
-		if( 'post' === $this->search_method ) {
546
+		if ( 'post' === $this->search_method ) {
547 547
 			$get = $_POST;
548 548
 		} else {
549 549
 			$get = $_GET;
@@ -562,15 +562,15 @@  discard block
 block discarded – undo
562 562
 		$get = gv_map_deep( $get, 'rawurldecode' );
563 563
 
564 564
 		// Make sure array key is set up
565
-		$search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() );
565
+		$search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() );
566 566
 
567 567
 		$searchable_fields = $this->get_view_searchable_fields( $view );
568 568
 		$searchable_field_objects = $this->get_view_searchable_fields( $view, true );
569 569
 
570 570
 		// add free search
571
-		if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) {
571
+		if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) {
572 572
 
573
-			$search_all_value = trim( $get['gv_search'] );
573
+			$search_all_value = trim( $get[ 'gv_search' ] );
574 574
 
575 575
 			/**
576 576
 			 * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase?
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 			}
596 596
 
597 597
 			foreach ( $words as $word ) {
598
-				$search_criteria['field_filters'][] = array(
598
+				$search_criteria[ 'field_filters' ][ ] = array(
599 599
 					'key' => null, // The field ID to search
600 600
 					'value' => $word, // The value to search
601 601
 					'operator' => 'contains', // What to search in. Options: `is` or `contains`
@@ -608,14 +608,14 @@  discard block
 block discarded – undo
608 608
 			/**
609 609
 			 * Get and normalize the dates according to the input format.
610 610
 			 */
611
-			if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) {
612
-				if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) {
611
+			if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) {
612
+				if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) {
613 613
 					$curr_start = $curr_start_date->format( 'Y-m-d' );
614 614
 				}
615 615
 			}
616 616
 
617
-			if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) {
618
-				if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) {
617
+			if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) {
618
+				if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) {
619 619
 					$curr_end = $curr_end_date->format( 'Y-m-d' );
620 620
 				}
621 621
 			}
@@ -650,22 +650,22 @@  discard block
 block discarded – undo
650 650
 			 */
651 651
 			if ( ! empty( $curr_start ) ) {
652 652
 				$curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) );
653
-				$search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
653
+				$search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
654 654
 			}
655 655
 
656 656
 			if ( ! empty( $curr_end ) ) {
657 657
 				// Fast-forward 24 hour on the end time
658 658
 				$curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS );
659
-				$search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
660
-				if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056
661
-					$search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 );
659
+				$search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
660
+				if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056
661
+					$search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 );
662 662
 				}
663 663
 			}
664 664
 		}
665 665
 
666 666
 		// search for a specific entry ID
667 667
 		if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) {
668
-			$search_criteria['field_filters'][] = array(
668
+			$search_criteria[ 'field_filters' ][ ] = array(
669 669
 				'key' => 'id',
670 670
 				'value' => absint( $get[ 'gv_id' ] ),
671 671
 				'operator' => $this->get_operator( $get, 'gv_id', array( '=' ), '=' ),
@@ -674,20 +674,20 @@  discard block
 block discarded – undo
674 674
 
675 675
 		// search for a specific Created_by ID
676 676
 		if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) {
677
-			$search_criteria['field_filters'][] = array(
677
+			$search_criteria[ 'field_filters' ][ ] = array(
678 678
 				'key' => 'created_by',
679
-				'value' => $get['gv_by'],
679
+				'value' => $get[ 'gv_by' ],
680 680
 				'operator' => $this->get_operator( $get, 'gv_by', array( '=' ), '=' ),
681 681
 			);
682 682
 		}
683 683
 
684 684
 		// Get search mode passed in URL
685
-		$mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ?  $get['mode'] : 'any';
685
+		$mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any';
686 686
 
687 687
 		// get the other search filters
688 688
 		foreach ( $get as $key => $value ) {
689 689
 
690
-			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) {
690
+			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) {
691 691
 				continue; // Not a filter, or empty
692 692
 			}
693 693
 
@@ -701,19 +701,19 @@  discard block
 block discarded – undo
701 701
 				continue;
702 702
 			}
703 703
 
704
-			if ( ! isset( $filter['operator'] ) ) {
705
-				$filter['operator'] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' );
704
+			if ( ! isset( $filter[ 'operator' ] ) ) {
705
+				$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' );
706 706
 			}
707 707
 
708
-			if ( isset( $filter[0]['value'] ) ) {
709
-				$search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter );
708
+			if ( isset( $filter[ 0 ][ 'value' ] ) ) {
709
+				$search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter );
710 710
 
711 711
 				// if date range type, set search mode to ALL
712
-				if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) {
712
+				if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) {
713 713
 					$mode = 'all';
714 714
 				}
715
-			} elseif( !empty( $filter ) ) {
716
-				$search_criteria['field_filters'][] = $filter;
715
+			} elseif ( ! empty( $filter ) ) {
716
+				$search_criteria[ 'field_filters' ][ ] = $filter;
717 717
 			}
718 718
 		}
719 719
 
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 		 * @since 1.5.1
723 723
 		 * @param[out,in] string $mode Search mode (`any` vs `all`)
724 724
 		 */
725
-		$search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode );
725
+		$search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode );
726 726
 
727 727
 		gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) );
728 728
 
@@ -756,19 +756,19 @@  discard block
 block discarded – undo
756 756
 
757 757
 		$query_class = $view->get_query_class();
758 758
 
759
-		if ( empty( $search_criteria['field_filters'] ) ) {
759
+		if ( empty( $search_criteria[ 'field_filters' ] ) ) {
760 760
 			return;
761 761
 		}
762 762
 
763 763
 		$widgets = $view->widgets->by_id( $this->widget_id );
764 764
 		if ( $widgets->count() ) {
765 765
 			$widgets = $widgets->all();
766
-			$widget  = $widgets[0];
766
+			$widget  = $widgets[ 0 ];
767 767
 
768 768
 			$search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true );
769 769
 
770
-			foreach ( (array) $search_fields as $search_field ) {
771
-				if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) {
770
+			foreach ( (array)$search_fields as $search_field ) {
771
+				if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) {
772 772
 					$created_by_text_mode = true;
773 773
 				}
774 774
 			}
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 		$extra_conditions = array();
778 778
 		$mode = 'any';
779 779
 
780
-		foreach ( $search_criteria['field_filters'] as &$filter ) {
780
+		foreach ( $search_criteria[ 'field_filters' ] as &$filter ) {
781 781
 			if ( ! is_array( $filter ) ) {
782 782
 				if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) {
783 783
 					$mode = $filter;
@@ -786,13 +786,13 @@  discard block
 block discarded – undo
786 786
 			}
787 787
 
788 788
 			// Construct a manual query for unapproved statuses
789
-			if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) {
790
-				$_tmp_query       = new $query_class( $view->form->ID, array(
789
+			if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) {
790
+				$_tmp_query = new $query_class( $view->form->ID, array(
791 791
 					'field_filters' => array(
792 792
 						array(
793 793
 							'operator' => 'in',
794 794
 							'key'      => 'is_approved',
795
-							'value'    => (array) $filter['value'],
795
+							'value'    => (array)$filter[ 'value' ],
796 796
 						),
797 797
 						array(
798 798
 							'operator' => 'is',
@@ -804,30 +804,30 @@  discard block
 block discarded – undo
804 804
 				) );
805 805
 				$_tmp_query_parts = $_tmp_query->_introspect();
806 806
 
807
-				$extra_conditions[] = $_tmp_query_parts['where'];
807
+				$extra_conditions[ ] = $_tmp_query_parts[ 'where' ];
808 808
 
809 809
 				$filter = false;
810 810
 				continue;
811 811
 			}
812 812
 
813 813
 			// Construct manual query for text mode creator search
814
-			if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) {
815
-				$extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view );
814
+			if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) {
815
+				$extra_conditions[ ] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view );
816 816
 				$filter = false;
817 817
 				continue;
818 818
 			}
819 819
 
820 820
 			// By default, we want searches to be wildcard for each field.
821
-			$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
821
+			$filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];
822 822
 
823 823
 			// For multichoice, let's have an in (OR) search.
824
-			if ( is_array( $filter['value'] ) ) {
825
-				$filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)?
824
+			if ( is_array( $filter[ 'value' ] ) ) {
825
+				$filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)?
826 826
 			}
827 827
 
828 828
 			// Default form with joins functionality
829
-			if ( empty( $filter['form_id'] ) ) {
830
-				$filter['form_id'] = $view->form ? $view->form->ID : 0;
829
+			if ( empty( $filter[ 'form_id' ] ) ) {
830
+				$filter[ 'form_id' ] = $view->form ? $view->form->ID : 0;
831 831
 			}
832 832
 
833 833
 			/**
@@ -837,28 +837,28 @@  discard block
 block discarded – undo
837 837
 			 * @since develop
838 838
 			 * @param \GV\View $view The View we're operating on.
839 839
 			 */
840
-			$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter, $view );
840
+			$filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter, $view );
841 841
 		}
842 842
 
843
-		if ( ! empty( $search_criteria['start_date'] ) || ! empty( $search_criteria['end_date'] ) ) {
843
+		if ( ! empty( $search_criteria[ 'start_date' ] ) || ! empty( $search_criteria[ 'end_date' ] ) ) {
844 844
 			$date_criteria = array();
845 845
 
846
-			if ( isset( $search_criteria['start_date'] ) ) {
847
-				$date_criteria['start_date'] = $search_criteria['start_date'];
846
+			if ( isset( $search_criteria[ 'start_date' ] ) ) {
847
+				$date_criteria[ 'start_date' ] = $search_criteria[ 'start_date' ];
848 848
 			}
849 849
 
850
-			if ( isset( $search_criteria['end_date'] ) ) {
851
-				$date_criteria['end_date'] = $search_criteria['end_date'];
850
+			if ( isset( $search_criteria[ 'end_date' ] ) ) {
851
+				$date_criteria[ 'end_date' ] = $search_criteria[ 'end_date' ];
852 852
 			}
853 853
 
854 854
 			$_tmp_query         = new $query_class( $view->form->ID, $date_criteria );
855 855
 			$_tmp_query_parts   = $_tmp_query->_introspect();
856
-			$extra_conditions[] = $_tmp_query_parts['where'];
856
+			$extra_conditions[ ] = $_tmp_query_parts[ 'where' ];
857 857
 		}
858 858
 
859 859
 		$search_conditions = array();
860 860
 
861
-		if ( $filters = array_filter( $search_criteria['field_filters'] ) ) {
861
+		if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) {
862 862
 			foreach ( $filters as &$filter ) {
863 863
 				if ( ! is_array( $filter ) ) {
864 864
 					continue;
@@ -870,12 +870,12 @@  discard block
 block discarded – undo
870 870
 				 * code by reusing what's inside GF_Query already as they
871 871
 				 * take care of many small things like forcing numeric, etc.
872 872
 				 */
873
-				$_tmp_query       = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) );
873
+				$_tmp_query       = new $query_class( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) );
874 874
 				$_tmp_query_parts = $_tmp_query->_introspect();
875
-				$search_condition = $_tmp_query_parts['where'];
875
+				$search_condition = $_tmp_query_parts[ 'where' ];
876 876
 
877
-				if ( empty( $filter['key'] ) && $search_condition->expressions ) {
878
-					$search_conditions[] = $search_condition;
877
+				if ( empty( $filter[ 'key' ] ) && $search_condition->expressions ) {
878
+					$search_conditions[ ] = $search_condition;
879 879
 				} else {
880 880
 					$left = $search_condition->left;
881 881
 					$alias = $query->_alias( $left->field_id, $left->source, $left->is_entry_column() ? 't' : 'm' );
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 							$on = $_join->join_on;
886 886
 							$join = $_join->join;
887 887
 
888
-							$search_conditions[] = GF_Query_Condition::_or(
888
+							$search_conditions[ ] = GF_Query_Condition::_or(
889 889
 								// Join
890 890
 								new GF_Query_Condition(
891 891
 									new GF_Query_Column( GF_Query_Column::META, $join->ID, $query->_alias( GF_Query_Column::META, $join->ID, 'm' ) ),
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 							);
902 902
 						}
903 903
 					} else {
904
-						$search_conditions[] = new GF_Query_Condition(
904
+						$search_conditions[ ] = new GF_Query_Condition(
905 905
 							new GF_Query_Column( $left->field_id, $left->source, $alias ),
906 906
 							$search_condition->operator,
907 907
 							$search_condition->right
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
 		/**
924 924
 		 * Combine the parts as a new WHERE clause.
925 925
 		 */
926
-		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) );
926
+		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) );
927 927
 		$query->where( $where );
928 928
 	}
929 929
 
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 		$field_id = str_replace( 'filter_', '', $key );
947 947
 
948 948
 		// calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox )
949
-		if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) {
949
+		if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) {
950 950
 			$field_id = str_replace( '_', '.', $field_id );
951 951
 		}
952 952
 
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 			// form is in searchable fields
1004 1004
 			$found = false;
1005 1005
 			foreach ( $searchable_fields as $field ) {
1006
-				if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) {
1006
+				if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) {
1007 1007
 					$found = true;
1008 1008
 					break;
1009 1009
 				}
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 
1044 1044
 			case 'select':
1045 1045
 			case 'radio':
1046
-				$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1046
+				$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1047 1047
 				break;
1048 1048
 
1049 1049
 			case 'post_category':
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
 
1058 1058
 				foreach ( $value as $val ) {
1059 1059
 					$cat = get_term( $val, 'category' );
1060
-					$filter[] = array(
1060
+					$filter[ ] = array(
1061 1061
 						'key'      => $field_id,
1062 1062
 						'value'    => esc_attr( $cat->name ) . ':' . $val,
1063 1063
 						'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ),
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 				$filter = array();
1077 1077
 
1078 1078
 				foreach ( $value as $val ) {
1079
-					$filter[] = array( 'key' => $field_id, 'value' => $val );
1079
+					$filter[ ] = array( 'key' => $field_id, 'value' => $val );
1080 1080
 				}
1081 1081
 
1082 1082
 				break;
@@ -1085,9 +1085,9 @@  discard block
 block discarded – undo
1085 1085
 				// convert checkbox on/off into the correct search filter
1086 1086
 				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) {
1087 1087
 					foreach ( $form_field->inputs as $k => $input ) {
1088
-						if ( $input['id'] == $field_id ) {
1089
-							$filter['value'] = $form_field->choices[ $k ]['value'];
1090
-							$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1088
+						if ( $input[ 'id' ] == $field_id ) {
1089
+							$filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ];
1090
+							$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1091 1091
 							break;
1092 1092
 						}
1093 1093
 					}
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 					$filter = array();
1098 1098
 
1099 1099
 					foreach ( $value as $val ) {
1100
-						$filter[] = array(
1100
+						$filter[ ] = array(
1101 1101
 							'key'      => $field_id,
1102 1102
 							'value'    => $val,
1103 1103
 							'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ),
@@ -1118,9 +1118,9 @@  discard block
 block discarded – undo
1118 1118
 					foreach ( $words as $word ) {
1119 1119
 						if ( ! empty( $word ) && strlen( $word ) > 1 ) {
1120 1120
 							// Keep the same key for each filter
1121
-							$filter['value'] = $word;
1121
+							$filter[ 'value' ] = $word;
1122 1122
 							// Add a search for the value
1123
-							$filters[] = $filter;
1123
+							$filters[ ] = $filter;
1124 1124
 						}
1125 1125
 					}
1126 1126
 
@@ -1134,19 +1134,19 @@  discard block
 block discarded – undo
1134 1134
 
1135 1135
 					foreach ( $searchable_fields as $searchable_field ) {
1136 1136
 
1137
-						if( $form_field->ID !== $searchable_field['field'] ) {
1137
+						if ( $form_field->ID !== $searchable_field[ 'field' ] ) {
1138 1138
 							continue;
1139 1139
 						}
1140 1140
 
1141 1141
 						// Only exact-match dropdowns, not text search
1142
-						if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) {
1142
+						if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) {
1143 1143
 							continue;
1144 1144
 						}
1145 1145
 
1146 1146
 						$input_id = gravityview_get_input_id_from_id( $form_field->ID );
1147 1147
 
1148 1148
 						if ( 4 === $input_id ) {
1149
-							$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1149
+							$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1150 1150
 						};
1151 1151
 					}
1152 1152
 				}
@@ -1173,12 +1173,12 @@  discard block
 block discarded – undo
1173 1173
 						 * @since 1.16.3
1174 1174
 						 * Safeguard until GF implements '<=' operator
1175 1175
 						 */
1176
-						if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1176
+						if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1177 1177
 							$operator = '<';
1178 1178
 							$date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) );
1179 1179
 						}
1180 1180
 
1181
-						$filter[] = array(
1181
+						$filter[ ] = array(
1182 1182
 							'key'      => $field_id,
1183 1183
 							'value'    => self::get_formatted_date( $date, 'Y-m-d', $date_format ),
1184 1184
 							'operator' => $this->get_operator( $get, $key, array( $operator ), $operator ),
@@ -1186,8 +1186,8 @@  discard block
 block discarded – undo
1186 1186
 					}
1187 1187
 				} else {
1188 1188
 					$date = $value;
1189
-					$filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1190
-					$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1189
+					$filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1190
+					$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1191 1191
 				}
1192 1192
 
1193 1193
 				break;
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 			'ymd_dot' => 'Y.m.d',
1219 1219
 		);
1220 1220
 
1221
-		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){
1221
+		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) {
1222 1222
 			$format = $datepicker[ $field->dateFormat ];
1223 1223
 		}
1224 1224
 
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 	public function add_template_path( $file_paths ) {
1256 1256
 
1257 1257
 		// Index 100 is the default GravityView template path.
1258
-		$file_paths[102] = self::$file . 'templates/';
1258
+		$file_paths[ 102 ] = self::$file . 'templates/';
1259 1259
 
1260 1260
 		return $file_paths;
1261 1261
 	}
@@ -1274,7 +1274,7 @@  discard block
 block discarded – undo
1274 1274
 		$has_date = false;
1275 1275
 
1276 1276
 		foreach ( $search_fields as $k => $field ) {
1277
-			if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) {
1277
+			if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) {
1278 1278
 				$has_date = true;
1279 1279
 				break;
1280 1280
 			}
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
 		$view = \GV\View::by_id( $gravityview_view->view_id );
1305 1305
 
1306 1306
 		// get configured search fields
1307
-		$search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : '';
1307
+		$search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : '';
1308 1308
 
1309 1309
 		if ( empty( $search_fields ) || ! is_array( $search_fields ) ) {
1310 1310
 			gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) );
@@ -1318,40 +1318,40 @@  discard block
 block discarded – undo
1318 1318
 
1319 1319
 			$updated_field = $this->get_search_filter_details( $updated_field, $context );
1320 1320
 
1321
-			switch ( $field['field'] ) {
1321
+			switch ( $field[ 'field' ] ) {
1322 1322
 
1323 1323
 				case 'search_all':
1324
-					$updated_field['key'] = 'search_all';
1325
-					$updated_field['input'] = 'search_all';
1326
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' );
1324
+					$updated_field[ 'key' ] = 'search_all';
1325
+					$updated_field[ 'input' ] = 'search_all';
1326
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' );
1327 1327
 					break;
1328 1328
 
1329 1329
 				case 'entry_date':
1330
-					$updated_field['key'] = 'entry_date';
1331
-					$updated_field['input'] = 'entry_date';
1332
-					$updated_field['value'] = array(
1330
+					$updated_field[ 'key' ] = 'entry_date';
1331
+					$updated_field[ 'input' ] = 'entry_date';
1332
+					$updated_field[ 'value' ] = array(
1333 1333
 						'start' => $this->rgget_or_rgpost( 'gv_start' ),
1334 1334
 						'end' => $this->rgget_or_rgpost( 'gv_end' ),
1335 1335
 					);
1336 1336
 					break;
1337 1337
 
1338 1338
 				case 'entry_id':
1339
-					$updated_field['key'] = 'entry_id';
1340
-					$updated_field['input'] = 'entry_id';
1341
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' );
1339
+					$updated_field[ 'key' ] = 'entry_id';
1340
+					$updated_field[ 'input' ] = 'entry_id';
1341
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' );
1342 1342
 					break;
1343 1343
 
1344 1344
 				case 'created_by':
1345
-					$updated_field['key'] = 'created_by';
1346
-					$updated_field['name'] = 'gv_by';
1347
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' );
1348
-					$updated_field['choices'] = self::get_created_by_choices( $view );
1345
+					$updated_field[ 'key' ] = 'created_by';
1346
+					$updated_field[ 'name' ] = 'gv_by';
1347
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' );
1348
+					$updated_field[ 'choices' ] = self::get_created_by_choices( $view );
1349 1349
 					break;
1350 1350
 
1351 1351
 				case 'is_approved':
1352
-					$updated_field['key'] = 'is_approved';
1353
-					$updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' );
1354
-					$updated_field['choices'] = self::get_is_approved_choices();
1352
+					$updated_field[ 'key' ] = 'is_approved';
1353
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' );
1354
+					$updated_field[ 'choices' ] = self::get_is_approved_choices();
1355 1355
 					break;
1356 1356
 			}
1357 1357
 
@@ -1372,16 +1372,16 @@  discard block
 block discarded – undo
1372 1372
 
1373 1373
 		$gravityview_view->permalink_fields = $this->add_no_permalink_fields( array(), $this, $widget_args );
1374 1374
 
1375
-		$gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal';
1375
+		$gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal';
1376 1376
 
1377 1377
 		/** @since 1.14 */
1378
-		$gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any';
1378
+		$gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any';
1379 1379
 
1380
-		$custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : '';
1380
+		$custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : '';
1381 1381
 
1382 1382
 		$gravityview_view->search_class = self::get_search_class( $custom_class );
1383 1383
 
1384
-		$gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false;
1384
+		$gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false;
1385 1385
 
1386 1386
 		if ( $this->has_date_field( $search_fields ) ) {
1387 1387
 			// enqueue datepicker stuff only if needed!
@@ -1403,10 +1403,10 @@  discard block
 block discarded – undo
1403 1403
 	public static function get_search_class( $custom_class = '' ) {
1404 1404
 		$gravityview_view = GravityView_View::getInstance();
1405 1405
 
1406
-		$search_class = 'gv-search-'.$gravityview_view->search_layout;
1406
+		$search_class = 'gv-search-' . $gravityview_view->search_layout;
1407 1407
 
1408
-		if ( ! empty( $custom_class )  ) {
1409
-			$search_class .= ' '.$custom_class;
1408
+		if ( ! empty( $custom_class ) ) {
1409
+			$search_class .= ' ' . $custom_class;
1410 1410
 		}
1411 1411
 
1412 1412
 		/**
@@ -1457,9 +1457,9 @@  discard block
 block discarded – undo
1457 1457
 
1458 1458
 		if ( ! $label ) {
1459 1459
 
1460
-			$label = isset( $form_field['label'] ) ? $form_field['label'] : '';
1460
+			$label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : '';
1461 1461
 
1462
-			switch( $field['field'] ) {
1462
+			switch ( $field[ 'field' ] ) {
1463 1463
 				case 'search_all':
1464 1464
 					$label = __( 'Search Entries:', 'gravityview' );
1465 1465
 					break;
@@ -1471,10 +1471,10 @@  discard block
 block discarded – undo
1471 1471
 					break;
1472 1472
 				default:
1473 1473
 					// If this is a field input, not a field
1474
-					if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) {
1474
+					if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) {
1475 1475
 
1476 1476
 						// Get the label for the field in question, which returns an array
1477
-						$items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) );
1477
+						$items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) );
1478 1478
 
1479 1479
 						// Get the item with the `label` key
1480 1480
 						$values = wp_list_pluck( $items, 'label' );
@@ -1515,13 +1515,13 @@  discard block
 block discarded – undo
1515 1515
 		$form = $gravityview_view->getForm();
1516 1516
 
1517 1517
 		// for advanced field ids (eg, first name / last name )
1518
-		$name = 'filter_' . str_replace( '.', '_', $field['field'] );
1518
+		$name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] );
1519 1519
 
1520 1520
 		// get searched value from $_GET/$_POST (string or array)
1521 1521
 		$value = $this->rgget_or_rgpost( $name );
1522 1522
 
1523 1523
 		// get form field details
1524
-		$form_field = gravityview_get_field( $form, $field['field'] );
1524
+		$form_field = gravityview_get_field( $form, $field[ 'field' ] );
1525 1525
 
1526 1526
 		$form_field_type = \GV\Utils::get( $form_field, 'type' );
1527 1527
 
@@ -1535,17 +1535,17 @@  discard block
 block discarded – undo
1535 1535
 		);
1536 1536
 
1537 1537
 		// collect choices
1538
-		if ( 'post_category' === $form_field_type && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) {
1539
-			$filter['choices'] = gravityview_get_terms_choices();
1540
-		} elseif ( ! empty( $form_field['choices'] ) ) {
1541
-			$filter['choices'] = $form_field['choices'];
1538
+		if ( 'post_category' === $form_field_type && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) {
1539
+			$filter[ 'choices' ] = gravityview_get_terms_choices();
1540
+		} elseif ( ! empty( $form_field[ 'choices' ] ) ) {
1541
+			$filter[ 'choices' ] = $form_field[ 'choices' ];
1542 1542
 		}
1543 1543
 
1544
-		if ( 'date_range' === $field['input'] && empty( $value ) ) {
1545
-			$filter['value'] = array( 'start' => '', 'end' => '' );
1544
+		if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) {
1545
+			$filter[ 'value' ] = array( 'start' => '', 'end' => '' );
1546 1546
 		}
1547 1547
 
1548
-		if ( ! empty( $filter['choices'] ) ) {
1548
+		if ( ! empty( $filter[ 'choices' ] ) ) {
1549 1549
 			/**
1550 1550
 			 * @filter `gravityview/search/sieve_choices` Only output used choices for this field.
1551 1551
 			 * @param[in,out] bool Yes or no.
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
 			 * @param \GV\Context The context.
1554 1554
 			 */
1555 1555
 			if ( apply_filters( 'gravityview/search/sieve_choices', false, $field, $context ) ) {
1556
-				$filter['choices'] = $this->sieve_filter_choices( $filter, $context );
1556
+				$filter[ 'choices' ] = $this->sieve_filter_choices( $filter, $context );
1557 1557
 			}
1558 1558
 		}
1559 1559
 
@@ -1582,11 +1582,11 @@  discard block
 block discarded – undo
1582 1582
 	 * @return array The filter choices.
1583 1583
 	 */
1584 1584
 	private function sieve_filter_choices( $filter, $context ) {
1585
-		if ( empty( $filter['key'] ) || empty( $filter['choices'] ) ) {
1585
+		if ( empty( $filter[ 'key' ] ) || empty( $filter[ 'choices' ] ) ) {
1586 1586
 			return $filter; // @todo Populate plugins might give us empty choices
1587 1587
 		}
1588 1588
 
1589
-		if ( ! is_numeric( $filter['key'] ) ) {
1589
+		if ( ! is_numeric( $filter[ 'key' ] ) ) {
1590 1590
 			return $filter;
1591 1591
 		}
1592 1592
 
@@ -1596,29 +1596,29 @@  discard block
 block discarded – undo
1596 1596
 
1597 1597
 		$table = GFFormsModel::get_entry_meta_table_name();
1598 1598
 
1599
-		$key_like = $wpdb->esc_like( $filter['key'] ) . '.%';
1599
+		$key_like = $wpdb->esc_like( $filter[ 'key' ] ) . '.%';
1600 1600
 
1601 1601
 		switch ( \GV\Utils::get( $filter, 'type' ) ):
1602 1602
 			case 'post_category':
1603 1603
 				$choices = $wpdb->get_col( $wpdb->prepare(
1604 1604
 					"SELECT DISTINCT SUBSTRING_INDEX(meta_value, ':', 1) FROM $table WHERE (meta_key LIKE %s OR meta_key = %d) AND form_id = %d",
1605
-					$key_like, $filter['key'], $form_id
1605
+					$key_like, $filter[ 'key' ], $form_id
1606 1606
 				) );
1607 1607
 				break;
1608 1608
 			default:
1609 1609
 				$choices = $wpdb->get_col( $wpdb->prepare(
1610 1610
 					"SELECT DISTINCT meta_value FROM $table WHERE (meta_key LIKE %s OR meta_key = %d) AND form_id = %d",
1611
-					$key_like, $filter['key'], $form_id
1611
+					$key_like, $filter[ 'key' ], $form_id
1612 1612
 				) );
1613 1613
 
1614
-				if ( ( $field = gravityview_get_field( $form_id, $filter['key'] ) ) && 'json' === $field->storageType ) {
1614
+				if ( ( $field = gravityview_get_field( $form_id, $filter[ 'key' ] ) ) && 'json' === $field->storageType ) {
1615 1615
 					$choices = array_map( 'json_decode', $choices );
1616 1616
 					$_choices_array = array();
1617 1617
 					foreach ( $choices as $choice ) {
1618 1618
 						if ( is_array( $choice ) ) {
1619 1619
 							$_choices_array = array_merge( $_choices_array, $choice );
1620 1620
 						} else {
1621
-							$_choices_array []= $choice;
1621
+							$_choices_array [ ] = $choice;
1622 1622
 						}
1623 1623
 					}
1624 1624
 					$choices = array_unique( $_choices_array );
@@ -1628,9 +1628,9 @@  discard block
 block discarded – undo
1628 1628
 		endswitch;
1629 1629
 
1630 1630
 		$filter_choices = array();
1631
-		foreach ( $filter['choices'] as $choice ) {
1632
-			if ( in_array( $choice['text'], $choices, true ) || in_array( $choice['value'], $choices, true ) ) {
1633
-				$filter_choices[] = $choice;
1631
+		foreach ( $filter[ 'choices' ] as $choice ) {
1632
+			if ( in_array( $choice[ 'text' ], $choices, true ) || in_array( $choice[ 'value' ], $choices, true ) ) {
1633
+				$filter_choices[ ] = $choice;
1634 1634
 			}
1635 1635
 		}
1636 1636
 
@@ -1665,7 +1665,7 @@  discard block
 block discarded – undo
1665 1665
 			 * @param \GV\View $view The view.
1666 1666
 			 */
1667 1667
 			$text = apply_filters( 'gravityview/search/created_by/text', $user->display_name, $user, $view );
1668
-			$choices[] = array(
1668
+			$choices[ ] = array(
1669 1669
 				'value' => $user->ID,
1670 1670
 				'text' => $text,
1671 1671
 			);
@@ -1685,9 +1685,9 @@  discard block
 block discarded – undo
1685 1685
 
1686 1686
 		$choices = array();
1687 1687
 		foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) {
1688
-			$choices[] = array(
1689
-				'value' => $status['value'],
1690
-				'text' => $status['label'],
1688
+			$choices[ ] = array(
1689
+				'value' => $status[ 'value' ],
1690
+				'text' => $status[ 'label' ],
1691 1691
 			);
1692 1692
 		}
1693 1693
 
@@ -1739,7 +1739,7 @@  discard block
 block discarded – undo
1739 1739
 	 */
1740 1740
 	public function add_datepicker_js_dependency( $js_dependencies ) {
1741 1741
 
1742
-		$js_dependencies[] = 'jquery-ui-datepicker';
1742
+		$js_dependencies[ ] = 'jquery-ui-datepicker';
1743 1743
 
1744 1744
 		return $js_dependencies;
1745 1745
 	}
@@ -1783,7 +1783,7 @@  discard block
 block discarded – undo
1783 1783
 			'isRTL'             => is_rtl(),
1784 1784
 		), $view_data );
1785 1785
 
1786
-		$localizations['datepicker'] = $datepicker_settings;
1786
+		$localizations[ 'datepicker' ] = $datepicker_settings;
1787 1787
 
1788 1788
 		return $localizations;
1789 1789
 
@@ -1810,7 +1810,7 @@  discard block
 block discarded – undo
1810 1810
 	 * @return void
1811 1811
 	 */
1812 1812
 	private function maybe_enqueue_flexibility() {
1813
-		if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) {
1813
+		if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
1814 1814
 			wp_enqueue_script( 'gv-flexibility' );
1815 1815
 		}
1816 1816
 	}
@@ -1832,7 +1832,7 @@  discard block
 block discarded – undo
1832 1832
 		add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 );
1833 1833
 
1834 1834
 		$scheme = is_ssl() ? 'https://' : 'http://';
1835
-		wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1835
+		wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1836 1836
 
1837 1837
 		/**
1838 1838
 		 * @filter `gravityview_search_datepicker_class`
@@ -1911,7 +1911,7 @@  discard block
 block discarded – undo
1911 1911
 	public function add_preview_inputs() {
1912 1912
 		global $wp;
1913 1913
 
1914
-		if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) {
1914
+		if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) {
1915 1915
 			return;
1916 1916
 		}
1917 1917
 
@@ -1963,7 +1963,7 @@  discard block
 block discarded – undo
1963 1963
  */
1964 1964
 class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition {
1965 1965
 	public function __construct( $filter, $view ) {
1966
-		$this->value = $filter['value'];
1966
+		$this->value = $filter[ 'value' ];
1967 1967
 		$this->view = $view;
1968 1968
 	}
1969 1969
 
@@ -1995,11 +1995,11 @@  discard block
 block discarded – undo
1995 1995
 		$conditions = array();
1996 1996
 
1997 1997
 		foreach ( $user_fields as $user_field ) {
1998
-			$conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) .  '%' );
1998
+			$conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' );
1999 1999
 		}
2000 2000
 
2001 2001
 		foreach ( $user_meta_fields as $meta_field ) {
2002
-			$conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) .  '%' );
2002
+			$conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' );
2003 2003
 		}
2004 2004
 
2005 2005
 		$conditions = '(' . implode( ' OR ', $conditions ) . ')';
Please login to merge, or discard this patch.
includes/class-common.php 1 patch
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 
126 126
 		$form = false;
127 127
 
128
-		if( $entry ) {
129
-			$form = GFAPI::get_form( $entry['form_id'] );
128
+		if ( $entry ) {
129
+			$form = GFAPI::get_form( $entry[ 'form_id' ] );
130 130
 		}
131 131
 
132 132
 		return $form;
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 			}
203 203
 		}
204 204
 
205
-		return (bool) $has_transaction_data;
205
+		return (bool)$has_transaction_data;
206 206
 	}
207 207
 
208 208
 	/**
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
 		$results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging );
242 242
 
243
-		$result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null;
243
+		$result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null;
244 244
 
245 245
 		return $result;
246 246
 	}
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 	 *
261 261
 	 * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms
262 262
 	 */
263
-	public static function get_forms(  $active = true, $trash = false, $order_by = 'date_created', $order = 'ASC' ) {
263
+	public static function get_forms( $active = true, $trash = false, $order_by = 'date_created', $order = 'ASC' ) {
264 264
 		$forms = array();
265 265
 		if ( ! class_exists( 'GFAPI' ) ) {
266 266
 			return array();
267 267
 		}
268 268
 
269
-		if( 'any' === $active ) {
269
+		if ( 'any' === $active ) {
270 270
 			$active_forms = GFAPI::get_forms( true, $trash );
271 271
 			$inactive_forms = GFAPI::get_forms( false, $trash );
272 272
 			$forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) );
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
 		$has_post_fields = false;
300 300
 
301 301
 		if ( $form ) {
302
-			foreach ( $form['fields'] as $field ) {
303
-				if ( $include_parent_field || empty( $field['inputs'] ) ) {
304
-					$fields["{$field['id']}"] = array(
302
+			foreach ( $form[ 'fields' ] as $field ) {
303
+				if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) {
304
+					$fields[ "{$field[ 'id' ]}" ] = array(
305 305
 						'label' => \GV\Utils::get( $field, 'label' ),
306 306
 						'parent' => null,
307 307
 						'type' => \GV\Utils::get( $field, 'type' ),
@@ -310,10 +310,10 @@  discard block
 block discarded – undo
310 310
 					);
311 311
 				}
312 312
 
313
-				if ( $add_default_properties && ! empty( $field['inputs'] ) ) {
314
-					foreach ( $field['inputs'] as $input ) {
313
+				if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) {
314
+					foreach ( $field[ 'inputs' ] as $input ) {
315 315
 
316
-						if( ! empty( $input['isHidden'] ) ) {
316
+						if ( ! empty( $input[ 'isHidden' ] ) ) {
317 317
 							continue;
318 318
 						}
319 319
 
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
                          * @hack
322 322
                          * In case of email/email confirmation, the input for email has the same id as the parent field
323 323
                          */
324
-						if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) {
324
+						if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) {
325 325
                             continue;
326 326
                         }
327
-						$fields["{$input['id']}"] = array(
327
+						$fields[ "{$input[ 'id' ]}" ] = array(
328 328
 							'label' => \GV\Utils::get( $input, 'label' ),
329 329
 							'customLabel' => \GV\Utils::get( $input, 'customLabel' ),
330 330
 							'parent' => $field,
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 				}
337 337
 
338 338
 
339
-				if( GFCommon::is_product_field( $field['type'] ) ){
339
+				if ( GFCommon::is_product_field( $field[ 'type' ] ) ) {
340 340
 					$has_product_fields = true;
341 341
 				}
342 342
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 		 * @since 1.7
351 351
 		 */
352 352
 		if ( $has_post_fields ) {
353
-			$fields['post_id'] = array(
353
+			$fields[ 'post_id' ] = array(
354 354
 				'label' => __( 'Post ID', 'gravityview' ),
355 355
 				'type' => 'post_id',
356 356
 			);
@@ -363,11 +363,11 @@  discard block
 block discarded – undo
363 363
 			foreach ( $payment_fields as $payment_field ) {
364 364
 
365 365
 				// Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key
366
-				if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) {
366
+				if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) {
367 367
 					continue;
368 368
 				}
369 369
 
370
-				$fields["{$payment_field->name}"] = array(
370
+				$fields[ "{$payment_field->name}" ] = array(
371 371
 					'label' => $payment_field->label,
372 372
 					'desc' => $payment_field->description,
373 373
 					'type' => $payment_field->name,
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
 
400 400
 		$fields = array();
401 401
 
402
-		foreach ( $extra_fields as $key => $field ){
403
-			if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) {
404
-				$fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' );
402
+		foreach ( $extra_fields as $key => $field ) {
403
+			if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) {
404
+				$fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' );
405 405
 			}
406 406
 		}
407 407
 
@@ -441,33 +441,33 @@  discard block
 block discarded – undo
441 441
 			'search_criteria' => null,
442 442
 			'sorting' => null,
443 443
 			'paging' => null,
444
-			'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true),
444
+			'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ),
445 445
 			'context_view_id' => null,
446 446
 		);
447 447
 
448 448
 		$criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults );
449 449
 
450
-		if ( ! empty( $criteria['search_criteria']['field_filters'] ) && is_array( $criteria['search_criteria']['field_filters'] ) ) {
451
-			foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) {
450
+		if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) && is_array( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) {
451
+			foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) {
452 452
 
453 453
 				if ( ! is_array( $filter ) ) {
454 454
 					continue;
455 455
 				}
456 456
 
457 457
 				// By default, we want searches to be wildcard for each field.
458
-				$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
458
+				$filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];
459 459
 
460 460
 				/**
461 461
 				 * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc)
462 462
 				 * @param string $operator Existing search operator
463 463
 				 * @param array $filter array with `key`, `value`, `operator`, `type` keys
464 464
 				 */
465
-				$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter );
465
+				$filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter );
466 466
 			}
467 467
 
468 468
 			// don't send just the [mode] without any field filter.
469
-			if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) {
470
-				unset( $criteria['search_criteria']['field_filters']['mode'] );
469
+			if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) {
470
+				unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] );
471 471
 			}
472 472
 
473 473
 		}
@@ -478,33 +478,33 @@  discard block
 block discarded – undo
478 478
 		 * Prepare date formats to be in Gravity Forms DB format;
479 479
 		 * $passed_criteria may include date formats incompatible with Gravity Forms.
480 480
 		 */
481
-		foreach ( array('start_date', 'end_date' ) as $key ) {
481
+		foreach ( array( 'start_date', 'end_date' ) as $key ) {
482 482
 
483
-			if ( ! empty( $criteria['search_criteria'][ $key ] ) ) {
483
+			if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) {
484 484
 
485 485
 				// Use date_create instead of new DateTime so it returns false if invalid date format.
486
-				$date = date_create( $criteria['search_criteria'][ $key ] );
486
+				$date = date_create( $criteria[ 'search_criteria' ][ $key ] );
487 487
 
488 488
 				if ( $date ) {
489 489
 					// Gravity Forms wants dates in the `Y-m-d H:i:s` format.
490
-					$criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' );
490
+					$criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' );
491 491
 				} else {
492
-					gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria['search_criteria'][ $key ] ) );
492
+					gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria[ 'search_criteria' ][ $key ] ) );
493 493
 
494 494
 					// If it's an invalid date, unset it. Gravity Forms freaks out otherwise.
495
-					unset( $criteria['search_criteria'][ $key ] );
495
+					unset( $criteria[ 'search_criteria' ][ $key ] );
496 496
 				}
497 497
 			}
498 498
 		}
499 499
 
500
-		if ( empty( $criteria['context_view_id'] ) ) {
500
+		if ( empty( $criteria[ 'context_view_id' ] ) ) {
501 501
 			// Calculate the context view id and send it to the advanced filter
502 502
 			if ( GravityView_frontend::getInstance()->getSingleEntry() ) {
503
-				$criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id();
503
+				$criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id();
504 504
 			} else if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) {
505
-				$criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id();
505
+				$criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id();
506 506
 			} else if ( 'delete' === GFForms::get( 'action' ) ) {
507
-				$criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null;
507
+				$criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null;
508 508
 			}
509 509
 		}
510 510
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 		 * @param array $form_ids Forms to search
515 515
 		 * @param int $view_id ID of the view being used to search
516 516
 		 */
517
-		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] );
517
+		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] );
518 518
 
519 519
 		return (array)$criteria;
520 520
 	}
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 		/** Reduce # of database calls */
550 550
 		add_filter( 'gform_is_encrypted_field', '__return_false' );
551 551
 
552
-		if ( ! empty( $criteria['cache'] ) ) {
552
+		if ( ! empty( $criteria[ 'cache' ] ) ) {
553 553
 
554 554
 			$Cache = new GravityView_Cache( $form_ids, $criteria );
555 555
 
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 
558 558
 				// Still update the total count when using cached results
559 559
 				if ( ! is_null( $total ) ) {
560
-					$total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] );
560
+					$total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] );
561 561
 				}
562 562
 
563 563
 				$return = $entries;
@@ -579,9 +579,9 @@  discard block
 block discarded – undo
579 579
 			$entries = apply_filters_ref_array( 'gravityview_before_get_entries', array( null, $criteria, $passed_criteria, &$total ) );
580 580
 
581 581
 			// No entries returned from gravityview_before_get_entries
582
-			if( is_null( $entries ) ) {
582
+			if ( is_null( $entries ) ) {
583 583
 
584
-				$entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total );
584
+				$entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total );
585 585
 
586 586
 				if ( is_wp_error( $entries ) ) {
587 587
 					gravityview()->log->error( '{error}', array( 'error' => $entries->get_error_message(), 'data' => $entries ) );
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 				}
593 593
 			}
594 594
 
595
-			if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) {
595
+			if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) {
596 596
 
597 597
 				// Cache results
598 598
 				$Cache->set( $entries, 'entries' );
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 		 */
706 706
 		$check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry, $view );
707 707
 
708
-		if( $check_entry_display ) {
708
+		if ( $check_entry_display ) {
709 709
 
710 710
 			global $post;
711 711
 
@@ -715,12 +715,12 @@  discard block
 block discarded – undo
715 715
 
716 716
 				$views = \GV\View_Collection::from_post( $post );
717 717
 
718
-				foreach( $views->all() as $view ) {
718
+				foreach ( $views->all() as $view ) {
719 719
 
720 720
 					// Is the entry allowed
721 721
 					$check_entry = self::check_entry_display( $entry, $view );
722 722
 
723
-					if( is_wp_error( $entry ) ) {
723
+					if ( is_wp_error( $entry ) ) {
724 724
 						continue;
725 725
 					}
726 726
 
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 			}
733 733
 		}
734 734
 
735
-		if( is_wp_error( $entry ) ) {
735
+		if ( is_wp_error( $entry ) ) {
736 736
 			gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) );
737 737
 			return false;
738 738
 		}
@@ -766,12 +766,12 @@  discard block
 block discarded – undo
766 766
 
767 767
 		$value = false;
768 768
 
769
-		if( 'context' === $val1 ) {
769
+		if ( 'context' === $val1 ) {
770 770
 
771 771
 			$matching_contexts = array( $val2 );
772 772
 
773 773
 			// We allow for non-standard contexts.
774
-			switch( $val2 ) {
774
+			switch ( $val2 ) {
775 775
 				// Check for either single or edit
776 776
 				case 'singular':
777 777
 					$matching_contexts = array( 'single', 'edit' );
@@ -814,18 +814,18 @@  discard block
 block discarded – undo
814 814
 				$json_val_1 = json_decode( $val1, true );
815 815
 				$json_val_2 = json_decode( $val2, true );
816 816
 
817
-				if( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) {
817
+				if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) {
818 818
 
819 819
 					$json_in = false;
820
-					$json_val_1 = $json_val_1 ? (array) $json_val_1 : array( $val1 );
821
-					$json_val_2 = $json_val_2 ? (array) $json_val_2 : array( $val2 );
820
+					$json_val_1 = $json_val_1 ? (array)$json_val_1 : array( $val1 );
821
+					$json_val_2 = $json_val_2 ? (array)$json_val_2 : array( $val2 );
822 822
 
823 823
 					// For JSON, we want to compare as "in" or "not in" rather than "contains"
824 824
 					foreach ( $json_val_1 as $item_1 ) {
825 825
 						foreach ( $json_val_2 as $item_2 ) {
826 826
 							$json_in = self::matches_operation( $item_1, $item_2, 'is' );
827 827
 
828
-							if( $json_in ) {
828
+							if ( $json_in ) {
829 829
 								break 2;
830 830
 							}
831 831
 						}
@@ -876,10 +876,10 @@  discard block
 block discarded – undo
876 876
 	public static function check_entry_display( $entry, $view = null ) {
877 877
 
878 878
 		if ( ! $entry || is_wp_error( $entry ) ) {
879
-			return new WP_Error('entry_not_found', 'Entry was not found.', $entry );
879
+			return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry );
880 880
 		}
881 881
 
882
-		if ( empty( $entry['form_id'] ) ) {
882
+		if ( empty( $entry[ 'form_id' ] ) ) {
883 883
 			return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry );
884 884
 		}
885 885
 
@@ -895,12 +895,12 @@  discard block
 block discarded – undo
895 895
 		$view_form_id = $view->form->ID;
896 896
 
897 897
 		if ( $view->joins ) {
898
-			if ( in_array( (int)$entry['form_id'], array_keys( $view::get_joined_forms( $view->ID ) ), true ) ) {
899
-				$view_form_id = $entry['form_id'];
898
+			if ( in_array( (int)$entry[ 'form_id' ], array_keys( $view::get_joined_forms( $view->ID ) ), true ) ) {
899
+				$view_form_id = $entry[ 'form_id' ];
900 900
 			}
901 901
 		}
902 902
 
903
-		if ( $view_form_id != $entry['form_id'] ) {
903
+		if ( $view_form_id != $entry[ 'form_id' ] ) {
904 904
 			return new WP_Error( 'view_id_not_match', 'View form source does not match entry form source ID.', $entry );
905 905
 		}
906 906
 
@@ -908,13 +908,13 @@  discard block
 block discarded – undo
908 908
 		 * Check whether the entry is in the entries subset by running a modified query.
909 909
 		 */
910 910
 		add_action( 'gravityview/view/query', $entry_subset_callback = function( &$query, $view, $request ) use ( $entry, $view_form_id ) {
911
-			$_tmp_query       = new \GF_Query( $view_form_id, array(
911
+			$_tmp_query = new \GF_Query( $view_form_id, array(
912 912
 				'field_filters' => array(
913 913
 					'mode' => 'all',
914 914
 					array(
915 915
 						'key' => 'id',
916 916
 						'operation' => 'is',
917
-						'value' => $entry['id']
917
+						'value' => $entry[ 'id' ]
918 918
 					)
919 919
 				)
920 920
 			) );
@@ -924,14 +924,14 @@  discard block
 block discarded – undo
924 924
 			/** @var \GF_Query $query */
925 925
 			$query_parts      = $query->_introspect();
926 926
 
927
-			$query->where( \GF_Query_Condition::_and( $_tmp_query_parts['where'], $query_parts['where'] ) );
927
+			$query->where( \GF_Query_Condition::_and( $_tmp_query_parts[ 'where' ], $query_parts[ 'where' ] ) );
928 928
 
929 929
 		}, 10, 3 );
930 930
 
931 931
 		// Prevent page offset from being applied to the single entry query; it's used to return to the referring page number
932 932
 		add_filter( 'gravityview_search_criteria', $remove_pagenum = function( $criteria ) {
933 933
 
934
-			$criteria['paging'] = array(
934
+			$criteria[ 'paging' ] = array(
935 935
 				'offset' => 0,
936 936
 				'page_size' => 25
937 937
 			);
@@ -950,20 +950,20 @@  discard block
 block discarded – undo
950 950
 		}
951 951
 
952 952
 		// This entry is on a View with joins
953
-		if ( $entries[0]->is_multi() ) {
953
+		if ( $entries[ 0 ]->is_multi() ) {
954 954
 
955 955
 			$multi_entry_ids = array();
956 956
 
957
-			foreach ( $entries[0]->entries as $multi_entry ) {
958
-				$multi_entry_ids[] = (int) $multi_entry->ID;
957
+			foreach ( $entries[ 0 ]->entries as $multi_entry ) {
958
+				$multi_entry_ids[ ] = (int)$multi_entry->ID;
959 959
 			}
960 960
 
961
-			if ( ! in_array( (int) $entry['id'], $multi_entry_ids, true ) ) {
961
+			if ( ! in_array( (int)$entry[ 'id' ], $multi_entry_ids, true ) ) {
962 962
 				remove_action( 'gravityview/view/query', $entry_subset_callback );
963 963
 				return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' );
964 964
 			}
965 965
 
966
-		} elseif ( (int) $entries[0]->ID !== (int) $entry['id'] ) {
966
+		} elseif ( (int)$entries[ 0 ]->ID !== (int)$entry[ 'id' ] ) {
967 967
 			remove_action( 'gravityview/view/query', $entry_subset_callback );
968 968
 			return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' );
969 969
 		}
@@ -1008,18 +1008,18 @@  discard block
 block discarded – undo
1008 1008
 		 * Gravity Forms code to adjust date to locally-configured Time Zone
1009 1009
 		 * @see GFCommon::format_date() for original code
1010 1010
 		 */
1011
-		$date_gmt_time   = mysql2date( 'G', $date_string );
1011
+		$date_gmt_time = mysql2date( 'G', $date_string );
1012 1012
 		$date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time );
1013 1013
 
1014
-		$format  = \GV\Utils::get( $atts, 'format' );
1015
-		$is_human  = ! empty( $atts['human'] );
1016
-		$is_diff  = ! empty( $atts['diff'] );
1017
-		$is_raw = ! empty( $atts['raw'] );
1018
-		$is_timestamp = ! empty( $atts['timestamp'] );
1019
-		$include_time = ! empty( $atts['time'] );
1014
+		$format = \GV\Utils::get( $atts, 'format' );
1015
+		$is_human = ! empty( $atts[ 'human' ] );
1016
+		$is_diff = ! empty( $atts[ 'diff' ] );
1017
+		$is_raw = ! empty( $atts[ 'raw' ] );
1018
+		$is_timestamp = ! empty( $atts[ 'timestamp' ] );
1019
+		$include_time = ! empty( $atts[ 'time' ] );
1020 1020
 
1021 1021
 		// If we're using time diff, we want to have a different default format
1022
-		if( empty( $format ) ) {
1022
+		if ( empty( $format ) ) {
1023 1023
 			/* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */
1024 1024
 			$format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' );
1025 1025
 		}
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 		// If raw was specified, don't modify the stored value
1028 1028
 		if ( $is_raw ) {
1029 1029
 			$formatted_date = $date_string;
1030
-		} elseif( $is_timestamp ) {
1030
+		} elseif ( $is_timestamp ) {
1031 1031
 			$formatted_date = $date_local_timestamp;
1032 1032
 		} elseif ( $is_diff ) {
1033 1033
 			$formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) );
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
 
1062 1062
 		$label = \GV\Utils::get( $field, 'label' );
1063 1063
 
1064
-		if( floor( $field_id ) !== floatval( $field_id ) ) {
1064
+		if ( floor( $field_id ) !== floatval( $field_id ) ) {
1065 1065
 			$label = GFFormsModel::get_choice_text( $field, $field_value, $field_id );
1066 1066
 		}
1067 1067
 
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 			$form = GFAPI::get_form( $form );
1090 1090
 		}
1091 1091
 
1092
-		if ( class_exists( 'GFFormsModel' ) ){
1092
+		if ( class_exists( 'GFFormsModel' ) ) {
1093 1093
 			return GFFormsModel::get_field( $form, $field_id );
1094 1094
 		} else {
1095 1095
 			return null;
@@ -1136,19 +1136,19 @@  discard block
 block discarded – undo
1136 1136
 			$shortcodes = array();
1137 1137
 
1138 1138
 			preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
1139
-			if ( empty( $matches ) ){
1139
+			if ( empty( $matches ) ) {
1140 1140
 				return false;
1141 1141
 			}
1142 1142
 
1143 1143
 			foreach ( $matches as $shortcode ) {
1144
-				if ( $tag === $shortcode[2] ) {
1144
+				if ( $tag === $shortcode[ 2 ] ) {
1145 1145
 
1146 1146
 					// Changed this to $shortcode instead of true so we get the parsed atts.
1147
-					$shortcodes[] = $shortcode;
1147
+					$shortcodes[ ] = $shortcode;
1148 1148
 
1149
-				} else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) {
1150
-					foreach( $results as $result ) {
1151
-						$shortcodes[] = $result;
1149
+				} else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) {
1150
+					foreach ( $results as $result ) {
1151
+						$shortcodes[ ] = $result;
1152 1152
 					}
1153 1153
 				}
1154 1154
 			}
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
 			'post_type'      => 'gravityview',
1181 1181
 			'posts_per_page' => 100,
1182 1182
 			'meta_key'       => '_gravityview_form_id',
1183
-			'meta_value'     => (int) $form_id,
1183
+			'meta_value'     => (int)$form_id,
1184 1184
 		);
1185 1185
 		$args     = wp_parse_args( $args, $defaults );
1186 1186
 		$views    = get_posts( $args );
@@ -1192,21 +1192,21 @@  discard block
 block discarded – undo
1192 1192
 
1193 1193
 			$data = unserialize( $view->meta_value );
1194 1194
 
1195
-			if( ! $data || ! is_array( $data ) ) {
1195
+			if ( ! $data || ! is_array( $data ) ) {
1196 1196
 				continue;
1197 1197
 			}
1198 1198
 
1199 1199
 			foreach ( $data as $datum ) {
1200
-				if ( ! empty( $datum[2] ) && (int) $datum[2] === (int) $form_id ) {
1201
-					$joined_forms[] = $view->post_id;
1200
+				if ( ! empty( $datum[ 2 ] ) && (int)$datum[ 2 ] === (int)$form_id ) {
1201
+					$joined_forms[ ] = $view->post_id;
1202 1202
 				}
1203 1203
 			}
1204 1204
 		}
1205 1205
 
1206 1206
 		if ( $joined_forms ) {
1207
-			$joined_args  = array(
1207
+			$joined_args = array(
1208 1208
 				'post_type'      => 'gravityview',
1209
-				'posts_per_page' => $args['posts_per_page'],
1209
+				'posts_per_page' => $args[ 'posts_per_page' ],
1210 1210
 				'post__in'       => $joined_forms,
1211 1211
 			);
1212 1212
 			$views = array_merge( $views, get_posts( $joined_args ) );
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
 
1363 1363
 		$directory_widgets = wp_parse_args( $view_widgets, $defaults );
1364 1364
 
1365
-		if( $json_decode ) {
1365
+		if ( $json_decode ) {
1366 1366
 			$directory_widgets = gv_map_deep( $directory_widgets, 'gv_maybe_json_decode' );
1367 1367
 		}
1368 1368
 
@@ -1378,7 +1378,7 @@  discard block
 block discarded – undo
1378 1378
 	 * @return string         html
1379 1379
 	 */
1380 1380
 	public static function get_sortable_fields( $formid, $current = '' ) {
1381
-		$output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>';
1381
+		$output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>';
1382 1382
 
1383 1383
 		if ( empty( $formid ) ) {
1384 1384
 			return $output;
@@ -1391,11 +1391,11 @@  discard block
 block discarded – undo
1391 1391
 			$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null );
1392 1392
 
1393 1393
 			foreach ( $fields as $id => $field ) {
1394
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
1394
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1395 1395
 					continue;
1396 1396
 				}
1397 1397
 
1398
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>';
1398
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>';
1399 1399
 			}
1400 1400
 		}
1401 1401
 
@@ -1430,16 +1430,16 @@  discard block
 block discarded – undo
1430 1430
 		$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL );
1431 1431
 
1432 1432
 		// TODO: Convert to using array_filter
1433
-		foreach( $fields as $id => $field ) {
1433
+		foreach ( $fields as $id => $field ) {
1434 1434
 
1435
-			if( in_array( $field['type'], $blacklist_field_types ) ) {
1435
+			if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1436 1436
 				unset( $fields[ $id ] );
1437 1437
 			}
1438 1438
 
1439 1439
 			/**
1440 1440
 			 * Merge date and time subfields.
1441 1441
 			 */
1442
-			if ( in_array( $field['type'], array( 'date', 'time' ) ) && ! empty( $field['parent'] ) ) {
1442
+			if ( in_array( $field[ 'type' ], array( 'date', 'time' ) ) && ! empty( $field[ 'parent' ] ) ) {
1443 1443
 				$fields[ intval( $id ) ] = array(
1444 1444
 					'label' => \GV\Utils::get( $field, 'parent/label' ),
1445 1445
 					'parent' => null,
@@ -1489,14 +1489,14 @@  discard block
 block discarded – undo
1489 1489
 	 * @param  int|array  $field field key or field array
1490 1490
 	 * @return boolean
1491 1491
 	 */
1492
-	public static function is_field_numeric(  $form = null, $field = '' ) {
1492
+	public static function is_field_numeric( $form = null, $field = '' ) {
1493 1493
 
1494 1494
 		if ( ! is_array( $form ) && ! is_array( $field ) ) {
1495 1495
 			$form = self::get_form( $form );
1496 1496
 		}
1497 1497
 
1498 1498
 		// If entry meta, it's a string. Otherwise, numeric
1499
-		if( ! is_numeric( $field ) && is_string( $field ) ) {
1499
+		if ( ! is_numeric( $field ) && is_string( $field ) ) {
1500 1500
 			$type = $field;
1501 1501
 		} else {
1502 1502
 			$type = self::get_field_type( $form, $field );
@@ -1510,9 +1510,9 @@  discard block
 block discarded – undo
1510 1510
 		$numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) );
1511 1511
 
1512 1512
 		// Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true
1513
-		if( $gv_field = GravityView_Fields::get( $type ) ) {
1514
-			if( true === $gv_field->is_numeric ) {
1515
-				$numeric_types[] = $gv_field->is_numeric;
1513
+		if ( $gv_field = GravityView_Fields::get( $type ) ) {
1514
+			if ( true === $gv_field->is_numeric ) {
1515
+				$numeric_types[ ] = $gv_field->is_numeric;
1516 1516
 			}
1517 1517
 		}
1518 1518
 
@@ -1662,18 +1662,18 @@  discard block
 block discarded – undo
1662 1662
 		$final_atts = array_filter( $final_atts );
1663 1663
 
1664 1664
 		// If the href wasn't passed as an attribute, use the value passed to the function
1665
-		if ( empty( $final_atts['href'] ) && ! empty( $href ) ) {
1666
-			$final_atts['href'] = $href;
1665
+		if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) {
1666
+			$final_atts[ 'href' ] = $href;
1667 1667
 		}
1668 1668
 
1669
-		$final_atts['href'] = esc_url_raw( $href );
1669
+		$final_atts[ 'href' ] = esc_url_raw( $href );
1670 1670
 
1671 1671
 		/**
1672 1672
 		 * Fix potential security issue with target=_blank
1673 1673
 		 * @see https://dev.to/ben/the-targetblank-vulnerability-by-example
1674 1674
 		 */
1675
-		if( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) {
1676
-			$final_atts['rel'] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' );
1675
+		if ( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) {
1676
+			$final_atts[ 'rel' ] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' );
1677 1677
 		}
1678 1678
 
1679 1679
 		// Sort the attributes alphabetically, to help testing
@@ -1685,7 +1685,7 @@  discard block
 block discarded – undo
1685 1685
 			$output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) );
1686 1686
 		}
1687 1687
 
1688
-		if( '' !== $output ) {
1688
+		if ( '' !== $output ) {
1689 1689
 			$output = '<a' . $output . '>' . $anchor_text . '</a>';
1690 1690
 		}
1691 1691
 
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
 			if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
1713 1713
 				$merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );
1714 1714
 			} else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) {
1715
-				$merged[] = $value;
1715
+				$merged[ ] = $value;
1716 1716
 			} else {
1717 1717
 				$merged[ $key ] = $value;
1718 1718
 			}
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
 		 * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..)
1746 1746
 		 * @param array $settings Settings array, with `number` key defining the # of users to display
1747 1747
 		 */
1748
-		$get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1748
+		$get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1749 1749
 
1750 1750
 		return get_users( $get_users_settings );
1751 1751
 	}
@@ -1765,11 +1765,11 @@  discard block
 block discarded – undo
1765 1765
     public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) {
1766 1766
 
1767 1767
     	// If $cap is defined, only show notice if user has capability
1768
-    	if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) {
1768
+    	if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) {
1769 1769
     		return '';
1770 1770
 	    }
1771 1771
 
1772
-        return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>';
1772
+        return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>';
1773 1773
     }
1774 1774
 
1775 1775
 	/**
Please login to merge, or discard this patch.