Completed
Push — develop ( 59de7b...287c78 )
by Zack
17:33 queued 13:47
created
includes/class-api.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -214,7 +214,6 @@  discard block
 block discarded – undo
214 214
 	 *
215 215
 	 * @access public
216 216
 	 * @param array $entry
217
-	 * @param array $field
218 217
 	 * @return null|string
219 218
 	 */
220 219
 	public static function field_value( $entry, $field_settings, $format = 'html' ) {
@@ -1000,7 +999,7 @@  discard block
 block discarded – undo
1000 999
  * Get the current View ID being rendered
1001 1000
  *
1002 1001
  * @global GravityView_View $gravityview_view
1003
- * @return string View context "directory" or "single"
1002
+ * @return integer View context "directory" or "single"
1004 1003
  */
1005 1004
 function gravityview_get_view_id() {
1006 1005
 	return GravityView_View::getInstance()->getViewId();
Please login to merge, or discard this patch.
Spacing   +139 added lines, -139 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,20 +219,20 @@  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
-		$field_id = $field_settings['id'];
228
+		$field_id = $field_settings[ 'id' ];
229 229
 		$form = $gravityview_view->getForm();
230 230
 		$field = gravityview_get_field( $form, $field_id );
231 231
 
232 232
 		// Prevent any PHP warnings that may be generated
233 233
 		ob_start();
234 234
 
235
-		if( $field && is_numeric( $field_id ) ) {
235
+		if ( $field && is_numeric( $field_id ) ) {
236 236
 			// Used as file name of field template in GV.
237 237
 			// Don't use RGFormsModel::get_input_type( $field ); we don't care if it's a radio input; we want to know it's a 'quiz' field
238 238
 			$field_type = $field->type;
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 		}
244 244
 
245 245
 		// If a Gravity Forms Field is found, get the field display
246
-		if( $field ) {
247
-			$display_value = GFCommon::get_lead_field_display( $field, $value, $entry["currency"], false, $format );
246
+		if ( $field ) {
247
+			$display_value = GFCommon::get_lead_field_display( $field, $value, $entry[ "currency" ], false, $format );
248 248
 
249 249
 			if ( $errors = ob_get_clean() ) {
250 250
 				do_action( 'gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors );
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 			$display_value = apply_filters( "gform_entry_field_value", $display_value, $field, $entry, $form );
254 254
 
255 255
 			// prevent the use of merge_tags for non-admin fields
256
-			if( !empty( $field->adminOnly ) ) {
256
+			if ( ! empty( $field->adminOnly ) ) {
257 257
 				$display_value = self::replace_variables( $display_value, $form, $entry );
258 258
 			}
259 259
 		} else {
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 
264 264
 		// Check whether the field exists in /includes/fields/{$field_type}.php
265 265
 		// This can be overridden by user template files.
266
-		$field_path = $gravityview_view->locate_template("fields/{$field_type}.php");
266
+		$field_path = $gravityview_view->locate_template( "fields/{$field_type}.php" );
267 267
 
268 268
 		// Set the field data to be available in the templates
269 269
 		$gravityview_view->setCurrentField( array(
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
 			'entry' => $entry,
278 278
 			'field_type' => $field_type, /** {@since 1.6} */
279 279
 		    'field_path' => $field_path, /** {@since 1.16} */
280
-		));
280
+		) );
281 281
 
282
-		if( ! empty( $field_path ) ) {
282
+		if ( ! empty( $field_path ) ) {
283 283
 
284
-			do_action( 'gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path ) );
284
+			do_action( 'gravityview_log_debug', sprintf( '[field_value] Rendering %s', $field_path ) );
285 285
 
286 286
 			ob_start();
287 287
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 		}
298 298
 
299 299
 		// Get the field settings again so that the field template can override the settings
300
-		$field_settings = $gravityview_view->getCurrentField('field_settings');
300
+		$field_settings = $gravityview_view->getCurrentField( 'field_settings' );
301 301
 
302 302
 		/**
303 303
 		 * @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`
@@ -315,9 +315,9 @@  discard block
 block discarded – undo
315 315
 		 * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example.
316 316
 		 *
317 317
 		 */
318
-		if( !empty( $field_settings['show_as_link'] ) && ! gv_empty( $output, false, false ) ) {
318
+		if ( ! empty( $field_settings[ 'show_as_link' ] ) && ! gv_empty( $output, false, false ) ) {
319 319
 
320
-			$link_atts = empty( $field_settings['new_window'] ) ? array() : array( 'target' => '_blank' );
320
+			$link_atts = empty( $field_settings[ 'new_window' ] ) ? array() : array( 'target' => '_blank' );
321 321
 
322 322
 			$output = self::entry_link_html( $entry, $output, $link_atts, $field_settings );
323 323
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 		 * @param  array $field_settings Settings for the particular GV field
332 332
 		 * @param array $field Current field being displayed
333 333
 		 */
334
-		$output = apply_filters( 'gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() );
334
+		$output = apply_filters( 'gravityview_field_entry_value_' . $field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() );
335 335
 
336 336
 		/**
337 337
 		 * @filter `gravityview_field_entry_value` Modify the field value output for all field types
@@ -360,14 +360,14 @@  discard block
 block discarded – undo
360 360
 	 */
361 361
 	public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array() ) {
362 362
 
363
-		if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) {
363
+		if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry[ 'id' ] ) ) {
364 364
 			do_action( 'gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry );
365 365
 			return NULL;
366 366
 		}
367 367
 
368 368
 		$href = self::entry_link( $entry );
369 369
 
370
-		if( '' === $href ) {
370
+		if ( '' === $href ) {
371 371
 			return NULL;
372 372
 		}
373 373
 
@@ -390,19 +390,19 @@  discard block
 block discarded – undo
390 390
 	 * @param  boolean     $wpautop Apply wpautop() to the output?
391 391
 	 * @return string               HTML of "no results" text
392 392
 	 */
393
-	public static function no_results($wpautop = true) {
393
+	public static function no_results( $wpautop = true ) {
394 394
 		$gravityview_view = GravityView_View::getInstance();
395 395
 
396 396
 		$is_search = false;
397 397
 
398
-		if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) {
398
+		if ( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) {
399 399
 			$is_search = true;
400 400
 		}
401 401
 
402
-		if($is_search) {
403
-			$output = __('This search returned no results.', 'gravityview');
402
+		if ( $is_search ) {
403
+			$output = __( 'This search returned no results.', 'gravityview' );
404 404
 		} else {
405
-			$output = __('No entries match your request.', 'gravityview');
405
+			$output = __( 'No entries match your request.', 'gravityview' );
406 406
 		}
407 407
 
408 408
 		/**
@@ -410,9 +410,9 @@  discard block
 block discarded – undo
410 410
 		 * @param string $output The existing "No Entries" text
411 411
 		 * @param boolean $is_search Is the current page a search result, or just a multiple entries screen?
412 412
 		 */
413
-		$output = apply_filters( 'gravitview_no_entries_text', $output, $is_search);
413
+		$output = apply_filters( 'gravitview_no_entries_text', $output, $is_search );
414 414
 
415
-		return $wpautop ? wpautop($output) : $output;
415
+		return $wpautop ? wpautop( $output ) : $output;
416 416
 	}
417 417
 
418 418
 	/**
@@ -429,37 +429,37 @@  discard block
 block discarded – undo
429 429
 
430 430
 		$gravityview_view = GravityView_View::getInstance();
431 431
 
432
-		if( empty( $post_id ) ) {
432
+		if ( empty( $post_id ) ) {
433 433
 
434 434
 			$post_id = false;
435 435
 
436 436
 			// DataTables passes the Post ID
437
-			if( defined('DOING_AJAX') && DOING_AJAX ) {
437
+			if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
438 438
 
439
-				$post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : false;
439
+				$post_id = isset( $_POST[ 'post_id' ] ) ? (int)$_POST[ 'post_id' ] : false;
440 440
 
441 441
 			} else {
442 442
 
443 443
 				// The Post ID has been passed via the shortcode
444
-				if( !empty( $gravityview_view ) && $gravityview_view->getPostId() ) {
444
+				if ( ! empty( $gravityview_view ) && $gravityview_view->getPostId() ) {
445 445
 
446 446
 					$post_id = $gravityview_view->getPostId();
447 447
 
448 448
 				} else {
449 449
 
450 450
 					// This is a GravityView post type
451
-					if( GravityView_frontend::getInstance()->isGravityviewPostType() ) {
451
+					if ( GravityView_frontend::getInstance()->isGravityviewPostType() ) {
452 452
 
453 453
 						$post_id = isset( $gravityview_view ) ? $gravityview_view->getViewId() : $post->ID;
454 454
 
455 455
 					} else {
456 456
 
457 457
 						// This is an embedded GravityView; use the embedded post's ID as the base.
458
-						if( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) {
458
+						if ( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) {
459 459
 
460 460
 							$post_id = $post->ID;
461 461
 
462
-						} elseif( $gravityview_view->getViewId() ) {
462
+						} elseif ( $gravityview_view->getViewId() ) {
463 463
 
464 464
 							// The GravityView has been embedded in a widget or in a template, and
465 465
 							// is not in the current content. Thus, we defer to the View's own ID.
@@ -474,36 +474,36 @@  discard block
 block discarded – undo
474 474
 		}
475 475
 
476 476
 		// No post ID, get outta here.
477
-		if( empty( $post_id ) ) {
477
+		if ( empty( $post_id ) ) {
478 478
 			return NULL;
479 479
 		}
480 480
 
481 481
 		// If we've saved the permalink in memory, use it
482 482
 		// @since 1.3
483
-		$link = wp_cache_get( 'gv_directory_link_'.$post_id );
483
+		$link = wp_cache_get( 'gv_directory_link_' . $post_id );
484 484
 
485
-		if( empty( $link ) ) {
485
+		if ( empty( $link ) ) {
486 486
 
487 487
 			$link = get_permalink( $post_id );
488 488
 
489 489
 			// If not yet saved, cache the permalink.
490 490
 			// @since 1.3
491
-			wp_cache_set( 'gv_directory_link_'.$post_id, $link );
491
+			wp_cache_set( 'gv_directory_link_' . $post_id, $link );
492 492
 
493 493
 		}
494 494
 
495 495
 		// Deal with returning to proper pagination for embedded views
496
-		if( $link && $add_query_args ) {
496
+		if ( $link && $add_query_args ) {
497 497
 
498 498
 			$args = array();
499 499
 
500
-			if( $pagenum = rgget('pagenum') ) {
501
-				$args['pagenum'] = intval( $pagenum );
500
+			if ( $pagenum = rgget( 'pagenum' ) ) {
501
+				$args[ 'pagenum' ] = intval( $pagenum );
502 502
 			}
503 503
 
504
-			if( $sort = rgget('sort') ) {
505
-				$args['sort'] = $sort;
506
-				$args['dir'] = rgget('dir');
504
+			if ( $sort = rgget( 'sort' ) ) {
505
+				$args[ 'sort' ] = $sort;
506
+				$args[ 'dir' ] = rgget( 'dir' );
507 507
 			}
508 508
 
509 509
 			$link = add_query_arg( $args, $link );
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 	private static function get_custom_entry_slug( $id, $entry = array() ) {
527 527
 
528 528
 		// Generate an unique hash to use as the default value
529
-		$slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 );
529
+		$slug = substr( wp_hash( $id, 'gravityview' . $id ), 0, 8 );
530 530
 
531 531
 		/**
532 532
 		 * @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}`
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 		$slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry );
538 538
 
539 539
 		// Make sure we have something - use the original ID as backup.
540
-		if( empty( $slug ) ) {
540
+		if ( empty( $slug ) ) {
541 541
 			$slug = $id;
542 542
 		}
543 543
 
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 		 * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs.
567 567
 		 * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default)
568 568
 		 */
569
-		$custom = apply_filters('gravityview_custom_entry_slug', false );
569
+		$custom = apply_filters( 'gravityview_custom_entry_slug', false );
570 570
 
571 571
 		// If we're using custom slug...
572 572
 		if ( $custom ) {
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 			// If it does have a hash set, and the hash is expected, use it.
581 581
 			// This check allows users to change the hash structure using the
582 582
 			// gravityview_entry_hash filter and have the old hashes expire.
583
-			if( empty( $value ) || $value !== $hash ) {
583
+			if ( empty( $value ) || $value !== $hash ) {
584 584
 
585 585
 				gform_update_meta( $id_or_string, 'gravityview_unique_id', $hash );
586 586
 
@@ -608,12 +608,12 @@  discard block
 block discarded – undo
608 608
          * @param boolean $custom Should we process the custom entry slug?
609 609
          */
610 610
         $custom = apply_filters( 'gravityview_custom_entry_slug', false );
611
-        if( $custom ) {
611
+        if ( $custom ) {
612 612
             // create the gravityview_unique_id and save it
613 613
 
614 614
             // Get the entry hash
615
-            $hash = self::get_custom_entry_slug( $entry['id'], $entry );
616
-            gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash );
615
+            $hash = self::get_custom_entry_slug( $entry[ 'id' ], $entry );
616
+            gform_update_meta( $entry[ 'id' ], 'gravityview_unique_id', $hash );
617 617
 
618 618
         }
619 619
     }
@@ -630,14 +630,14 @@  discard block
 block discarded – undo
630 630
 	 */
631 631
 	public static function entry_link( $entry, $post_id = NULL, $add_directory_args = true ) {
632 632
 
633
-		if( ! empty( $entry ) && ! is_array( $entry ) ) {
633
+		if ( ! empty( $entry ) && ! is_array( $entry ) ) {
634 634
 			$entry = GVCommon::get_entry( $entry );
635
-		} else if( empty( $entry ) ) {
635
+		} else if ( empty( $entry ) ) {
636 636
 			$entry = GravityView_frontend::getInstance()->getEntry();
637 637
 		}
638 638
 
639 639
 		// Second parameter used to be passed as $field; this makes sure it's not an array
640
-		if( !is_numeric( $post_id ) ) {
640
+		if ( ! is_numeric( $post_id ) ) {
641 641
 			$post_id = NULL;
642 642
 		}
643 643
 
@@ -645,19 +645,19 @@  discard block
 block discarded – undo
645 645
 		$directory_link = self::directory_link( $post_id, false );
646 646
 
647 647
 		// No post ID? Get outta here.
648
-		if( empty( $directory_link ) ) {
648
+		if ( empty( $directory_link ) ) {
649 649
 			return '';
650 650
 		}
651 651
 
652 652
 		$query_arg_name = GravityView_Post_Types::get_entry_var_name();
653 653
 
654
-		$entry_slug = self::get_entry_slug( $entry['id'], $entry );
654
+		$entry_slug = self::get_entry_slug( $entry[ 'id' ], $entry );
655 655
 
656
-		if( get_option('permalink_structure') && !is_preview() ) {
656
+		if ( get_option( 'permalink_structure' ) && ! is_preview() ) {
657 657
 
658 658
 			$args = array();
659 659
 
660
-			$directory_link = trailingslashit( $directory_link ) . $query_arg_name . '/'. $entry_slug .'/';
660
+			$directory_link = trailingslashit( $directory_link ) . $query_arg_name . '/' . $entry_slug . '/';
661 661
 
662 662
 		} else {
663 663
 
@@ -667,18 +667,18 @@  discard block
 block discarded – undo
667 667
 		/**
668 668
 		 * @since 1.7.3
669 669
 		 */
670
-		if( $add_directory_args ) {
670
+		if ( $add_directory_args ) {
671 671
 
672
-			if( !empty( $_GET['pagenum'] ) ) {
673
-				$args['pagenum'] = intval( $_GET['pagenum'] );
672
+			if ( ! empty( $_GET[ 'pagenum' ] ) ) {
673
+				$args[ 'pagenum' ] = intval( $_GET[ 'pagenum' ] );
674 674
 			}
675 675
 
676 676
 			/**
677 677
 			 * @since 1.7
678 678
 			 */
679
-			if( $sort = rgget('sort') ) {
680
-				$args['sort'] = $sort;
681
-				$args['dir'] = rgget('dir');
679
+			if ( $sort = rgget( 'sort' ) ) {
680
+				$args[ 'sort' ] = $sort;
681
+				$args[ 'dir' ] = rgget( 'dir' );
682 682
 			}
683 683
 
684 684
 		}
@@ -688,8 +688,8 @@  discard block
 block discarded – undo
688 688
 		 * has the view id so that Advanced Filters can be applied correctly when rendering the single view
689 689
 		 * @see GravityView_frontend::get_context_view_id()
690 690
 		 */
691
-		if( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) {
692
-			$args['gvid'] = gravityview_get_view_id();
691
+		if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) {
692
+			$args[ 'gvid' ] = gravityview_get_view_id();
693 693
 		}
694 694
 
695 695
 		return add_query_arg( $args, $directory_link );
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 }
708 708
 
709 709
 function gv_class( $field, $form = NULL, $entry = array() ) {
710
-	return GravityView_API::field_class( $field, $form, $entry  );
710
+	return GravityView_API::field_class( $field, $form, $entry );
711 711
 }
712 712
 
713 713
 /**
@@ -729,15 +729,15 @@  discard block
 block discarded – undo
729 729
 
730 730
 	$default_css_class = ! empty( $view_id ) ? sprintf( 'gv-container gv-container-%d', $view_id ) : 'gv-container';
731 731
 
732
-	if( GravityView_View::getInstance()->isHideUntilSearched() ) {
732
+	if ( GravityView_View::getInstance()->isHideUntilSearched() ) {
733 733
 		$default_css_class .= ' hidden';
734 734
 	}
735 735
 
736
-	if( 0 === GravityView_View::getInstance()->getTotalEntries() ) {
736
+	if ( 0 === GravityView_View::getInstance()->getTotalEntries() ) {
737 737
 		$default_css_class .= ' gv-container-no-results';
738 738
 	}
739 739
 
740
-	$css_class = trim( $passed_css_class . ' '. $default_css_class );
740
+	$css_class = trim( $passed_css_class . ' ' . $default_css_class );
741 741
 
742 742
 	/**
743 743
 	 * @filter `gravityview/render/container/class` Modify the CSS class to be added to the wrapper <div> of a View
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 
749 749
 	$css_class = gravityview_sanitize_html_class( $css_class );
750 750
 
751
-	if( $echo ) {
751
+	if ( $echo ) {
752 752
 		echo $css_class;
753 753
 	}
754 754
 
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 
760 760
 	$value = GravityView_API::field_value( $entry, $field );
761 761
 
762
-	if( $value === '' ) {
762
+	if ( $value === '' ) {
763 763
 		/**
764 764
 		 * @filter `gravityview_empty_value` What to display when a field is empty
765 765
 		 * @param string $value (empty string)
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 	return GravityView_API::entry_link( $entry, $post_id );
779 779
 }
780 780
 
781
-function gv_no_results($wpautop = true) {
781
+function gv_no_results( $wpautop = true ) {
782 782
 	return GravityView_API::no_results( $wpautop );
783 783
 }
784 784
 
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 
792 792
 	$href = gv_directory_link();
793 793
 
794
-	if( empty( $href ) ) { return NULL; }
794
+	if ( empty( $href ) ) { return NULL; }
795 795
 
796 796
 	// calculate link label
797 797
 	$gravityview_view = GravityView_View::getInstance();
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
 
808 808
 	$link = gravityview_get_link( $href, esc_html( $label ), array(
809 809
 		'data-viewid' => $gravityview_view->getViewId()
810
-	));
810
+	) );
811 811
 
812 812
 	return $link;
813 813
 }
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
  */
827 827
 function gravityview_get_field_value( $entry, $field_id, $display_value ) {
828 828
 
829
-	if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) {
829
+	if ( floatval( $field_id ) === floor( floatval( $field_id ) ) ) {
830 830
 
831 831
 		// For the complete field value as generated by Gravity Forms
832 832
 		return $display_value;
@@ -856,16 +856,16 @@  discard block
 block discarded – undo
856 856
 
857 857
 	$terms = explode( ', ', $value );
858 858
 
859
-	foreach ($terms as $term_name ) {
859
+	foreach ( $terms as $term_name ) {
860 860
 
861 861
 		// If we're processing a category,
862
-		if( $taxonomy === 'category' ) {
862
+		if ( $taxonomy === 'category' ) {
863 863
 
864 864
 			// Use rgexplode to prevent errors if : doesn't exist
865 865
 			list( $term_name, $term_id ) = rgexplode( ':', $value, 2 );
866 866
 
867 867
 			// The explode was succesful; we have the category ID
868
-			if( !empty( $term_id )) {
868
+			if ( ! empty( $term_id ) ) {
869 869
 				$term = get_term_by( 'id', $term_id, $taxonomy );
870 870
 			} else {
871 871
 			// We have to fall back to the name
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 		}
879 879
 
880 880
 		// There's still a tag/category here.
881
-		if( $term ) {
881
+		if ( $term ) {
882 882
 
883 883
 			$term_link = get_term_link( $term, $taxonomy );
884 884
 
@@ -887,11 +887,11 @@  discard block
 block discarded – undo
887 887
 			    continue;
888 888
 			}
889 889
 
890
-			$output[] = gravityview_get_link( $term_link, esc_html( $term->name ) );
890
+			$output[ ] = gravityview_get_link( $term_link, esc_html( $term->name ) );
891 891
 		}
892 892
 	}
893 893
 
894
-	return implode(', ', $output );
894
+	return implode( ', ', $output );
895 895
 }
896 896
 
897 897
 /**
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 
906 906
 	$output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' );
907 907
 
908
-	if( empty( $link ) ) {
909
-		return strip_tags( $output);
908
+	if ( empty( $link ) ) {
909
+		return strip_tags( $output );
910 910
 	}
911 911
 
912 912
 	return $output;
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 	$fe = GravityView_frontend::getInstance();
926 926
 
927 927
 	// Solve problem when loading content via admin-ajax.php
928
-	if( ! $fe->getGvOutputData() ) {
928
+	if ( ! $fe->getGvOutputData() ) {
929 929
 
930 930
 		do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.' );
931 931
 
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 	}
934 934
 
935 935
 	// Make 100% sure that we're dealing with a properly called situation
936
-	if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) {
936
+	if ( ! is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) {
937 937
 
938 938
 		do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData() );
939 939
 
@@ -953,10 +953,10 @@  discard block
 block discarded – undo
953 953
 
954 954
 	$fe = GravityView_frontend::getInstance();
955 955
 
956
-	if( ! $fe->getGvOutputData() ) { return array(); }
956
+	if ( ! $fe->getGvOutputData() ) { return array(); }
957 957
 
958 958
 	// If not set, grab the current view ID
959
-	if( empty( $view_id ) ) {
959
+	if ( empty( $view_id ) ) {
960 960
 		$view_id = $fe->get_context_view_id();
961 961
 	}
962 962
 
@@ -1021,11 +1021,11 @@  discard block
 block discarded – undo
1021 1021
 	 */
1022 1022
 	$is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false );
1023 1023
 
1024
-	if( $is_edit_entry ) {
1024
+	if ( $is_edit_entry ) {
1025 1025
 		$context = 'edit';
1026
-	} else if( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) {
1026
+	} else if ( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) {
1027 1027
 		$context = 'single';
1028
-	} else if( class_exists( 'GravityView_View' ) ) {
1028
+	} else if ( class_exists( 'GravityView_View' ) ) {
1029 1029
 		$context = GravityView_View::getInstance()->getContext();
1030 1030
 	}
1031 1031
 
@@ -1053,12 +1053,12 @@  discard block
 block discarded – undo
1053 1053
 function gravityview_get_files_array( $value, $gv_class = '' ) {
1054 1054
 	/** @define "GRAVITYVIEW_DIR" "../" */
1055 1055
 
1056
-	if( !class_exists( 'GravityView_Field' ) ) {
1057
-		include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' );
1056
+	if ( ! class_exists( 'GravityView_Field' ) ) {
1057
+		include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' );
1058 1058
 	}
1059 1059
 
1060
-	if( !class_exists( 'GravityView_Field_FileUpload' ) ) {
1061
-		include_once( GRAVITYVIEW_DIR .'includes/fields/fileupload.php' );
1060
+	if ( ! class_exists( 'GravityView_Field_FileUpload' ) ) {
1061
+		include_once( GRAVITYVIEW_DIR . 'includes/fields/fileupload.php' );
1062 1062
 	}
1063 1063
 
1064 1064
 	return GravityView_Field_FileUpload::get_files_array( $value, $gv_class );
@@ -1136,12 +1136,12 @@  discard block
 block discarded – undo
1136 1136
 	$args = apply_filters( 'gravityview/field_output/args', $args, $passed_args );
1137 1137
 
1138 1138
 	// Required fields.
1139
-	if ( empty( $args['field'] ) || empty( $args['form'] ) ) {
1139
+	if ( empty( $args[ 'field' ] ) || empty( $args[ 'form' ] ) ) {
1140 1140
 		do_action( 'gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args );
1141 1141
 		return '';
1142 1142
 	}
1143 1143
 
1144
-	$entry = empty( $args['entry'] ) ? array() : $args['entry'];
1144
+	$entry = empty( $args[ 'entry' ] ) ? array() : $args[ 'entry' ];
1145 1145
 
1146 1146
 	/**
1147 1147
 	 * Create the content variables for replacing.
@@ -1157,37 +1157,37 @@  discard block
 block discarded – undo
1157 1157
 		'field_id' => '',
1158 1158
 	);
1159 1159
 
1160
-	$context['value'] = gv_value( $entry, $args['field'] );
1160
+	$context[ 'value' ] = gv_value( $entry, $args[ 'field' ] );
1161 1161
 
1162 1162
 	// If the value is empty and we're hiding empty, return empty.
1163
-	if ( $context['value'] === '' && ! empty( $args['hide_empty'] ) ) {
1163
+	if ( $context[ 'value' ] === '' && ! empty( $args[ 'hide_empty' ] ) ) {
1164 1164
 		return '';
1165 1165
 	}
1166 1166
 
1167
-	if ( $context['value'] !== '' && ! empty( $args['wpautop'] ) ) {
1168
-		$context['value'] = wpautop( $context['value'] );
1167
+	if ( $context[ 'value' ] !== '' && ! empty( $args[ 'wpautop' ] ) ) {
1168
+		$context[ 'value' ] = wpautop( $context[ 'value' ] );
1169 1169
 	}
1170 1170
 
1171 1171
 	// Get width setting, if exists
1172
-	$context['width'] = GravityView_API::field_width( $args['field'] );
1172
+	$context[ 'width' ] = GravityView_API::field_width( $args[ 'field' ] );
1173 1173
 
1174 1174
 	// If replacing with CSS inline formatting, let's do it.
1175
-	$context['width:style'] = GravityView_API::field_width( $args['field'], 'width:' . $context['width'] . '%;' );
1175
+	$context[ 'width:style' ] = GravityView_API::field_width( $args[ 'field' ], 'width:' . $context[ 'width' ] . '%;' );
1176 1176
 
1177 1177
 	// Grab the Class using `gv_class`
1178
-	$context['class'] = gv_class( $args['field'], $args['form'], $entry );
1179
-	$context['field_id'] = GravityView_API::field_html_attr_id( $args['field'], $args['form'], $entry );
1178
+	$context[ 'class' ] = gv_class( $args[ 'field' ], $args[ 'form' ], $entry );
1179
+	$context[ 'field_id' ] = GravityView_API::field_html_attr_id( $args[ 'field' ], $args[ 'form' ], $entry );
1180 1180
 
1181 1181
 	// Get field label if needed
1182
-	if ( ! empty( $args['label_markup'] ) && ! empty( $args['field']['show_label'] ) ) {
1183
-		$context['label'] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup'] );
1182
+	if ( ! empty( $args[ 'label_markup' ] ) && ! empty( $args[ 'field' ][ 'show_label' ] ) ) {
1183
+		$context[ 'label' ] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args[ 'label_markup' ] );
1184 1184
 	}
1185 1185
 
1186 1186
 	// Default Label value
1187
-	$context['label_value'] = gv_label( $args['field'], $entry );
1187
+	$context[ 'label_value' ] = gv_label( $args[ 'field' ], $entry );
1188 1188
 
1189
-	if ( empty( $context['label'] ) && ! empty( $context['label_value'] ) ){
1190
-		$context['label'] = '<span class="gv-field-label">{{ label_value }}</span>';
1189
+	if ( empty( $context[ 'label' ] ) && ! empty( $context[ 'label_value' ] ) ) {
1190
+		$context[ 'label' ] = '<span class="gv-field-label">{{ label_value }}</span>';
1191 1191
 	}
1192 1192
 
1193 1193
 	/**
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 	 * @param string $markup The HTML for the markup
1197 1197
 	 * @param array $args All args for the field output
1198 1198
 	 */
1199
-	$html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args );
1199
+	$html = apply_filters( 'gravityview/field_output/pre_html', $args[ 'markup' ], $args );
1200 1200
 
1201 1201
 	/**
1202 1202
 	 * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders
@@ -1219,7 +1219,7 @@  discard block
 block discarded – undo
1219 1219
 	foreach ( $context as $tag => $value ) {
1220 1220
 
1221 1221
 		// If the tag doesn't exist just skip it
1222
-		if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){
1222
+		if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ) {
1223 1223
 			continue;
1224 1224
 		}
1225 1225
 
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-quiz.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
 	function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
20 20
 
21
-		if( 'edit' === $context ) {
21
+		if ( 'edit' === $context ) {
22 22
 			return $field_options;
23 23
 		}
24 24
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 			'quiz_show_explanation' => array(
27 27
 				'type' => 'checkbox',
28 28
 				'label' => __( 'Show Answer Explanation?', 'gravityview' ),
29
-				'desc' => __('If the field has an answer explanation, show it?', 'gravityview'),
29
+				'desc' => __( 'If the field has an answer explanation, show it?', 'gravityview' ),
30 30
 				'value' => false,
31 31
 				'merge_tags' => false,
32 32
 			),
Please login to merge, or discard this patch.