Completed
Pull Request — develop (#701)
by Zack
05:24
created
includes/class-frontend-views.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	private function __construct() {}
86 86
 
87 87
 	private function initialize() {
88
-		add_action( 'wp', array( $this, 'parse_content'), 11 );
89
-		add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 );
88
+		add_action( 'wp', array( $this, 'parse_content' ), 11 );
89
+		add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 );
90 90
 
91 91
 		// Enqueue scripts and styles after GravityView_Template::register_styles()
92 92
 		add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 );
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 
234 234
 			$this->context_view_id = $view_id;
235 235
 
236
-		} elseif ( isset( $_GET['gvid'] ) && $this->getGvOutputData()->has_multiple_views() ) {
236
+		} elseif ( isset( $_GET[ 'gvid' ] ) && $this->getGvOutputData()->has_multiple_views() ) {
237 237
 			/**
238 238
 			 * used on a has_multiple_views context
239 239
 			 * @see GravityView_API::entry_link
240 240
 			 * @see GravityView_View_Data::getInstance()->has_multiple_views()
241 241
 			 */
242
-			$this->context_view_id = $_GET['gvid'];
242
+			$this->context_view_id = $_GET[ 'gvid' ];
243 243
 
244
-		} elseif ( ! $this->getGvOutputData()->has_multiple_views() )  {
244
+		} elseif ( ! $this->getGvOutputData()->has_multiple_views() ) {
245 245
 			$array_keys = array_keys( $this->getGvOutputData()->get_views() );
246 246
 			$this->context_view_id = array_pop( $array_keys );
247 247
 			unset( $array_keys );
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		global $post;
270 270
 
271 271
 		// If in admin and NOT AJAX request, get outta here.
272
-		if ( GravityView_Plugin::is_admin() )  {
272
+		if ( GravityView_Plugin::is_admin() ) {
273 273
 			return;
274 274
 		}
275 275
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
 		$this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' );
283 283
 
284
-		$post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null );
284
+		$post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null );
285 285
 		$this->setPostId( $post_id );
286 286
 		$post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false;
287 287
 		$this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) );
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
 		$search_method = GravityView_Widget_Search::getInstance()->get_search_method();
319 319
 
320
-		if( 'post' === $search_method ) {
320
+		if ( 'post' === $search_method ) {
321 321
 			$get = $_POST;
322 322
 		} else {
323 323
 			$get = $_GET;
@@ -373,20 +373,20 @@  discard block
 block discarded – undo
373 373
 		 * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop
374 374
 		 * @param array $entry Current entry
375 375
 		 */
376
-		$apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry );
376
+		$apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry );
377 377
 
378 378
 		if ( ! $apply_outside_loop ) {
379 379
 			return $title;
380 380
 		}
381 381
 
382 382
 		// User reported WooCommerce doesn't pass two args.
383
-		if ( empty( $passed_post_id ) )  {
383
+		if ( empty( $passed_post_id ) ) {
384 384
 			return $title;
385 385
 		}
386 386
 
387 387
 		// Don't modify the title for anything other than the current view/post.
388 388
 		// This is true for embedded shortcodes and Views.
389
-		if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) {
389
+		if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) {
390 390
 			return $title;
391 391
 		}
392 392
 
@@ -396,19 +396,19 @@  discard block
 block discarded – undo
396 396
 			$view_meta = $this->getGvOutputData()->get_view( $context_view_id );
397 397
 		} else {
398 398
 			foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) {
399
-				if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) {
399
+				if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) {
400 400
 					$view_meta = $view_data;
401 401
 					break;
402 402
 				}
403 403
 			}
404 404
 		}
405 405
 
406
-		if ( ! empty( $view_meta['atts']['single_title'] ) ) {
406
+		if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) {
407 407
 
408
-			$title = $view_meta['atts']['single_title'];
408
+			$title = $view_meta[ 'atts' ][ 'single_title' ];
409 409
 
410 410
 			// We are allowing HTML in the fields, so no escaping the output
411
-			$title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry );
411
+			$title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry );
412 412
 
413 413
 			$title = do_shortcode( $title );
414 414
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 	public function render_view( $passed_args ) {
510 510
 
511 511
 		// validate attributes
512
-		if ( empty( $passed_args['id'] ) ) {
512
+		if ( empty( $passed_args[ 'id' ] ) ) {
513 513
 			do_action( 'gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args );
514 514
 			return null;
515 515
 		}
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 			return null;
532 532
 		}
533 533
 
534
-		$view_id = $passed_args['id'];
534
+		$view_id = $passed_args[ 'id' ];
535 535
 
536 536
 		$view_data = $this->getGvOutputData()->get_view( $view_id, $passed_args );
537 537
 
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 		$passed_args = array_filter( $passed_args, 'strlen' );
545 545
 
546 546
 		//Override shortcode args over View template settings
547
-		$atts = wp_parse_args( $passed_args, $view_data['atts'] );
547
+		$atts = wp_parse_args( $passed_args, $view_data[ 'atts' ] );
548 548
 
549 549
 		do_action( 'gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts );
550 550
 
@@ -566,14 +566,14 @@  discard block
 block discarded – undo
566 566
 		 * Don't render View if user isn't allowed to see it
567 567
 		 * @since 1.15
568 568
 		 */
569
-		if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
569
+		if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
570 570
 
571 571
 			do_action( 'gravityview_log_debug', sprintf( '[render_view] Returning: View %d is not visible by current user.', $view_id ) );
572 572
 
573 573
 			return null;
574 574
 		}
575 575
 
576
-		if( $this->isGravityviewPostType() ) {
576
+		if ( $this->isGravityviewPostType() ) {
577 577
 
578 578
 			/**
579 579
 			 * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode?
@@ -585,9 +585,9 @@  discard block
 block discarded – undo
585 585
 			 */
586 586
 			$direct_access = apply_filters( 'gravityview_direct_access', true, $view_id );
587 587
 
588
-			$embed_only = ! empty( $atts['embed_only'] );
588
+			$embed_only = ! empty( $atts[ 'embed_only' ] );
589 589
 
590
-			if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) {
590
+			if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) {
591 591
 				return __( 'You are not allowed to view this content.', 'gravityview' );
592 592
 			}
593 593
 		}
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 
603 603
 		$gravityview_view = new GravityView_View( $view_data );
604 604
 
605
-		$post_id = ! empty( $atts['post_id'] ) ? intval( $atts['post_id'] ) : $this->getPostId();
605
+		$post_id = ! empty( $atts[ 'post_id' ] ) ? intval( $atts[ 'post_id' ] ) : $this->getPostId();
606 606
 
607 607
 		$gravityview_view->setPostId( $post_id );
608 608
 
@@ -612,20 +612,20 @@  discard block
 block discarded – undo
612 612
 			do_action( 'gravityview_log_debug', '[render_view] Executing Directory View' );
613 613
 
614 614
 			//fetch template and slug
615
-			$view_slug = apply_filters( 'gravityview_template_slug_'. $view_data['template_id'], 'table', 'directory' );
615
+			$view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'directory' );
616 616
 
617 617
 			do_action( 'gravityview_log_debug', '[render_view] View template slug: ', $view_slug );
618 618
 
619 619
 			/**
620 620
 			 * Disable fetching initial entries for views that don't need it (DataTables)
621 621
 			 */
622
-			$get_entries = apply_filters( 'gravityview_get_view_entries_'.$view_slug, true );
622
+			$get_entries = apply_filters( 'gravityview_get_view_entries_' . $view_slug, true );
623 623
 
624 624
 			/**
625 625
 			 * Hide View data until search is performed
626 626
 			 * @since 1.5.4
627 627
 			 */
628
-			if ( ! empty( $atts['hide_until_searched'] ) && ! $this->isSearch() ) {
628
+			if ( ! empty( $atts[ 'hide_until_searched' ] ) && ! $this->isSearch() ) {
629 629
 				$gravityview_view->setHideUntilSearched( true );
630 630
 				$get_entries = false;
631 631
 			}
@@ -633,23 +633,23 @@  discard block
 block discarded – undo
633 633
 
634 634
 			if ( $get_entries ) {
635 635
 
636
-				if ( ! empty( $atts['sort_columns'] ) ) {
636
+				if ( ! empty( $atts[ 'sort_columns' ] ) ) {
637 637
 					// add filter to enable column sorting
638
-					add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ) , 100, 3 );
638
+					add_filter( 'gravityview/template/field_label', array( $this, 'add_columns_sort_links' ), 100, 3 );
639 639
 				}
640 640
 
641
-				$view_entries = self::get_view_entries( $atts, $view_data['form_id'] );
641
+				$view_entries = self::get_view_entries( $atts, $view_data[ 'form_id' ] );
642 642
 
643
-				do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof( $view_entries['entries'] ) ) );
643
+				do_action( 'gravityview_log_debug', sprintf( '[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries[ 'count' ], sizeof( $view_entries[ 'entries' ] ) ) );
644 644
 
645 645
 			} else {
646 646
 
647 647
 				$view_entries = array( 'count' => null, 'entries' => null, 'paging' => null );
648 648
 
649
-				do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_'.$view_slug.'` is false' );
649
+				do_action( 'gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_' . $view_slug . '` is false' );
650 650
 			}
651 651
 
652
-			$gravityview_view->setPaging( $view_entries['paging'] );
652
+			$gravityview_view->setPaging( $view_entries[ 'paging' ] );
653 653
 			$gravityview_view->setContext( 'directory' );
654 654
 			$sections = array( 'header', 'body', 'footer' );
655 655
 
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 			 * @action `gravityview_render_entry_{View ID}` Before rendering a single entry for a specific View ID
664 664
 			 * @since 1.17
665 665
 			 */
666
-			do_action( 'gravityview_render_entry_'.$view_data['id'] );
666
+			do_action( 'gravityview_render_entry_' . $view_data[ 'id' ] );
667 667
 
668 668
 			$entry = $this->getEntry();
669 669
 
@@ -690,20 +690,20 @@  discard block
 block discarded – undo
690 690
 			// We're in single view, but the view being processed is not the same view the single entry belongs to.
691 691
 			// important: do not remove this as it prevents fake attempts of displaying entries from other views/forms
692 692
 			if ( $this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id() ) {
693
-				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 );
693
+				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 );
694 694
 				return null;
695 695
 			}
696 696
 
697 697
 			//fetch template and slug
698
-			$view_slug = apply_filters( 'gravityview_template_slug_' . $view_data['template_id'], 'table', 'single' );
698
+			$view_slug = apply_filters( 'gravityview_template_slug_' . $view_data[ 'template_id' ], 'table', 'single' );
699 699
 			do_action( 'gravityview_log_debug', '[render_view] View single template slug: ', $view_slug );
700 700
 
701 701
 			//fetch entry detail
702
-			$view_entries['count'] = 1;
703
-			$view_entries['entries'][] = $entry;
704
-			do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries'] );
702
+			$view_entries[ 'count' ] = 1;
703
+			$view_entries[ 'entries' ][ ] = $entry;
704
+			do_action( 'gravityview_log_debug', '[render_view] Get single entry: ', $view_entries[ 'entries' ] );
705 705
 
706
-			$back_link_label = isset( $atts['back_link_label'] ) ? $atts['back_link_label'] : null;
706
+			$back_link_label = isset( $atts[ 'back_link_label' ] ) ? $atts[ 'back_link_label' ] : null;
707 707
 
708 708
 			// set back link label
709 709
 			$gravityview_view->setBackLinkLabel( $back_link_label );
@@ -713,11 +713,11 @@  discard block
 block discarded – undo
713 713
 		}
714 714
 
715 715
 		// add template style
716
-		self::add_style( $view_data['template_id'] );
716
+		self::add_style( $view_data[ 'template_id' ] );
717 717
 
718 718
 		// Prepare to render view and set vars
719
-		$gravityview_view->setEntries( $view_entries['entries'] );
720
-		$gravityview_view->setTotalEntries( $view_entries['count'] );
719
+		$gravityview_view->setEntries( $view_entries[ 'entries' ] );
720
+		$gravityview_view->setTotalEntries( $view_entries[ 'count' ] );
721 721
 
722 722
 		// If Edit
723 723
 		if ( 'edit' === gravityview_get_context() ) {
@@ -730,11 +730,11 @@  discard block
 block discarded – undo
730 730
 
731 731
 		} else {
732 732
 			// finaly we'll render some html
733
-			$sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data['template_id'] );
733
+			$sections = apply_filters( 'gravityview_render_view_sections', $sections, $view_data[ 'template_id' ] );
734 734
 
735 735
 			do_action( 'gravityview_log_debug', '[render_view] Sections to render: ', $sections );
736 736
 			foreach ( $sections as $section ) {
737
-				do_action( 'gravityview_log_debug', '[render_view] Rendering '. $section . ' section.' );
737
+				do_action( 'gravityview_log_debug', '[render_view] Rendering ' . $section . ' section.' );
738 738
 				$gravityview_view->render( $view_slug, $section, false );
739 739
 			}
740 740
 		}
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 				$datetime_format = 'Y-m-d H:i:s';
789 789
 				$search_is_outside_view_bounds = false;
790 790
 
791
-				if( ! empty( $search_criteria[ $key ] ) ) {
791
+				if ( ! empty( $search_criteria[ $key ] ) ) {
792 792
 
793 793
 					$search_date = strtotime( $search_criteria[ $key ] );
794 794
 
@@ -816,14 +816,14 @@  discard block
 block discarded – undo
816 816
 				if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) {
817 817
 
818 818
 					// Then we override the search and re-set the start date
819
-					$return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true );
819
+					$return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true );
820 820
 				}
821 821
 			}
822 822
 		}
823 823
 
824
-		if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) {
824
+		if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) {
825 825
 			// The start date is AFTER the end date. This will result in no results, but let's not force the issue.
826
-			if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) {
826
+			if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) {
827 827
 				do_action( 'gravityview_log_error', __METHOD__ . ' Invalid search: the start date is after the end date.', $return_search_criteria );
828 828
 			}
829 829
 		}
@@ -841,9 +841,9 @@  discard block
 block discarded – undo
841 841
 	 */
842 842
 	public static function process_search_only_approved( $args, $search_criteria ) {
843 843
 
844
-		if ( ! empty( $args['show_only_approved'] ) ) {
845
-			$search_criteria['field_filters'][] = array( 'key' => 'is_approved', 'value' => 'Approved' );
846
-			$search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met
844
+		if ( ! empty( $args[ 'show_only_approved' ] ) ) {
845
+			$search_criteria[ 'field_filters' ][ ] = array( 'key' => 'is_approved', 'value' => 'Approved' );
846
+			$search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met
847 847
 
848 848
 			do_action( 'gravityview_log_debug', '[process_search_only_approved] Search Criteria if show only approved: ', $search_criteria );
849 849
 		}
@@ -867,12 +867,12 @@  discard block
 block discarded – undo
867 867
 	 */
868 868
 	public static function is_entry_approved( $entry, $args = array() ) {
869 869
 
870
-		if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) {
870
+		if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) {
871 871
 			// is implicitly approved if entry is null or View settings doesn't require to check for approval
872 872
 			return true;
873 873
 		}
874 874
 
875
-		$is_approved = gform_get_meta( $entry['id'], 'is_approved' );
875
+		$is_approved = gform_get_meta( $entry[ 'id' ], 'is_approved' );
876 876
 
877 877
 		if ( $is_approved ) {
878 878
 			return true;
@@ -905,26 +905,26 @@  discard block
 block discarded – undo
905 905
 		do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', $search_criteria );
906 906
 
907 907
 		// implicity search
908
-		if ( ! empty( $args['search_value'] ) ) {
908
+		if ( ! empty( $args[ 'search_value' ] ) ) {
909 909
 
910 910
 			// Search operator options. Options: `is` or `contains`
911
-			$operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains';
911
+			$operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains';
912 912
 
913
-			$search_criteria['field_filters'][] = array(
913
+			$search_criteria[ 'field_filters' ][ ] = array(
914 914
 				'key' => rgget( 'search_field', $args ), // The field ID to search
915
-				'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes.
915
+				'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes.
916 916
 				'operator' => $operator,
917 917
 			);
918 918
 		}
919 919
 
920
-		if( $search_criteria !== $original_search_criteria ) {
920
+		if ( $search_criteria !== $original_search_criteria ) {
921 921
 			do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after implicity search: ', $search_criteria );
922 922
 		}
923 923
 
924 924
 		// Handle setting date range
925 925
 		$search_criteria = self::process_search_dates( $args, $search_criteria );
926 926
 
927
-		if( $search_criteria !== $original_search_criteria ) {
927
+		if ( $search_criteria !== $original_search_criteria ) {
928 928
 			do_action( 'gravityview_log_debug', '[get_search_criteria] Search Criteria after date params: ', $search_criteria );
929 929
 		}
930 930
 
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 		 * @filter `gravityview_status` Modify entry status requirements to be included in search results.
936 936
 		 * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash`
937 937
 		 */
938
-		$search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args );
938
+		$search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args );
939 939
 
940 940
 		return $search_criteria;
941 941
 	}
@@ -981,16 +981,16 @@  discard block
 block discarded – undo
981 981
 		$search_criteria = self::get_search_criteria( $args, $form_id );
982 982
 
983 983
 		// Paging & offset
984
-		$page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : apply_filters( 'gravityview_default_page_size', 25 );
984
+		$page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : apply_filters( 'gravityview_default_page_size', 25 );
985 985
 
986 986
 		if ( -1 === $page_size ) {
987 987
 			$page_size = PHP_INT_MAX;
988 988
 		}
989 989
 
990
-		if ( isset( $args['offset'] ) ) {
991
-			$offset = intval( $args['offset'] );
990
+		if ( isset( $args[ 'offset' ] ) ) {
991
+			$offset = intval( $args[ 'offset' ] );
992 992
 		} else {
993
-			$curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] );
993
+			$curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] );
994 994
 			$offset = ( $curr_page - 1 ) * $page_size;
995 995
 		}
996 996
 
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 			'search_criteria' => $search_criteria,
1009 1009
 			'sorting' => $sorting,
1010 1010
 			'paging' => $paging,
1011
-			'cache' => isset( $args['cache'] ) ? $args['cache'] : true,
1011
+			'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true,
1012 1012
 		);
1013 1013
 
1014 1014
 		/**
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 		 * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys.
1034 1034
 		 * @param array $args View configuration args.
1035 1035
 		 */
1036
-		$parameters = apply_filters( 'gravityview_get_entries_'.$args['id'], $parameters, $args, $form_id );
1036
+		$parameters = apply_filters( 'gravityview_get_entries_' . $args[ 'id' ], $parameters, $args, $form_id );
1037 1037
 
1038 1038
 		do_action( 'gravityview_log_debug', '[get_view_entries] $parameters passed to gravityview_get_entries(): ', $parameters );
1039 1039
 
@@ -1073,8 +1073,8 @@  discard block
 block discarded – undo
1073 1073
 	 */
1074 1074
 	public static function updateViewSorting( $args, $form_id ) {
1075 1075
 		$sorting = array();
1076
-		$sort_field_id = isset( $_GET['sort'] ) ? $_GET['sort'] : rgar( $args, 'sort_field' );
1077
-		$sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : rgar( $args, 'sort_direction' );
1076
+		$sort_field_id = isset( $_GET[ 'sort' ] ) ? $_GET[ 'sort' ] : rgar( $args, 'sort_field' );
1077
+		$sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : rgar( $args, 'sort_direction' );
1078 1078
 
1079 1079
 		$sort_field_id = self::_override_sorting_id_by_field_type( $sort_field_id, $form_id );
1080 1080
 
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
 
1115 1115
 		$sort_field = GFFormsModel::get_field( $form, $sort_field_id );
1116 1116
 
1117
-		switch ( $sort_field['type'] ) {
1117
+		switch ( $sort_field[ 'type' ] ) {
1118 1118
 
1119 1119
 			case 'address':
1120 1120
 				// Sorting by full address
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
 					 */
1132 1132
 					$address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id );
1133 1133
 
1134
-					switch( strtolower( $address_part ) ){
1134
+					switch ( strtolower( $address_part ) ) {
1135 1135
 						case 'street':
1136 1136
 							$sort_field_id .= '.1';
1137 1137
 							break;
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 		 */
1212 1212
 		$single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry );
1213 1213
 
1214
-		if ( empty( $single_entry ) ){
1214
+		if ( empty( $single_entry ) ) {
1215 1215
 			return false;
1216 1216
 		} else {
1217 1217
 			return $single_entry;
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
 				 * Don't enqueue the scripts or styles if it's not going to be displayed.
1239 1239
 				 * @since 1.15
1240 1240
 				 */
1241
-				if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
1241
+				if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) {
1242 1242
 					continue;
1243 1243
 				}
1244 1244
 
@@ -1247,19 +1247,19 @@  discard block
 block discarded – undo
1247 1247
 				$css_dependencies = array();
1248 1248
 
1249 1249
 				// If the thickbox is enqueued, add dependencies
1250
-				if ( ! empty( $data['atts']['lightbox'] ) ) {
1250
+				if ( ! empty( $data[ 'atts' ][ 'lightbox' ] ) ) {
1251 1251
 
1252 1252
 					/**
1253 1253
 					 * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox`
1254 1254
 					 * @param string $script_slug If you want to use a different lightbox script, return the name of it here.
1255 1255
 					 */
1256
-					$js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' );
1256
+					$js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' );
1257 1257
 
1258 1258
 					/**
1259 1259
 					 * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox`
1260 1260
 					 * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here.
1261 1261
 					 */
1262
-					$css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' );
1262
+					$css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' );
1263 1263
 				}
1264 1264
 
1265 1265
 				/**
@@ -1267,27 +1267,27 @@  discard block
 block discarded – undo
1267 1267
 				 * @see https://github.com/katzwebservices/GravityView/issues/536
1268 1268
 				 * @since 1.15
1269 1269
 				 */
1270
-				if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) {
1271
-					$css_dependencies[] = 'dashicons';
1270
+				if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) {
1271
+					$css_dependencies[ ] = 'dashicons';
1272 1272
 				}
1273 1273
 
1274 1274
 				wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true );
1275 1275
 
1276 1276
 				$script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
1277 1277
 
1278
-				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 );
1278
+				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 );
1279 1279
 
1280 1280
 				wp_enqueue_script( 'gravityview-fe-view' );
1281 1281
 
1282
-				if ( ! empty( $data['atts']['sort_columns'] ) ) {
1282
+				if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) {
1283 1283
 					wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' );
1284 1284
 				}
1285 1285
 
1286 1286
 				$rtl = is_rtl() ? '-rtl' : '';
1287 1287
 
1288
-				wp_enqueue_style( 'gravityview_default_style', plugins_url( 'templates/css/gv-default-styles' . $rtl .'.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' );
1288
+				wp_enqueue_style( 'gravityview_default_style', plugins_url( 'templates/css/gv-default-styles' . $rtl . '.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' );
1289 1289
 
1290
-				self::add_style( $data['template_id'] );
1290
+				self::add_style( $data[ 'template_id' ] );
1291 1291
 
1292 1292
 			}
1293 1293
 
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
 		} elseif ( empty( $template_id ) ) {
1324 1324
 			do_action( 'gravityview_log_error', '[add_style] Cannot add template style; template_id is empty' );
1325 1325
 		} else {
1326
-			do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_'.$template_id ) );
1326
+			do_action( 'gravityview_log_error', sprintf( '[add_style] Cannot add template style; %s is not registered', 'gravityview_style_' . $template_id ) );
1327 1327
 		}
1328 1328
 
1329 1329
 	}
@@ -1348,11 +1348,11 @@  discard block
 block discarded – undo
1348 1348
 		 * Not a table-based template; don't add sort icons
1349 1349
 		 * @since 1.12
1350 1350
 		 */
1351
-		if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) {
1351
+		if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) {
1352 1352
 			return $label;
1353 1353
 		}
1354 1354
 
1355
-		if ( ! $this->is_field_sortable( $field['id'], $form ) ) {
1355
+		if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) {
1356 1356
 			return $label;
1357 1357
 		}
1358 1358
 
@@ -1360,29 +1360,29 @@  discard block
 block discarded – undo
1360 1360
 
1361 1361
 		$class = 'gv-sort';
1362 1362
 
1363
-		$sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] );
1363
+		$sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] );
1364 1364
 
1365 1365
 		$sort_args = array(
1366
-			'sort' => $field['id'],
1366
+			'sort' => $field[ 'id' ],
1367 1367
 			'dir' => 'asc',
1368 1368
 		);
1369 1369
 
1370
-		if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) {
1370
+		if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) {
1371 1371
 			//toggle sorting direction.
1372
-			if ( 'asc' === $sorting['direction'] ) {
1373
-				$sort_args['dir'] = 'desc';
1372
+			if ( 'asc' === $sorting[ 'direction' ] ) {
1373
+				$sort_args[ 'dir' ] = 'desc';
1374 1374
 				$class .= ' gv-icon-sort-desc';
1375 1375
 			} else {
1376
-				$sort_args['dir'] = 'asc';
1376
+				$sort_args[ 'dir' ] = 'asc';
1377 1377
 				$class .= ' gv-icon-sort-asc';
1378 1378
 			}
1379 1379
 		} else {
1380 1380
 			$class .= ' gv-icon-caret-up-down';
1381 1381
 		}
1382 1382
 
1383
-		$url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) );
1383
+		$url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) );
1384 1384
 
1385
-		return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a>&nbsp;'. $label;
1385
+		return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a>&nbsp;' . $label;
1386 1386
 
1387 1387
 	}
1388 1388
 
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 
1401 1401
 		$field_type = $field_id;
1402 1402
 
1403
-		if( is_numeric( $field_id ) ) {
1403
+		if ( is_numeric( $field_id ) ) {
1404 1404
 			$field = GFFormsModel::get_field( $form, $field_id );
1405 1405
 			$field_type = $field->type;
1406 1406
 		}
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
 			return false;
1424 1424
 		}
1425 1425
 
1426
-		return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) );
1426
+		return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) );
1427 1427
 
1428 1428
 	}
1429 1429
 
Please login to merge, or discard this patch.