Completed
Pull Request — master (#1028)
by Gennady
37:45 queued 18:37
created
future/includes/class-gv-template-view-table.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 
20 20
 
21 21
 	/**
22
-     * Constructor. Add filters to modify output.
23
-     *
22
+	 * Constructor. Add filters to modify output.
23
+	 *
24 24
 	 * @since 2.0.4
25 25
 	 *
26 26
 	 * @param View $view
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function __construct( View $view, Entry_Collection $entries, Request $request ) {
31 31
 
32
-	    add_filter( 'gravityview/template/field/label', array( $this, 'add_columns_sort_links' ), 100, 2 );
32
+		add_filter( 'gravityview/template/field/label', array( $this, 'add_columns_sort_links' ), 100, 2 );
33 33
 
34 34
 		parent::__construct( $view, $entries, $request );
35 35
 	}
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	/**
48
-     * Add sorting links to HTML columns that support sorting
49
-     *
50
-     * @since 2.0.4
51
-     *
48
+	 * Add sorting links to HTML columns that support sorting
49
+	 *
50
+	 * @since 2.0.4
51
+	 *
52 52
 	 * @param string $column_label Label for the table column
53 53
 	 * @param \GV\Template_Context $context
54 54
 	 *
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$sort_columns = $context->view->settings->get( 'sort_columns' );
60 60
 
61 61
 		if ( empty( $sort_columns ) ) {
62
-            return $column_label;
62
+			return $column_label;
63 63
 		}
64 64
 
65 65
 		if ( ! \GravityView_frontend::getInstance()->is_field_sortable( $context->field->ID, $context->view->form->form ) ) {
@@ -200,15 +200,15 @@  discard block
 block discarded – undo
200 200
 				 */
201 201
 				do_action( 'gravityview/template/table/cells/before', $context );
202 202
 
203
-                /**
204
-                 * @action `gravityview_table_cells_before` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells.
205
-                 * @since 1.0.7
203
+				/**
204
+				 * @action `gravityview_table_cells_before` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells.
205
+				 * @since 1.0.7
206 206
 				 * @param GravityView_View $this Current GravityView_View object
207 207
 				 * @deprecated Use `gravityview/template/table/cells/before`
208
-                 */
209
-                do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() );
208
+				 */
209
+				do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() );
210 210
 
211
-                foreach ( $fields->all() as $field ) {
211
+				foreach ( $fields->all() as $field ) {
212 212
 					$this->the_field( $field, $entry );
213 213
 				}
214 214
 
@@ -219,13 +219,13 @@  discard block
 block discarded – undo
219 219
 				 */
220 220
 				do_action( 'gravityview/template/table/cells/after', $context );
221 221
 
222
-                /**
223
-                 * @action `gravityview_table_cells_after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells.
224
-                 * @since 1.0.7
222
+				/**
223
+				 * @action `gravityview_table_cells_after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells.
224
+				 * @since 1.0.7
225 225
 				 * @param GravityView_View $this Current GravityView_View object
226 226
 				 * @deprecated Use `gravityview/template/table/cells/after`
227
-                 */
228
-                do_action( 'gravityview_table_cells_after', \GravityView_View::getInstance() );
227
+				 */
228
+				do_action( 'gravityview_table_cells_after', \GravityView_View::getInstance() );
229 229
 
230 230
 				?>
231 231
 			</tr>
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 			'hide_empty' => false,
263 263
 			'zone_id' => 'directory_table-columns',
264 264
 			'markup' => '<td id="{{ field_id }}" class="{{ class }}">{{ value }}</td>',
265
-            'form' => $form,
265
+			'form' => $form,
266 266
 		);
267 267
 
268 268
 		/** Output. */
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
 		do_action( 'gravityview/template/table/body/before', $context );
288 288
 
289 289
 		/**
290
-		* @action `gravityview_table_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows.
291
-		* @deprecated Use `gravityview/template/table/body/before`
292
-		* @since 1.0.7
293
-		* @param \GravityView_View $gravityview_view Current GravityView_View object.
294
-		*/
290
+		 * @action `gravityview_table_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows.
291
+		 * @deprecated Use `gravityview/template/table/body/before`
292
+		 * @since 1.0.7
293
+		 * @param \GravityView_View $gravityview_view Current GravityView_View object.
294
+		 */
295 295
 		do_action( 'gravityview_table_body_before', \GravityView_View::getInstance() /** ugh! */ );
296 296
 	}
297 297
 
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
 		do_action( 'gravityview/template/table/body/after', $context );
314 314
 
315 315
 		/**
316
-		* @action `gravityview_table_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows.
317
-		* @deprecated Use `gravityview/template/table/body/after`
318
-		* @since 1.0.7
319
-		* @param \GravityView_View $gravityview_view Current GravityView_View object.
320
-		*/
316
+		 * @action `gravityview_table_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows.
317
+		 * @deprecated Use `gravityview/template/table/body/after`
318
+		 * @since 1.0.7
319
+		 * @param \GravityView_View $gravityview_view Current GravityView_View object.
320
+		 */
321 321
 		do_action( 'gravityview_table_body_after', \GravityView_View::getInstance() /** ugh! */ );
322 322
 	}
323 323
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -77,22 +77,22 @@
 block discarded – undo
77 77
 			'dir' => 'asc',
78 78
 		);
79 79
 
80
-		if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) {
80
+		if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) {
81 81
 			//toggle sorting direction.
82
-			if ( 'asc' === $sorting['direction'] ) {
83
-				$sort_args['dir'] = 'desc';
82
+			if ( 'asc' === $sorting[ 'direction' ] ) {
83
+				$sort_args[ 'dir' ] = 'desc';
84 84
 				$class .= ' gv-icon-sort-desc';
85 85
 			} else {
86
-				$sort_args['dir'] = 'asc';
86
+				$sort_args[ 'dir' ] = 'asc';
87 87
 				$class .= ' gv-icon-sort-asc';
88 88
 			}
89 89
 		} else {
90 90
 			$class .= ' gv-icon-caret-up-down';
91 91
 		}
92 92
 
93
-		$url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) );
93
+		$url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) );
94 94
 
95
-		return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a>&nbsp;'. $column_label;
95
+		return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a>&nbsp;' . $column_label;
96 96
 	}
97 97
 
98 98
 	/**
Please login to merge, or discard this patch.
future/_mocks.php 1 patch
Spacing   +43 added lines, -46 removed lines patch added patch discarded remove patch
@@ -101,8 +101,7 @@  discard block
 block discarded – undo
101 101
 			$entries = $view->get_entries( gravityview()->request );
102 102
 		}
103 103
 
104
-		$page = \GV\Utils::get( $parameters['paging'], 'current_page' ) ?
105
-			: ( ( ( $parameters['paging']['offset'] - $view->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 );
104
+		$page = \GV\Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $view->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 );
106 105
 
107 106
 		/** Set paging, count and unwrap the entries. */
108 107
 		$paging = array(
@@ -141,16 +140,16 @@  discard block
 block discarded – undo
141 140
  * @return null|string The value of a field in an entry.
142 141
  */
143 142
 function GravityView_API_field_value( $entry, $field_settings, $format ) {
144
-	if ( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) {
143
+	if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) {
145 144
 		gravityview()->log->error( 'No entry or field_settings[id] supplied', array( 'data' => array( func_get_args() ) ) );
146 145
 		return null;
147 146
 	}
148 147
 
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'] ];
148
+	if ( ! empty( $entry[ '_multi' ] ) && ! empty( $field_settings[ 'form_id' ] ) && ! empty( $entry[ '_multi' ][ $field_settings[ 'form_id' ] ] ) ) {
149
+		$entry = $entry[ '_multi' ][ $field_settings[ 'form_id' ] ];
151 150
 	}
152 151
 
153
-	if ( empty( $entry['id'] ) || ! $entry = \GV\GF_Entry::by_id( $entry['id'] ) ) {
152
+	if ( empty( $entry[ 'id' ] ) || ! $entry = \GV\GF_Entry::by_id( $entry[ 'id' ] ) ) {
154 153
 		gravityview()->log->error( 'Invalid \GV\GF_Entry supplied', array( 'data' => $entry ) );
155 154
 		return null;
156 155
 	}
@@ -160,18 +159,18 @@  discard block
 block discarded – undo
160 159
 	 *
161 160
 	 * Fields with a numeric ID are Gravity Forms ones.
162 161
 	 */
163
-	$source = is_numeric( $field_settings['id'] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL;;
162
+	$source = is_numeric( $field_settings[ 'id' ] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL; ;
164 163
 
165 164
 	/** Initialize the future field. */
166 165
 	switch ( $source ):
167 166
 		/** The Gravity Forms backend. */
168 167
 		case \GV\Source::BACKEND_GRAVITYFORMS:
169
-			if ( ! $form = \GV\GF_Form::by_id( $entry['form_id'] ) ) {
168
+			if ( ! $form = \GV\GF_Form::by_id( $entry[ 'form_id' ] ) ) {
170 169
 				gravityview()->log->error( 'No form Gravity Form found for entry', array( 'data' => $entry ) );
171 170
 				return null;
172 171
 			}
173 172
 
174
-			if ( ! $field = $form::get_field( $form, $field_settings['id'] ) ) {
173
+			if ( ! $field = $form::get_field( $form, $field_settings[ 'id' ] ) ) {
175 174
 				return null;
176 175
 			}
177 176
 
@@ -179,7 +178,7 @@  discard block
 block discarded – undo
179 178
 
180 179
 		/** Our internal backend. */
181 180
 		case \GV\Source::BACKEND_INTERNAL:
182
-			if ( ! $field = \GV\Internal_Source::get_field( $field_settings['id'] ) ) {
181
+			if ( ! $field = \GV\Internal_Source::get_field( $field_settings[ 'id' ] ) ) {
183 182
 				return null;
184 183
 			}
185 184
 
@@ -213,13 +212,13 @@  discard block
 block discarded – undo
213 212
 
214 213
 	/** A bail condition. */
215 214
 	$bail = function( $label, $field_settings, $entry, $force_show_label, $form ) {
216
-		if ( ! empty( $field_settings['show_label'] ) || $force_show_label ) {
215
+		if ( ! empty( $field_settings[ 'show_label' ] ) || $force_show_label ) {
217 216
 
218
-			$label = isset( $field_settings['label'] ) ? $field_settings['label'] : '';
217
+			$label = isset( $field_settings[ 'label' ] ) ? $field_settings[ 'label' ] : '';
219 218
 
220 219
 			// Use Gravity Forms label by default, but if a custom label is defined in GV, use it.
221
-			if ( ! empty( $field_settings['custom_label'] ) ) {
222
-				$label = \GravityView_API::replace_variables( $field_settings['custom_label'], $form, $entry );
220
+			if ( ! empty( $field_settings[ 'custom_label' ] ) ) {
221
+				$label = \GravityView_API::replace_variables( $field_settings[ 'custom_label' ], $form, $entry );
223 222
 			}
224 223
 
225 224
 			/**
@@ -245,19 +244,19 @@  discard block
 block discarded – undo
245 244
 
246 245
 	$label = '';
247 246
 
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'] ) ) {
247
+	if ( ! empty( $entry[ '_multi' ] ) && ! empty( $field_settings[ 'form_id' ] ) && ! empty( $entry[ '_multi' ][ $field_settings[ 'form_id' ] ] ) ) {
248
+		$entry = $entry[ '_multi' ][ $field_settings[ 'form_id' ] ];
249
+		if ( $_form = \GV\GF_Form::by_id( $field_settings[ 'form_id' ] ) ) {
251 250
 			$form = $_form->form;
252 251
 		}
253 252
 	}
254 253
 
255
-	if ( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) {
254
+	if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) {
256 255
 		gravityview()->log->error( 'No entry or field_settings[id] supplied', array( 'data' => array( func_get_args() ) ) );
257 256
 		return $bail( $label, $field_settings, $entry, $force_show_label, $form );
258 257
 	}
259 258
 
260
-	if ( empty( $entry['id'] ) || ! $gv_entry = \GV\GF_Entry::by_id( $entry['id'] ) ) {
259
+	if ( empty( $entry[ 'id' ] ) || ! $gv_entry = \GV\GF_Entry::by_id( $entry[ 'id' ] ) ) {
261 260
 		gravityview()->log->error( 'Invalid \GV\GF_Entry supplied', array( 'data' => $entry ) );
262 261
 		return $bail( $label, $field_settings, $entry, $force_show_label, $form );
263 262
 	}
@@ -269,31 +268,31 @@  discard block
 block discarded – undo
269 268
 	 *
270 269
 	 * Fields with a numeric ID are Gravity Forms ones.
271 270
 	 */
272
-	$source = is_numeric( $field_settings['id'] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL;
271
+	$source = is_numeric( $field_settings[ 'id' ] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL;
273 272
 
274 273
 	/** Initialize the future field. */
275 274
 	switch ( $source ):
276 275
 		/** The Gravity Forms backend. */
277 276
 		case \GV\Source::BACKEND_GRAVITYFORMS:
278
-			if ( ! $gf_form = \GV\GF_Form::by_id( $entry['form_id'] ) ) {
277
+			if ( ! $gf_form = \GV\GF_Form::by_id( $entry[ 'form_id' ] ) ) {
279 278
 				gravityview()->log->error( 'No form Gravity Form found for entry', array( 'data' => $entry ) );
280 279
 				return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $form );
281 280
 			}
282 281
 
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 ) );
282
+			if ( ! $field = $gf_form::get_field( $gf_form, $field_settings[ 'id' ] ) ) {
283
+				gravityview()->log->error( 'No field found for specified form and field ID #{field_id}', array( 'field_id' => $field_settings[ 'id' ], 'data' => $form ) );
285 284
 				return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $gf_form->form );
286 285
 			}
287
-			if ( empty( $field_settings['show_label'] ) ) {
286
+			if ( empty( $field_settings[ 'show_label' ] ) ) {
288 287
 				/** The label never wins... */
289
-				$field_settings['label'] = '';
288
+				$field_settings[ 'label' ] = '';
290 289
 			}
291 290
 
292 291
 			break;
293 292
 
294 293
 		/** Our internal backend. */
295 294
 		case \GV\Source::BACKEND_INTERNAL:
296
-			if ( ! $field = \GV\Internal_Source::get_field( $field_settings['id'] ) ) {
295
+			if ( ! $field = \GV\Internal_Source::get_field( $field_settings[ 'id' ] ) ) {
297 296
 				return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $form );
298 297
 			}
299 298
 			break;
@@ -305,8 +304,8 @@  discard block
 block discarded – undo
305 304
 			break;
306 305
 	endswitch;
307 306
 
308
-	if( $force_show_label ) {
309
-		$field_settings['show_label'] = '1';
307
+	if ( $force_show_label ) {
308
+		$field_settings[ 'show_label' ] = '1';
310 309
 	}
311 310
 
312 311
 	/** Add the field settings. */
@@ -440,7 +439,7 @@  discard block
 block discarded – undo
440 439
 			'\GravityView_frontend::entry' => \GravityView_frontend::getInstance()->getEntry(),
441 440
 			'\GravityView_View::_current_entry' => \GravityView_View::getInstance()->getCurrentEntry(),
442 441
 			'\GravityView_View::fields' => \GravityView_View::getInstance()->getFields(),
443
-			'wp_actions[loop_start]' => empty( $wp_actions['loop_start'] ) ? 0 : $wp_actions['loop_start'],
442
+			'wp_actions[loop_start]' => empty( $wp_actions[ 'loop_start' ] ) ? 0 : $wp_actions[ 'loop_start' ],
444 443
 			'wp_query::in_the_loop' => $wp_query->in_the_loop,
445 444
 		);
446 445
 	}
@@ -522,7 +521,7 @@  discard block
 block discarded – undo
522 521
 					break;
523 522
 				case 'wp_actions[loop_start]':
524 523
 					global $wp_actions;
525
-					$wp_actions['loop_start'] = $value;
524
+					$wp_actions[ 'loop_start' ] = $value;
526 525
 					break;
527 526
 				case 'wp_query::in_the_loop':
528 527
 					global $wp_query;
@@ -600,9 +599,7 @@  discard block
 block discarded – undo
600 599
 				case 'request':
601 600
 					self::thaw( array(
602 601
 						'\GravityView_View::context' => (
603
-							$value->is_entry() ? 'single' :
604
-								( $value->is_edit_entry() ? 'edit' :
605
-									( $value->is_view() ? 'directory': null )
602
+							$value->is_entry() ? 'single' : ( $value->is_edit_entry() ? 'edit' : ( $value->is_view() ? 'directory' : null )
606 603
 								)
607 604
 						),
608 605
 						'\GravityView_frontend::is_search' => $value->is_search(),
@@ -656,14 +653,14 @@  discard block
 block discarded – undo
656 653
 		global $wp_query, $wp_actions;
657 654
 
658 655
 		$wp_query->in_the_loop = false;
659
-		$wp_actions['loop_start'] = 0;
656
+		$wp_actions[ 'loop_start' ] = 0;
660 657
 	}
661 658
 }
662 659
 
663 660
 
664 661
 /** Add some global fix for field capability discrepancies. */
665 662
 add_filter( 'gravityview/configuration/fields', function( $fields ) {
666
-	if ( empty( $fields  ) ) {
663
+	if ( empty( $fields ) ) {
667 664
 		return $fields;
668 665
 	}
669 666
 
@@ -690,11 +687,11 @@  discard block
 block discarded – undo
690 687
 		}
691 688
 
692 689
 		foreach ( $_fields as $uid => &$_field ) {
693
-			if ( ! isset( $_field['only_loggedin'] ) ) {
690
+			if ( ! isset( $_field[ 'only_loggedin' ] ) ) {
694 691
 				continue;
695 692
 			}
696 693
 			/** If we do not require login, we don't require a cap. */
697
-			$_field['only_loggedin'] != '1' && ( $_field['only_loggedin_cap'] = '' );
694
+			$_field[ 'only_loggedin' ] != '1' && ( $_field[ 'only_loggedin_cap' ] = '' );
698 695
 		}
699 696
 	}
700 697
 	return $fields;
@@ -725,8 +722,8 @@  discard block
 block discarded – undo
725 722
 		}
726 723
 
727 724
 		foreach ( $_fields as $uid => &$_field ) {
728
-			if ( ! empty( $_field['id'] ) && is_numeric( $_field['id'] ) && empty( $_field['form_id'] ) ) {
729
-				$_field['form_id'] = $view->form->ID;
725
+			if ( ! empty( $_field[ 'id' ] ) && is_numeric( $_field[ 'id' ] ) && empty( $_field[ 'form_id' ] ) ) {
726
+				$_field[ 'form_id' ] = $view->form->ID;
730 727
 			}
731 728
 		}
732 729
 	}
@@ -740,25 +737,25 @@  discard block
 block discarded – undo
740 737
 	if ( class_exists( '\GravityView_frontend' ) ) {
741 738
 		global $wp_filter;
742 739
 
743
-		if ( empty( $wp_filter['gravityview_after'] ) ) {
740
+		if ( empty( $wp_filter[ 'gravityview_after' ] ) ) {
744 741
 			return;
745 742
 		}
746 743
 
747 744
 		/** WordPress 4.6 and lower compatibility, when WP_Hook classes were still absent. */
748
-		if ( is_array( $wp_filter['gravityview_after'] ) ) {
749
-			if ( ! empty( $wp_filter['gravityview_after'][10] ) ) {
750
-				foreach ( $wp_filter['gravityview_after'][10] as $function_key => $callback ) {
745
+		if ( is_array( $wp_filter[ 'gravityview_after' ] ) ) {
746
+			if ( ! empty( $wp_filter[ 'gravityview_after' ][ 10 ] ) ) {
747
+				foreach ( $wp_filter[ 'gravityview_after' ][ 10 ] as $function_key => $callback ) {
751 748
 					if ( strpos( $function_key, 'context_not_configured_warning' ) ) {
752
-						unset( $wp_filter['gravityview_after'][10][ $function_key ] );
749
+						unset( $wp_filter[ 'gravityview_after' ][ 10 ][ $function_key ] );
753 750
 					}
754 751
 				}
755 752
 			}
756 753
 			return;
757 754
 		}
758 755
 
759
-		foreach ( $wp_filter['gravityview_after']->callbacks[10] as $function_key => $callback ) {
756
+		foreach ( $wp_filter[ 'gravityview_after' ]->callbacks[ 10 ] as $function_key => $callback ) {
760 757
 			if ( strpos( $function_key, 'context_not_configured_warning' ) ) {
761
-				unset( $wp_filter['gravityview_after']->callbacks[10][ $function_key ] );
758
+				unset( $wp_filter[ 'gravityview_after' ]->callbacks[ 10 ][ $function_key ] );
762 759
 			}
763 760
 		}
764 761
 	}
Please login to merge, or discard this patch.
future/lib/class-gamajo-template-loader.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		 *
86 86
 		 * @var array
87 87
 		 */
88
-		private $template_data_var_names = array('data');
88
+		private $template_data_var_names = array( 'data' );
89 89
 
90 90
 		/**
91 91
 		 * Clean up template data.
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 		public function set_template_data( $data, $var_name = 'data' ) {
139 139
 			global $wp_query;
140 140
 
141
-			$wp_query->query_vars[ $var_name ] = (object) $data;
141
+			$wp_query->query_vars[ $var_name ] = (object)$data;
142 142
 
143 143
 			// Add $var_name to custom variable store if not default value
144
-			if( $var_name !== 'data' ) {
145
-				$this->template_data_var_names[] = $var_name;
144
+			if ( $var_name !== 'data' ) {
145
+				$this->template_data_var_names[ ] = $var_name;
146 146
 			}
147 147
 
148 148
 			return $this;
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
 
166 166
 			// Remove each custom data reference from $wp_query
167 167
 			foreach ( $custom_var_names as $var ) {
168
-				if ( isset( $wp_query->query_vars[$var] ) ) {
169
-					unset( $wp_query->query_vars[$var] );
168
+				if ( isset( $wp_query->query_vars[ $var ] ) ) {
169
+					unset( $wp_query->query_vars[ $var ] );
170 170
 				}
171 171
 			}
172 172
 
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
 		protected function get_template_file_names( $slug, $name ) {
187 187
 			$templates = array();
188 188
 			if ( isset( $name ) ) {
189
-				$templates[] = $slug . '-' . $name . '.php';
189
+				$templates[ ] = $slug . '-' . $name . '.php';
190 190
 			}
191
-			$templates[] = $slug . '.php';
191
+			$templates[ ] = $slug . '.php';
192 192
 
193 193
 			/**
194 194
 			 * Allow template choices to be filtered.
@@ -224,18 +224,18 @@  discard block
 block discarded – undo
224 224
 		public function locate_template( $template_names, $load = false, $require_once = true ) {
225 225
 
226 226
 			// Use $template_names as a cache key - either first element of array or the variable itself if it's a string
227
-			$cache_key = is_array( $template_names ) ? $template_names[0] : $template_names;
227
+			$cache_key = is_array( $template_names ) ? $template_names[ 0 ] : $template_names;
228 228
 
229 229
 			// If the key is in the cache array, we've already located this file.
230
-			if ( isset( $this->template_path_cache[$cache_key] ) ) {
231
-				$located = $this->template_path_cache[$cache_key];
230
+			if ( isset( $this->template_path_cache[ $cache_key ] ) ) {
231
+				$located = $this->template_path_cache[ $cache_key ];
232 232
 			} else {
233 233
 
234 234
 				// No file found yet.
235 235
 				$located = false;
236 236
 
237 237
 				// Remove empty entries.
238
-				$template_names = array_filter( (array) $template_names );
238
+				$template_names = array_filter( (array)$template_names );
239 239
 				$template_paths = $this->get_template_paths();
240 240
 
241 241
 				// Try to find a template file.
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 						if ( file_exists( $template_path . $template_name ) ) {
249 249
 							$located = $template_path . $template_name;
250 250
 							// Store the template path in the cache
251
-							$this->template_path_cache[$cache_key] = $located;
251
+							$this->template_path_cache[ $cache_key ] = $located;
252 252
 							break 2;
253 253
 						}
254 254
 					}
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 
284 284
 			// Only add this conditionally, so non-child themes don't redundantly check active theme twice.
285 285
 			if ( get_stylesheet_directory() !== get_template_directory() ) {
286
-				$file_paths[1] = trailingslashit( get_stylesheet_directory() ) . $theme_directory;
286
+				$file_paths[ 1 ] = trailingslashit( get_stylesheet_directory() ) . $theme_directory;
287 287
 			}
288 288
 
289 289
 			/**
Please login to merge, or discard this patch.
future/includes/class-gv-view.php 1 patch
Spacing   +19 added lines, -20 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
 		/**
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		 * Editing a single entry.
283 283
 		 */
284 284
 		if ( $entry = $request->is_edit_entry() ) {
285
-			if ( $entry['status'] != 'active' ) {
285
+			if ( $entry[ 'status' ] != 'active' ) {
286 286
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
287 287
 				return __( 'You are not allowed to view this content.', 'gravityview' );
288 288
 			}
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 			}
294 294
 
295 295
 			if ( $view->settings->get( 'show_only_approved' ) ) {
296
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
296
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
297 297
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
298 298
 					return __( 'You are not allowed to view this content.', 'gravityview' );
299 299
 				}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		 * Viewing a single entry.
307 307
 		 */
308 308
 		} else if ( $entry = $request->is_entry() ) {
309
-			if ( $entry['status'] != 'active' ) {
309
+			if ( $entry[ 'status' ] != 'active' ) {
310 310
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
311 311
 				return __( 'You are not allowed to view this content.', 'gravityview' );
312 312
 			}
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 			}
318 318
 
319 319
 			if ( $view->settings->get( 'show_only_approved' ) ) {
320
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
320
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
321 321
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
322 322
 					return __( 'You are not allowed to view this content.', 'gravityview' );
323 323
 				}
@@ -365,11 +365,11 @@  discard block
 block discarded – undo
365 365
 		if ( ! $view->form ) {
366 366
 			gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array(
367 367
 				'view_id' => $view->ID,
368
-				'form_id' => $view->_gravityview_form_id ? : 0,
368
+				'form_id' => $view->_gravityview_form_id ?: 0,
369 369
 			) );
370 370
 		} else if ( gravityview()->plugin->supports( Plugin::FEATURE_JOINS ) ) {
371 371
 			/** And the connected joins. */
372
-			foreach( (array)get_post_meta( $view->ID, '_gravityview_form_joins', true ) as $_join ) {
372
+			foreach ( (array)get_post_meta( $view->ID, '_gravityview_form_joins', true ) as $_join ) {
373 373
 				if ( ! is_array( $_join ) || count( $_join ) != 4 ) {
374 374
 					continue;
375 375
 				}
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 				$join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field( $join_column );
382 382
 				$join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field( $join_on_column );
383 383
 
384
-				$view->joins []= new Join( $join, $join_column, $join_on, $join_on_column );
384
+				$view->joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column );
385 385
 			}
386 386
 		}
387 387
 
@@ -605,27 +605,26 @@  discard block
 block discarded – undo
605 605
 			 * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead
606 606
 			 */
607 607
 			$parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID );
608
-			$parameters['context_view_id'] = $this->ID;
608
+			$parameters[ 'context_view_id' ] = $this->ID;
609 609
 			$parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID );
610 610
 
611 611
 			if ( $request instanceof REST\Request ) {
612 612
 				$atts = $this->settings->as_atts();
613 613
 				$paging_parameters = wp_parse_args( $request->get_paging(), array(
614
-						'paging' => array( 'page_size' => $atts['page_size'] ),
614
+						'paging' => array( 'page_size' => $atts[ 'page_size' ] ),
615 615
 					) );
616
-				$parameters['paging'] = $paging_parameters['paging'];
616
+				$parameters[ 'paging' ] = $paging_parameters[ 'paging' ];
617 617
 			}
618 618
 
619
-			$page = Utils::get( $parameters['paging'], 'current_page' ) ?
620
-				: ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 );
619
+			$page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 );
621 620
 
622 621
 			if ( gravityview()->plugin->supports( Plugin::FEATURE_GFQUERY ) ) {
623 622
 				/**
624 623
 				 * New \GF_Query stuff :)
625 624
 				 */
626
-				$query = new \GF_Query( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] );
625
+				$query = new \GF_Query( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] );
627 626
 
628
-				$query->limit( $parameters['paging']['page_size'] )
627
+				$query->limit( $parameters[ 'paging' ][ 'page_size' ] )
629 628
 					->page( $page );
630 629
 
631 630
 				/**
@@ -666,15 +665,15 @@  discard block
 block discarded – undo
666 665
 				} );
667 666
 			} else {
668 667
 				$entries = $this->form->entries
669
-					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) )
668
+					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) )
670 669
 					->offset( $this->settings->get( 'offset' ) )
671
-					->limit( $parameters['paging']['page_size'] )
670
+					->limit( $parameters[ 'paging' ][ 'page_size' ] )
672 671
 					->page( $page );
673 672
 				
674
-				if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) {
673
+				if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) {
675 674
 					$field = new \GV\Field();
676
-					$field->ID = $parameters['sorting']['key'];
677
-					$direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
675
+					$field->ID = $parameters[ 'sorting' ][ 'key' ];
676
+					$direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
678 677
 					$entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) );
679 678
 				}
680 679
 			}
Please login to merge, or discard this patch.
future/includes/class-gv-template-field.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 		$this->request = $request;
87 87
 
88 88
 		/** Add granular overrides. */
89
-		add_filter( $this->filter_prefix . '_get_template_part', $this->_add_id_specific_templates_callback  = self::add_id_specific_templates( $this ), 10, 3 );
89
+		add_filter( $this->filter_prefix . '_get_template_part', $this->_add_id_specific_templates_callback = self::add_id_specific_templates( $this ), 10, 3 );
90 90
 
91 91
 		parent::__construct();
92 92
 	}
93 93
 
94 94
 	public function __destruct() {
95
-		remove_filter( $this->filter_prefix . '_get_template_part', $this->_add_id_specific_templates_callback );;
95
+		remove_filter( $this->filter_prefix . '_get_template_part', $this->_add_id_specific_templates_callback ); ;
96 96
 	}
97 97
 
98 98
 	/**
@@ -175,59 +175,59 @@  discard block
 block discarded – undo
175 175
 
176 176
 			if ( $is_view && $post ) {
177 177
 				if ( $field_type ) {
178
-					$specifics []= sprintf( '%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID, $view_id, $field_type, $slug_name );
179
-					$inputType && $specifics []= sprintf( '%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID, $view_id, $inputType, $slug_name );
180
-					$specifics []= sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $field_type );
181
-					$inputType && $specifics []= sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $inputType );
182
-					$specifics []= sprintf( '%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $field_type, $slug_name );
183
-					$inputType && $specifics []= sprintf( '%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $inputType, $slug_name );
184
-					$specifics []= sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $field_type );
185
-					$inputType &&  $specifics []= sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $inputType );
178
+					$specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID, $view_id, $field_type, $slug_name );
179
+					$inputType && $specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s-%s.php', $slug_dir, $post->ID, $view_id, $inputType, $slug_name );
180
+					$specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $field_type );
181
+					$inputType && $specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $inputType );
182
+					$specifics [ ] = sprintf( '%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $field_type, $slug_name );
183
+					$inputType && $specifics [ ] = sprintf( '%spost-%d-field-%s-%s.php', $slug_dir, $post->ID, $inputType, $slug_name );
184
+					$specifics [ ] = sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $field_type );
185
+					$inputType && $specifics [ ] = sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $inputType );
186 186
 				}
187 187
 
188
-				$specifics []= sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $slug_name );
189
-				$specifics []= sprintf( '%spost-%d-view-%d-field.php', $slug_dir, $post->ID, $view_id );
190
-				$specifics []= sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $slug_name );
191
-				$specifics []= sprintf( '%spost-%d-field.php', $slug_dir, $post->ID );
188
+				$specifics [ ] = sprintf( '%spost-%d-view-%d-field-%s.php', $slug_dir, $post->ID, $view_id, $slug_name );
189
+				$specifics [ ] = sprintf( '%spost-%d-view-%d-field.php', $slug_dir, $post->ID, $view_id );
190
+				$specifics [ ] = sprintf( '%spost-%d-field-%s.php', $slug_dir, $post->ID, $slug_name );
191
+				$specifics [ ] = sprintf( '%spost-%d-field.php', $slug_dir, $post->ID );
192 192
 			}
193 193
 			
194 194
 			/** Field-specific */
195 195
 			if ( $field_id && $form_id ) {
196 196
 
197 197
 				if ( $field_id ) {
198
-					$specifics []= sprintf( '%sform-%d-field-%d-%s.php', $slug_dir, $form_id, $field_id, $slug_name );
199
-					$specifics []= sprintf( '%sform-%d-field-%d.php', $slug_dir, $form_id, $field_id );
198
+					$specifics [ ] = sprintf( '%sform-%d-field-%d-%s.php', $slug_dir, $form_id, $field_id, $slug_name );
199
+					$specifics [ ] = sprintf( '%sform-%d-field-%d.php', $slug_dir, $form_id, $field_id );
200 200
 				}
201 201
 
202 202
 				if ( $field_type ) {
203
-					$specifics []= sprintf( '%sform-%d-field-%s-%s.php', $slug_dir, $form_id, $field_type, $slug_name );
204
-					$inputType && $specifics []= sprintf( '%sform-%d-field-%s-%s.php', $slug_dir, $form_id, $inputType, $slug_name );
205
-					$specifics []= sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $field_type );
206
-					$inputType && $specifics []= sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $inputType );
207
-
208
-					$specifics []= sprintf( '%sview-%d-field-%s-%s.php', $slug_dir, $view_id, $field_type, $slug_name );
209
-					$inputType && $specifics []= sprintf( '%sview-%d-field-%s-%s.php', $slug_dir, $view_id, $inputType, $slug_name );
210
-					$specifics []= sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $field_type );
211
-					$inputType && $specifics []= sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $inputType );
212
-
213
-					$specifics []= sprintf( '%sfield-%s-%s.php', $slug_dir, $field_type, $slug_name );
214
-					$inputType && $specifics []= sprintf( '%sfield-%s-%s.php', $slug_dir, $inputType, $slug_name );
215
-					$specifics []= sprintf( '%sfield-%s.php', $slug_dir, $field_type );
216
-					$inputType && $specifics []= sprintf( '%sfield-%s.php', $slug_dir, $inputType );
203
+					$specifics [ ] = sprintf( '%sform-%d-field-%s-%s.php', $slug_dir, $form_id, $field_type, $slug_name );
204
+					$inputType && $specifics [ ] = sprintf( '%sform-%d-field-%s-%s.php', $slug_dir, $form_id, $inputType, $slug_name );
205
+					$specifics [ ] = sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $field_type );
206
+					$inputType && $specifics [ ] = sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $inputType );
207
+
208
+					$specifics [ ] = sprintf( '%sview-%d-field-%s-%s.php', $slug_dir, $view_id, $field_type, $slug_name );
209
+					$inputType && $specifics [ ] = sprintf( '%sview-%d-field-%s-%s.php', $slug_dir, $view_id, $inputType, $slug_name );
210
+					$specifics [ ] = sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $field_type );
211
+					$inputType && $specifics [ ] = sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $inputType );
212
+
213
+					$specifics [ ] = sprintf( '%sfield-%s-%s.php', $slug_dir, $field_type, $slug_name );
214
+					$inputType && $specifics [ ] = sprintf( '%sfield-%s-%s.php', $slug_dir, $inputType, $slug_name );
215
+					$specifics [ ] = sprintf( '%sfield-%s.php', $slug_dir, $field_type );
216
+					$inputType && $specifics [ ] = sprintf( '%sfield-%s.php', $slug_dir, $inputType );
217 217
 				}
218 218
 			}
219 219
 
220 220
 			if ( $form_id ) {
221 221
 				/** Generic field templates */
222
-				$specifics []= sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $slug_name );
223
-				$specifics []= sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $slug_name );
222
+				$specifics [ ] = sprintf( '%sview-%d-field-%s.php', $slug_dir, $view_id, $slug_name );
223
+				$specifics [ ] = sprintf( '%sform-%d-field-%s.php', $slug_dir, $form_id, $slug_name );
224 224
 
225
-				$specifics []= sprintf( '%sview-%d-field.php', $slug_dir, $view_id );
226
-				$specifics []= sprintf( '%sform-%d-field.php', $slug_dir, $form_id );
225
+				$specifics [ ] = sprintf( '%sview-%d-field.php', $slug_dir, $view_id );
226
+				$specifics [ ] = sprintf( '%sform-%d-field.php', $slug_dir, $form_id );
227 227
 			}
228 228
 
229
-			$specifics []= sprintf( '%sfield-%s.php', $slug_dir, $slug_name );
230
-			$specifics []= sprintf( '%sfield.php', $slug_dir );
229
+			$specifics [ ] = sprintf( '%sfield-%s.php', $slug_dir, $slug_name );
230
+			$specifics [ ] = sprintf( '%sfield.php', $slug_dir );
231 231
 
232 232
 
233 233
 			return array_merge( $specifics, $templates );
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 			/** Prevent any PHP warnings that may be generated. */
255 255
 			ob_start();
256 256
 
257
-			$display_value = \GFCommon::get_lead_field_display( $this->field->field, $value, $this->entry['currency'], false, 'html' );
257
+			$display_value = \GFCommon::get_lead_field_display( $this->field->field, $value, $this->entry[ 'currency' ], false, 'html' );
258 258
 
259 259
 			if ( $errors = ob_get_clean() ) {
260 260
 				gravityview()->log->error( 'Errors when calling GFCommon::get_lead_field_display()', array( 'data' => $errors ) );
Please login to merge, or discard this patch.