Completed
Push — develop ( d231fb...9ab8cc )
by Zack
18:08
created
future/includes/class-gv-view.php 1 patch
Spacing   +21 added lines, -22 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
 		/**
@@ -289,13 +289,13 @@  discard block
 block discarded – undo
289 289
 			return __( 'You are not allowed to view this content.', 'gravityview' );
290 290
 		}
291 291
 
292
-		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID );
292
+		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID );
293 293
 
294 294
 		/**
295 295
 		 * Editing a single entry.
296 296
 		 */
297 297
 		if ( $entry = $request->is_edit_entry() ) {
298
-			if ( $entry['status'] != 'active' ) {
298
+			if ( $entry[ 'status' ] != 'active' ) {
299 299
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
300 300
 				return __( 'You are not allowed to view this content.', 'gravityview' );
301 301
 			}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 			}
307 307
 
308 308
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
309
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
309
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
310 310
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
311 311
 					return __( 'You are not allowed to view this content.', 'gravityview' );
312 312
 				}
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		 * Viewing a single entry.
320 320
 		 */
321 321
 		} else if ( $entry = $request->is_entry() ) {
322
-			if ( $entry['status'] != 'active' ) {
322
+			if ( $entry[ 'status' ] != 'active' ) {
323 323
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
324 324
 				return __( 'You are not allowed to view this content.', 'gravityview' );
325 325
 			}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 			}
331 331
 
332 332
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
333
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
333
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
334 334
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
335 335
 					return __( 'You are not allowed to view this content.', 'gravityview' );
336 336
 				}
@@ -378,11 +378,11 @@  discard block
 block discarded – undo
378 378
 		if ( ! $view->form ) {
379 379
 			gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array(
380 380
 				'view_id' => $view->ID,
381
-				'form_id' => $view->_gravityview_form_id ? : 0,
381
+				'form_id' => $view->_gravityview_form_id ?: 0,
382 382
 			) );
383 383
 		} else if ( gravityview()->plugin->supports( Plugin::FEATURE_JOINS ) ) {
384 384
 			/** And the connected joins. */
385
-			foreach( (array)get_post_meta( $view->ID, '_gravityview_form_joins', true ) as $_join ) {
385
+			foreach ( (array)get_post_meta( $view->ID, '_gravityview_form_joins', true ) as $_join ) {
386 386
 				if ( ! is_array( $_join ) || count( $_join ) != 4 ) {
387 387
 					continue;
388 388
 				}
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 				$join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field( $join_column );
395 395
 				$join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field( $join_on_column );
396 396
 
397
-				$view->joins []= new Join( $join, $join_column, $join_on, $join_on_column );
397
+				$view->joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column );
398 398
 			}
399 399
 		}
400 400
 
@@ -618,28 +618,27 @@  discard block
 block discarded – undo
618 618
 			 * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead
619 619
 			 */
620 620
 			$parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID );
621
-			$parameters['context_view_id'] = $this->ID;
621
+			$parameters[ 'context_view_id' ] = $this->ID;
622 622
 			$parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID );
623 623
 
624 624
 			if ( $request instanceof REST\Request ) {
625 625
 				$atts = $this->settings->as_atts();
626 626
 				$paging_parameters = wp_parse_args( $request->get_paging(), array(
627
-						'paging' => array( 'page_size' => $atts['page_size'] ),
627
+						'paging' => array( 'page_size' => $atts[ 'page_size' ] ),
628 628
 					) );
629
-				$parameters['paging'] = $paging_parameters['paging'];
629
+				$parameters[ 'paging' ] = $paging_parameters[ 'paging' ];
630 630
 			}
631 631
 
632
-			$page = Utils::get( $parameters['paging'], 'current_page' ) ?
633
-				: ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 );
632
+			$page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 );
634 633
 
635 634
 			if ( gravityview()->plugin->supports( Plugin::FEATURE_GFQUERY ) ) {
636 635
 				/**
637 636
 				 * New \GF_Query stuff :)
638 637
 				 */
639
-				$query = new \GF_Query( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] );
638
+				$query = new \GF_Query( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] );
640 639
 
641
-				$query->limit( $parameters['paging']['page_size'] )
642
-					->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) );
640
+				$query->limit( $parameters[ 'paging' ][ 'page_size' ] )
641
+					->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) );
643 642
 
644 643
 				/**
645 644
 				 * Any joins?
@@ -679,15 +678,15 @@  discard block
 block discarded – undo
679 678
 				} );
680 679
 			} else {
681 680
 				$entries = $this->form->entries
682
-					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) )
681
+					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) )
683 682
 					->offset( $this->settings->get( 'offset' ) )
684
-					->limit( $parameters['paging']['page_size'] )
683
+					->limit( $parameters[ 'paging' ][ 'page_size' ] )
685 684
 					->page( $page );
686 685
 				
687
-				if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) {
686
+				if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) {
688 687
 					$field = new \GV\Field();
689
-					$field->ID = $parameters['sorting']['key'];
690
-					$direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
688
+					$field->ID = $parameters[ 'sorting' ][ 'key' ];
689
+					$direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
691 690
 					$entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) );
692 691
 				}
693 692
 			}
Please login to merge, or discard this patch.
future/includes/class-gv-shortcode-gravityview.php 1 patch
Spacing   +14 added lines, -14 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
 		}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			return get_the_password_form( $view->ID );
77 77
 		}
78 78
 
79
-		if ( ! $view->form  ) {
79
+		if ( ! $view->form ) {
80 80
 			gravityview()->log->notice( 'View #{id} has no form attached to it.', array( 'id' => $view->ID ) );
81 81
 
82 82
 			/**
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 			return __( 'You are not allowed to view this content.', 'gravityview' );
98 98
 		}
99 99
 
100
-		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID );
100
+		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID );
101 101
 
102 102
 		/**
103 103
 		 * View details.
104 104
 		 */
105
-		if ( $atts['detail'] ) {
105
+		if ( $atts[ 'detail' ] ) {
106 106
 			return $this->detail( $view, $entries, $atts );
107 107
 
108 108
 		/**
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 				return '';
117 117
 			}
118 118
 
119
-			if ( $entry['status'] != 'active' ) {
119
+			if ( $entry[ 'status' ] != 'active' ) {
120 120
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
121 121
 				return __( 'You are not allowed to view this content.', 'gravityview' );
122 122
 			}
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 			}
128 128
 
129 129
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
130
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
130
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
131 131
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
132 132
 					return __( 'You are not allowed to view this content.', 'gravityview' );
133 133
 				}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 				return '';
148 148
 			}
149 149
 
150
-			if ( $entry['status'] != 'active' ) {
150
+			if ( $entry[ 'status' ] != 'active' ) {
151 151
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
152 152
 				return __( 'You are not allowed to view this content.', 'gravityview' );
153 153
 			}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			}
159 159
 
160 160
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
161
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
161
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
162 162
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
163 163
 					return __( 'You are not allowed to view this content.', 'gravityview' );
164 164
 				}
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 				
176 176
 				// Mock the request with the actual View, not the global one
177 177
 				$mock_request = new \GV\Mock_Request();
178
-				$mock_request->returns['is_view'] = $view;
179
-				$mock_request->returns['is_entry'] = $request->is_entry();
180
-				$mock_request->returns['is_edit_entry'] = $request->is_edit_entry();
181
-				$mock_request->returns['is_search'] = $request->is_search();
178
+				$mock_request->returns[ 'is_view' ] = $view;
179
+				$mock_request->returns[ 'is_entry' ] = $request->is_entry();
180
+				$mock_request->returns[ 'is_edit_entry' ] = $request->is_edit_entry();
181
+				$mock_request->returns[ 'is_search' ] = $request->is_search();
182 182
 
183 183
 				$request = $mock_request;
184 184
 			}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	private function detail( $view, $entries, $atts ) {
201 201
 		$output = '';
202 202
 
203
-		switch ( $key = $atts['detail'] ):
203
+		switch ( $key = $atts[ 'detail' ] ):
204 204
 			case 'total_entries':
205 205
 				$output = number_format_i18n( $entries->total() );
206 206
 				break;
Please login to merge, or discard this patch.
future/includes/rest/class-gv-rest-views-route.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			'total' => wp_count_posts( 'gravityview' )->publish,
64 64
 		);
65 65
 		foreach ( $items as $item ) {
66
-			$data['views'][] = $this->prepare_view_for_response( $item, $request );
66
+			$data[ 'views' ][ ] = $this->prepare_view_for_response( $item, $request );
67 67
 		}
68 68
 
69 69
 		return new \WP_REST_Response( $data, 200 );
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
 		$url = $request->get_url_params();
84 84
 
85
-		$view_id = intval( $url['id'] );
85
+		$view_id = intval( $url[ 'id' ] );
86 86
 
87 87
 		$item = get_post( $view_id );
88 88
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		// Only output the fields that should be displayed.
112 112
 		$allowed = array();
113 113
 		foreach ( $view->fields->by_position( "{$context}_*" )->by_visible()->all() as $field ) {
114
-			$allowed[] = $field->ID;
114
+			$allowed[ ] = $field->ID;
115 115
 		}
116 116
 
117 117
 		/**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	public function get_sub_items( $request ) {
157 157
 
158 158
 		$url     = $request->get_url_params();
159
-		$view_id = intval( $url['id'] );
159
+		$view_id = intval( $url[ 'id' ] );
160 160
 		$format  = \GV\Utils::get( $url, 'format', 'json' );
161 161
 
162 162
 		$view = \GV\View::by_id( $view_id );
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 
200 200
 		$data = array( 'entries' => $entries->all(), 'total' => $entries->total() );
201 201
 
202
-		foreach ( $data['entries'] as &$entry ) {
202
+		foreach ( $data[ 'entries' ] as &$entry ) {
203 203
 			$entry = $this->prepare_entry_for_response( $view, $entry, $request, 'directory' );
204 204
 		}
205 205
 
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 	 */
219 219
 	public function get_sub_item( $request ) {
220 220
 		$url      = $request->get_url_params();
221
-		$view_id  = intval( $url['id'] );
222
-		$entry_id = intval( $url['s_id'] );
221
+		$view_id  = intval( $url[ 'id' ] );
222
+		$entry_id = intval( $url[ 's_id' ] );
223 223
 		$format   = \GV\Utils::get( $url, 'format', 'json' );
224 224
 
225 225
 		$view  = \GV\View::by_id( $view_id );
@@ -254,32 +254,32 @@  discard block
 block discarded – undo
254 254
 		// Add all the WP_Post data
255 255
 		$view_post = $view_post->to_array();
256 256
 
257
-		unset( $view_post['to_ping'], $view_post['ping_status'], $view_post['pinged'], $view_post['post_type'], $view_post['filter'], $view_post['post_category'], $view_post['tags_input'], $view_post['post_content'], $view_post['post_content_filtered'] );
257
+		unset( $view_post[ 'to_ping' ], $view_post[ 'ping_status' ], $view_post[ 'pinged' ], $view_post[ 'post_type' ], $view_post[ 'filter' ], $view_post[ 'post_category' ], $view_post[ 'tags_input' ], $view_post[ 'post_content' ], $view_post[ 'post_content_filtered' ] );
258 258
 
259 259
 		$return = wp_parse_args( $item, $view_post );
260 260
 
261
-		$return['title'] = $return['post_title'];
261
+		$return[ 'title' ] = $return[ 'post_title' ];
262 262
 
263
-		$return['settings'] = isset( $return['atts'] ) ? $return['atts'] : array();
264
-		unset( $return['atts'], $return['view_id'] );
263
+		$return[ 'settings' ] = isset( $return[ 'atts' ] ) ? $return[ 'atts' ] : array();
264
+		unset( $return[ 'atts' ], $return[ 'view_id' ] );
265 265
 
266
-		$return['search_criteria'] = array(
266
+		$return[ 'search_criteria' ] = array(
267 267
 			'page_size' => rgars( $return, 'settings/page_size' ),
268 268
 			'sort_field' => rgars( $return, 'settings/sort_field' ),
269 269
 			'sort_direction' => rgars( $return, 'settings/sort_direction' ),
270 270
 			'offset' => rgars( $return, 'settings/offset' ),
271 271
 		);
272 272
 
273
-		unset( $return['settings']['page_size'], $return['settings']['sort_field'], $return['settings']['sort_direction'] );
273
+		unset( $return[ 'settings' ][ 'page_size' ], $return[ 'settings' ][ 'sort_field' ], $return[ 'settings' ][ 'sort_direction' ] );
274 274
 
275 275
 		// Redact for non-logged ins
276 276
 		if ( ! \GVCommon::has_cap( 'edit_others_gravityviews' ) ) {
277
-			unset( $return['settings'] );
278
-			unset( $return['search_criteria'] );
277
+			unset( $return[ 'settings' ] );
278
+			unset( $return[ 'search_criteria' ] );
279 279
 		}
280 280
 		
281 281
 		if ( ! \GFCommon::current_user_can_any( 'gravityforms_edit_forms' ) ) {
282
-			unset( $return['form'] );
282
+			unset( $return[ 'form' ] );
283 283
 		}
284 284
 
285 285
 		return $return;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 			$view_id = func_get_arg( 1 ); // $view_id override
291 291
 		} else {
292 292
 			$url     = $request->get_url_params();
293
-			$view_id = intval( $url['id'] );
293
+			$view_id = intval( $url[ 'id' ] );
294 294
 		}
295 295
 
296 296
 		if ( ! $view = \GV\View::by_id( $view_id ) ) {
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 		}
344 344
 
345 345
 		$url     = $request->get_url_params();
346
-		$view_id = intval( $url['id'] );
347
-		$entry_id = intval( $url['s_id'] );
346
+		$view_id = intval( $url[ 'id' ] );
347
+		$entry_id = intval( $url[ 's_id' ] );
348 348
 
349 349
 		$view = \GV\View::by_id( $view_id );
350 350
 
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
 			return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' );
353 353
 		}
354 354
 
355
-		if ( $entry['form_id'] != $view->form->ID ) {
355
+		if ( $entry[ 'form_id' ] != $view->form->ID ) {
356 356
 			return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' );
357 357
 		}
358 358
 
359
-		if ( $entry['status'] != 'active' ) {
359
+		if ( $entry[ 'status' ] != 'active' ) {
360 360
 			return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' );
361 361
 		}
362 362
 
@@ -364,10 +364,10 @@  discard block
 block discarded – undo
364 364
 			return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' );
365 365
 		}
366 366
 
367
-		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID );
367
+		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID );
368 368
 
369 369
 		if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
370
-			if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
370
+			if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
371 371
 				return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' );
372 372
 			}
373 373
 		}
Please login to merge, or discard this patch.
future/includes/class-gv-shortcode-gventry.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 		 */
45 45
 		$atts = apply_filters( 'gravityview/shortcodes/gventry/atts', $atts );
46 46
 
47
-		$view = \GV\View::by_id( $atts['view_id'] );
47
+		$view = \GV\View::by_id( $atts[ 'view_id' ] );
48 48
 
49 49
 		if ( ! $view ) {
50
-			gravityview()->log->error( 'View does not exist #{view_id}', array( 'view_id' => $atts['view_id'] ) );
50
+			gravityview()->log->error( 'View does not exist #{view_id}', array( 'view_id' => $atts[ 'view_id' ] ) );
51 51
 			return apply_filters( 'gravityview/shortcodes/gventry/output', '', null, null, $atts );
52 52
 		}
53 53
 
54
-		$entry_id = ! empty( $atts['entry_id'] ) ? $atts['entry_id'] : $atts['id'];
54
+		$entry_id = ! empty( $atts[ 'entry_id' ] ) ? $atts[ 'entry_id' ] : $atts[ 'id' ];
55 55
 
56
-		switch( $entry_id ):
56
+		switch ( $entry_id ):
57 57
 			case 'last':
58 58
 				if ( class_exists( '\GF_Query' ) ) {
59 59
 					/**
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
 					 * Since we're using \GF_Query shorthand initialization we have to reverse the order parameters here.
63 63
 					 */
64 64
 					add_filter( 'gravityview_get_entries', $filter = function( $parameters, $args, $form_id ) {
65
-						if ( ! empty( $parameters['sorting'] ) ) {
65
+						if ( ! empty( $parameters[ 'sorting' ] ) ) {
66 66
 							/**
67 67
 							 * Reverse existing sorts.
68 68
 							 */
69
-							$sort = &$parameters['sorting'];
70
-							$sort['direction'] = $sort['direction'] == 'RAND' ? : ( $sort['direction'] == 'ASC' ? 'DESC' : 'ASC' );
69
+							$sort = &$parameters[ 'sorting' ];
70
+							$sort[ 'direction' ] = $sort[ 'direction' ] == 'RAND' ?: ( $sort[ 'direction' ] == 'ASC' ? 'DESC' : 'ASC' );
71 71
 						} else {
72 72
 							/**
73 73
 							 * Otherwise, sort by date_created.
74 74
 							 */
75
-							$parameters['sorting'] = array(
75
+							$parameters[ 'sorting' ] = array(
76 76
 								'key' => 'id',
77 77
 								'direction' => 'ASC',
78 78
 								'is_numeric' => true
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
 					/** If a sort already exists, reverse it. */
89 89
 					if ( $sort = end( $entries->sorts ) ) {
90
-						$entries = $entries->sort( new \GV\Entry_Sort( $sort->field, $sort->direction == \GV\Entry_Sort::RAND ? : ( $sort->direction == \GV\Entry_Sort::ASC ? \GV\Entry_Sort::DESC : \GV\Entry_Sort::ASC ) ), $sort->mode );
90
+						$entries = $entries->sort( new \GV\Entry_Sort( $sort->field, $sort->direction == \GV\Entry_Sort::RAND ?: ( $sort->direction == \GV\Entry_Sort::ASC ? \GV\Entry_Sort::DESC : \GV\Entry_Sort::ASC ) ), $sort->mode );
91 91
 					} else {
92 92
 						/** Otherwise, sort by date_created */
93 93
 						$entries = $entries->sort( new \GV\Entry_Sort( \GV\Internal_Field::by_id( 'id' ), \GV\Entry_Sort::ASC ), \GV\Entry_Sort::NUMERIC );
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
 				break;
106 106
 			default:
107 107
 				if ( ! $entry = \GV\GF_Entry::by_id( $entry_id ) ) {
108
-					gravityview()->log->error( 'Entry #{entry_id} not found', array( 'view_id' => $atts['view_id'] ) );
108
+					gravityview()->log->error( 'Entry #{entry_id} not found', array( 'view_id' => $atts[ 'view_id' ] ) );
109 109
 					return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, null, $atts );
110 110
 				}
111 111
 		endswitch;
112 112
 
113
-		if ( $view->form->ID != $entry['form_id'] ) {
113
+		if ( $view->form->ID != $entry[ 'form_id' ] ) {
114 114
 			gravityview()->log->error( 'Entry does not belong to view (form mismatch)' );
115 115
 			return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts );
116 116
 		}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 			return apply_filters( 'gravityview/shortcodes/gventry/output', get_the_password_form( $view->ID ), $view, $entry, $atts );
121 121
 		}
122 122
 
123
-		if ( ! $view->form  ) {
123
+		if ( ! $view->form ) {
124 124
 			gravityview()->log->notice( 'View #{id} has no form attached to it.', array( 'id' => $view->ID ) );
125 125
 
126 126
 			/**
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
 		}
144 144
 
145 145
 		/** Unapproved entries. */
146
-		if ( $entry['status'] != 'active' ) {
146
+		if ( $entry[ 'status' ] != 'active' ) {
147 147
 			gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
148 148
 			return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts );
149 149
 		}
150 150
 
151
-		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID );
151
+		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID );
152 152
 
153 153
 		if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
154
-			if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
154
+			if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
155 155
 				gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
156 156
 				return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts );
157 157
 			}
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		$renderer = new \GV\Entry_Renderer();
164 164
 
165 165
 		$request = new \GV\Mock_Request();
166
-		$request->returns['is_entry'] = $entry;
166
+		$request->returns[ 'is_entry' ] = $entry;
167 167
 
168 168
 		$output = $renderer->render( $entry, $view, $request );
169 169
 
Please login to merge, or discard this patch.
future/includes/class-gv-form-gravityforms.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		$self = new self();
56 56
 		$self->form = $form;
57 57
 
58
-		$self->ID = $self->form['id'];
58
+		$self->ID = $self->form[ 'id' ];
59 59
 
60 60
 		return $self;
61 61
 	}
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 	 * @return \GV\GF_Form|null An instance of this form or null if not found.
71 71
 	 */
72 72
 	public static function from_form( $form ) {
73
-		if ( empty( $form['id'] ) ) {
73
+		if ( empty( $form[ 'id' ] ) ) {
74 74
 			return null;
75 75
 		}
76 76
 
77 77
 		$self = new self();
78 78
 		$self->form = $form;
79
-		$self->ID = $self->form['id'];
79
+		$self->ID = $self->form[ 'id' ];
80 80
 
81 81
 		return $self;
82 82
 	}
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 
120 120
 			/** The offset and limit */
121 121
 			if ( ! empty( $offset->limit ) ) {
122
-				$paging['page_size'] = $offset->limit;
122
+				$paging[ 'page_size' ] = $offset->limit;
123 123
 			}
124 124
 
125 125
 			if ( ! empty( $offset->offset ) ) {
126
-				$paging['offset'] = $offset->offset;
126
+				$paging[ 'offset' ] = $offset->offset;
127 127
 			}
128 128
 
129 129
 			foreach ( \GFAPI::get_entries( $form->ID, $search_criteria, $sorting, $paging ) as $entry ) {
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	public function get_fields() {
182 182
 		$fields = array();
183
-		foreach ( $this['fields'] as $field ) {
184
-			foreach ( empty( $field['inputs'] ) ? array( $field['id'] ) : wp_list_pluck( $field['inputs'], 'id' ) as $id ) {
183
+		foreach ( $this[ 'fields' ] as $field ) {
184
+			foreach ( empty( $field[ 'inputs' ] ) ? array( $field[ 'id' ] ) : wp_list_pluck( $field[ 'inputs' ], 'id' ) as $id ) {
185 185
 				if ( is_numeric( $id ) ) {
186 186
 					$fields[ $id ] = self::get_field( $this, $id );
187 187
 				} else {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @return bool Whether the offset exists or not.
219 219
 	 */
220 220
 	public function offsetExists( $offset ) {
221
-		return isset( $this->form[$offset] );
221
+		return isset( $this->form[ $offset ] );
222 222
 	}
223 223
 
224 224
 	/**
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * @return mixed The value of the requested form data.
234 234
 	 */
235 235
 	public function offsetGet( $offset ) {
236
-		return $this->form[$offset];
236
+		return $this->form[ $offset ];
237 237
 	}
238 238
 
239 239
 	/**
Please login to merge, or discard this patch.
future/includes/class-gv-field-internal.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@
 block discarded – undo
29 29
 	 */
30 30
 	public static function from_configuration( $configuration ) {
31 31
 
32
-		if ( empty( $configuration['id'] ) || ! is_string( $configuration['id'] ) ) {
32
+		if ( empty( $configuration[ 'id' ] ) || ! is_string( $configuration[ 'id' ] ) ) {
33 33
 			gravityview()->log->error( 'Invalid configuration[id] supplied.' );
34 34
 			return null;
35 35
 		}
36 36
 
37
-		$field = self::by_id( $configuration['id'] );
37
+		$field = self::by_id( $configuration[ 'id' ] );
38 38
 
39 39
 		$field->update_configuration( $configuration );
40 40
 
Please login to merge, or discard this patch.
includes/class-gravityview-entry-approval.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 	private function add_hooks() {
40 40
 
41 41
 		// in case entry is edited (on admin or frontend)
42
-		add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2);
42
+		add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2 );
43 43
 
44 44
 		// when using the User opt-in field, check on entry submission
45 45
 		add_action( 'gform_after_submission', array( $this, 'after_submission' ), 10, 2 );
46 46
 
47 47
 		// process ajax approve entry requests
48
-		add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved'));
48
+		add_action( 'wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved' ) );
49 49
 
50 50
 	}
51 51
 
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public static function get_entry_status( $entry, $value_or_label = 'label' ) {
64 64
 
65
-		$entry_id = is_array( $entry ) ? $entry['id'] : GVCommon::get_entry_id( $entry, true );
65
+		$entry_id = is_array( $entry ) ? $entry[ 'id' ] : GVCommon::get_entry_id( $entry, true );
66 66
 
67 67
 		$status = gform_get_meta( $entry_id, self::meta_key );
68 68
 
69 69
 		$status = GravityView_Entry_Approval_Status::maybe_convert_status( $status );
70 70
 
71
-		if( 'value' === $value_or_label ) {
71
+		if ( 'value' === $value_or_label ) {
72 72
 			return $status;
73 73
 		}
74 74
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		$nonce = \GV\Utils::_POST( 'nonce' );
107 107
 
108 108
 		// Valid status
109
-		if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) {
109
+		if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) {
110 110
 
111 111
 			gravityview()->log->error( 'Invalid approval status', array( 'data' => $_POST ) );
112 112
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 
138 138
 			gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' );
139 139
 
140
-			$result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview') );
140
+			$result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview' ) );
141 141
 
142 142
 		}
143 143
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 * @param $form array Gravity Forms form object
171 171
 	 */
172 172
 	public function after_submission( $entry, $form ) {
173
-		$this->after_update_entry_update_approved_meta( $form , $entry['id'] );
173
+		$this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] );
174 174
 	}
175 175
 
176 176
 	/**
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
 	 */
185 185
 	public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) {
186 186
 
187
-		$approved_column = self::get_approved_column( $form['id'] );
187
+		$approved_column = self::get_approved_column( $form[ 'id' ] );
188 188
 
189 189
 		/**
190 190
 		 * If the form doesn't contain the approve field, don't assume anything.
191 191
 		 */
192
-		if( empty( $approved_column ) ) {
192
+		if ( empty( $approved_column ) ) {
193 193
 			return;
194 194
 		}
195 195
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 			$value = GravityView_Entry_Approval_Status::APPROVED;
204 204
 		}
205 205
 
206
-		self::update_approved_meta( $entry_id, $value, $form['id'] );
206
+		self::update_approved_meta( $entry_id, $value, $form[ 'id' ] );
207 207
 	}
208 208
 
209 209
 	/**
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
 	 */
222 222
 	public static function update_bulk( $entries = array(), $approved, $form_id ) {
223 223
 
224
-		if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) {
224
+		if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) {
225 225
 			gravityview()->log->error( 'Entries were empty or malformed.', array( 'data' => $entries ) );
226 226
 			return NULL;
227 227
 		}
228 228
 
229
-		if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) {
229
+		if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) {
230 230
 			gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' );
231 231
 			return NULL;
232 232
 		}
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
 		$approved_column_id = self::get_approved_column( $form_id );
242 242
 
243 243
 		$success = true;
244
-		foreach( $entries as $entry_id ) {
244
+		foreach ( $entries as $entry_id ) {
245 245
 			$update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id );
246 246
 
247
-			if( ! $update_success ) {
247
+			if ( ! $update_success ) {
248 248
 				$success = false;
249 249
 			}
250 250
 		}
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 	 */
269 269
 	public static function update_approved( $entry_id = 0, $approved = 2, $form_id = 0, $approvedcolumn = 0 ) {
270 270
 
271
-		if( !class_exists( 'GFAPI' ) ) {
271
+		if ( ! class_exists( 'GFAPI' ) ) {
272 272
 			gravityview()->log->error( 'GFAPI does not exist' );
273 273
 			return false;
274 274
 		}
275 275
 
276
-		if( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) {
276
+		if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) {
277 277
 			gravityview()->log->error( 'Not a valid approval value.' );
278 278
 			return false;
279 279
 		}
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 		// If the form has an Approve/Reject field, update that value
291 291
 		$result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn );
292 292
 
293
-		if( is_wp_error( $result ) ) {
293
+		if ( is_wp_error( $result ) ) {
294 294
 			gravityview()->log->error( 'Entry approval not updated: {error}', array( 'error' => $result->get_error_message() ) );
295 295
 			return false;
296 296
 		}
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
 		// add note to entry if approval field updating worked or there was no approved field
304 304
 		// There's no validation for the meta
305
-		if( true === $result ) {
305
+		if ( true === $result ) {
306 306
 
307 307
 			// Add an entry note
308 308
 			self::add_approval_status_updated_note( $entry_id, $approved );
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 
356 356
 		$note_id = false;
357 357
 
358
-		if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) {
358
+		if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) {
359 359
 
360 360
 			$current_user = wp_get_current_user();
361 361
 
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	 */
378 378
 	private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) {
379 379
 
380
-		if( empty( $approvedcolumn ) ) {
380
+		if ( empty( $approvedcolumn ) ) {
381 381
 			$approvedcolumn = self::get_approved_column( $form_id );
382 382
 		}
383 383
 
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
 		$status = GravityView_Entry_Approval_Status::maybe_convert_status( $status );
401 401
 
402 402
 		$new_value = '';
403
-		if( GravityView_Entry_Approval_Status::APPROVED === $status ) {
403
+		if ( GravityView_Entry_Approval_Status::APPROVED === $status ) {
404 404
 			$new_value = self::get_approved_column_input_label( $form_id, $approvedcolumn );
405 405
 		}
406 406
 
407 407
 		//update entry
408
-		$entry["{$approvedcolumn}"] = $new_value;
408
+		$entry[ "{$approvedcolumn}" ] = $new_value;
409 409
 
410 410
 		/**
411 411
 		 * Note: GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves
@@ -436,12 +436,12 @@  discard block
 block discarded – undo
436 436
 		// If the user has enabled a different value than the label (for some reason), use it.
437 437
 		// This is highly unlikely
438 438
 		if ( is_array( $field->choices ) && ! empty( $field->choices ) ) {
439
-			return isset( $field->choices[0]['value'] ) ? $field->choices[0]['value'] : $field->choices[0]['text'];
439
+			return isset( $field->choices[ 0 ][ 'value' ] ) ? $field->choices[ 0 ][ 'value' ] : $field->choices[ 0 ][ 'text' ];
440 440
 		}
441 441
 
442 442
 		// Otherwise, fall back on the inputs array
443 443
 		if ( is_array( $field->inputs ) && ! empty( $field->inputs ) ) {
444
-			return $field->inputs[0]['label'];
444
+			return $field->inputs[ 0 ][ 'label' ];
445 445
 		}
446 446
 
447 447
 		return null;
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 
476 476
 		// update entry meta
477 477
 
478
-		if( GravityView_Entry_Approval_Status::is_unapproved( $status ) ) {
478
+		if ( GravityView_Entry_Approval_Status::is_unapproved( $status ) ) {
479 479
 			gform_delete_meta( $entry_id, self::meta_key );
480 480
 		} else {
481 481
 			gform_update_meta( $entry_id, self::meta_key, $status, $form_id );
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 		 * @since 1.18 Added "unapproved"
499 499
 		 * @param  int $entry_id ID of the Gravity Forms entry
500 500
 		 */
501
-		do_action( 'gravityview/approve_entries/' . $action , $entry_id );
501
+		do_action( 'gravityview/approve_entries/' . $action, $entry_id );
502 502
 	}
503 503
 
504 504
 	/**
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
 	 */
512 512
 	static public function get_approved_column( $form ) {
513 513
 
514
-		if( empty( $form ) ) {
514
+		if ( empty( $form ) ) {
515 515
 			return null;
516 516
 		}
517 517
 
518
-		if( !is_array( $form ) ) {
518
+		if ( ! is_array( $form ) ) {
519 519
 			$form = GVCommon::get_form( $form );
520 520
 		}
521 521
 
@@ -525,22 +525,22 @@  discard block
 block discarded – undo
525 525
 		 * @var string $key
526 526
 		 * @var GF_Field $field
527 527
 		 */
528
-		foreach( $form['fields'] as $key => $field ) {
528
+		foreach ( $form[ 'fields' ] as $key => $field ) {
529 529
 
530 530
 			$inputs = $field->get_entry_inputs();
531 531
 
532
-			if( !empty( $field->gravityview_approved ) ) {
533
-				if ( ! empty( $inputs ) && !empty( $inputs[0]['id'] ) ) {
534
-					$approved_column_id = $inputs[0]['id'];
532
+			if ( ! empty( $field->gravityview_approved ) ) {
533
+				if ( ! empty( $inputs ) && ! empty( $inputs[ 0 ][ 'id' ] ) ) {
534
+					$approved_column_id = $inputs[ 0 ][ 'id' ];
535 535
 					break;
536 536
 				}
537 537
 			}
538 538
 
539 539
 			// Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work..
540
-			if( 'checkbox' === $field->type && ! empty( $inputs ) ) {
540
+			if ( 'checkbox' === $field->type && ! empty( $inputs ) ) {
541 541
 				foreach ( $inputs as $input ) {
542
-					if ( 'approved' === strtolower( $input['label'] ) ) {
543
-						$approved_column_id = $input['id'];
542
+					if ( 'approved' === strtolower( $input[ 'label' ] ) ) {
543
+						$approved_column_id = $input[ 'id' ];
544 544
 						break;
545 545
 					}
546 546
 				}
Please login to merge, or discard this patch.