Completed
Push — develop ( 244be8...d44f70 )
by Zack
07:40
created
includes/class-frontend-views.php 1 patch
Spacing   +114 added lines, -114 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 );
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 
238 238
 			$this->context_view_id = $view_id;
239 239
 
240
-		} elseif ( isset( $_GET['gvid'] ) && $multiple_views ) {
240
+		} elseif ( isset( $_GET[ 'gvid' ] ) && $multiple_views ) {
241 241
 			/**
242 242
 			 * used on a has_multiple_views context
243 243
 			 * @see GravityView_API::entry_link
244 244
 			 */
245
-			$this->context_view_id = $_GET['gvid'];
245
+			$this->context_view_id = $_GET[ 'gvid' ];
246 246
 
247 247
 		} elseif ( ! $multiple_views ) {
248 248
 			if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) {
@@ -285,24 +285,24 @@  discard block
 block discarded – undo
285 285
 		global $wp_rewrite;
286 286
 
287 287
 		$is_front_page = ( $query->is_home || $query->is_page );
288
-		$show_on_front = ( 'page' === get_option('show_on_front') );
289
-		$front_page_id = get_option('page_on_front');
288
+		$show_on_front = ( 'page' === get_option( 'show_on_front' ) );
289
+		$front_page_id = get_option( 'page_on_front' );
290 290
 
291
-		if (  $is_front_page && $show_on_front && $front_page_id ) {
291
+		if ( $is_front_page && $show_on_front && $front_page_id ) {
292 292
 
293 293
 			// Force to be an array, potentially a query string ( entry=16 )
294 294
 			$_query = wp_parse_args( $query->query );
295 295
 
296 296
 			// pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename.
297
-			if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) {
298
-				unset( $_query['pagename'] );
297
+			if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) {
298
+				unset( $_query[ 'pagename' ] );
299 299
 			}
300 300
 
301 301
 			// this is where will break from core wordpress
302 302
 			$ignore = apply_filters( 'gravityview/internal/ignored_endpoints', array( 'preview', 'page', 'paged', 'cpage' ), $query );
303 303
 			$endpoints = rgobj( $wp_rewrite, 'endpoints' );
304
-			foreach ( (array) $endpoints as $endpoint ) {
305
-				$ignore[] = $endpoint[1];
304
+			foreach ( (array)$endpoints as $endpoint ) {
305
+				$ignore[ ] = $endpoint[ 1 ];
306 306
 			}
307 307
 			unset( $endpoints );
308 308
 
@@ -312,21 +312,21 @@  discard block
 block discarded – undo
312 312
 			// - The query includes keys that are associated with registered endpoints. `entry`, for example.
313 313
 			if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) {
314 314
 
315
-				$qv =& $query->query_vars;
315
+				$qv = & $query->query_vars;
316 316
 
317 317
 				// Prevent redirect when on the single entry endpoint
318
-				if( self::is_single_entry() ) {
318
+				if ( self::is_single_entry() ) {
319 319
 					add_filter( 'redirect_canonical', '__return_false' );
320 320
 				}
321 321
 
322 322
 				$query->is_page = true;
323 323
 				$query->is_home = false;
324
-				$qv['page_id']  = $front_page_id;
324
+				$qv[ 'page_id' ]  = $front_page_id;
325 325
 
326 326
 				// Correct <!--nextpage--> for page_on_front
327
-				if ( ! empty( $qv['paged'] ) ) {
328
-					$qv['page'] = $qv['paged'];
329
-					unset( $qv['paged'] );
327
+				if ( ! empty( $qv[ 'paged' ] ) ) {
328
+					$qv[ 'page' ] = $qv[ 'paged' ];
329
+					unset( $qv[ 'paged' ] );
330 330
 				}
331 331
 			}
332 332
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 
360 360
 		$this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' );
361 361
 
362
-		$post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null );
362
+		$post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null );
363 363
 		$this->setPostId( $post_id );
364 364
 		$post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false;
365 365
 		$this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) );
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 
396 396
 		$search_method = GravityView_Widget_Search::getInstance()->get_search_method();
397 397
 
398
-		if( 'post' === $search_method ) {
398
+		if ( 'post' === $search_method ) {
399 399
 			$get = $_POST;
400 400
 		} else {
401 401
 			$get = $_GET;
@@ -451,20 +451,20 @@  discard block
 block discarded – undo
451 451
 		 * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop
452 452
 		 * @param array $entry Current entry
453 453
 		 */
454
-		$apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry );
454
+		$apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry );
455 455
 
456 456
 		if ( ! $apply_outside_loop ) {
457 457
 			return $title;
458 458
 		}
459 459
 
460 460
 		// User reported WooCommerce doesn't pass two args.
461
-		if ( empty( $passed_post_id ) )  {
461
+		if ( empty( $passed_post_id ) ) {
462 462
 			return $title;
463 463
 		}
464 464
 
465 465
 		// Don't modify the title for anything other than the current view/post.
466 466
 		// This is true for embedded shortcodes and Views.
467
-		if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) {
467
+		if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) {
468 468
 			return $title;
469 469
 		}
470 470
 
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 		} else {
488 488
 			if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) {
489 489
 				foreach ( gravityview()->views->all() as $_view ) {
490
-					if ( intval( $_view->form->ID ) === intval( $entry['form_id'] ) ) {
490
+					if ( intval( $_view->form->ID ) === intval( $entry[ 'form_id' ] ) ) {
491 491
 						$view = $_view;
492 492
 						break;
493 493
 					}
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 			} else {
500 500
 				/** Deprecated. Use gravityview()->views->all() or gravityview()->request->all() */
501 501
 				foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) {
502
-					if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) {
502
+					if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) {
503 503
 						$view_meta = $view_data;
504 504
 						break;
505 505
 					}
@@ -514,12 +514,12 @@  discard block
 block discarded – undo
514 514
 			}
515 515
 		} else {
516 516
 			/** Deprecated stuff in the future. See the branch above. */
517
-			if ( ! empty( $view_meta['atts']['single_title'] ) ) {
517
+			if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) {
518 518
 
519
-				$title = $view_meta['atts']['single_title'];
519
+				$title = $view_meta[ 'atts' ][ 'single_title' ];
520 520
 
521 521
 				// We are allowing HTML in the fields, so no escaping the output
522
-				$title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry );
522
+				$title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry );
523 523
 
524 524
 				$title = do_shortcode( $title );
525 525
 			}
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 		}
558 558
 
559 559
 		// Only render in the loop. Fixes issues with the_content filter being applied in places like the sidebar
560
-		if( ! in_the_loop() ) {
560
+		if ( ! in_the_loop() ) {
561 561
 			return $content;
562 562
 		}
563 563
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 
633 633
 		$context = GravityView_View::getInstance()->getContext();
634 634
 
635
-		switch( $context ) {
635
+		switch ( $context ) {
636 636
 			case 'directory':
637 637
 				$tab = __( 'Multiple Entries', 'gravityview' );
638 638
 				break;
@@ -646,12 +646,12 @@  discard block
 block discarded – undo
646 646
 		}
647 647
 
648 648
 
649
-		$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 );
649
+		$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 );
650 650
 		$edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $view_id, $context ) );
651
-		$action_text = sprintf( esc_html__('Add fields to %s', 'gravityview' ), $tab );
651
+		$action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab );
652 652
 		$message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' );
653 653
 
654
-		$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 ) ) );
654
+		$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 ) ) );
655 655
 		$output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message );
656 656
 
657 657
 		echo GVCommon::generate_notice( $output . $image, 'gv-error error', 'edit_gravityview', $view_id );
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 	public function render_view( $passed_args ) {
683 683
 
684 684
 		// validate attributes
685
-		if ( empty( $passed_args['id'] ) ) {
685
+		if ( empty( $passed_args[ 'id' ] ) ) {
686 686
 			do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args );
687 687
 			return null;
688 688
 		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 			return null;
705 705
 		}
706 706
 
707
-		$view_id = $passed_args['id'];
707
+		$view_id = $passed_args[ 'id' ];
708 708
 
709 709
 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) {
710 710
 			$view = gravityview()->views->get( $view_id );
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 			$passed_args = array_filter( $passed_args, 'strlen' );
735 735
 
736 736
 			//Override shortcode args over View template settings
737
-			$atts = wp_parse_args( $passed_args, $view_data['atts'] );
737
+			$atts = wp_parse_args( $passed_args, $view_data[ 'atts' ] );
738 738
 
739 739
 			do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts );
740 740
 		}
@@ -758,14 +758,14 @@  discard block
 block discarded – undo
758 758
 		 * @since 1.15
759 759
 		 * @since 1.17.2 Added check for if a user has no caps but is logged in (member of multisite, but not any site). Treat as if logged-out.
760 760
 		 */
761
-		if( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
761
+		if ( is_user_logged_in() && ! ( empty( wp_get_current_user()->caps ) && empty( wp_get_current_user()->roles ) ) && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
762 762
 
763 763
 			do_action( 'gravityview_log_debug', sprintf( '%s Returning: View %d is not visible by current user.', __METHOD__, $view_id ) );
764 764
 
765 765
 			return null;
766 766
 		}
767 767
 
768
-		if( $this->isGravityviewPostType() ) {
768
+		if ( $this->isGravityviewPostType() ) {
769 769
 
770 770
 			/**
771 771
 			 * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode?
@@ -781,10 +781,10 @@  discard block
 block discarded – undo
781 781
 				$embed_only = $view->settings->get( 'embed_only' );
782 782
 			} else {
783 783
 				/** Deprecated. View attributes moved to \GV\View::$settings. */
784
-				$embed_only = ! empty( $atts['embed_only'] );
784
+				$embed_only = ! empty( $atts[ 'embed_only' ] );
785 785
 			}
786 786
 
787
-			if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) {
787
+			if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) {
788 788
 				return __( 'You are not allowed to view this content.', 'gravityview' );
789 789
 			}
790 790
 		}
@@ -800,13 +800,13 @@  discard block
 block discarded – undo
800 800
 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) {
801 801
 			$view_data = $view->as_data();
802 802
 			$gravityview_view = new GravityView_View( $view_data );
803
-			$post_id = intval( $view->settings->get( 'post_id' ) ? : get_the_ID() );
803
+			$post_id = intval( $view->settings->get( 'post_id' ) ?: get_the_ID() );
804 804
 			$template_id = $view->template ? $view->template->ID : null;
805 805
 		} else {
806 806
 			/** These constructs are deprecated. Use the new gravityview() wrapper. */
807 807
 			$gravityview_view = new GravityView_View( $view_data );
808
-			$post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : get_the_ID();
809
-			$template_id = $view_data['template_id'];
808
+			$post_id = ! empty( $atts[ 'post_id' ] ) ? intval( $atts[ 'post_id' ] ) : get_the_ID();
809
+			$template_id = $view_data[ 'template_id' ];
810 810
 		}
811 811
 
812 812
 		$gravityview_view->setPostId( $post_id );
@@ -817,20 +817,20 @@  discard block
 block discarded – undo
817 817
 			do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' );
818 818
 
819 819
 			//fetch template and slug
820
-			$view_slug = apply_filters( 'gravityview_template_slug_'. $template_id, 'table', 'directory' );
820
+			$view_slug = apply_filters( 'gravityview_template_slug_' . $template_id, 'table', 'directory' );
821 821
 
822 822
 			do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug );
823 823
 
824 824
 			/**
825 825
 			 * Disable fetching initial entries for views that don't need it (DataTables)
826 826
 			 */
827
-			$get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true );
827
+			$get_entries = apply_filters( 'gravityview_get_view_entries_' . $view_slug, true );
828 828
 
829 829
 			if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) {
830 830
 				$hide_until_searched = $view->settings->get( 'hide_until_searched' );
831 831
 			} else {
832 832
 				/** $atts is deprecated, use \GV\View:$settings */
833
-				$hide_until_searched = ! empty( $atts['hide_until_searched'] );
833
+				$hide_until_searched = ! empty( $atts[ 'hide_until_searched' ] );
834 834
 			}
835 835
 
836 836
 			/**
@@ -848,12 +848,12 @@  discard block
 block discarded – undo
848 848
 					$sort_columns = $view->settings->get( 'sort_columns' );
849 849
 				} else {
850 850
 					/** $atts is deprecated, use \GV\View:$settings */
851
-					$sort_columns = ! empty( $atts['sort_columns'] );
851
+					$sort_columns = ! empty( $atts[ 'sort_columns' ] );
852 852
 				}
853 853
 
854 854
 				if ( $sort_columns ) {
855 855
 					// add filter to enable column sorting
856
-					add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 );
856
+					add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ), 100, 3 );
857 857
 				}
858 858
 
859 859
 				if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) {
@@ -861,19 +861,19 @@  discard block
 block discarded – undo
861 861
 				} else {
862 862
 					/** $atts is deprecated, use \GV\View:$settings */
863 863
 					/** $view_data is depreacted, use \GV\View properties */
864
-					$view_entries = self::get_view_entries( $atts, $view_data['form_id'] );
864
+					$view_entries = self::get_view_entries( $atts, $view_data[ 'form_id' ] );
865 865
 				}
866 866
 
867
-				do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) );
867
+				do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries[ 'count' ], sizeof( $view_entries[ 'entries' ] ) ) );
868 868
 
869 869
 			} else {
870 870
 
871 871
 				$view_entries = array( 'count' => null, 'entries' => null, 'paging' => null );
872 872
 
873
-				do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' );
873
+				do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_' . $view_slug . '` is false' );
874 874
 			}
875 875
 
876
-			$gravityview_view->setPaging( $view_entries['paging'] );
876
+			$gravityview_view->setPaging( $view_entries[ 'paging' ] );
877 877
 			$gravityview_view->setContext( 'directory' );
878 878
 			$sections = array( 'header', 'body', 'footer' );
879 879
 
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 				do_action( 'gravityview_render_entry_' . $view->ID );
891 891
 			} else {
892 892
 				/** $view_data is depreacted, use \GV\View properties */
893
-				do_action( 'gravityview_render_entry_'.$view_data['id'] );
893
+				do_action( 'gravityview_render_entry_' . $view_data[ 'id' ] );
894 894
 			}
895 895
 
896 896
 			$entry = $this->getEntry();
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 				do_action( 'gravityview_log_debug', '[render_view] Entry does not exist. This may be because of View filters limiting access.' );
902 902
 
903 903
 				// Only display warning once when multiple Views are embedded
904
-				if( $view_id !== (int) GravityView_frontend::get_context_view_id() ) {
904
+				if ( $view_id !== (int)GravityView_frontend::get_context_view_id() ) {
905 905
 					ob_end_clean();
906 906
 					return null;
907 907
 				}
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 			// important: do not remove this as it prevents fake attempts of displaying entries from other views/forms
927 927
 			$multiple_views = defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? gravityview()->views->count() > 1 : $this->getGvOutputData()->has_multiple_views();
928 928
 			if ( $multiple_views && $view_id != $this->get_context_view_id() ) {
929
-				do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: '. $view_id );
929
+				do_action( 'gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: ' . $view_id );
930 930
 				ob_end_clean();
931 931
 				return null;
932 932
 			}
@@ -936,14 +936,14 @@  discard block
 block discarded – undo
936 936
 			do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug );
937 937
 
938 938
 			//fetch entry detail
939
-			$view_entries['count'] = 1;
940
-			$view_entries['entries'][] = $entry;
941
-			do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] );
939
+			$view_entries[ 'count' ] = 1;
940
+			$view_entries[ 'entries' ][ ] = $entry;
941
+			do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries[ 'entries' ] );
942 942
 
943 943
 			if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) {
944 944
 				$back_link_label = $view->settings->get( 'back_link_label', null );
945 945
 			} else {
946
-				$back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null;
946
+				$back_link_label = isset( $atts[ 'back_link_label' ] ) ? $atts[ 'back_link_label' ] : null;
947 947
 			}
948 948
 
949 949
 			// set back link label
@@ -957,8 +957,8 @@  discard block
 block discarded – undo
957 957
 		self::add_style( $template_id );
958 958
 
959 959
 		// Prepare to render view and set vars
960
-		$gravityview_view->setEntries( $view_entries['entries'] );
961
-		$gravityview_view->setTotalEntries( $view_entries['count'] );
960
+		$gravityview_view->setEntries( $view_entries[ 'entries' ] );
961
+		$gravityview_view->setTotalEntries( $view_entries[ 'count' ] );
962 962
 
963 963
 		// If Edit
964 964
 		if ( 'edit' === gravityview_get_context() ) {
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
 
976 976
 			do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections );
977 977
 			foreach ( $sections as $section ) {
978
-				do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' );
978
+				do_action( 'gravityview_log_debug', '[render_view] Rendering ' . $section . ' section.' );
979 979
 				$gravityview_view->render( $view_slug, $section, false );
980 980
 			}
981 981
 		}
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
 				$datetime_format = 'Y-m-d H:i:s';
1030 1030
 				$search_is_outside_view_bounds = false;
1031 1031
 
1032
-				if( ! empty( $search_criteria[ $key ] ) ) {
1032
+				if ( ! empty( $search_criteria[ $key ] ) ) {
1033 1033
 
1034 1034
 					$search_date = strtotime( $search_criteria[ $key ] );
1035 1035
 
@@ -1057,14 +1057,14 @@  discard block
 block discarded – undo
1057 1057
 				if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) {
1058 1058
 
1059 1059
 					// Then we override the search and re-set the start date
1060
-					$return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true );
1060
+					$return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true );
1061 1061
 				}
1062 1062
 			}
1063 1063
 		}
1064 1064
 
1065
-		if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) {
1065
+		if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) {
1066 1066
 			// The start date is AFTER the end date. This will result in no results, but let's not force the issue.
1067
-			if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) {
1067
+			if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) {
1068 1068
 				do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria );
1069 1069
 			}
1070 1070
 		}
@@ -1083,19 +1083,19 @@  discard block
 block discarded – undo
1083 1083
 	public static function process_search_only_approved( $args, $search_criteria ) {
1084 1084
 
1085 1085
 		/** @since 1.19 */
1086
-		if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) {
1086
+		if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) {
1087 1087
 			do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries; showing all approval statuses' );
1088 1088
 			return $search_criteria;
1089 1089
 		}
1090 1090
 
1091
-		if ( ! empty( $args['show_only_approved'] ) ) {
1091
+		if ( ! empty( $args[ 'show_only_approved' ] ) ) {
1092 1092
 
1093
-			$search_criteria['field_filters'][] = array(
1093
+			$search_criteria[ 'field_filters' ][ ] = array(
1094 1094
 				'key' => GravityView_Entry_Approval::meta_key,
1095 1095
 				'value' => GravityView_Entry_Approval_Status::APPROVED
1096 1096
 			);
1097 1097
 
1098
-			$search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met
1098
+			$search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met
1099 1099
 
1100 1100
 			do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria );
1101 1101
 		}
@@ -1122,18 +1122,18 @@  discard block
 block discarded – undo
1122 1122
 	 */
1123 1123
 	public static function is_entry_approved( $entry, $args = array() ) {
1124 1124
 
1125
-		if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) {
1125
+		if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) {
1126 1126
 			// is implicitly approved if entry is null or View settings doesn't require to check for approval
1127 1127
 			return true;
1128 1128
 		}
1129 1129
 
1130 1130
 		/** @since 1.19 */
1131
-		if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) {
1131
+		if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) {
1132 1132
 			do_action( 'gravityview_log_debug', __METHOD__ . ': User can moderate entries, so entry is approved for viewing' );
1133 1133
 			return true;
1134 1134
 		}
1135 1135
 
1136
-		$is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key );
1136
+		$is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key );
1137 1137
 
1138 1138
 		return GravityView_Entry_Approval_Status::is_approved( $is_approved );
1139 1139
 	}
@@ -1167,29 +1167,29 @@  discard block
 block discarded – undo
1167 1167
 		do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria );
1168 1168
 
1169 1169
 		// implicity search
1170
-		if ( ! empty( $args['search_value'] ) ) {
1170
+		if ( ! empty( $args[ 'search_value' ] ) ) {
1171 1171
 
1172 1172
 			// Search operator options. Options: `is` or `contains`
1173
-			$operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains';
1173
+			$operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains';
1174 1174
 
1175
-			$search_criteria['field_filters'][] = array(
1175
+			$search_criteria[ 'field_filters' ][ ] = array(
1176 1176
 				'key' => rgget( 'search_field', $args ), // The field ID to search
1177
-				'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes.
1177
+				'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes.
1178 1178
 				'operator' => $operator,
1179 1179
 			);
1180 1180
 
1181 1181
 			// Lock search mode to "all" with implicit presearch filter.
1182
-			$search_criteria['field_filters']['mode'] = 'all';
1182
+			$search_criteria[ 'field_filters' ][ 'mode' ] = 'all';
1183 1183
 		}
1184 1184
 
1185
-		if( $search_criteria !== $original_search_criteria ) {
1185
+		if ( $search_criteria !== $original_search_criteria ) {
1186 1186
 			do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria );
1187 1187
 		}
1188 1188
 
1189 1189
 		// Handle setting date range
1190 1190
 		$search_criteria = self::process_search_dates( $args, $search_criteria );
1191 1191
 
1192
-		if( $search_criteria !== $original_search_criteria ) {
1192
+		if ( $search_criteria !== $original_search_criteria ) {
1193 1193
 			do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria );
1194 1194
 		}
1195 1195
 
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
 		 * @filter `gravityview_status` Modify entry status requirements to be included in search results.
1201 1201
 		 * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash`
1202 1202
 		 */
1203
-		$search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args );
1203
+		$search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args );
1204 1204
 
1205 1205
 		return $search_criteria;
1206 1206
 	}
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
 			'search_criteria' => $search_criteria,
1325 1325
 			'sorting' => self::updateViewSorting( $args, $form_id ),
1326 1326
 			'paging' => $paging,
1327
-			'cache' => isset( $args['cache'] ) ? $args['cache'] : true,
1327
+			'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true,
1328 1328
 		);
1329 1329
 
1330 1330
 		/**
@@ -1349,7 +1349,7 @@  discard block
 block discarded – undo
1349 1349
 		 * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys.
1350 1350
 		 * @param array $args View configuration args.
1351 1351
 		 */
1352
-		$parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id );
1352
+		$parameters = apply_filters( 'gravityview_get_entries_' . $args[ 'id' ], $parameters, $args, $form_id );
1353 1353
 
1354 1354
 		do_action( 'gravityview_log_debug', __METHOD__ . ': $parameters passed to gravityview_get_entries(): ', $parameters );
1355 1355
 
@@ -1374,17 +1374,17 @@  discard block
 block discarded – undo
1374 1374
 		$default_page_size = apply_filters( 'gravityview_default_page_size', 25 );
1375 1375
 
1376 1376
 		// Paging & offset
1377
-		$page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : $default_page_size;
1377
+		$page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : $default_page_size;
1378 1378
 
1379 1379
 		if ( -1 === $page_size ) {
1380 1380
 			$page_size = PHP_INT_MAX;
1381 1381
 		}
1382 1382
 
1383
-		$curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] );
1383
+		$curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] );
1384 1384
 		$offset = ( $curr_page - 1 ) * $page_size;
1385 1385
 
1386
-		if ( ! empty( $args['offset'] ) ) {
1387
-			$offset += intval( $args['offset'] );
1386
+		if ( ! empty( $args[ 'offset' ] ) ) {
1387
+			$offset += intval( $args[ 'offset' ] );
1388 1388
 		}
1389 1389
 
1390 1390
 		$paging = array(
@@ -1408,8 +1408,8 @@  discard block
 block discarded – undo
1408 1408
 	 */
1409 1409
 	public static function updateViewSorting( $args, $form_id ) {
1410 1410
 		$sorting = array();
1411
-		$sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' );
1412
-		$sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' );
1411
+		$sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : rgar( $args, 'sort_field' );
1412
+		$sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : rgar( $args, 'sort_direction' );
1413 1413
 
1414 1414
 		$sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id );
1415 1415
 
@@ -1449,11 +1449,11 @@  discard block
 block discarded – undo
1449 1449
 
1450 1450
 		$sort_field = GFFormsModel::get_field( $form, $sort_field_id );
1451 1451
 
1452
-		if( ! $sort_field ) {
1452
+		if ( ! $sort_field ) {
1453 1453
 			return $sort_field_id;
1454 1454
 		}
1455 1455
 
1456
-		switch ( $sort_field['type'] ) {
1456
+		switch ( $sort_field[ 'type' ] ) {
1457 1457
 
1458 1458
 			case 'address':
1459 1459
 				// Sorting by full address
@@ -1470,7 +1470,7 @@  discard block
 block discarded – undo
1470 1470
 					 */
1471 1471
 					$address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id );
1472 1472
 
1473
-					switch( strtolower( $address_part ) ){
1473
+					switch ( strtolower( $address_part ) ) {
1474 1474
 						case 'street':
1475 1475
 							$sort_field_id .= '.1';
1476 1476
 							break;
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
 		 */
1556 1556
 		$single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry );
1557 1557
 
1558
-		if ( empty( $single_entry ) ){
1558
+		if ( empty( $single_entry ) ) {
1559 1559
 			return false;
1560 1560
 		} else {
1561 1561
 			return $single_entry;
@@ -1588,14 +1588,14 @@  discard block
 block discarded – undo
1588 1588
 					$template_id = $view->template ? $view->template->ID : null;
1589 1589
 					$data = $view->as_data();
1590 1590
 				} else {
1591
-					$template_id = $data['template_id'];
1591
+					$template_id = $data[ 'template_id' ];
1592 1592
 				}
1593 1593
 
1594 1594
 				/**
1595 1595
 				 * Don't enqueue the scripts or styles if it's not going to be displayed.
1596 1596
 				 * @since 1.15
1597 1597
 				 */
1598
-				if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
1598
+				if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
1599 1599
 					continue;
1600 1600
 				}
1601 1601
 
@@ -1607,7 +1607,7 @@  discard block
 block discarded – undo
1607 1607
 					$lightbox = $view->settings->get( 'lightbox' );
1608 1608
 				} else {
1609 1609
 					/** View data attributes are now stored in \GV\View::$settings */
1610
-					$lightbox = ! empty( $data['atts']['lightbox'] );
1610
+					$lightbox = ! empty( $data[ 'atts' ][ 'lightbox' ] );
1611 1611
 				}
1612 1612
 
1613 1613
 				// If the thickbox is enqueued, add dependencies
@@ -1617,13 +1617,13 @@  discard block
 block discarded – undo
1617 1617
 					 * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox`
1618 1618
 					 * @param string $script_slug If you want to use a different lightbox script, return the name of it here.
1619 1619
 					 */
1620
-					$js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' );
1620
+					$js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' );
1621 1621
 
1622 1622
 					/**
1623 1623
 					 * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox`
1624 1624
 					 * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here.
1625 1625
 					 */
1626
-					$css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' );
1626
+					$css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' );
1627 1627
 				}
1628 1628
 
1629 1629
 				/**
@@ -1631,19 +1631,19 @@  discard block
 block discarded – undo
1631 1631
 				 * @see https://github.com/katzwebservices/GravityView/issues/536
1632 1632
 				 * @since 1.15
1633 1633
 				 */
1634
-				if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) {
1635
-					$css_dependencies[] = 'dashicons';
1634
+				if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) {
1635
+					$css_dependencies[ ] = 'dashicons';
1636 1636
 				}
1637 1637
 
1638 1638
 				wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true );
1639 1639
 
1640 1640
 				$script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
1641 1641
 
1642
-				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 );
1642
+				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 );
1643 1643
 
1644 1644
 				wp_enqueue_script( 'gravityview-fe-view' );
1645 1645
 
1646
-				if ( ! empty( $data['atts']['sort_columns'] ) ) {
1646
+				if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) {
1647 1647
 					wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' );
1648 1648
 				}
1649 1649
 
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
 		} elseif ( empty( $template_id ) ) {
1712 1712
 			do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' );
1713 1713
 		} else {
1714
-			do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) );
1714
+			do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_' . $template_id ) );
1715 1715
 		}
1716 1716
 
1717 1717
 	}
@@ -1736,11 +1736,11 @@  discard block
 block discarded – undo
1736 1736
 		 * Not a table-based template; don't add sort icons
1737 1737
 		 * @since 1.12
1738 1738
 		 */
1739
-		if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) {
1739
+		if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) {
1740 1740
 			return $label;
1741 1741
 		}
1742 1742
 
1743
-		if ( ! $this->is_field_sortable( $field['id'], $form ) ) {
1743
+		if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) {
1744 1744
 			return $label;
1745 1745
 		}
1746 1746
 
@@ -1748,29 +1748,29 @@  discard block
 block discarded – undo
1748 1748
 
1749 1749
 		$class = 'gv-sort';
1750 1750
 
1751
-		$sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] );
1751
+		$sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] );
1752 1752
 
1753 1753
 		$sort_args = array(
1754
-			'sort' => $field['id'],
1754
+			'sort' => $field[ 'id' ],
1755 1755
 			'dir' => 'asc',
1756 1756
 		);
1757 1757
 
1758
-		if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) {
1758
+		if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) {
1759 1759
 			//toggle sorting direction.
1760
-			if ( 'asc' === $sorting['direction'] ) {
1761
-				$sort_args['dir'] = 'desc';
1760
+			if ( 'asc' === $sorting[ 'direction' ] ) {
1761
+				$sort_args[ 'dir' ] = 'desc';
1762 1762
 				$class .= ' gv-icon-sort-desc';
1763 1763
 			} else {
1764
-				$sort_args['dir'] = 'asc';
1764
+				$sort_args[ 'dir' ] = 'asc';
1765 1765
 				$class .= ' gv-icon-sort-asc';
1766 1766
 			}
1767 1767
 		} else {
1768 1768
 			$class .= ' gv-icon-caret-up-down';
1769 1769
 		}
1770 1770
 
1771
-		$url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) );
1771
+		$url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) );
1772 1772
 
1773
-		return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a>&nbsp;'. $label;
1773
+		return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a>&nbsp;' . $label;
1774 1774
 
1775 1775
 	}
1776 1776
 
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
 
1789 1789
 		$field_type = $field_id;
1790 1790
 
1791
-		if( is_numeric( $field_id ) ) {
1791
+		if ( is_numeric( $field_id ) ) {
1792 1792
 			$field = GFFormsModel::get_field( $form, $field_id );
1793 1793
 			$field_type = $field->type;
1794 1794
 		}
@@ -1811,7 +1811,7 @@  discard block
 block discarded – undo
1811 1811
 			return false;
1812 1812
 		}
1813 1813
 
1814
-		return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) );
1814
+		return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) );
1815 1815
 
1816 1816
 	}
1817 1817
 
Please login to merge, or discard this patch.