Completed
Pull Request — develop (#1194)
by Gennady
18:19
created
future/includes/class-gv-view.php 1 patch
Spacing   +33 added lines, -34 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		$supports = array( 'title', 'revisions' );
109 109
 
110 110
 		if ( $is_hierarchical ) {
111
-			$supports[] = 'page-attributes';
111
+			$supports[ ] = 'page-attributes';
112 112
 		}
113 113
 
114 114
 		/**
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
 		$rule = array( sprintf( '%s/([^/]+)/csv/?', $slug ), 'index.php?gravityview=$matches[1]&csv=1', 'top' );
211 211
 
212 212
 		add_filter( 'query_vars', function( $query_vars ) { 
213
-			$query_vars[] = 'csv';
213
+			$query_vars[ ] = 'csv';
214 214
 			return $query_vars;
215 215
 		} );
216 216
 
217
-		if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[0] ] ) ) {
217
+		if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[ 0 ] ] ) ) {
218 218
 			call_user_func_array( 'add_rewrite_rule', $rule );
219 219
 		}
220 220
 	}
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
 			return $content;
284 284
 		}
285 285
 
286
-		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID );
286
+		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID );
287 287
 
288 288
 		/**
289 289
 		 * Editing a single entry.
290 290
 		 */
291 291
 		if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) {
292
-			if ( $entry['status'] != 'active' ) {
292
+			if ( $entry[ 'status' ] != 'active' ) {
293 293
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
294 294
 				return __( 'You are not allowed to view this content.', 'gravityview' );
295 295
 			}
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 			}
301 301
 
302 302
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
303
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
303
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
304 304
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
305 305
 					return __( 'You are not allowed to view this content.', 'gravityview' );
306 306
 				}
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		 * Viewing a single entry.
314 314
 		 */
315 315
 		} else if ( $entry = $request->is_entry( $view->form ? $view->form->ID : 0 ) ) {
316
-			if ( $entry['status'] != 'active' ) {
316
+			if ( $entry[ 'status' ] != 'active' ) {
317 317
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
318 318
 				return __( 'You are not allowed to view this content.', 'gravityview' );
319 319
 			}
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 			}
325 325
 
326 326
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
327
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
327
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
328 328
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
329 329
 					return __( 'You are not allowed to view this content.', 'gravityview' );
330 330
 				}
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 			$join_column    = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field( $join_column );
499 499
 			$join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field( $join_on_column );
500 500
 
501
-			$joins [] = new Join( $join, $join_column, $join_on, $join_on_column );
501
+			$joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column );
502 502
 		}
503 503
 
504 504
 		return $joins;
@@ -540,10 +540,10 @@  discard block
 block discarded – undo
540 540
 
541 541
 			list( $join, $join_column, $join_on, $join_on_column ) = $meta;
542 542
 
543
-			$forms_ids [] = GF_Form::by_id( $join_on );
543
+			$forms_ids [ ] = GF_Form::by_id( $join_on );
544 544
 		}
545 545
 
546
-		return ( !empty( $forms_ids) ) ? $forms_ids : null;
546
+		return ( ! empty( $forms_ids ) ) ? $forms_ids : null;
547 547
 	}
548 548
 
549 549
 	/**
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 		if ( ! $view->form ) {
582 582
 			gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array(
583 583
 				'view_id' => $view->ID,
584
-				'form_id' => $view->_gravityview_form_id ? : 0,
584
+				'form_id' => $view->_gravityview_form_id ?: 0,
585 585
 			) );
586 586
 		}
587 587
 
@@ -816,11 +816,11 @@  discard block
 block discarded – undo
816 816
 			 * Remove multiple sorting before calling legacy filters.
817 817
 			 * This allows us to fake it till we make it.
818 818
 			 */
819
-			if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) {
819
+			if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) {
820 820
 				$has_multisort = true;
821
-				$parameters['sort_field'] = reset( $parameters['sort_field'] );
822
-				if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) {
823
-					$parameters['sort_direction'] = reset( $parameters['sort_direction'] );
821
+				$parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] );
822
+				if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) {
823
+					$parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] );
824 824
 				}
825 825
 			}
826 826
 
@@ -828,34 +828,33 @@  discard block
 block discarded – undo
828 828
 			 * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead
829 829
 			 */
830 830
 			$parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID );
831
-			$parameters['context_view_id'] = $this->ID;
831
+			$parameters[ 'context_view_id' ] = $this->ID;
832 832
 			$parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID );
833 833
 
834 834
 			if ( $request instanceof REST\Request ) {
835 835
 				$atts = $this->settings->as_atts();
836 836
 				$paging_parameters = wp_parse_args( $request->get_paging(), array(
837
-						'paging' => array( 'page_size' => $atts['page_size'] ),
837
+						'paging' => array( 'page_size' => $atts[ 'page_size' ] ),
838 838
 					) );
839
-				$parameters['paging'] = $paging_parameters['paging'];
839
+				$parameters[ 'paging' ] = $paging_parameters[ 'paging' ];
840 840
 			}
841 841
 
842
-			$page = Utils::get( $parameters['paging'], 'current_page' ) ?
843
-				: ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 );
842
+			$page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 );
844 843
 
845 844
 			/**
846 845
 			 * Cleanup duplicate field_filter parameters to simplify the query.
847 846
 			 */
848 847
 			$unique_field_filters = array();
849
-			foreach ( $parameters['search_criteria']['field_filters'] as $key => $filter ) {
848
+			foreach ( $parameters[ 'search_criteria' ][ 'field_filters' ] as $key => $filter ) {
850 849
 				if ( 'mode' === $key ) {
851
-					$unique_field_filters['mode'] = $filter;
850
+					$unique_field_filters[ 'mode' ] = $filter;
852 851
 				} else if ( ! in_array( $filter, $unique_field_filters ) ) {
853
-					$unique_field_filters[] = $filter;
852
+					$unique_field_filters[ ] = $filter;
854 853
 				}
855 854
 			}
856
-			$parameters['search_criteria']['field_filters'] = $unique_field_filters;
855
+			$parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters;
857 856
 
858
-			if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) {
857
+			if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) {
859 858
 				gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' );
860 859
 			}
861 860
 
@@ -863,7 +862,7 @@  discard block
 block discarded – undo
863 862
 				/**
864 863
 				 * New \GF_Query stuff :)
865 864
 				 */
866
-				$query = new \GF_Query( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] );
865
+				$query = new \GF_Query( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] );
867 866
 
868 867
 				/**
869 868
 				 * Apply multisort.
@@ -896,8 +895,8 @@  discard block
 block discarded – undo
896 895
 					}
897 896
 				}
898 897
 
899
-				$query->limit( $parameters['paging']['page_size'] )
900
-					->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) );
898
+				$query->limit( $parameters[ 'paging' ][ 'page_size' ] )
899
+					->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) );
901 900
 
902 901
 				/**
903 902
 				 * Any joins?
@@ -939,15 +938,15 @@  discard block
 block discarded – undo
939 938
 				} );
940 939
 			} else {
941 940
 				$entries = $this->form->entries
942
-					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) )
941
+					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) )
943 942
 					->offset( $this->settings->get( 'offset' ) )
944
-					->limit( $parameters['paging']['page_size'] )
943
+					->limit( $parameters[ 'paging' ][ 'page_size' ] )
945 944
 					->page( $page );
946 945
 
947
-				if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) {
946
+				if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) {
948 947
 					$field = new \GV\Field();
949
-					$field->ID = $parameters['sorting']['key'];
950
-					$direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
948
+					$field->ID = $parameters[ 'sorting' ][ 'key' ];
949
+					$direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
951 950
 					$entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) );
952 951
 				}
953 952
 			}
Please login to merge, or discard this patch.
includes/admin/metaboxes/views/sort-filter.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 		$secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'][1] );
34 34
 	} else {
35 35
 		$primary_sort_fields = $secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'] );
36
-    }
36
+	}
37 37
 
38 38
 
39 39
 	GravityView_Render_Settings::render_setting_row( 'sort_field', $current_settings, sprintf( $sort_fields_input, $primary_sort_fields ) );
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@
 block discarded – undo
28 28
 
29 29
 	$sort_fields_input = '<select name="template_settings[sort_field][]" id="gravityview_sort_field">%s</select>';
30 30
 
31
-	if ( is_array( $current_settings['sort_field'] ) ) {
32
-		$primary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'][0] );
33
-		$secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'][1] );
31
+	if ( is_array( $current_settings[ 'sort_field' ] ) ) {
32
+		$primary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings[ 'sort_field' ][ 0 ] );
33
+		$secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings[ 'sort_field' ][ 1 ] );
34 34
 	} else {
35
-		$primary_sort_fields = $secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'] );
35
+		$primary_sort_fields = $secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings[ 'sort_field' ] );
36 36
     }
37 37
 
38 38
 
Please login to merge, or discard this patch.
future/includes/class-gv-template-legacy-override.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
 		$additional = array();
99 99
 
100 100
 		// form-19-table-body.php
101
-		$additional[] = sprintf( 'form-%d-%s-%s.php', $this->view->form ? $this->view->form->ID : 0, $slug, $name );
101
+		$additional[ ] = sprintf( 'form-%d-%s-%s.php', $this->view->form ? $this->view->form->ID : 0, $slug, $name );
102 102
 
103 103
 		// view-3-table-body.php
104
-		$additional[] = sprintf( 'view-%d-%s-%s.php', $this->view->ID, $slug, $name );
104
+		$additional[ ] = sprintf( 'view-%d-%s-%s.php', $this->view->ID, $slug, $name );
105 105
 
106 106
 		global $post;
107 107
 		if ( $post ) {
108 108
 			// page-19-table-body.php
109
-			$additional[] = sprintf( 'page-%d-%s-%s.php', $post->ID, $slug, $name );
109
+			$additional[ ] = sprintf( 'page-%d-%s-%s.php', $post->ID, $slug, $name );
110 110
 		}
111 111
 
112 112
 		// Combine with existing table-body.php and table.php
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		ob_start();
131 131
 
132 132
 		$request = new Mock_Request();
133
-		$request->returns['is_view'] = $this->view;
133
+		$request->returns[ 'is_view' ] = $this->view;
134 134
 
135 135
 		/**
136 136
 		 * You got one shot. One opportunity. To render all the widgets you have ever wanted.
@@ -144,17 +144,17 @@  discard block
 block discarded – undo
144 144
 		foreach ( array( 'gravityview_before', 'gravityview_after' ) as $hook ) {
145 145
 			/** WordPress 4.6 and lower compatibility, when WP_Hook classes were still absent. */
146 146
 			if ( is_array( $wp_filter[ $hook ] ) ) {
147
-				if ( ! empty( $wp_filter[ $hook ][10] ) ) {
148
-					foreach ( $wp_filter[ $hook ][10] as $function_key => $callback ) {
147
+				if ( ! empty( $wp_filter[ $hook ][ 10 ] ) ) {
148
+					foreach ( $wp_filter[ $hook ][ 10 ] as $function_key => $callback ) {
149 149
 						if ( strpos( $function_key, 'render_widget_hooks' ) ) {
150
-							unset( $wp_filter[ $hook ][10][ $function_key ] );
150
+							unset( $wp_filter[ $hook ][ 10 ][ $function_key ] );
151 151
 						}
152 152
 					}
153 153
 				}
154 154
 			} else {
155
-				foreach ( $wp_filter[ $hook ]->callbacks[10] as $function_key => $callback ) {
155
+				foreach ( $wp_filter[ $hook ]->callbacks[ 10 ] as $function_key => $callback ) {
156 156
 					if ( strpos( $function_key, 'render_widget_hooks' ) ) {
157
-						unset( $wp_filter[ $hook ]->callbacks[10][ $function_key ] );
157
+						unset( $wp_filter[ $hook ]->callbacks[ 10 ][ $function_key ] );
158 158
 					}
159 159
 				}
160 160
 			}
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		 */
166 166
 		if ( $this->entry ) {
167 167
 
168
-			$request->returns['is_entry'] = $this->entry;
168
+			$request->returns[ 'is_entry' ] = $this->entry;
169 169
 
170 170
 			global $post;
171 171
 
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 			 * This allows us to fake it till we make it.
200 200
 			 */
201 201
 			$parameters = $view->settings->as_atts();
202
-			if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) {
202
+			if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) {
203 203
 				$has_multisort = true;
204
-				$parameters['sort_field'] = reset( $parameters['sort_field'] );
205
-				if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) {
206
-					$parameters['sort_direction'] = reset( $parameters['sort_direction'] );
204
+				$parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] );
205
+				if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) {
206
+					$parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] );
207 207
 				}
208 208
 			}
209 209
 
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 					'fields' => $this->view->fields->by_visible(),
223 223
 					'in_the_loop' => true,
224 224
 				), empty( $parameters ) ? array() : array(
225
-					'paging' => $parameters['paging'],
226
-					'sorting' => $parameters['sorting'],
225
+					'paging' => $parameters[ 'paging' ],
226
+					'sorting' => $parameters[ 'sorting' ],
227 227
 				), $post ? array(
228 228
 					'post' => $post,
229 229
 				) : array() ) );
Please login to merge, or discard this patch.
future/includes/class-gv-renderer-view.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 		 * This allows us to fake it till we make it.
110 110
 		 */
111 111
 		$parameters = $view->settings->as_atts();
112
-		if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) {
112
+		if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) {
113 113
 			$has_multisort = true;
114
-			$parameters['sort_field'] = reset( $parameters['sort_field'] );
115
-			if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) {
116
-				$parameters['sort_direction'] = reset( $parameters['sort_direction'] );
114
+			$parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] );
115
+			if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) {
116
+				$parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] );
117 117
 			}
118 118
 		}
119 119
 
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 			'entries' => $entries,
129 129
 			'request' => $request,
130 130
 		), empty( $parameters ) ? array() : array(
131
-			'paging' => $parameters['paging'],
132
-			'sorting' => $parameters['sorting'],
131
+			'paging' => $parameters[ 'paging' ],
132
+			'sorting' => $parameters[ 'sorting' ],
133 133
 		), empty( $post ) ? array() : array(
134 134
 			'post' => $post,
135 135
 		) ) );
Please login to merge, or discard this patch.