Completed
Push — develop ( 18c868...ba95ea )
by Gennady
42:44
created
future/includes/class-gv-request.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -128,10 +128,10 @@
 block discarded – undo
128 128
 	 */
129 129
 	public function is_edit_entry( $form_id = 0 ) {
130 130
 		/**
131
-		* @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n
132
-		* The Edit Entry functionality overrides this value.
133
-		* @param boolean $is_edit_entry
134
-		*/
131
+		 * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n
132
+		 * The Edit Entry functionality overrides this value.
133
+		 * @param boolean $is_edit_entry
134
+		 */
135 135
 		if ( ( $entry = $this->is_entry( $form_id ) ) && apply_filters( 'gravityview_is_edit_entry', false ) ) {
136 136
 			return $entry;
137 137
 		}
Please login to merge, or discard this patch.
future/includes/class-gv-view.php 1 patch
Spacing   +25 added lines, -26 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
 				}
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 
333 333
 			$error = \GVCommon::check_entry_display( $entry->as_entry(), $view );
334 334
 
335
-			if( is_wp_error( $error ) ) {
335
+			if ( is_wp_error( $error ) ) {
336 336
 				gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing: {message}', array( 'entry_id' => $entry->ID, 'message' => $error->get_error_message() ) );
337 337
 				return __( 'You are not allowed to view this content.', 'gravityview' );
338 338
 			}
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 			$join_column    = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field( $join_column );
502 502
 			$join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field( $join_on_column );
503 503
 
504
-			$joins [] = new Join( $join, $join_column, $join_on, $join_on_column );
504
+			$joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column );
505 505
 		}
506 506
 
507 507
 		return $joins;
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
 
544 544
 			list( $join, $join_column, $join_on, $join_on_column ) = $meta;
545 545
 
546
-			$forms_ids [] = GF_Form::by_id( $join_on );
546
+			$forms_ids [ ] = GF_Form::by_id( $join_on );
547 547
 		}
548 548
 
549
-		return ( !empty( $forms_ids) ) ? $forms_ids : null;
549
+		return ( ! empty( $forms_ids ) ) ? $forms_ids : null;
550 550
 	}
551 551
 
552 552
 	/**
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 		if ( ! $view->form ) {
585 585
 			gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array(
586 586
 				'view_id' => $view->ID,
587
-				'form_id' => $view->_gravityview_form_id ? : 0,
587
+				'form_id' => $view->_gravityview_form_id ?: 0,
588 588
 			) );
589 589
 		}
590 590
 
@@ -817,28 +817,27 @@  discard block
 block discarded – undo
817 817
 			 * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead
818 818
 			 */
819 819
 			$parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID );
820
-			$parameters['context_view_id'] = $this->ID;
820
+			$parameters[ 'context_view_id' ] = $this->ID;
821 821
 			$parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID );
822 822
 
823 823
 			if ( $request instanceof REST\Request ) {
824 824
 				$atts = $this->settings->as_atts();
825 825
 				$paging_parameters = wp_parse_args( $request->get_paging(), array(
826
-						'paging' => array( 'page_size' => $atts['page_size'] ),
826
+						'paging' => array( 'page_size' => $atts[ 'page_size' ] ),
827 827
 					) );
828
-				$parameters['paging'] = $paging_parameters['paging'];
828
+				$parameters[ 'paging' ] = $paging_parameters[ 'paging' ];
829 829
 			}
830 830
 
831
-			$page = Utils::get( $parameters['paging'], 'current_page' ) ?
832
-				: ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 );
831
+			$page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 );
833 832
 
834 833
 			if ( gravityview()->plugin->supports( Plugin::FEATURE_GFQUERY ) ) {
835 834
 				/**
836 835
 				 * New \GF_Query stuff :)
837 836
 				 */
838
-				$query = new \GF_Query( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] );
837
+				$query = new \GF_Query( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] );
839 838
 
840
-				$query->limit( $parameters['paging']['page_size'] )
841
-					->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) );
839
+				$query->limit( $parameters[ 'paging' ][ 'page_size' ] )
840
+					->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) );
842 841
 
843 842
 				/**
844 843
 				 * Any joins?
@@ -878,15 +877,15 @@  discard block
 block discarded – undo
878 877
 				} );
879 878
 			} else {
880 879
 				$entries = $this->form->entries
881
-					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) )
880
+					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) )
882 881
 					->offset( $this->settings->get( 'offset' ) )
883
-					->limit( $parameters['paging']['page_size'] )
882
+					->limit( $parameters[ 'paging' ][ 'page_size' ] )
884 883
 					->page( $page );
885 884
 
886
-				if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) {
885
+				if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) {
887 886
 					$field = new \GV\Field();
888
-					$field->ID = $parameters['sorting']['key'];
889
-					$direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
887
+					$field->ID = $parameters[ 'sorting' ][ 'key' ];
888
+					$direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
890 889
 					$entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) );
891 890
 				}
892 891
 			}
Please login to merge, or discard this patch.
future/includes/class-gv-renderer.php 1 patch
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
 				$tab = __( 'Edit Entry', 'gravityview' );
41 41
 				$context = 'edit';
42 42
 				break;
43
-			case ( $gravityview->request->is_entry( $gravityview->view->form ? $gravityview->view->form->ID : 0 ) ):
44
-				$tab = __( 'Single Entry', 'gravityview' );
43
+			case ( $gravityview->request->is_entry( $gravityview->view->form ? $gravityview->view->form->ID : 0 ) ) : $tab = __( 'Single Entry', 'gravityview' );
45 44
 				$context = 'single';
46 45
 				break;
47 46
 			default:
@@ -61,7 +60,7 @@  discard block
 block discarded – undo
61 60
 		$action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab );
62 61
 		$message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' );
63 62
 
64
-		$image =  sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) );
63
+		$image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) );
65 64
 		$output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message );
66 65
 
67 66
 		echo \GVCommon::generate_notice( $output . $image, 'gv-error error', 'edit_gravityview', $gravityview->view->ID );
Please login to merge, or discard this patch.
future/includes/class-gv-shortcode-gravityview.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 			'detail' => null,
42 42
 		) );
43 43
 		
44
-		if ( ! $view_id = $atts['id'] ? : $atts['view_id'] ) {
45
-			if ( $atts['detail'] && $view = $request->is_view() ) {
44
+		if ( ! $view_id = $atts[ 'id' ] ?: $atts[ 'view_id' ] ) {
45
+			if ( $atts[ 'detail' ] && $view = $request->is_view() ) {
46 46
 				$view_id = $view->ID;
47 47
 			}
48 48
 		}
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
 			}
112 112
 		}
113 113
 
114
-		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID );
114
+		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID );
115 115
 
116 116
 		/**
117 117
 		 * View details.
118 118
 		 */
119
-		if ( $atts['detail'] ) {
119
+		if ( $atts[ 'detail' ] ) {
120 120
 			$entries = $view->get_entries( $request );
121 121
 			return self::_return( $this->detail( $view, $entries, $atts ) );
122 122
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 				return self::_return( '' );
134 134
 			}
135 135
 
136
-			if ( $entry['status'] != 'active' ) {
136
+			if ( $entry[ 'status' ] != 'active' ) {
137 137
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
138 138
 				return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
139 139
 			}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 			}
145 145
 
146 146
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
147
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
147
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
148 148
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
149 149
 					return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
150 150
 				}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 				return self::_return( '' );
165 165
 			}
166 166
 
167
-			if ( $entry['status'] != 'active' ) {
167
+			if ( $entry[ 'status' ] != 'active' ) {
168 168
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
169 169
 				return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
170 170
 			}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 			}
176 176
 
177 177
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
178
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
178
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
179 179
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
180 180
 					return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
181 181
 				}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
 			$error = \GVCommon::check_entry_display( $entry->as_entry(), $view );
185 185
 
186
-			if( is_wp_error( $error ) ) {
186
+			if ( is_wp_error( $error ) ) {
187 187
 				gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing: {message}', array( 'entry_id' => $entry->ID, 'message' => $error->get_error_message() ) );
188 188
 				return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) );
189 189
 			}
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 				
200 200
 				// Mock the request with the actual View, not the global one
201 201
 				$mock_request = new \GV\Mock_Request();
202
-				$mock_request->returns['is_view'] = $view;
203
-				$mock_request->returns['is_entry'] = $request->is_entry( $view->form ? $view->form->ID : 0 );
204
-				$mock_request->returns['is_edit_entry'] = $request->is_edit_entry( $view->form ? $view->form->ID : 0 );
205
-				$mock_request->returns['is_search'] = $request->is_search();
202
+				$mock_request->returns[ 'is_view' ] = $view;
203
+				$mock_request->returns[ 'is_entry' ] = $request->is_entry( $view->form ? $view->form->ID : 0 );
204
+				$mock_request->returns[ 'is_edit_entry' ] = $request->is_edit_entry( $view->form ? $view->form->ID : 0 );
205
+				$mock_request->returns[ 'is_search' ] = $request->is_search();
206 206
 
207 207
 				$request = $mock_request;
208 208
 			}
@@ -238,16 +238,16 @@  discard block
 block discarded – undo
238 238
 		$filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' );
239 239
 
240 240
 		// Only keep the passed attributes after making sure that they're valid pairs
241
-		$filtered_atts = array_intersect_key( (array) $passed_atts, $filtered_atts );
241
+		$filtered_atts = array_intersect_key( (array)$passed_atts, $filtered_atts );
242 242
 
243 243
 		$atts = array();
244 244
 
245
-		foreach( $filtered_atts as $key => $passed_value ) {
245
+		foreach ( $filtered_atts as $key => $passed_value ) {
246 246
 
247 247
 			// Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by}
248 248
 			$passed_value = \GravityView_Merge_Tags::replace_variables( $passed_value );
249 249
 
250
-			switch( $defaults[ $key ]['type'] ) {
250
+			switch ( $defaults[ $key ][ 'type' ] ) {
251 251
 
252 252
 				/**
253 253
 				 * Make sure number fields are numeric.
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 				 * @see http://php.net/manual/en/function.is-numeric.php#107326
256 256
 				 */
257 257
 				case 'number':
258
-					if( is_numeric( $passed_value ) ) {
258
+					if ( is_numeric( $passed_value ) ) {
259 259
 						$atts[ $key ] = ( $passed_value + 0 );
260 260
 					}
261 261
 					break;
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 				 */
271 271
 				case 'select':
272 272
 				case 'radio':
273
-					$options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options'];
274
-					if( in_array( $passed_value, array_keys( $options ) ) ) {
273
+					$options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ];
274
+					if ( in_array( $passed_value, array_keys( $options ) ) ) {
275 275
 						$atts[ $key ] = $passed_value;
276 276
 					}
277 277
 					break;
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 			}
284 284
 		}
285 285
 
286
-		$atts['detail'] = \GV\Utils::get( $passed_atts, 'detail', null );
286
+		$atts[ 'detail' ] = \GV\Utils::get( $passed_atts, 'detail', null );
287 287
 
288 288
 		return $atts;
289 289
 	}
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	private function detail( $view, $entries, $atts ) {
301 301
 		$output = '';
302 302
 
303
-		switch ( $key = $atts['detail'] ):
303
+		switch ( $key = $atts[ 'detail' ] ):
304 304
 			case 'total_entries':
305 305
 				$output = number_format_i18n( $entries->total() );
306 306
 				break;
Please login to merge, or discard this patch.