Completed
Push — develop ( 93e220...771813 )
by Zack
18:09
created
future/_mocks.php 1 patch
Spacing   +43 added lines, -46 removed lines patch added patch discarded remove patch
@@ -102,8 +102,7 @@  discard block
 block discarded – undo
102 102
 			$entries = $view->get_entries( gravityview()->request );
103 103
 		}
104 104
 
105
-		$page = \GV\Utils::get( $parameters['paging'], 'current_page' ) ?
106
-			: ( ( ( $parameters['paging']['offset'] - $view->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 );
105
+		$page = \GV\Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $view->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 );
107 106
 
108 107
 		/** Set paging, count and unwrap the entries. */
109 108
 		$paging = array(
@@ -142,16 +141,16 @@  discard block
 block discarded – undo
142 141
  * @return null|string The value of a field in an entry.
143 142
  */
144 143
 function GravityView_API_field_value( $entry, $field_settings, $format ) {
145
-	if ( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) {
144
+	if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) {
146 145
 		gravityview()->log->error( 'No entry or field_settings[id] supplied', array( 'data' => array( func_get_args() ) ) );
147 146
 		return null;
148 147
 	}
149 148
 
150
-	if ( ! empty( $entry['_multi'] ) && ! empty( $field_settings['form_id'] ) && ! empty( $entry['_multi'][ $field_settings['form_id'] ] ) ) {
151
-		$entry = $entry['_multi'][ $field_settings['form_id'] ];
149
+	if ( ! empty( $entry[ '_multi' ] ) && ! empty( $field_settings[ 'form_id' ] ) && ! empty( $entry[ '_multi' ][ $field_settings[ 'form_id' ] ] ) ) {
150
+		$entry = $entry[ '_multi' ][ $field_settings[ 'form_id' ] ];
152 151
 	}
153 152
 
154
-	if ( empty( $entry['id'] ) || ! $entry = \GV\GF_Entry::by_id( $entry['id'] ) ) {
153
+	if ( empty( $entry[ 'id' ] ) || ! $entry = \GV\GF_Entry::by_id( $entry[ 'id' ] ) ) {
155 154
 		gravityview()->log->error( 'Invalid \GV\GF_Entry supplied', array( 'data' => $entry ) );
156 155
 		return null;
157 156
 	}
@@ -161,18 +160,18 @@  discard block
 block discarded – undo
161 160
 	 *
162 161
 	 * Fields with a numeric ID are Gravity Forms ones.
163 162
 	 */
164
-	$source = is_numeric( $field_settings['id'] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL;;
163
+	$source = is_numeric( $field_settings[ 'id' ] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL; ;
165 164
 
166 165
 	/** Initialize the future field. */
167 166
 	switch ( $source ):
168 167
 		/** The Gravity Forms backend. */
169 168
 		case \GV\Source::BACKEND_GRAVITYFORMS:
170
-			if ( ! $form = \GV\GF_Form::by_id( $entry['form_id'] ) ) {
169
+			if ( ! $form = \GV\GF_Form::by_id( $entry[ 'form_id' ] ) ) {
171 170
 				gravityview()->log->error( 'No form Gravity Form found for entry', array( 'data' => $entry ) );
172 171
 				return null;
173 172
 			}
174 173
 
175
-			if ( ! $field = $form::get_field( $form, $field_settings['id'] ) ) {
174
+			if ( ! $field = $form::get_field( $form, $field_settings[ 'id' ] ) ) {
176 175
 				return null;
177 176
 			}
178 177
 
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
 
181 180
 		/** Our internal backend. */
182 181
 		case \GV\Source::BACKEND_INTERNAL:
183
-			if ( ! $field = \GV\Internal_Source::get_field( $field_settings['id'] ) ) {
182
+			if ( ! $field = \GV\Internal_Source::get_field( $field_settings[ 'id' ] ) ) {
184 183
 				return null;
185 184
 			}
186 185
 
@@ -214,13 +213,13 @@  discard block
 block discarded – undo
214 213
 
215 214
 	/** A bail condition. */
216 215
 	$bail = function( $label, $field_settings, $entry, $force_show_label, $form ) {
217
-		if ( ! empty( $field_settings['show_label'] ) || $force_show_label ) {
216
+		if ( ! empty( $field_settings[ 'show_label' ] ) || $force_show_label ) {
218 217
 
219
-			$label = isset( $field_settings['label'] ) ? $field_settings['label'] : '';
218
+			$label = isset( $field_settings[ 'label' ] ) ? $field_settings[ 'label' ] : '';
220 219
 
221 220
 			// Use Gravity Forms label by default, but if a custom label is defined in GV, use it.
222
-			if ( ! empty( $field_settings['custom_label'] ) ) {
223
-				$label = \GravityView_API::replace_variables( $field_settings['custom_label'], $form, $entry );
221
+			if ( ! empty( $field_settings[ 'custom_label' ] ) ) {
222
+				$label = \GravityView_API::replace_variables( $field_settings[ 'custom_label' ], $form, $entry );
224 223
 			}
225 224
 
226 225
 			/**
@@ -246,19 +245,19 @@  discard block
 block discarded – undo
246 245
 
247 246
 	$label = '';
248 247
 
249
-	if ( ! empty( $entry['_multi'] ) && ! empty( $field_settings['form_id'] ) && ! empty( $entry['_multi'][ $field_settings['form_id'] ] ) ) {
250
-		$entry = $entry['_multi'][ $field_settings['form_id'] ];
251
-		if ( $_form = \GV\GF_Form::by_id( $field_settings['form_id'] ) ) {
248
+	if ( ! empty( $entry[ '_multi' ] ) && ! empty( $field_settings[ 'form_id' ] ) && ! empty( $entry[ '_multi' ][ $field_settings[ 'form_id' ] ] ) ) {
249
+		$entry = $entry[ '_multi' ][ $field_settings[ 'form_id' ] ];
250
+		if ( $_form = \GV\GF_Form::by_id( $field_settings[ 'form_id' ] ) ) {
252 251
 			$form = $_form->form;
253 252
 		}
254 253
 	}
255 254
 
256
-	if ( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) {
255
+	if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) {
257 256
 		gravityview()->log->error( 'No entry or field_settings[id] supplied', array( 'data' => array( func_get_args() ) ) );
258 257
 		return $bail( $label, $field_settings, $entry, $force_show_label, $form );
259 258
 	}
260 259
 
261
-	if ( empty( $entry['id'] ) || ! $gv_entry = \GV\GF_Entry::by_id( $entry['id'] ) ) {
260
+	if ( empty( $entry[ 'id' ] ) || ! $gv_entry = \GV\GF_Entry::by_id( $entry[ 'id' ] ) ) {
262 261
 		gravityview()->log->error( 'Invalid \GV\GF_Entry supplied', array( 'data' => $entry ) );
263 262
 		return $bail( $label, $field_settings, $entry, $force_show_label, $form );
264 263
 	}
@@ -270,31 +269,31 @@  discard block
 block discarded – undo
270 269
 	 *
271 270
 	 * Fields with a numeric ID are Gravity Forms ones.
272 271
 	 */
273
-	$source = is_numeric( $field_settings['id'] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL;
272
+	$source = is_numeric( $field_settings[ 'id' ] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL;
274 273
 
275 274
 	/** Initialize the future field. */
276 275
 	switch ( $source ):
277 276
 		/** The Gravity Forms backend. */
278 277
 		case \GV\Source::BACKEND_GRAVITYFORMS:
279
-			if ( ! $gf_form = \GV\GF_Form::by_id( $entry['form_id'] ) ) {
278
+			if ( ! $gf_form = \GV\GF_Form::by_id( $entry[ 'form_id' ] ) ) {
280 279
 				gravityview()->log->error( 'No form Gravity Form found for entry', array( 'data' => $entry ) );
281 280
 				return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $form );
282 281
 			}
283 282
 
284
-			if ( ! $field = $gf_form::get_field( $gf_form, $field_settings['id'] ) ) {
285
-				gravityview()->log->error( 'No field found for specified form and field ID #{field_id}', array( 'field_id' => $field_settings['id'], 'data' => $form ) );
283
+			if ( ! $field = $gf_form::get_field( $gf_form, $field_settings[ 'id' ] ) ) {
284
+				gravityview()->log->error( 'No field found for specified form and field ID #{field_id}', array( 'field_id' => $field_settings[ 'id' ], 'data' => $form ) );
286 285
 				return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $gf_form->form );
287 286
 			}
288
-			if ( empty( $field_settings['show_label'] ) ) {
287
+			if ( empty( $field_settings[ 'show_label' ] ) ) {
289 288
 				/** The label never wins... */
290
-				$field_settings['label'] = '';
289
+				$field_settings[ 'label' ] = '';
291 290
 			}
292 291
 
293 292
 			break;
294 293
 
295 294
 		/** Our internal backend. */
296 295
 		case \GV\Source::BACKEND_INTERNAL:
297
-			if ( ! $field = \GV\Internal_Source::get_field( $field_settings['id'] ) ) {
296
+			if ( ! $field = \GV\Internal_Source::get_field( $field_settings[ 'id' ] ) ) {
298 297
 				return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $form );
299 298
 			}
300 299
 			break;
@@ -306,8 +305,8 @@  discard block
 block discarded – undo
306 305
 			break;
307 306
 	endswitch;
308 307
 
309
-	if( $force_show_label ) {
310
-		$field_settings['show_label'] = '1';
308
+	if ( $force_show_label ) {
309
+		$field_settings[ 'show_label' ] = '1';
311 310
 	}
312 311
 
313 312
 	/** Add the field settings. */
@@ -442,7 +441,7 @@  discard block
 block discarded – undo
442 441
 			'\GravityView_frontend::entry' => \GravityView_frontend::getInstance()->getEntry(),
443 442
 			'\GravityView_View::_current_entry' => \GravityView_View::getInstance()->getCurrentEntry(),
444 443
 			'\GravityView_View::fields' => \GravityView_View::getInstance()->getFields(),
445
-			'wp_actions[loop_start]' => empty( $wp_actions['loop_start'] ) ? 0 : $wp_actions['loop_start'],
444
+			'wp_actions[loop_start]' => empty( $wp_actions[ 'loop_start' ] ) ? 0 : $wp_actions[ 'loop_start' ],
446 445
 			'wp_query::in_the_loop' => $wp_query->in_the_loop,
447 446
 		);
448 447
 	}
@@ -530,7 +529,7 @@  discard block
 block discarded – undo
530 529
 					break;
531 530
 				case 'wp_actions[loop_start]':
532 531
 					global $wp_actions;
533
-					$wp_actions['loop_start'] = $value;
532
+					$wp_actions[ 'loop_start' ] = $value;
534 533
 					break;
535 534
 				case 'wp_query::in_the_loop':
536 535
 					global $wp_query;
@@ -626,9 +625,7 @@  discard block
 block discarded – undo
626 625
 				case 'request':
627 626
 					self::thaw( array(
628 627
 						'\GravityView_View::context' => (
629
-							$value->is_entry() ? 'single' :
630
-							( $value->is_edit_entry() ? 'edit' :
631
-									( $value->is_view() ? 'directory': null )
628
+							$value->is_entry() ? 'single' : ( $value->is_edit_entry() ? 'edit' : ( $value->is_view() ? 'directory' : null )
632 629
 								)
633 630
 						),
634 631
 						'\GravityView_frontend::is_search' => $value->is_search(),
@@ -682,14 +679,14 @@  discard block
 block discarded – undo
682 679
 		global $wp_query, $wp_actions;
683 680
 
684 681
 		$wp_query->in_the_loop = false;
685
-		$wp_actions['loop_start'] = 0;
682
+		$wp_actions[ 'loop_start' ] = 0;
686 683
 	}
687 684
 }
688 685
 
689 686
 
690 687
 /** Add some global fix for field capability discrepancies. */
691 688
 add_filter( 'gravityview/configuration/fields', function( $fields ) {
692
-	if ( empty( $fields  ) ) {
689
+	if ( empty( $fields ) ) {
693 690
 		return $fields;
694 691
 	}
695 692
 
@@ -716,11 +713,11 @@  discard block
 block discarded – undo
716 713
 		}
717 714
 
718 715
 		foreach ( $_fields as $uid => &$_field ) {
719
-			if ( ! isset( $_field['only_loggedin'] ) ) {
716
+			if ( ! isset( $_field[ 'only_loggedin' ] ) ) {
720 717
 				continue;
721 718
 			}
722 719
 			/** If we do not require login, we don't require a cap. */
723
-			$_field['only_loggedin'] != '1' && ( $_field['only_loggedin_cap'] = '' );
720
+			$_field[ 'only_loggedin' ] != '1' && ( $_field[ 'only_loggedin_cap' ] = '' );
724 721
 		}
725 722
 	}
726 723
 	return $fields;
@@ -751,8 +748,8 @@  discard block
 block discarded – undo
751 748
 		}
752 749
 
753 750
 		foreach ( $_fields as $uid => &$_field ) {
754
-			if ( ! empty( $_field['id'] ) && is_numeric( $_field['id'] ) && empty( $_field['form_id'] ) ) {
755
-				$_field['form_id'] = $view->form->ID;
751
+			if ( ! empty( $_field[ 'id' ] ) && is_numeric( $_field[ 'id' ] ) && empty( $_field[ 'form_id' ] ) ) {
752
+				$_field[ 'form_id' ] = $view->form->ID;
756 753
 			}
757 754
 		}
758 755
 	}
@@ -766,25 +763,25 @@  discard block
 block discarded – undo
766 763
 	if ( class_exists( '\GravityView_frontend' ) ) {
767 764
 		global $wp_filter;
768 765
 
769
-		if ( empty( $wp_filter['gravityview_after'] ) ) {
766
+		if ( empty( $wp_filter[ 'gravityview_after' ] ) ) {
770 767
 			return;
771 768
 		}
772 769
 
773 770
 		/** WordPress 4.6 and lower compatibility, when WP_Hook classes were still absent. */
774
-		if ( is_array( $wp_filter['gravityview_after'] ) ) {
775
-			if ( ! empty( $wp_filter['gravityview_after'][10] ) ) {
776
-				foreach ( $wp_filter['gravityview_after'][10] as $function_key => $callback ) {
771
+		if ( is_array( $wp_filter[ 'gravityview_after' ] ) ) {
772
+			if ( ! empty( $wp_filter[ 'gravityview_after' ][ 10 ] ) ) {
773
+				foreach ( $wp_filter[ 'gravityview_after' ][ 10 ] as $function_key => $callback ) {
777 774
 					if ( strpos( $function_key, 'context_not_configured_warning' ) ) {
778
-						unset( $wp_filter['gravityview_after'][10][ $function_key ] );
775
+						unset( $wp_filter[ 'gravityview_after' ][ 10 ][ $function_key ] );
779 776
 					}
780 777
 				}
781 778
 			}
782 779
 			return;
783 780
 		}
784 781
 
785
-		foreach ( $wp_filter['gravityview_after']->callbacks[10] as $function_key => $callback ) {
782
+		foreach ( $wp_filter[ 'gravityview_after' ]->callbacks[ 10 ] as $function_key => $callback ) {
786 783
 			if ( strpos( $function_key, 'context_not_configured_warning' ) ) {
787
-				unset( $wp_filter['gravityview_after']->callbacks[10][ $function_key ] );
784
+				unset( $wp_filter[ 'gravityview_after' ]->callbacks[ 10 ][ $function_key ] );
788 785
 			}
789 786
 		}
790 787
 	}
Please login to merge, or discard this patch.