Completed
Push — develop ( 72e40e...f33cb6 )
by Gennady
17:09
created
future/includes/class-gv-view.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 	 *                                 rest      A REST call.
336 336
 	 * @param \GV\Request $request The request
337 337
 	 *
338
-	 * @return bool|\WP_Error An error if this View shouldn't be rendered here.
338
+	 * @return \WP_Error|null An error if this View shouldn't be rendered here.
339 339
 	 */
340 340
 	public function can_render( $context = null, $request = null ) {
341 341
 		if ( ! $request ) {
@@ -745,6 +745,7 @@  discard block
 block discarded – undo
745 745
 	 * Retrieve the entries for the current view and request.
746 746
 	 *
747 747
 	 * @param \GV\Request The request. Usued for now.
748
+	 * @param Request $request
748 749
 	 *
749 750
 	 * @return \GV\Entry_Collection The entries.
750 751
 	 */
Please login to merge, or discard this patch.
Spacing   +23 added lines, -24 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
 		/**
@@ -254,13 +254,13 @@  discard block
 block discarded – undo
254 254
 			return $content;
255 255
 		}
256 256
 
257
-		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID );
257
+		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID );
258 258
 
259 259
 		/**
260 260
 		 * Editing a single entry.
261 261
 		 */
262 262
 		if ( $entry = $request->is_edit_entry() ) {
263
-			if ( $entry['status'] != 'active' ) {
263
+			if ( $entry[ 'status' ] != 'active' ) {
264 264
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
265 265
 				return __( 'You are not allowed to view this content.', 'gravityview' );
266 266
 			}
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 			}
272 272
 
273 273
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
274
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
274
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
275 275
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
276 276
 					return __( 'You are not allowed to view this content.', 'gravityview' );
277 277
 				}
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 		 * Viewing a single entry.
285 285
 		 */
286 286
 		} else if ( $entry = $request->is_entry() ) {
287
-			if ( $entry['status'] != 'active' ) {
287
+			if ( $entry[ 'status' ] != 'active' ) {
288 288
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
289 289
 				return __( 'You are not allowed to view this content.', 'gravityview' );
290 290
 			}
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 			}
296 296
 
297 297
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
298
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
298
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
299 299
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
300 300
 					return __( 'You are not allowed to view this content.', 'gravityview' );
301 301
 				}
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 
304 304
 			$error = \GVCommon::check_entry_display( $entry->as_entry() );
305 305
 
306
-			if( is_wp_error( $error ) ) {
306
+			if ( is_wp_error( $error ) ) {
307 307
 				gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing: {message}', array( 'entry_id' => $entry->ID, 'message' => $error->get_error_message() ) );
308 308
 				return __( 'You are not allowed to view this content.', 'gravityview' );
309 309
 			}
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 			$join_column    = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field( $join_column );
454 454
 			$join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field( $join_on_column );
455 455
 
456
-			$joins [] = new Join( $join, $join_column, $join_on, $join_on_column );
456
+			$joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column );
457 457
 		}
458 458
 
459 459
 		return $joins;
@@ -495,10 +495,10 @@  discard block
 block discarded – undo
495 495
 
496 496
 			list( $join, $join_column, $join_on, $join_on_column ) = $meta;
497 497
 
498
-			$forms_ids [] = GF_Form::by_id( $join_on );
498
+			$forms_ids [ ] = GF_Form::by_id( $join_on );
499 499
 		}
500 500
 
501
-		return ( !empty( $forms_ids) ) ? $forms_ids : null;
501
+		return ( ! empty( $forms_ids ) ) ? $forms_ids : null;
502 502
 	}
503 503
 
504 504
 	/**
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 		if ( ! $view->form ) {
530 530
 			gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array(
531 531
 				'view_id' => $view->ID,
532
-				'form_id' => $view->_gravityview_form_id ? : 0,
532
+				'form_id' => $view->_gravityview_form_id ?: 0,
533 533
 			) );
534 534
 		}
535 535
 
@@ -755,28 +755,27 @@  discard block
 block discarded – undo
755 755
 			 * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead
756 756
 			 */
757 757
 			$parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID );
758
-			$parameters['context_view_id'] = $this->ID;
758
+			$parameters[ 'context_view_id' ] = $this->ID;
759 759
 			$parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID );
760 760
 
761 761
 			if ( $request instanceof REST\Request ) {
762 762
 				$atts = $this->settings->as_atts();
763 763
 				$paging_parameters = wp_parse_args( $request->get_paging(), array(
764
-						'paging' => array( 'page_size' => $atts['page_size'] ),
764
+						'paging' => array( 'page_size' => $atts[ 'page_size' ] ),
765 765
 					) );
766
-				$parameters['paging'] = $paging_parameters['paging'];
766
+				$parameters[ 'paging' ] = $paging_parameters[ 'paging' ];
767 767
 			}
768 768
 
769
-			$page = Utils::get( $parameters['paging'], 'current_page' ) ?
770
-				: ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 );
769
+			$page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 );
771 770
 
772 771
 			if ( gravityview()->plugin->supports( Plugin::FEATURE_GFQUERY ) ) {
773 772
 				/**
774 773
 				 * New \GF_Query stuff :)
775 774
 				 */
776
-				$query = new \GF_Query( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] );
775
+				$query = new \GF_Query( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] );
777 776
 
778
-				$query->limit( $parameters['paging']['page_size'] )
779
-					->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) );
777
+				$query->limit( $parameters[ 'paging' ][ 'page_size' ] )
778
+					->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) );
780 779
 
781 780
 				/**
782 781
 				 * Any joins?
@@ -816,15 +815,15 @@  discard block
 block discarded – undo
816 815
 				} );
817 816
 			} else {
818 817
 				$entries = $this->form->entries
819
-					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) )
818
+					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) )
820 819
 					->offset( $this->settings->get( 'offset' ) )
821
-					->limit( $parameters['paging']['page_size'] )
820
+					->limit( $parameters[ 'paging' ][ 'page_size' ] )
822 821
 					->page( $page );
823 822
 
824
-				if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) {
823
+				if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) {
825 824
 					$field = new \GV\Field();
826
-					$field->ID = $parameters['sorting']['key'];
827
-					$direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
825
+					$field->ID = $parameters[ 'sorting' ][ 'key' ];
826
+					$direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
828 827
 					$entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) );
829 828
 				}
830 829
 			}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -230,8 +230,9 @@
 block discarded – undo
230 230
 		 * Check permissions.
231 231
 		 */
232 232
 		while ( $error = $view->can_render( null, $request ) ) {
233
-			if ( ! is_wp_error( $error ) )
234
-				break;
233
+			if ( ! is_wp_error( $error ) ) {
234
+							break;
235
+			}
235 236
 
236 237
 			switch ( str_replace( 'gravityview/', '', $error->get_error_code() ) ) {
237 238
 				case 'post_password_required':
Please login to merge, or discard this patch.
future/includes/class-gv-shortcode-gravityview.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 			'detail' => null,
38 38
 		) );
39 39
 		
40
-		if ( ! $view_id = $atts['id'] ? : $atts['view_id'] ) {
41
-			if ( $atts['detail'] && $view = $request->is_view() ) {
40
+		if ( ! $view_id = $atts[ 'id' ] ?: $atts[ 'view_id' ] ) {
41
+			if ( $atts[ 'detail' ] && $view = $request->is_view() ) {
42 42
 				$view_id = $view->ID;
43 43
 			}
44 44
 		}
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 			}
102 102
 		}
103 103
 
104
-		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID );
104
+		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID );
105 105
 
106 106
 		/**
107 107
 		 * View details.
108 108
 		 */
109
-		if ( $atts['detail'] ) {
109
+		if ( $atts[ 'detail' ] ) {
110 110
 			return $this->detail( $view, $entries, $atts );
111 111
 
112 112
 		/**
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 				return '';
123 123
 			}
124 124
 
125
-			if ( $entry['status'] != 'active' ) {
125
+			if ( $entry[ 'status' ] != 'active' ) {
126 126
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
127 127
 				return __( 'You are not allowed to view this content.', 'gravityview' );
128 128
 			}
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 			}
134 134
 
135 135
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
136
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
136
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
137 137
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
138 138
 					return __( 'You are not allowed to view this content.', 'gravityview' );
139 139
 				}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 				return '';
154 154
 			}
155 155
 
156
-			if ( $entry['status'] != 'active' ) {
156
+			if ( $entry[ 'status' ] != 'active' ) {
157 157
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
158 158
 				return __( 'You are not allowed to view this content.', 'gravityview' );
159 159
 			}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 			}
165 165
 
166 166
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
167
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
167
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
168 168
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
169 169
 					return __( 'You are not allowed to view this content.', 'gravityview' );
170 170
 				}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 
173 173
 			$error = \GVCommon::check_entry_display( $entry->as_entry() );
174 174
 
175
-			if( is_wp_error( $error ) ) {
175
+			if ( is_wp_error( $error ) ) {
176 176
 				gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing: {message}', array( 'entry_id' => $entry->ID, 'message' => $error->get_error_message() ) );
177 177
 				return __( 'You are not allowed to view this content.', 'gravityview' );
178 178
 			}
@@ -188,10 +188,10 @@  discard block
 block discarded – undo
188 188
 				
189 189
 				// Mock the request with the actual View, not the global one
190 190
 				$mock_request = new \GV\Mock_Request();
191
-				$mock_request->returns['is_view'] = $view;
192
-				$mock_request->returns['is_entry'] = $request->is_entry();
193
-				$mock_request->returns['is_edit_entry'] = $request->is_edit_entry();
194
-				$mock_request->returns['is_search'] = $request->is_search();
191
+				$mock_request->returns[ 'is_view' ] = $view;
192
+				$mock_request->returns[ 'is_entry' ] = $request->is_entry();
193
+				$mock_request->returns[ 'is_edit_entry' ] = $request->is_edit_entry();
194
+				$mock_request->returns[ 'is_search' ] = $request->is_search();
195 195
 
196 196
 				$request = $mock_request;
197 197
 			}
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
 		$filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' );
228 228
 
229 229
 		// Only keep the passed attributes after making sure that they're valid pairs
230
-		$filtered_atts = array_intersect_key( (array) $passed_atts, $filtered_atts );
230
+		$filtered_atts = array_intersect_key( (array)$passed_atts, $filtered_atts );
231 231
 
232 232
 		$atts = array();
233 233
 
234
-		foreach( $filtered_atts as $key => $passed_value ) {
234
+		foreach ( $filtered_atts as $key => $passed_value ) {
235 235
 
236 236
 			// Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by}
237 237
 			$passed_value = \GravityView_Merge_Tags::replace_variables( $passed_value );
238 238
 
239
-			switch( $defaults[ $key ]['type'] ) {
239
+			switch ( $defaults[ $key ][ 'type' ] ) {
240 240
 
241 241
 				/**
242 242
 				 * Make sure number fields are numeric.
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 				 * @see http://php.net/manual/en/function.is-numeric.php#107326
245 245
 				 */
246 246
 				case 'number':
247
-					if( is_numeric( $passed_value ) ) {
247
+					if ( is_numeric( $passed_value ) ) {
248 248
 						$atts[ $key ] = ( $passed_value + 0 );
249 249
 					}
250 250
 					break;
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 				 */
260 260
 				case 'select':
261 261
 				case 'radio':
262
-					$options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options'];
263
-					if( in_array( $passed_value, array_keys( $options ) ) ) {
262
+					$options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ];
263
+					if ( in_array( $passed_value, array_keys( $options ) ) ) {
264 264
 						$atts[ $key ] = $passed_value;
265 265
 					}
266 266
 					break;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 			}
273 273
 		}
274 274
 
275
-		$atts['detail'] = \GV\Utils::get( $passed_atts, 'detail', null );
275
+		$atts[ 'detail' ] = \GV\Utils::get( $passed_atts, 'detail', null );
276 276
 
277 277
 		return $atts;
278 278
 	}
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	private function detail( $view, $entries, $atts ) {
290 290
 		$output = '';
291 291
 
292
-		switch ( $key = $atts['detail'] ):
292
+		switch ( $key = $atts[ 'detail' ] ):
293 293
 			case 'total_entries':
294 294
 				$output = number_format_i18n( $entries->total() );
295 295
 				break;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,8 +79,9 @@
 block discarded – undo
79 79
 		 * Check permissions.
80 80
 		 */
81 81
 		while ( $error = $view->can_render( array( 'shortcode' ), $request ) ) {
82
-			if ( ! is_wp_error( $error ) )
83
-				break;
82
+			if ( ! is_wp_error( $error ) ) {
83
+							break;
84
+			}
84 85
 
85 86
 			switch ( str_replace( 'gravityview/', '', $error->get_error_code() ) ) {
86 87
 				case 'post_password_required':
Please login to merge, or discard this patch.
future/includes/rest/class-gv-rest-views-route.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -319,8 +319,9 @@
 block discarded – undo
319 319
 		}
320 320
 
321 321
 		while ( $error = $view->can_render( array( 'rest' ), $request ) ) {
322
-			if ( ! is_wp_error( $error ) )
323
-				break;
322
+			if ( ! is_wp_error( $error ) ) {
323
+							break;
324
+			}
324 325
 
325 326
 			switch ( str_replace( 'gravityview/', '', $error->get_error_code() ) ) {
326 327
 				case 'rest_disabled':
Please login to merge, or discard this patch.