Completed
Push — master ( 9cf7be...029c15 )
by Zack
04:07
created
includes/widgets/search-widget/class-search-widget.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 				'type' => 'radio',
57 57
 				'full_width' => true,
58 58
 				'label' => esc_html__( 'Search Mode', 'gravityview' ),
59
-				'desc' => __('Should search results match all search fields, or any?', 'gravityview'),
59
+				'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ),
60 60
 				'value' => 'any',
61 61
 				'class' => 'hide-if-js',
62 62
 				'options' => array(
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
112 112
 		$script_source = empty( $script_min ) ? '/source' : '';
113 113
 
114
-		wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version );
114
+		wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), GravityView_Plugin::version );
115 115
 
116 116
 
117 117
 		/**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * Add admin script to the whitelist
164 164
 	 */
165 165
 	public function register_no_conflict( $required ) {
166
-		$required[] = 'gravityview_searchwidget_admin';
166
+		$required[ ] = 'gravityview_searchwidget_admin';
167 167
 		return $required;
168 168
 	}
169 169
 
@@ -176,24 +176,24 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	public static function get_searchable_fields() {
178 178
 
179
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) {
179
+		if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) {
180 180
 			exit( '0' );
181 181
 		}
182 182
 
183 183
 		$form = '';
184 184
 
185 185
 		// Fetch the form for the current View
186
-		if ( ! empty( $_POST['view_id'] ) ) {
186
+		if ( ! empty( $_POST[ 'view_id' ] ) ) {
187 187
 
188
-			$form = gravityview_get_form_id( $_POST['view_id'] );
188
+			$form = gravityview_get_form_id( $_POST[ 'view_id' ] );
189 189
 
190
-		} elseif ( ! empty( $_POST['formid'] ) ) {
190
+		} elseif ( ! empty( $_POST[ 'formid' ] ) ) {
191 191
 
192
-			$form = (int) $_POST['formid'];
192
+			$form = (int)$_POST[ 'formid' ];
193 193
 
194
-		} elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) {
194
+		} elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) {
195 195
 
196
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
196
+			$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
197 197
 
198 198
 		}
199 199
 
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 			)
242 242
 		);
243 243
 
244
-		foreach( $custom_fields as $custom_field_key => $custom_field ) {
245
-			$output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] );
244
+		foreach ( $custom_fields as $custom_field_key => $custom_field ) {
245
+			$output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] );
246 246
 		}
247 247
 
248 248
 		if ( ! empty( $fields ) ) {
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
 
252 252
 			foreach ( $fields as $id => $field ) {
253 253
 
254
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
254
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
255 255
 					continue;
256 256
 				}
257 257
 
258
-				$types = self::get_search_input_types( $id, $field['type'] );
258
+				$types = self::get_search_input_types( $id, $field[ 'type' ] );
259 259
 
260
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>';
260
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>';
261 261
 			}
262 262
 		}
263 263
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	public static function get_search_input_types( $id = '', $field_type = null ) {
280 280
 
281 281
 		// @todo - This needs to be improved - many fields have . including products and addresses
282
-		if ( false !== strpos( (string) $id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) {
282
+		if ( false !== strpos( (string)$id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $id, array( 'is_fulfilled' ) ) ) {
283 283
 			$input_type = 'boolean'; // on/off checkbox
284 284
 		} elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) {
285 285
 			$input_type = 'multi'; //multiselect
@@ -321,19 +321,19 @@  discard block
 block discarded – undo
321 321
 			$post_id = 0;
322 322
 
323 323
 			// We're in the WordPress Widget context, and an overriding post ID has been set.
324
-			if ( ! empty( $widget_args['post_id'] ) ) {
325
-				$post_id = absint( $widget_args['post_id'] );
324
+			if ( ! empty( $widget_args[ 'post_id' ] ) ) {
325
+				$post_id = absint( $widget_args[ 'post_id' ] );
326 326
 			}
327 327
 			// We're in the WordPress Widget context, and the base View ID should be used
328
-			else if ( ! empty( $widget_args['view_id'] ) ) {
329
-				$post_id = absint( $widget_args['view_id'] );
328
+			else if ( ! empty( $widget_args[ 'view_id' ] ) ) {
329
+				$post_id = absint( $widget_args[ 'view_id' ] );
330 330
 			}
331 331
 
332 332
 			$args = gravityview_get_permalink_query_args( $post_id );
333 333
 
334 334
 			// Add hidden fields to the search form
335 335
 			foreach ( $args as $key => $value ) {
336
-				$search_fields[] = array(
336
+				$search_fields[ ] = array(
337 337
 					'name'  => $key,
338 338
 					'input' => 'hidden',
339 339
 					'value' => $value,
@@ -365,15 +365,15 @@  discard block
 block discarded – undo
365 365
 		$get = array_map( 'urldecode', $get );
366 366
 
367 367
 		// add free search
368
-		if ( ! empty( $get['gv_search'] ) ) {
368
+		if ( ! empty( $get[ 'gv_search' ] ) ) {
369 369
 
370 370
 			// Search for a piece
371
-			$words = explode( ' ', $get['gv_search'] );
371
+			$words = explode( ' ', $get[ 'gv_search' ] );
372 372
 
373 373
 			$words = array_filter( $words );
374 374
 
375 375
 			foreach ( $words as $word ) {
376
-				$search_criteria['field_filters'][] = array(
376
+				$search_criteria[ 'field_filters' ][ ] = array(
377 377
 					'key' => null, // The field ID to search
378 378
 					'value' => $word, // The value to search
379 379
 					'operator' => 'contains', // What to search in. Options: `is` or `contains`
@@ -398,16 +398,16 @@  discard block
 block discarded – undo
398 398
 		/**
399 399
 		 * Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries)
400 400
 		 */
401
-		if( !empty( $curr_start ) ) {
402
-			$search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
401
+		if ( ! empty( $curr_start ) ) {
402
+			$search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
403 403
 		}
404
-		if( !empty( $curr_end ) ) {
405
-			$search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
404
+		if ( ! empty( $curr_end ) ) {
405
+			$search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
406 406
 		}
407 407
 
408 408
 		// search for a specific entry ID
409 409
 		if ( ! empty( $get[ 'gv_id' ] ) ) {
410
-			$search_criteria['field_filters'][] = array(
410
+			$search_criteria[ 'field_filters' ][ ] = array(
411 411
 				'key' => 'id',
412 412
 				'value' => absint( $get[ 'gv_id' ] ),
413 413
 				'operator' => '=',
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
 
417 417
 		// search for a specific Created_by ID
418 418
 		if ( ! empty( $get[ 'gv_by' ] ) ) {
419
-			$search_criteria['field_filters'][] = array(
419
+			$search_criteria[ 'field_filters' ][ ] = array(
420 420
 				'key' => 'created_by',
421
-				'value' => absint( $get['gv_by'] ),
421
+				'value' => absint( $get[ 'gv_by' ] ),
422 422
 				'operator' => '=',
423 423
 			);
424 424
 		}
@@ -430,22 +430,22 @@  discard block
 block discarded – undo
430 430
 		// get the other search filters
431 431
 		foreach ( $get as $key => $value ) {
432 432
 
433
-			if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[0] ) ) ) {
433
+			if ( 0 !== strpos( $key, 'filter_' ) || empty( $value ) || ( is_array( $value ) && count( $value ) === 1 && empty( $value[ 0 ] ) ) ) {
434 434
 				continue;
435 435
 			}
436 436
 
437 437
 			// could return simple filter or multiple filters
438 438
 			$filter = $this->prepare_field_filter( $key, $value );
439 439
 
440
-			if ( isset( $filter[0]['value'] ) ) {
441
-				$search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter );
440
+			if ( isset( $filter[ 0 ][ 'value' ] ) ) {
441
+				$search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter );
442 442
 
443 443
 				// if date range type, set search mode to ALL
444
-				if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>', '<' ) ) ) {
444
+				if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>', '<' ) ) ) {
445 445
 					$mode = 'all';
446 446
 				}
447
-			} elseif( !empty( $filter ) ) {
448
-				$search_criteria['field_filters'][] = $filter;
447
+			} elseif ( ! empty( $filter ) ) {
448
+				$search_criteria[ 'field_filters' ][ ] = $filter;
449 449
 			}
450 450
 		}
451 451
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 		 * @since 1.5.1
455 455
 		 * @param[out,in] string $mode Search mode (`any` vs `all`)
456 456
 		 */
457
-		$search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode );
457
+		$search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode );
458 458
 
459 459
 		do_action( 'gravityview_log_debug', sprintf( '%s[filter_entries] Returned Search Criteria: ', get_class( $this ) ), $search_criteria );
460 460
 
@@ -490,11 +490,11 @@  discard block
 block discarded – undo
490 490
 			'value' => _wp_specialchars( $value ), // Gravity Forms encodes ampersands but not quotes
491 491
 		);
492 492
 
493
-		switch ( $form_field['type'] ) {
493
+		switch ( $form_field[ 'type' ] ) {
494 494
 
495 495
 			case 'select':
496 496
 			case 'radio':
497
-				$filter['operator'] = 'is';
497
+				$filter[ 'operator' ] = 'is';
498 498
 				break;
499 499
 
500 500
 			case 'post_category':
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 
509 509
 				foreach ( $value as $val ) {
510 510
 					$cat = get_term( $val, 'category' );
511
-					$filter[] = array(
511
+					$filter[ ] = array(
512 512
 						'key' => $field_id,
513 513
 						'value' => esc_attr( $cat->name ) . ':' . $val,
514 514
 						'operator' => 'is',
@@ -527,18 +527,18 @@  discard block
 block discarded – undo
527 527
 				$filter = array();
528 528
 
529 529
 				foreach ( $value as $val ) {
530
-					$filter[] = array( 'key' => $field_id, 'value' => $val );
530
+					$filter[ ] = array( 'key' => $field_id, 'value' => $val );
531 531
 				}
532 532
 
533 533
 				break;
534 534
 
535 535
 			case 'checkbox':
536 536
 				// convert checkbox on/off into the correct search filter
537
-				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field['inputs'] ) && ! empty( $form_field['choices'] ) ) {
538
-					foreach ( $form_field['inputs'] as $k => $input ) {
539
-						if ( $input['id'] == $field_id ) {
540
-							$filter['value'] = $form_field['choices'][ $k ]['value'];
541
-							$filter['operator'] = 'is';
537
+				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field[ 'inputs' ] ) && ! empty( $form_field[ 'choices' ] ) ) {
538
+					foreach ( $form_field[ 'inputs' ] as $k => $input ) {
539
+						if ( $input[ 'id' ] == $field_id ) {
540
+							$filter[ 'value' ] = $form_field[ 'choices' ][ $k ][ 'value' ];
541
+							$filter[ 'operator' ] = 'is';
542 542
 							break;
543 543
 						}
544 544
 					}
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 					$filter = array();
549 549
 
550 550
 					foreach ( $value as $val ) {
551
-						$filter[] = array(
551
+						$filter[ ] = array(
552 552
 								'key'   => $field_id,
553 553
 								'value' => $val,
554 554
 								'operator' => 'is',
@@ -569,9 +569,9 @@  discard block
 block discarded – undo
569 569
 					foreach ( $words as $word ) {
570 570
 						if ( ! empty( $word ) && strlen( $word ) > 1 ) {
571 571
 							// Keep the same key for each filter
572
-							$filter['value'] = $word;
572
+							$filter[ 'value' ] = $word;
573 573
 							// Add a search for the value
574
-							$filters[] = $filter;
574
+							$filters[ ] = $filter;
575 575
 						}
576 576
 					}
577 577
 
@@ -593,14 +593,14 @@  discard block
 block discarded – undo
593 593
 						}
594 594
 						$operator = 'start' === $k ? '>' : '<';
595 595
 
596
-						$filter[] = array(
596
+						$filter[ ] = array(
597 597
 							'key' => $field_id,
598 598
 							'value' => self::get_formatted_date( $date, 'Y-m-d' ),
599 599
 							'operator' => $operator,
600 600
 						);
601 601
 					}
602 602
 				} else {
603
-					$filter['value'] = self::get_formatted_date( $value, 'Y-m-d' );
603
+					$filter[ 'value' ] = self::get_formatted_date( $value, 'Y-m-d' );
604 604
 				}
605 605
 
606 606
 				break;
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 			'ymd_dot' => 'Y.m.d',
632 632
 		);
633 633
 
634
-		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){
634
+		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) {
635 635
 			$format = $datepicker[ $field->dateFormat ];
636 636
 		}
637 637
 
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	public function add_template_path( $file_paths ) {
663 663
 
664 664
 		// Index 100 is the default GravityView template path.
665
-		$file_paths[102] = self::$file . 'templates/';
665
+		$file_paths[ 102 ] = self::$file . 'templates/';
666 666
 
667 667
 		return $file_paths;
668 668
 	}
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 		}
685 685
 
686 686
 		// get configured search fields
687
-		$search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : '';
687
+		$search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : '';
688 688
 
689 689
 		if ( empty( $search_fields ) || ! is_array( $search_fields ) ) {
690 690
 			do_action( 'gravityview_log_debug', sprintf( '%s[render_frontend] No search fields configured for widget:', get_class( $this ) ), $widget_args );
@@ -698,24 +698,24 @@  discard block
 block discarded – undo
698 698
 
699 699
 			$updated_field = $field;
700 700
 
701
-			if ( in_array( $field['input'], array( 'date', 'date_range' ) ) ) {
701
+			if ( in_array( $field[ 'input' ], array( 'date', 'date_range' ) ) ) {
702 702
 				$has_date = true;
703 703
 			}
704 704
 
705 705
 			$updated_field = $this->get_search_filter_details( $updated_field );
706 706
 
707
-			switch ( $field['field'] ) {
707
+			switch ( $field[ 'field' ] ) {
708 708
 
709 709
 				case 'search_all':
710
-					$updated_field['key'] = 'search_all';
711
-					$updated_field['input'] = 'search_all';
712
-					$updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_search' ) ) );
710
+					$updated_field[ 'key' ] = 'search_all';
711
+					$updated_field[ 'input' ] = 'search_all';
712
+					$updated_field[ 'value' ] = esc_attr( stripslashes_deep( rgget( 'gv_search' ) ) );
713 713
 					break;
714 714
 
715 715
 				case 'entry_date':
716
-					$updated_field['key'] = 'entry_date';
717
-					$updated_field['input'] = 'entry_date';
718
-					$updated_field['value'] = array(
716
+					$updated_field[ 'key' ] = 'entry_date';
717
+					$updated_field[ 'input' ] = 'entry_date';
718
+					$updated_field[ 'value' ] = array(
719 719
 						'start' => esc_attr( stripslashes_deep( rgget( 'gv_start' ) ) ),
720 720
 						'end' => esc_attr( stripslashes_deep( rgget( 'gv_end' ) ) ),
721 721
 					);
@@ -723,16 +723,16 @@  discard block
 block discarded – undo
723 723
 					break;
724 724
 
725 725
 				case 'entry_id':
726
-					$updated_field['key'] = 'entry_id';
727
-					$updated_field['input'] = 'entry_id';
728
-					$updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_id' ) ) );
726
+					$updated_field[ 'key' ] = 'entry_id';
727
+					$updated_field[ 'input' ] = 'entry_id';
728
+					$updated_field[ 'value' ] = esc_attr( stripslashes_deep( rgget( 'gv_id' ) ) );
729 729
 					break;
730 730
 
731 731
 				case 'created_by':
732
-					$updated_field['key'] = 'created_by';
733
-					$updated_field['name'] = 'gv_by';
734
-					$updated_field['value'] = esc_attr( stripslashes_deep( rgget( 'gv_by' ) ) );
735
-					$updated_field['choices'] = self::get_created_by_choices();
732
+					$updated_field[ 'key' ] = 'created_by';
733
+					$updated_field[ 'name' ] = 'gv_by';
734
+					$updated_field[ 'value' ] = esc_attr( stripslashes_deep( rgget( 'gv_by' ) ) );
735
+					$updated_field[ 'choices' ] = self::get_created_by_choices();
736 736
 					break;
737 737
 			}
738 738
 
@@ -750,16 +750,16 @@  discard block
 block discarded – undo
750 750
 		 */
751 751
 		$gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args );
752 752
 
753
-		$gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal';
753
+		$gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal';
754 754
 
755 755
 		/** @since 1.14 */
756
-		$gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any';
756
+		$gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any';
757 757
 
758
-		$custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : '';
758
+		$custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : '';
759 759
 
760 760
 		$gravityview_view->search_class = self::get_search_class( $custom_class );
761 761
 
762
-		$gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false;
762
+		$gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false;
763 763
 
764 764
 		if ( $has_date ) {
765 765
 			// enqueue datepicker stuff only if needed!
@@ -779,10 +779,10 @@  discard block
 block discarded – undo
779 779
 	public static function get_search_class( $custom_class = '' ) {
780 780
 		$gravityview_view = GravityView_View::getInstance();
781 781
 
782
-		$search_class = 'gv-search-'.$gravityview_view->search_layout;
782
+		$search_class = 'gv-search-' . $gravityview_view->search_layout;
783 783
 
784
-		if ( ! empty( $custom_class )  ) {
785
-			$search_class .= ' '.$custom_class;
784
+		if ( ! empty( $custom_class ) ) {
785
+			$search_class .= ' ' . $custom_class;
786 786
 		}
787 787
 
788 788
 		/**
@@ -825,11 +825,11 @@  discard block
 block discarded – undo
825 825
 
826 826
 		$label = rgget( 'label', $field );
827 827
 
828
-		if( '' === $label ) {
828
+		if ( '' === $label ) {
829 829
 
830
-			$label = isset( $form_field['label'] ) ? $form_field['label'] : '';
830
+			$label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : '';
831 831
 
832
-			switch( $field['field'] ) {
832
+			switch ( $field[ 'field' ] ) {
833 833
 				case 'search_all':
834 834
 					$label = __( 'Search Entries:', 'gravityview' );
835 835
 					break;
@@ -847,10 +847,10 @@  discard block
 block discarded – undo
847 847
 					break;
848 848
 				default:
849 849
 					// If this is a field input, not a field
850
-					if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) {
850
+					if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) {
851 851
 
852 852
 						// Get the label for the field in question, which returns an array
853
-						$items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) );
853
+						$items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) );
854 854
 
855 855
 						// Get the item with the `label` key
856 856
 						$values = wp_list_pluck( $items, 'label' );
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 		$form = $gravityview_view->getForm();
888 888
 
889 889
 		// for advanced field ids (eg, first name / last name )
890
-		$name = 'filter_' . str_replace( '.', '_', $field['field'] );
890
+		$name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] );
891 891
 
892 892
 		// get searched value from $_GET (string or array)
893 893
 		$value = rgget( $name );
@@ -897,26 +897,26 @@  discard block
 block discarded – undo
897 897
 		$value = is_array( $value ) ? array_map( 'urldecode', $value ) : urldecode( $value );
898 898
 
899 899
 		// get form field details
900
-		$form_field = gravityview_get_field( $form, $field['field'] );
900
+		$form_field = gravityview_get_field( $form, $field[ 'field' ] );
901 901
 
902 902
 		$filter = array(
903
-			'key' => $field['field'],
903
+			'key' => $field[ 'field' ],
904 904
 			'name' => $name,
905 905
 			'label' => self::get_field_label( $field, $form_field ),
906
-			'input' => $field['input'],
906
+			'input' => $field[ 'input' ],
907 907
 			'value' => _wp_specialchars( $value ),
908
-			'type' => $form_field['type'],
908
+			'type' => $form_field[ 'type' ],
909 909
 		);
910 910
 
911 911
 		// collect choices
912
-		if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) {
913
-			$filter['choices'] = gravityview_get_terms_choices();
914
-		} elseif ( ! empty( $form_field['choices'] ) ) {
915
-			$filter['choices'] = $form_field['choices'];
912
+		if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) {
913
+			$filter[ 'choices' ] = gravityview_get_terms_choices();
914
+		} elseif ( ! empty( $form_field[ 'choices' ] ) ) {
915
+			$filter[ 'choices' ] = $form_field[ 'choices' ];
916 916
 		}
917 917
 
918
-		if ( 'date_range' === $field['input'] && empty( $value ) ) {
919
-			$filter['value'] = array( 'start' => '', 'end' => '' );
918
+		if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) {
919
+			$filter[ 'value' ] = array( 'start' => '', 'end' => '' );
920 920
 		}
921 921
 
922 922
 		return $filter;
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 
941 941
 		$choices = array();
942 942
 		foreach ( $users as $user ) {
943
-			$choices[] = array(
943
+			$choices[ ] = array(
944 944
 				'value' => $user->ID,
945 945
 				'text' => $user->display_name,
946 946
 			);
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 	 */
975 975
 	public function add_datepicker_js_dependency( $js_dependencies ) {
976 976
 
977
-		$js_dependencies[] = 'jquery-ui-datepicker';
977
+		$js_dependencies[ ] = 'jquery-ui-datepicker';
978 978
 
979 979
 		return $js_dependencies;
980 980
 	}
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
 			'isRTL'             => is_rtl(),
1019 1019
 		), $view_data );
1020 1020
 
1021
-		$localizations['datepicker'] = $datepicker_settings;
1021
+		$localizations[ 'datepicker' ] = $datepicker_settings;
1022 1022
 
1023 1023
 		return $localizations;
1024 1024
 
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 		add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 );
1042 1042
 
1043 1043
 		$scheme = is_ssl() ? 'https://' : 'http://';
1044
-		wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1044
+		wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1045 1045
 
1046 1046
 		/**
1047 1047
 		 * @filter `gravityview_search_datepicker_class`
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-user-registration.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	     * @since 1.11
44 44
 	     * @param boolean $boolean Whether to trigger update on user registration (default: true)
45 45
 	     */
46
-        if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
47
-            add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
46
+        if ( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
47
+            add_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10, 2 );
48 48
 
49 49
             // last resort in case the current user display name don't match any of the defaults
50 50
             add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function update_user( $form = array(), $entry_id = 0 ) {
64 64
 
65
-        if( !class_exists( 'GFAPI' ) || !class_exists( 'GFUser' ) || empty( $entry_id ) ) {
65
+        if ( ! class_exists( 'GFAPI' ) || ! class_exists( 'GFUser' ) || empty( $entry_id ) ) {
66 66
             return;
67 67
         }
68 68
 
69 69
         // support for GF User Registration 3.x
70
-        $gf_user_3 =  class_exists('GF_User_Registration') ? true : false;
70
+        $gf_user_3 = class_exists( 'GF_User_Registration' ) ? true : false;
71 71
 
72
-        if( $gf_user_3 ) {
72
+        if ( $gf_user_3 ) {
73 73
             $gf_user_registration = GF_User_Registration::get_instance();
74 74
         }
75 75
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         /**
87 87
          * @since 1.14
88 88
          */
89
-        if( $gf_user_3 ) {
89
+        if ( $gf_user_3 ) {
90 90
             $config = $gf_user_registration->get_single_submission_feed( $entry, $form );
91 91
         } else {
92 92
             $config = GFUser::get_active_config( $form, $entry );
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
          */
104 104
         $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
105 105
 
106
-        if( $preserve_role ) {
107
-            $config['meta']['role'] = 'gfur_preserve_role';
106
+        if ( $preserve_role ) {
107
+            $config[ 'meta' ][ 'role' ] = 'gfur_preserve_role';
108 108
         }
109 109
 
110 110
         /**
111 111
          * Make sure the current display name is not changed with the update user method.
112 112
          * @since 1.15
113 113
          */
114
-        $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] );
114
+        $config[ 'meta' ][ 'displayname' ] = $this->match_current_display_name( $entry[ 'created_by' ] );
115 115
 
116 116
 
117 117
         /**
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
          */
124 124
         $config = apply_filters( 'gravityview/edit_entry/user_registration/config', $config, $form, $entry );
125 125
 
126
-        $is_create_feed = ( $config && rgars( $config, 'meta/feed_type') === 'create' );
126
+        $is_create_feed = ( $config && rgars( $config, 'meta/feed_type' ) === 'create' );
127 127
 
128 128
         // Only update if it's a create feed
129
-        if( ! $is_create_feed ) {
129
+        if ( ! $is_create_feed ) {
130 130
             return;
131 131
         }
132 132
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         add_filter( 'send_email_change_email', '__return_false', 3 );
136 136
 
137 137
         // Trigger the User Registration update user method
138
-        if( $gf_user_3 ) {
138
+        if ( $gf_user_3 ) {
139 139
             $gf_user_registration->update_user( $entry, $form, $config );
140 140
         } else {
141 141
             GFUser::update_user( $entry, $form, $config );
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 
166 166
         // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support)
167 167
         //   trigger last resort method at the 'gform_user_updated' hook
168
-        if( false === $format || 'nickname' === $format ) {
168
+        if ( false === $format || 'nickname' === $format ) {
169 169
             $this->_user_before_update = $user;
170 170
             $format = 'nickname';
171 171
         }
@@ -185,18 +185,18 @@  discard block
 block discarded – undo
185 185
     public function generate_display_names( $profileuser ) {
186 186
 
187 187
         $public_display = array();
188
-        $public_display['nickname']  = $profileuser->nickname;
189
-        $public_display['username']  = $profileuser->user_login;
188
+        $public_display[ 'nickname' ]  = $profileuser->nickname;
189
+        $public_display[ 'username' ]  = $profileuser->user_login;
190 190
 
191
-        if ( !empty($profileuser->first_name) )
192
-            $public_display['firstname'] = $profileuser->first_name;
191
+        if ( ! empty( $profileuser->first_name ) )
192
+            $public_display[ 'firstname' ] = $profileuser->first_name;
193 193
 
194
-        if ( !empty($profileuser->last_name) )
195
-            $public_display['lastname'] = $profileuser->last_name;
194
+        if ( ! empty( $profileuser->last_name ) )
195
+            $public_display[ 'lastname' ] = $profileuser->last_name;
196 196
 
197
-        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
198
-            $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
199
-            $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
197
+        if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
198
+            $public_display[ 'firstlast' ] = $profileuser->first_name . ' ' . $profileuser->last_name;
199
+            $public_display[ 'lastfirst' ] = $profileuser->last_name . ' ' . $profileuser->first_name;
200 200
         }
201 201
 
202 202
         $public_display = array_map( 'trim', $public_display );
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
          */
227 227
         $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
228 228
 
229
-        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
229
+        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type' ) === 'update' );
230 230
 
231 231
         /**
232 232
          * Don't restore display name:
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
          *   - or we don't need as we found the correct format before updating user.
236 236
          * @since 1.14.4
237 237
          */
238
-        if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
238
+        if ( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
239 239
             return;
240 240
         }
241 241
 
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 
262 262
         $updated = wp_update_user( $restored_user );
263 263
 
264
-        if( is_wp_error( $updated ) ) {
265
-            do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
264
+        if ( is_wp_error( $updated ) ) {
265
+            do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
266 266
         } else {
267
-            do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
267
+            do_action( 'gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
268 268
         }
269 269
 
270 270
         $this->_user_before_update = null;
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
         self::$file = plugin_dir_path( __FILE__ );
38 38
 
39
-        if( is_admin() ) {
39
+        if ( is_admin() ) {
40 40
             $this->load_components( 'admin' );
41 41
         }
42 42
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         $this->load_components( 'render' );
45 45
 
46 46
         // If GF User Registration Add-on exists
47
-        if( class_exists( 'GFUser' ) || class_exists( 'GF_User_Registration' ) ) {
47
+        if ( class_exists( 'GFUser' ) || class_exists( 'GF_User_Registration' ) ) {
48 48
             $this->load_components( 'user-registration' );
49 49
         }
50 50
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
     static function getInstance() {
59 59
 
60
-        if( empty( self::$instance ) ) {
60
+        if ( empty( self::$instance ) ) {
61 61
             self::$instance = new GravityView_Edit_Entry;
62 62
         }
63 63
 
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
     private function add_hooks() {
84 84
 
85 85
         // Add front-end access to Gravity Forms delete file action
86
-        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file') );
86
+        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'RGForms', 'delete_file' ) );
87 87
 
88 88
         // Make sure this hook is run for non-admins
89
-        add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file') );
89
+        add_action( 'wp_ajax_rg_delete_file', array( 'RGForms', 'delete_file' ) );
90 90
 
91 91
         add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
92 92
 
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	private function addon_specific_hooks() {
103 103
 
104
-		if( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) {
105
-			add_filter('gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script'));
104
+		if ( class_exists( 'GFSignature' ) && is_callable( array( 'GFSignature', 'get_instance' ) ) ) {
105
+			add_filter( 'gform_admin_pre_render', array( GFSignature::get_instance(), 'edit_lead_script' ) );
106 106
 		}
107 107
 
108 108
 	}
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
150 150
 
151
-        $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
151
+        $nonce_key = self::get_nonce_key( $view_id, $entry[ 'form_id' ], $entry[ 'id' ] );
152 152
 
153 153
         $base = gv_entry_link( $entry, $post_id );
154 154
 
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 	     * Allow passing params to dynamically populate entry with values
163 163
 	     * @since 1.9.2
164 164
 	     */
165
-	    if( !empty( $field_values ) ) {
165
+	    if ( ! empty( $field_values ) ) {
166 166
 
167
-		    if( is_array( $field_values ) ) {
167
+		    if ( is_array( $field_values ) ) {
168 168
 			    // If already an array, no parse_str() needed
169 169
 			    $params = $field_values;
170 170
 		    } else {
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	public function modify_field_blacklist( $fields = array(), $context = NULL ) {
188 188
 
189
-		if( empty( $context ) || $context !== 'edit' ) {
189
+		if ( empty( $context ) || $context !== 'edit' ) {
190 190
 			return $fields;
191 191
 		}
192 192
 
@@ -228,24 +228,24 @@  discard block
 block discarded – undo
228 228
         // If they can edit any entries (as defined in Gravity Forms)
229 229
         // Or if they can edit other people's entries
230 230
         // Then we're good.
231
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
231
+        if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry[ 'id' ] ) ) {
232 232
 
233
-            do_action('gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.');
233
+            do_action( 'gravityview_log_debug', __METHOD__ . ' - User has ability to edit all entries.' );
234 234
 
235 235
             $user_can_edit = true;
236 236
 
237
-        } else if( !isset( $entry['created_by'] ) ) {
237
+        } else if ( ! isset( $entry[ 'created_by' ] ) ) {
238 238
 
239
-            do_action('gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.');
239
+            do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[check_user_cap_edit_entry] Entry `created_by` doesn\'t exist.' );
240 240
 
241 241
             $user_can_edit = false;
242 242
 
243 243
         } else {
244 244
 
245 245
             // get user_edit setting
246
-            if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) {
246
+            if ( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) {
247 247
                 // if View ID not specified or is the current view
248
-                $user_edit = GravityView_View::getInstance()->getAtts('user_edit');
248
+                $user_edit = GravityView_View::getInstance()->getAtts( 'user_edit' );
249 249
             } else {
250 250
                 // in case is specified and not the current view
251 251
                 $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' );
@@ -254,21 +254,21 @@  discard block
 block discarded – undo
254 254
             $current_user = wp_get_current_user();
255 255
 
256 256
             // User edit is disabled
257
-            if( empty( $user_edit ) ) {
257
+            if ( empty( $user_edit ) ) {
258 258
 
259
-                do_action('gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' );
259
+                do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[check_user_cap_edit_entry] User Edit is disabled. Returning false.' );
260 260
 
261 261
                 $user_can_edit = false;
262 262
             }
263 263
 
264 264
             // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
265
-            else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
265
+            else if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) {
266 266
 
267
-                do_action('gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) );
267
+                do_action( 'gravityview_log_debug', sprintf( 'GravityView_Edit_Entry[check_user_cap_edit_entry] User %s created the entry.', $current_user->ID ) );
268 268
 
269 269
                 $user_can_edit = true;
270 270
 
271
-            } else if( ! is_user_logged_in() ) {
271
+            } else if ( ! is_user_logged_in() ) {
272 272
 
273 273
                 do_action( 'gravityview_log_debug', __METHOD__ . ' No user defined; edit entry requires logged in user' );
274 274
             }
Please login to merge, or discard this patch.
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.