Completed
Push — develop ( 6c787a...2f7cb5 )
by Zack
03:50
created
includes/class-api.php 1 patch
Spacing   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -30,29 +30,29 @@  discard block
 block discarded – undo
30 30
 
31 31
 		$label = '';
32 32
 
33
-		if( !empty( $field['show_label'] ) || $force_show_label ) {
33
+		if ( ! empty( $field[ 'show_label' ] ) || $force_show_label ) {
34 34
 
35
-			$label = $field['label'];
35
+			$label = $field[ 'label' ];
36 36
 
37 37
 			// Support Gravity Forms 1.9+
38
-			if( class_exists( 'GF_Field' ) ) {
38
+			if ( class_exists( 'GF_Field' ) ) {
39 39
 
40
-				$field_object = RGFormsModel::get_field( $form, $field['id'] );
40
+				$field_object = RGFormsModel::get_field( $form, $field[ 'id' ] );
41 41
 
42
-				if( $field_object ) {
42
+				if ( $field_object ) {
43 43
 
44
-					$input = GFFormsModel::get_input( $field_object, $field['id'] );
44
+					$input = GFFormsModel::get_input( $field_object, $field[ 'id' ] );
45 45
 
46 46
 					// This is a complex field, with labels on a per-input basis
47
-					if( $input ) {
47
+					if ( $input ) {
48 48
 
49 49
 						// Does the input have a custom label on a per-input basis? Otherwise, default label.
50
-						$label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label'];
50
+						$label = ! empty( $input[ 'customLabel' ] ) ? $input[ 'customLabel' ] : $input[ 'label' ];
51 51
 
52 52
 					} else {
53 53
 
54 54
 						// This is a field with one label
55
-						$label = $field_object->get_field_label( true, $field['label'] );
55
+						$label = $field_object->get_field_label( true, $field[ 'label' ] );
56 56
 
57 57
 					}
58 58
 
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 			}
62 62
 
63 63
 			// Use Gravity Forms label by default, but if a custom label is defined in GV, use it.
64
-			if ( !empty( $field['custom_label'] ) ) {
64
+			if ( ! empty( $field[ 'custom_label' ] ) ) {
65 65
 
66
-				$label = self::replace_variables( $field['custom_label'], $form, $entry );
66
+				$label = self::replace_variables( $field[ 'custom_label' ], $form, $entry );
67 67
 
68 68
 			}
69 69
 
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 
118 118
 		$width = NULL;
119 119
 
120
-		if( !empty( $field['width'] ) ) {
121
-			$width = absint( $field['width'] );
120
+		if ( ! empty( $field[ 'width' ] ) ) {
121
+			$width = absint( $field[ 'width' ] );
122 122
 
123 123
 			// If using percentages, limit to 100%
124
-			if( '%d%%' === $format && $width > 100 ) {
124
+			if ( '%d%%' === $format && $width > 100 ) {
125 125
 				$width = 100;
126 126
 			}
127 127
 
@@ -144,39 +144,39 @@  discard block
 block discarded – undo
144 144
 
145 145
 		$classes = array();
146 146
 
147
-		if( !empty( $field['custom_class'] ) ) {
147
+		if ( ! empty( $field[ 'custom_class' ] ) ) {
148 148
 
149
-            $custom_class = $field['custom_class'];
149
+            $custom_class = $field[ 'custom_class' ];
150 150
 
151
-            if( !empty( $entry ) ) {
151
+            if ( ! empty( $entry ) ) {
152 152
 
153 153
                 // We want the merge tag to be formatted as a class. The merge tag may be
154 154
                 // replaced by a multiple-word value that should be output as a single class.
155 155
                 // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager`
156
-                add_filter('gform_merge_tag_filter', 'sanitize_html_class');
156
+                add_filter( 'gform_merge_tag_filter', 'sanitize_html_class' );
157 157
 
158
-                $custom_class = self::replace_variables( $custom_class, $form, $entry);
158
+                $custom_class = self::replace_variables( $custom_class, $form, $entry );
159 159
 
160 160
                 // And then we want life to return to normal
161
-                remove_filter('gform_merge_tag_filter', 'sanitize_html_class');
161
+                remove_filter( 'gform_merge_tag_filter', 'sanitize_html_class' );
162 162
             }
163 163
 
164 164
 			// And now we want the spaces to be handled nicely.
165
-			$classes[] = gravityview_sanitize_html_class( $custom_class );
165
+			$classes[ ] = gravityview_sanitize_html_class( $custom_class );
166 166
 
167 167
 		}
168 168
 
169
-		if(!empty($field['id'])) {
170
-			if( !empty( $form ) && !empty( $form['id'] ) ) {
171
-				$form_id = '-'.$form['id'];
169
+		if ( ! empty( $field[ 'id' ] ) ) {
170
+			if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) {
171
+				$form_id = '-' . $form[ 'id' ];
172 172
 			} else {
173
-				$form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : '';
173
+				$form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : '';
174 174
 			}
175 175
 
176
-			$classes[] = 'gv-field'.$form_id.'-'.$field['id'];
176
+			$classes[ ] = 'gv-field' . $form_id . '-' . $field[ 'id' ];
177 177
 		}
178 178
 
179
-		return esc_attr(implode(' ', $classes));
179
+		return esc_attr( implode( ' ', $classes ) );
180 180
 	}
181 181
 
182 182
 	/**
@@ -193,16 +193,16 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	public static function field_html_attr_id( $field, $form = array(), $entry = array() ) {
195 195
 		$gravityview_view = GravityView_View::getInstance();
196
-		$id = $field['id'];
196
+		$id = $field[ 'id' ];
197 197
 
198 198
 		if ( ! empty( $id ) ) {
199
-			if ( ! empty( $form ) && ! empty( $form['id'] ) ) {
200
-				$form_id = '-' . $form['id'];
199
+			if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) {
200
+				$form_id = '-' . $form[ 'id' ];
201 201
 			} else {
202 202
 				$form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : '';
203 203
 			}
204 204
 
205
-			$id = 'gv-field' . $form_id . '-' . $field['id'];
205
+			$id = 'gv-field' . $form_id . '-' . $field[ 'id' ];
206 206
 		}
207 207
 
208 208
 		return esc_attr( $id );
@@ -219,13 +219,13 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public static function field_value( $entry, $field_settings, $format = 'html' ) {
221 221
 
222
-		if( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) {
222
+		if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) {
223 223
 			return NULL;
224 224
 		}
225 225
 
226 226
 		$gravityview_view = GravityView_View::getInstance();
227 227
 
228
-		if( class_exists( 'GFCache' ) ) {
228
+		if ( class_exists( 'GFCache' ) ) {
229 229
 			/**
230 230
 			 * Gravity Forms' GFCache function was thrashing the database, causing double the amount of time for the field_value() method to run.
231 231
 			 *
@@ -240,46 +240,46 @@  discard block
 block discarded – undo
240 240
 			 * @param boolean false Tell Gravity Forms not to store this as a transient
241 241
 			 * @param  int 0 Time to store the value. 0 is maximum amount of time possible.
242 242
 			 */
243
-			GFCache::set( "GFFormsModel::get_lead_field_value_" . $entry["id"] . "_" . $field_settings["id"], false, false, 0 );
243
+			GFCache::set( "GFFormsModel::get_lead_field_value_" . $entry[ "id" ] . "_" . $field_settings[ "id" ], false, false, 0 );
244 244
 		}
245 245
 
246
-		$field_id = $field_settings['id'];
246
+		$field_id = $field_settings[ 'id' ];
247 247
 
248 248
 		$form = $gravityview_view->getForm();
249 249
 
250 250
 		$field = gravityview_get_field( $form, $field_id );
251 251
 
252
-		$field_type = RGFormsModel::get_input_type($field);
252
+		$field_type = RGFormsModel::get_input_type( $field );
253 253
 
254
-		if( $field_type ) {
255
-			$field_type = $field['type'];
256
-			$value = RGFormsModel::get_lead_field_value($entry, $field);
254
+		if ( $field_type ) {
255
+			$field_type = $field[ 'type' ];
256
+			$value = RGFormsModel::get_lead_field_value( $entry, $field );
257 257
 		} else {
258 258
 			// For non-integer field types (`id`, `date_created`, etc.)
259 259
 			$field_type = $field_id;
260
-			$field['type'] = $field_id;
261
-			$value = isset($entry[$field_type]) ? $entry[$field_type] : NULL;
260
+			$field[ 'type' ] = $field_id;
261
+			$value = isset( $entry[ $field_type ] ) ? $entry[ $field_type ] : NULL;
262 262
 		}
263 263
 
264 264
 		// Prevent any PHP warnings that may be generated
265 265
 		ob_start();
266 266
 
267
-		$display_value = GFCommon::get_lead_field_display($field, $value, $entry["currency"], false, $format);
267
+		$display_value = GFCommon::get_lead_field_display( $field, $value, $entry[ "currency" ], false, $format );
268 268
 
269
-		if( $errors = ob_get_clean() ) {
269
+		if ( $errors = ob_get_clean() ) {
270 270
 			do_action( 'gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors );
271 271
 		}
272 272
 
273
-		$display_value = apply_filters("gform_entry_field_value", $display_value, $field, $entry, $form);
273
+		$display_value = apply_filters( "gform_entry_field_value", $display_value, $field, $entry, $form );
274 274
 
275 275
 		// prevent the use of merge_tags for non-admin fields
276
-		if( !empty( $field['adminOnly'] ) ) {
276
+		if ( ! empty( $field[ 'adminOnly' ] ) ) {
277 277
 			$display_value = self::replace_variables( $display_value, $form, $entry );
278 278
 		}
279 279
 
280 280
 		// Check whether the field exists in /includes/fields/{$field_type}.php
281 281
 		// This can be overridden by user template files.
282
-		$field_path = $gravityview_view->locate_template("fields/{$field_type}.php");
282
+		$field_path = $gravityview_view->locate_template( "fields/{$field_type}.php" );
283 283
 
284 284
 		// Set the field data to be available in the templates
285 285
 		$gravityview_view->setCurrentField( array(
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
 			'entry' => $entry,
294 294
 			'field_type' => $field_type, /** {@since 1.6} */
295 295
 		    'field_path' => $field_path, /** {@since 1.16} */
296
-		));
296
+		) );
297 297
 
298
-		if( ! empty( $field_path ) ) {
298
+		if ( ! empty( $field_path ) ) {
299 299
 
300
-			do_action( 'gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path ) );
300
+			do_action( 'gravityview_log_debug', sprintf( '[field_value] Rendering %s', $field_path ) );
301 301
 
302 302
 			ob_start();
303 303
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 
313 313
 		}
314 314
 
315
-		$field_settings = $gravityview_view->getCurrentField('field_settings');
315
+		$field_settings = $gravityview_view->getCurrentField( 'field_settings' );
316 316
 
317 317
 		/**
318 318
 		 * @filter `gravityview_field_entry_value_{$field_type}_pre_link` Modify the field value output for a field type before Show As Link setting is applied. Example: `gravityview_field_entry_value_number_pre_link`
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
 		 * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example.
331 331
 		 *
332 332
 		 */
333
-		if( !empty( $field_settings['show_as_link'] ) && ! gv_empty( $output, false, false ) ) {
333
+		if ( ! empty( $field_settings[ 'show_as_link' ] ) && ! gv_empty( $output, false, false ) ) {
334 334
 
335
-			$link_atts = empty( $field_settings['new_window'] ) ? array() : array( 'target' => '_blank' );
335
+			$link_atts = empty( $field_settings[ 'new_window' ] ) ? array() : array( 'target' => '_blank' );
336 336
 
337 337
 			$output = self::entry_link_html( $entry, $output, $link_atts, $field_settings );
338 338
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 		 * @param  array $field_settings Settings for the particular GV field
347 347
 		 * @param array $field Current field being displayed
348 348
 		 */
349
-		$output = apply_filters( 'gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() );
349
+		$output = apply_filters( 'gravityview_field_entry_value_' . $field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() );
350 350
 
351 351
 		/**
352 352
 		 * @filter `gravityview_field_entry_value` Modify the field value output for all field types
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 */
372 372
 	public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array() ) {
373 373
 
374
-		if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) {
374
+		if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry[ 'id' ] ) ) {
375 375
 
376 376
 			do_action( 'gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry );
377 377
 
@@ -399,19 +399,19 @@  discard block
 block discarded – undo
399 399
 	 * @param  boolean     $wpautop Apply wpautop() to the output?
400 400
 	 * @return string               HTML of "no results" text
401 401
 	 */
402
-	public static function no_results($wpautop = true) {
402
+	public static function no_results( $wpautop = true ) {
403 403
 		$gravityview_view = GravityView_View::getInstance();
404 404
 
405 405
 		$is_search = false;
406 406
 
407
-		if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) {
407
+		if ( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) {
408 408
 			$is_search = true;
409 409
 		}
410 410
 
411
-		if($is_search) {
412
-			$output = __('This search returned no results.', 'gravityview');
411
+		if ( $is_search ) {
412
+			$output = __( 'This search returned no results.', 'gravityview' );
413 413
 		} else {
414
-			$output = __('No entries match your request.', 'gravityview');
414
+			$output = __( 'No entries match your request.', 'gravityview' );
415 415
 		}
416 416
 
417 417
 		/**
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
 		 * @param string $output The existing "No Entries" text
420 420
 		 * @param boolean $is_search Is the current page a search result, or just a multiple entries screen?
421 421
 		 */
422
-		$output = apply_filters( 'gravitview_no_entries_text', $output, $is_search);
422
+		$output = apply_filters( 'gravitview_no_entries_text', $output, $is_search );
423 423
 
424
-		return $wpautop ? wpautop($output) : $output;
424
+		return $wpautop ? wpautop( $output ) : $output;
425 425
 	}
426 426
 
427 427
 	/**
@@ -438,37 +438,37 @@  discard block
 block discarded – undo
438 438
 
439 439
 		$gravityview_view = GravityView_View::getInstance();
440 440
 
441
-		if( empty( $post_id ) ) {
441
+		if ( empty( $post_id ) ) {
442 442
 
443 443
 			$post_id = false;
444 444
 
445 445
 			// DataTables passes the Post ID
446
-			if( defined('DOING_AJAX') && DOING_AJAX ) {
446
+			if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
447 447
 
448
-				$post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : false;
448
+				$post_id = isset( $_POST[ 'post_id' ] ) ? (int)$_POST[ 'post_id' ] : false;
449 449
 
450 450
 			} else {
451 451
 
452 452
 				// The Post ID has been passed via the shortcode
453
-				if( !empty( $gravityview_view ) && $gravityview_view->getPostId() ) {
453
+				if ( ! empty( $gravityview_view ) && $gravityview_view->getPostId() ) {
454 454
 
455 455
 					$post_id = $gravityview_view->getPostId();
456 456
 
457 457
 				} else {
458 458
 
459 459
 					// This is a GravityView post type
460
-					if( GravityView_frontend::getInstance()->isGravityviewPostType() ) {
460
+					if ( GravityView_frontend::getInstance()->isGravityviewPostType() ) {
461 461
 
462 462
 						$post_id = isset( $gravityview_view ) ? $gravityview_view->getViewId() : $post->ID;
463 463
 
464 464
 					} else {
465 465
 
466 466
 						// This is an embedded GravityView; use the embedded post's ID as the base.
467
-						if( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) {
467
+						if ( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) {
468 468
 
469 469
 							$post_id = $post->ID;
470 470
 
471
-						} elseif( $gravityview_view->getViewId() ) {
471
+						} elseif ( $gravityview_view->getViewId() ) {
472 472
 
473 473
 							// The GravityView has been embedded in a widget or in a template, and
474 474
 							// is not in the current content. Thus, we defer to the View's own ID.
@@ -483,36 +483,36 @@  discard block
 block discarded – undo
483 483
 		}
484 484
 
485 485
 		// No post ID, get outta here.
486
-		if( empty( $post_id ) ) {
486
+		if ( empty( $post_id ) ) {
487 487
 			return NULL;
488 488
 		}
489 489
 
490 490
 		// If we've saved the permalink in memory, use it
491 491
 		// @since 1.3
492
-		$link = wp_cache_get( 'gv_directory_link_'.$post_id );
492
+		$link = wp_cache_get( 'gv_directory_link_' . $post_id );
493 493
 
494
-		if( empty( $link ) ) {
494
+		if ( empty( $link ) ) {
495 495
 
496 496
 			$link = get_permalink( $post_id );
497 497
 
498 498
 			// If not yet saved, cache the permalink.
499 499
 			// @since 1.3
500
-			wp_cache_set( 'gv_directory_link_'.$post_id, $link );
500
+			wp_cache_set( 'gv_directory_link_' . $post_id, $link );
501 501
 
502 502
 		}
503 503
 
504 504
 		// Deal with returning to proper pagination for embedded views
505
-		if( $link && $add_query_args ) {
505
+		if ( $link && $add_query_args ) {
506 506
 
507 507
 			$args = array();
508 508
 
509
-			if( $pagenum = rgget('pagenum') ) {
510
-				$args['pagenum'] = intval( $pagenum );
509
+			if ( $pagenum = rgget( 'pagenum' ) ) {
510
+				$args[ 'pagenum' ] = intval( $pagenum );
511 511
 			}
512 512
 
513
-			if( $sort = rgget('sort') ) {
514
-				$args['sort'] = $sort;
515
-				$args['dir'] = rgget('dir');
513
+			if ( $sort = rgget( 'sort' ) ) {
514
+				$args[ 'sort' ] = $sort;
515
+				$args[ 'dir' ] = rgget( 'dir' );
516 516
 			}
517 517
 
518 518
 			$link = add_query_arg( $args, $link );
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 	private static function get_custom_entry_slug( $id, $entry = array() ) {
536 536
 
537 537
 		// Generate an unique hash to use as the default value
538
-		$slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 );
538
+		$slug = substr( wp_hash( $id, 'gravityview' . $id ), 0, 8 );
539 539
 
540 540
 		/**
541 541
 		 * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}`
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 		$slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry );
547 547
 
548 548
 		// Make sure we have something - use the original ID as backup.
549
-		if( empty( $slug ) ) {
549
+		if ( empty( $slug ) ) {
550 550
 			$slug = $id;
551 551
 		}
552 552
 
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 		 * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs.
576 576
 		 * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default)
577 577
 		 */
578
-		$custom = apply_filters('gravityview_custom_entry_slug', false );
578
+		$custom = apply_filters( 'gravityview_custom_entry_slug', false );
579 579
 
580 580
 		// If we're using custom slug...
581 581
 		if ( $custom ) {
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 			// If it does have a hash set, and the hash is expected, use it.
590 590
 			// This check allows users to change the hash structure using the
591 591
 			// gravityview_entry_hash filter and have the old hashes expire.
592
-			if( empty( $value ) || $value !== $hash ) {
592
+			if ( empty( $value ) || $value !== $hash ) {
593 593
 
594 594
 				gform_update_meta( $id_or_string, 'gravityview_unique_id', $hash );
595 595
 
@@ -617,12 +617,12 @@  discard block
 block discarded – undo
617 617
          * @param boolean $custom Should we process the custom entry slug?
618 618
          */
619 619
         $custom = apply_filters( 'gravityview_custom_entry_slug', false );
620
-        if( $custom ) {
620
+        if ( $custom ) {
621 621
             // create the gravityview_unique_id and save it
622 622
 
623 623
             // Get the entry hash
624
-            $hash = self::get_custom_entry_slug( $entry['id'], $entry );
625
-            gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash );
624
+            $hash = self::get_custom_entry_slug( $entry[ 'id' ], $entry );
625
+            gform_update_meta( $entry[ 'id' ], 'gravityview_unique_id', $hash );
626 626
 
627 627
         }
628 628
     }
@@ -639,14 +639,14 @@  discard block
 block discarded – undo
639 639
 	 */
640 640
 	public static function entry_link( $entry, $post_id = NULL, $add_directory_args = true ) {
641 641
 
642
-		if( ! empty( $entry ) && ! is_array( $entry ) ) {
642
+		if ( ! empty( $entry ) && ! is_array( $entry ) ) {
643 643
 			$entry = GVCommon::get_entry( $entry );
644
-		} else if( empty( $entry ) ) {
644
+		} else if ( empty( $entry ) ) {
645 645
 			$entry = GravityView_frontend::getInstance()->getEntry();
646 646
 		}
647 647
 
648 648
 		// Second parameter used to be passed as $field; this makes sure it's not an array
649
-		if( !is_numeric( $post_id ) ) {
649
+		if ( ! is_numeric( $post_id ) ) {
650 650
 			$post_id = NULL;
651 651
 		}
652 652
 
@@ -654,19 +654,19 @@  discard block
 block discarded – undo
654 654
 		$directory_link = self::directory_link( $post_id, false );
655 655
 
656 656
 		// No post ID? Get outta here.
657
-		if( empty( $directory_link ) ) {
657
+		if ( empty( $directory_link ) ) {
658 658
 			return '';
659 659
 		}
660 660
 
661 661
 		$query_arg_name = GravityView_Post_Types::get_entry_var_name();
662 662
 
663
-		$entry_slug = self::get_entry_slug( $entry['id'], $entry );
663
+		$entry_slug = self::get_entry_slug( $entry[ 'id' ], $entry );
664 664
 
665
-		if( get_option('permalink_structure') && !is_preview() ) {
665
+		if ( get_option( 'permalink_structure' ) && ! is_preview() ) {
666 666
 
667 667
 			$args = array();
668 668
 
669
-			$directory_link = trailingslashit( $directory_link ) . $query_arg_name . '/'. $entry_slug .'/';
669
+			$directory_link = trailingslashit( $directory_link ) . $query_arg_name . '/' . $entry_slug . '/';
670 670
 
671 671
 		} else {
672 672
 
@@ -676,18 +676,18 @@  discard block
 block discarded – undo
676 676
 		/**
677 677
 		 * @since 1.7.3
678 678
 		 */
679
-		if( $add_directory_args ) {
679
+		if ( $add_directory_args ) {
680 680
 
681
-			if( !empty( $_GET['pagenum'] ) ) {
682
-				$args['pagenum'] = intval( $_GET['pagenum'] );
681
+			if ( ! empty( $_GET[ 'pagenum' ] ) ) {
682
+				$args[ 'pagenum' ] = intval( $_GET[ 'pagenum' ] );
683 683
 			}
684 684
 
685 685
 			/**
686 686
 			 * @since 1.7
687 687
 			 */
688
-			if( $sort = rgget('sort') ) {
689
-				$args['sort'] = $sort;
690
-				$args['dir'] = rgget('dir');
688
+			if ( $sort = rgget( 'sort' ) ) {
689
+				$args[ 'sort' ] = $sort;
690
+				$args[ 'dir' ] = rgget( 'dir' );
691 691
 			}
692 692
 
693 693
 		}
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
 		 * has the view id so that Advanced Filters can be applied correctly when rendering the single view
698 698
 		 * @see GravityView_frontend::get_context_view_id()
699 699
 		 */
700
-		if( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) {
701
-			$args['gvid'] = gravityview_get_view_id();
700
+		if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) {
701
+			$args[ 'gvid' ] = gravityview_get_view_id();
702 702
 		}
703 703
 
704 704
 		return add_query_arg( $args, $directory_link );
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 }
717 717
 
718 718
 function gv_class( $field, $form = NULL, $entry = array() ) {
719
-	return GravityView_API::field_class( $field, $form, $entry  );
719
+	return GravityView_API::field_class( $field, $form, $entry );
720 720
 }
721 721
 
722 722
 /**
@@ -738,11 +738,11 @@  discard block
 block discarded – undo
738 738
 
739 739
 	$default_css_class = ! empty( $view_id ) ? sprintf( 'gv-container gv-container-%d', $view_id ) : 'gv-container';
740 740
 
741
-	if( GravityView_View::getInstance()->isHideUntilSearched() ) {
741
+	if ( GravityView_View::getInstance()->isHideUntilSearched() ) {
742 742
 		$default_css_class .= ' hidden';
743 743
 	}
744 744
 
745
-	$css_class = trim( $passed_css_class . ' '. $default_css_class );
745
+	$css_class = trim( $passed_css_class . ' ' . $default_css_class );
746 746
 
747 747
 	/**
748 748
 	 * @filter `gravityview/render/container/class` Modify the CSS class to be added to the wrapper <div> of a View
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 
754 754
 	$css_class = gravityview_sanitize_html_class( $css_class );
755 755
 
756
-	if( $echo ) {
756
+	if ( $echo ) {
757 757
 		echo $css_class;
758 758
 	}
759 759
 
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 
765 765
 	$value = GravityView_API::field_value( $entry, $field );
766 766
 
767
-	if( $value === '') {
767
+	if ( $value === '' ) {
768 768
 		/**
769 769
 		 * @filter `gravityview_empty_value` What to display when a field is empty
770 770
 		 * @param string $value (empty string)
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 	return GravityView_API::entry_link( $entry, $post_id );
784 784
 }
785 785
 
786
-function gv_no_results($wpautop = true) {
786
+function gv_no_results( $wpautop = true ) {
787 787
 	return GravityView_API::no_results( $wpautop );
788 788
 }
789 789
 
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 
797 797
 	$href = gv_directory_link();
798 798
 
799
-	if( empty( $href ) ) { return NULL; }
799
+	if ( empty( $href ) ) { return NULL; }
800 800
 
801 801
 	// calculate link label
802 802
 	$gravityview_view = GravityView_View::getInstance();
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 
813 813
 	$link = gravityview_get_link( $href, esc_html( $label ), array(
814 814
 		'data-viewid' => $gravityview_view->getViewId()
815
-	));
815
+	) );
816 816
 
817 817
 	return $link;
818 818
 }
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
  */
832 832
 function gravityview_get_field_value( $entry, $field_id, $display_value ) {
833 833
 
834
-	if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) {
834
+	if ( floatval( $field_id ) === floor( floatval( $field_id ) ) ) {
835 835
 
836 836
 		// For the complete field value as generated by Gravity Forms
837 837
 		return $display_value;
@@ -861,16 +861,16 @@  discard block
 block discarded – undo
861 861
 
862 862
 	$terms = explode( ', ', $value );
863 863
 
864
-	foreach ($terms as $term_name ) {
864
+	foreach ( $terms as $term_name ) {
865 865
 
866 866
 		// If we're processing a category,
867
-		if( $taxonomy === 'category' ) {
867
+		if ( $taxonomy === 'category' ) {
868 868
 
869 869
 			// Use rgexplode to prevent errors if : doesn't exist
870 870
 			list( $term_name, $term_id ) = rgexplode( ':', $value, 2 );
871 871
 
872 872
 			// The explode was succesful; we have the category ID
873
-			if( !empty( $term_id )) {
873
+			if ( ! empty( $term_id ) ) {
874 874
 				$term = get_term_by( 'id', $term_id, $taxonomy );
875 875
 			} else {
876 876
 			// We have to fall back to the name
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 		}
884 884
 
885 885
 		// There's still a tag/category here.
886
-		if( $term ) {
886
+		if ( $term ) {
887 887
 
888 888
 			$term_link = get_term_link( $term, $taxonomy );
889 889
 
@@ -892,11 +892,11 @@  discard block
 block discarded – undo
892 892
 			    continue;
893 893
 			}
894 894
 
895
-			$output[] = gravityview_get_link( $term_link, esc_html( $term->name ) );
895
+			$output[ ] = gravityview_get_link( $term_link, esc_html( $term->name ) );
896 896
 		}
897 897
 	}
898 898
 
899
-	return implode(', ', $output );
899
+	return implode( ', ', $output );
900 900
 }
901 901
 
902 902
 /**
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 
911 911
 	$output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' );
912 912
 
913
-	if( empty( $link ) ) {
914
-		return strip_tags( $output);
913
+	if ( empty( $link ) ) {
914
+		return strip_tags( $output );
915 915
 	}
916 916
 
917 917
 	return $output;
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 	$fe = GravityView_frontend::getInstance();
931 931
 
932 932
 	// Solve problem when loading content via admin-ajax.php
933
-	if( ! $fe->getGvOutputData() ) {
933
+	if ( ! $fe->getGvOutputData() ) {
934 934
 
935 935
 		do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.' );
936 936
 
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
 	}
939 939
 
940 940
 	// Make 100% sure that we're dealing with a properly called situation
941
-	if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) {
941
+	if ( ! is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) {
942 942
 
943 943
 		do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData() );
944 944
 
@@ -958,10 +958,10 @@  discard block
 block discarded – undo
958 958
 
959 959
 	$fe = GravityView_frontend::getInstance();
960 960
 
961
-	if( ! $fe->getGvOutputData() ) { return array(); }
961
+	if ( ! $fe->getGvOutputData() ) { return array(); }
962 962
 
963 963
 	// If not set, grab the current view ID
964
-	if( empty( $view_id ) ) {
964
+	if ( empty( $view_id ) ) {
965 965
 		$view_id = $fe->get_context_view_id();
966 966
 	}
967 967
 
@@ -1026,11 +1026,11 @@  discard block
 block discarded – undo
1026 1026
 	 */
1027 1027
 	$is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false );
1028 1028
 
1029
-	if( $is_edit_entry ) {
1029
+	if ( $is_edit_entry ) {
1030 1030
 		$context = 'edit';
1031
-	} else if( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) {
1031
+	} else if ( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) {
1032 1032
 		$context = 'single';
1033
-	} else if( class_exists( 'GravityView_View' ) ) {
1033
+	} else if ( class_exists( 'GravityView_View' ) ) {
1034 1034
 		$context = GravityView_View::getInstance()->getContext();
1035 1035
 	}
1036 1036
 
@@ -1058,12 +1058,12 @@  discard block
 block discarded – undo
1058 1058
 function gravityview_get_files_array( $value, $gv_class = '' ) {
1059 1059
 	/** @define "GRAVITYVIEW_DIR" "../" */
1060 1060
 
1061
-	if( !class_exists( 'GravityView_Field' ) ) {
1062
-		include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' );
1061
+	if ( ! class_exists( 'GravityView_Field' ) ) {
1062
+		include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' );
1063 1063
 	}
1064 1064
 
1065
-	if( !class_exists( 'GravityView_Field_FileUpload' ) ) {
1066
-		include_once( GRAVITYVIEW_DIR .'includes/fields/fileupload.php' );
1065
+	if ( ! class_exists( 'GravityView_Field_FileUpload' ) ) {
1066
+		include_once( GRAVITYVIEW_DIR . 'includes/fields/fileupload.php' );
1067 1067
 	}
1068 1068
 
1069 1069
 	return GravityView_Field_FileUpload::get_files_array( $value, $gv_class );
@@ -1141,12 +1141,12 @@  discard block
 block discarded – undo
1141 1141
 	$args = apply_filters( 'gravityview/field_output/args', $args, $passed_args );
1142 1142
 
1143 1143
 	// Required fields.
1144
-	if ( empty( $args['field'] ) || empty( $args['form'] ) ) {
1144
+	if ( empty( $args[ 'field' ] ) || empty( $args[ 'form' ] ) ) {
1145 1145
 		do_action( 'gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args );
1146 1146
 		return '';
1147 1147
 	}
1148 1148
 
1149
-	$entry = empty( $args['entry'] ) ? array() : $args['entry'];
1149
+	$entry = empty( $args[ 'entry' ] ) ? array() : $args[ 'entry' ];
1150 1150
 
1151 1151
 	/**
1152 1152
 	 * Create the content variables for replacing.
@@ -1162,37 +1162,37 @@  discard block
 block discarded – undo
1162 1162
 		'field_id' => '',
1163 1163
 	);
1164 1164
 
1165
-	$context['value'] = gv_value( $entry, $args['field'] );
1165
+	$context[ 'value' ] = gv_value( $entry, $args[ 'field' ] );
1166 1166
 
1167 1167
 	// If the value is empty and we're hiding empty, return empty.
1168
-	if ( $context['value'] === '' && ! empty( $args['hide_empty'] ) ) {
1168
+	if ( $context[ 'value' ] === '' && ! empty( $args[ 'hide_empty' ] ) ) {
1169 1169
 		return '';
1170 1170
 	}
1171 1171
 
1172
-	if ( $context['value'] !== '' && ! empty( $args['wpautop'] ) ) {
1173
-		$context['value'] = wpautop( $context['value'] );
1172
+	if ( $context[ 'value' ] !== '' && ! empty( $args[ 'wpautop' ] ) ) {
1173
+		$context[ 'value' ] = wpautop( $context[ 'value' ] );
1174 1174
 	}
1175 1175
 
1176 1176
 	// Get width setting, if exists
1177
-	$context['width'] = GravityView_API::field_width( $args['field'] );
1177
+	$context[ 'width' ] = GravityView_API::field_width( $args[ 'field' ] );
1178 1178
 
1179 1179
 	// If replacing with CSS inline formatting, let's do it.
1180
-	$context['width:style'] = GravityView_API::field_width( $args['field'], 'width:' . $context['width'] . '%;' );
1180
+	$context[ 'width:style' ] = GravityView_API::field_width( $args[ 'field' ], 'width:' . $context[ 'width' ] . '%;' );
1181 1181
 
1182 1182
 	// Grab the Class using `gv_class`
1183
-	$context['class'] = gv_class( $args['field'], $args['form'], $entry );
1184
-	$context['field_id'] = GravityView_API::field_html_attr_id( $args['field'], $args['form'], $entry );
1183
+	$context[ 'class' ] = gv_class( $args[ 'field' ], $args[ 'form' ], $entry );
1184
+	$context[ 'field_id' ] = GravityView_API::field_html_attr_id( $args[ 'field' ], $args[ 'form' ], $entry );
1185 1185
 
1186 1186
 	// Get field label if needed
1187
-	if ( ! empty( $args['label_markup'] ) && ! empty( $args['field']['show_label'] ) ) {
1188
-		$context['label'] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup'] );
1187
+	if ( ! empty( $args[ 'label_markup' ] ) && ! empty( $args[ 'field' ][ 'show_label' ] ) ) {
1188
+		$context[ 'label' ] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args[ 'label_markup' ] );
1189 1189
 	}
1190 1190
 
1191 1191
 	// Default Label value
1192
-	$context['label_value'] = gv_label( $args['field'], $entry );
1192
+	$context[ 'label_value' ] = gv_label( $args[ 'field' ], $entry );
1193 1193
 
1194
-	if ( empty( $context['label'] ) && ! empty( $context['label_value'] ) ){
1195
-		$context['label'] = '<span class="gv-field-label">{{ label_value }}</span>';
1194
+	if ( empty( $context[ 'label' ] ) && ! empty( $context[ 'label_value' ] ) ) {
1195
+		$context[ 'label' ] = '<span class="gv-field-label">{{ label_value }}</span>';
1196 1196
 	}
1197 1197
 
1198 1198
 	/**
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 	 * @param string $markup The HTML for the markup
1202 1202
 	 * @param array $args All args for the field output
1203 1203
 	 */
1204
-	$html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args );
1204
+	$html = apply_filters( 'gravityview/field_output/pre_html', $args[ 'markup' ], $args );
1205 1205
 
1206 1206
 	/**
1207 1207
 	 * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders
@@ -1224,7 +1224,7 @@  discard block
 block discarded – undo
1224 1224
 	foreach ( $context as $tag => $value ) {
1225 1225
 
1226 1226
 		// If the tag doesn't exist just skip it
1227
-		if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){
1227
+		if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ) {
1228 1228
 			continue;
1229 1229
 		}
1230 1230
 
Please login to merge, or discard this patch.