Completed
Push — develop ( 4f29d3...a5558b )
by Zack
10:40
created
includes/class-common.php 1 patch
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 
127 127
 		$form = false;
128 128
 
129
-		if( $entry ) {
130
-			$form = GFAPI::get_form( $entry['form_id'] );
129
+		if ( $entry ) {
130
+			$form = GFAPI::get_form( $entry[ 'form_id' ] );
131 131
 		}
132 132
 
133 133
 		return $form;
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 
194 194
 			$has_transaction_data = rgar( $entry, $meta, false );
195 195
 
196
-			if( ! empty( $has_transaction_data ) ) {
196
+			if ( ! empty( $has_transaction_data ) ) {
197 197
 				break;
198 198
 			}
199 199
 		}
200 200
 
201
-		return (bool) $has_transaction_data;
201
+		return (bool)$has_transaction_data;
202 202
 	}
203 203
 
204 204
 	/**
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
 		$results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging );
238 238
 
239
-		$result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null;
239
+		$result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null;
240 240
 
241 241
 		return $result;
242 242
 	}
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 	 *
254 254
 	 * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms
255 255
 	 */
256
-	public static function get_forms(  $active = true, $trash = false ) {
256
+	public static function get_forms( $active = true, $trash = false ) {
257 257
 		$forms = array();
258 258
 		if ( class_exists( 'GFAPI' ) ) {
259
-			if( 'any' === $active ) {
259
+			if ( 'any' === $active ) {
260 260
 				$active_forms = GFAPI::get_forms( true, $trash );
261 261
 				$inactive_forms = GFAPI::get_forms( false, $trash );
262 262
 				$forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) );
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 		$has_post_fields = false;
288 288
 
289 289
 		if ( $form ) {
290
-			foreach ( $form['fields'] as $field ) {
291
-				if ( $include_parent_field || empty( $field['inputs'] ) ) {
292
-					$fields["{$field['id']}"] = array(
290
+			foreach ( $form[ 'fields' ] as $field ) {
291
+				if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) {
292
+					$fields[ "{$field[ 'id' ]}" ] = array(
293 293
 						'label' => rgar( $field, 'label' ),
294 294
 						'parent' => null,
295 295
 						'type' => rgar( $field, 'type' ),
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 					);
299 299
 				}
300 300
 
301
-				if ( $add_default_properties && ! empty( $field['inputs'] ) ) {
302
-					foreach ( $field['inputs'] as $input ) {
301
+				if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) {
302
+					foreach ( $field[ 'inputs' ] as $input ) {
303 303
 
304
-						if( ! empty( $input['isHidden'] ) ) {
304
+						if ( ! empty( $input[ 'isHidden' ] ) ) {
305 305
 							continue;
306 306
 						}
307 307
 
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
                          * @hack
310 310
                          * In case of email/email confirmation, the input for email has the same id as the parent field
311 311
                          */
312
-						if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) {
312
+						if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) {
313 313
                             continue;
314 314
                         }
315
-						$fields["{$input['id']}"] = array(
315
+						$fields[ "{$input[ 'id' ]}" ] = array(
316 316
 							'label' => rgar( $input, 'label' ),
317 317
 							'customLabel' => rgar( $input, 'customLabel' ),
318 318
 							'parent' => $field,
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 				}
325 325
 
326 326
 
327
-				if( GFCommon::is_product_field( $field['type'] ) ){
327
+				if ( GFCommon::is_product_field( $field[ 'type' ] ) ) {
328 328
 					$has_product_fields = true;
329 329
 				}
330 330
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 		 * @since 1.7
339 339
 		 */
340 340
 		if ( $has_post_fields ) {
341
-			$fields['post_id'] = array(
341
+			$fields[ 'post_id' ] = array(
342 342
 				'label' => __( 'Post ID', 'gravityview' ),
343 343
 				'type' => 'post_id',
344 344
 			);
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
 			$payment_fields = GravityView_Fields::get_all( 'pricing' );
350 350
 
351 351
 			foreach ( $payment_fields as $payment_field ) {
352
-				if( isset( $fields["{$payment_field->name}"] ) ) {
352
+				if ( isset( $fields[ "{$payment_field->name}" ] ) ) {
353 353
 					continue;
354 354
 				}
355
-				$fields["{$payment_field->name}"] = array(
355
+				$fields[ "{$payment_field->name}" ] = array(
356 356
 					'label' => $payment_field->label,
357 357
 					'desc' => $payment_field->description,
358 358
 					'type' => $payment_field->name,
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 
385 385
 		$fields = array();
386 386
 
387
-		foreach ( $extra_fields as $key => $field ){
388
-			if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) {
389
-				$fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' );
387
+		foreach ( $extra_fields as $key => $field ) {
388
+			if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) {
389
+				$fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' );
390 390
 			}
391 391
 		}
392 392
 
@@ -426,32 +426,32 @@  discard block
 block discarded – undo
426 426
 			'search_criteria' => null,
427 427
 			'sorting' => null,
428 428
 			'paging' => null,
429
-			'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true),
429
+			'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? $passed_criteria[ 'cache' ] : true ),
430 430
 		);
431 431
 
432 432
 		$criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults );
433 433
 
434
-		if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) {
435
-			foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) {
434
+		if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) {
435
+			foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) {
436 436
 
437 437
 				if ( ! is_array( $filter ) ) {
438 438
 					continue;
439 439
 				}
440 440
 
441 441
 				// By default, we want searches to be wildcard for each field.
442
-				$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
442
+				$filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];
443 443
 
444 444
 				/**
445 445
 				 * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc)
446 446
 				 * @param string $operator Existing search operator
447 447
 				 * @param array $filter array with `key`, `value`, `operator`, `type` keys
448 448
 				 */
449
-				$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter );
449
+				$filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter );
450 450
 			}
451 451
 
452 452
 			// don't send just the [mode] without any field filter.
453
-			if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) {
454
-				unset( $criteria['search_criteria']['field_filters']['mode'] );
453
+			if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) {
454
+				unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] );
455 455
 			}
456 456
 
457 457
 		}
@@ -462,21 +462,21 @@  discard block
 block discarded – undo
462 462
 		 * Prepare date formats to be in Gravity Forms DB format;
463 463
 		 * $passed_criteria may include date formats incompatible with Gravity Forms.
464 464
 		 */
465
-		foreach ( array('start_date', 'end_date' ) as $key ) {
465
+		foreach ( array( 'start_date', 'end_date' ) as $key ) {
466 466
 
467
-			if ( ! empty( $criteria['search_criteria'][ $key ] ) ) {
467
+			if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) {
468 468
 
469 469
 				// Use date_create instead of new DateTime so it returns false if invalid date format.
470
-				$date = date_create( $criteria['search_criteria'][ $key ] );
470
+				$date = date_create( $criteria[ 'search_criteria' ][ $key ] );
471 471
 
472 472
 				if ( $date ) {
473 473
 					// Gravity Forms wants dates in the `Y-m-d H:i:s` format.
474
-					$criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' );
474
+					$criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' );
475 475
 				} else {
476 476
 					// If it's an invalid date, unset it. Gravity Forms freaks out otherwise.
477
-					unset( $criteria['search_criteria'][ $key ] );
477
+					unset( $criteria[ 'search_criteria' ][ $key ] );
478 478
 
479
-					do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] );
479
+					do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] );
480 480
 				}
481 481
 			}
482 482
 		}
@@ -484,12 +484,12 @@  discard block
 block discarded – undo
484 484
 
485 485
 		// When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter
486 486
 		if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) {
487
-			$criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id();
487
+			$criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id();
488 488
 		} elseif ( 'delete' === GFForms::get( 'action' ) ) {
489
-			$criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null;
490
-		} elseif( !isset( $criteria['context_view_id'] ) ) {
489
+			$criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null;
490
+		} elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) {
491 491
             // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget)
492
-			$criteria['context_view_id'] = null;
492
+			$criteria[ 'context_view_id' ] = null;
493 493
 		}
494 494
 
495 495
 		/**
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 		 * @param array $form_ids Forms to search
499 499
 		 * @param int $view_id ID of the view being used to search
500 500
 		 */
501
-		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] );
501
+		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] );
502 502
 
503 503
 		return (array)$criteria;
504 504
 
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 		/** Reduce # of database calls */
530 530
 		add_filter( 'gform_is_encrypted_field', '__return_false' );
531 531
 
532
-		if ( ! empty( $criteria['cache'] ) ) {
532
+		if ( ! empty( $criteria[ 'cache' ] ) ) {
533 533
 
534 534
 			$Cache = new GravityView_Cache( $form_ids, $criteria );
535 535
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 
538 538
 				// Still update the total count when using cached results
539 539
 				if ( ! is_null( $total ) ) {
540
-					$total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] );
540
+					$total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] );
541 541
 				}
542 542
 
543 543
 				$return = $entries;
@@ -557,9 +557,9 @@  discard block
 block discarded – undo
557 557
 			$entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total );
558 558
 
559 559
 			// No entries returned from gravityview_before_get_entries
560
-			if( is_null( $entries ) ) {
560
+			if ( is_null( $entries ) ) {
561 561
 
562
-				$entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total );
562
+				$entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total );
563 563
 
564 564
 				if ( is_wp_error( $entries ) ) {
565 565
 					do_action( 'gravityview_log_error', $entries->get_error_message(), $entries );
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 				}
569 569
 			}
570 570
 
571
-			if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) {
571
+			if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) {
572 572
 
573 573
 				// Cache results
574 574
 				$Cache->set( $entries, 'entries' );
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 			 */
674 674
 			$check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry );
675 675
 
676
-			if( $check_entry_display ) {
676
+			if ( $check_entry_display ) {
677 677
 				// Is the entry allowed
678 678
 				$entry = self::check_entry_display( $entry );
679 679
 			}
@@ -706,12 +706,12 @@  discard block
 block discarded – undo
706 706
 
707 707
 		$value = false;
708 708
 
709
-		if( 'context' === $val1 ) {
709
+		if ( 'context' === $val1 ) {
710 710
 
711 711
 			$matching_contexts = array( $val2 );
712 712
 
713 713
 			// We allow for non-standard contexts.
714
-			switch( $val2 ) {
714
+			switch ( $val2 ) {
715 715
 				// Check for either single or edit
716 716
 				case 'singular':
717 717
 					$matching_contexts = array( 'single', 'edit' );
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 			return false;
772 772
 		}
773 773
 
774
-		if ( empty( $entry['form_id'] ) ) {
774
+		if ( empty( $entry[ 'form_id' ] ) ) {
775 775
 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry );
776 776
 			return false;
777 777
 		}
@@ -779,26 +779,26 @@  discard block
 block discarded – undo
779 779
 		$criteria = self::calculate_get_entries_criteria();
780 780
 
781 781
 		// Make sure the current View is connected to the same form as the Entry
782
-		if( ! empty( $criteria['context_view_id'] ) ) {
783
-			$context_view_id = intval( $criteria['context_view_id'] );
782
+		if ( ! empty( $criteria[ 'context_view_id' ] ) ) {
783
+			$context_view_id = intval( $criteria[ 'context_view_id' ] );
784 784
 			$context_form_id = gravityview_get_form_id( $context_view_id );
785
-			if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) {
786
-				do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] );
785
+			if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) {
786
+				do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] );
787 787
 				return false;
788 788
 			}
789 789
 		}
790 790
 
791
-		if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) {
791
+		if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) {
792 792
 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria );
793 793
 			return $entry;
794 794
 		}
795 795
 
796
-		$search_criteria = $criteria['search_criteria'];
796
+		$search_criteria = $criteria[ 'search_criteria' ];
797 797
 		unset( $criteria );
798 798
 
799 799
 		// check entry status
800
-		if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) {
801
-			do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria );
800
+		if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) {
801
+			do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria );
802 802
 			return false;
803 803
 		}
804 804
 
@@ -806,40 +806,40 @@  discard block
 block discarded – undo
806 806
 		// @todo: Does it make sense to apply the Date create filters to the single entry?
807 807
 
808 808
 		// field_filters
809
-		if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) {
809
+		if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) {
810 810
 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria );
811 811
 			return $entry;
812 812
 		}
813 813
 
814
-		$filters = $search_criteria['field_filters'];
814
+		$filters = $search_criteria[ 'field_filters' ];
815 815
 		unset( $search_criteria );
816 816
 
817
-		$mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all';
818
-		unset( $filters['mode'] );
817
+		$mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all';
818
+		unset( $filters[ 'mode' ] );
819 819
 
820
-		$form = self::get_form( $entry['form_id'] );
820
+		$form = self::get_form( $entry[ 'form_id' ] );
821 821
 
822 822
 		foreach ( $filters as $filter ) {
823 823
 
824
-			if ( ! isset( $filter['key'] ) ) {
824
+			if ( ! isset( $filter[ 'key' ] ) ) {
825 825
 				do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Filter key not set', $filter );
826 826
 				continue;
827 827
 			}
828 828
 
829
-			$k = $filter['key'];
829
+			$k = $filter[ 'key' ];
830 830
 
831 831
 			if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) {
832 832
 				$field_value = $entry[ $k ];
833 833
 				$field = null;
834 834
 			} else {
835 835
 				$field = self::get_field( $form, $k );
836
-				$field_value  = GFFormsModel::get_lead_field_value( $entry, $field );
836
+				$field_value = GFFormsModel::get_lead_field_value( $entry, $field );
837 837
 				 // If it's a complex field, then fetch the input's value
838 838
 				$field_value = is_array( $field_value ) ? rgar( $field_value, $k ) : $field_value;
839 839
 			}
840 840
 
841
-			$operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is';
842
-			$is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field );
841
+			$operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is';
842
+			$is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field );
843 843
 
844 844
 			// verify if we are already free to go!
845 845
 			if ( ! $is_value_match && 'all' === $mode ) {
@@ -897,18 +897,18 @@  discard block
 block discarded – undo
897 897
 		 * Gravity Forms code to adjust date to locally-configured Time Zone
898 898
 		 * @see GFCommon::format_date() for original code
899 899
 		 */
900
-		$date_gmt_time   = mysql2date( 'G', $date_string );
900
+		$date_gmt_time = mysql2date( 'G', $date_string );
901 901
 		$date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time );
902 902
 
903
-		$format  = rgar( $atts, 'format' );
904
-		$is_human  = ! empty( $atts['human'] );
905
-		$is_diff  = ! empty( $atts['diff'] );
906
-		$is_raw = ! empty( $atts['raw'] );
907
-		$is_timestamp = ! empty( $atts['timestamp'] );
908
-		$include_time = ! empty( $atts['time'] );
903
+		$format = rgar( $atts, 'format' );
904
+		$is_human = ! empty( $atts[ 'human' ] );
905
+		$is_diff = ! empty( $atts[ 'diff' ] );
906
+		$is_raw = ! empty( $atts[ 'raw' ] );
907
+		$is_timestamp = ! empty( $atts[ 'timestamp' ] );
908
+		$include_time = ! empty( $atts[ 'time' ] );
909 909
 
910 910
 		// If we're using time diff, we want to have a different default format
911
-		if( empty( $format ) ) {
911
+		if ( empty( $format ) ) {
912 912
 			/* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */
913 913
 			$format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' );
914 914
 		}
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
 		// If raw was specified, don't modify the stored value
917 917
 		if ( $is_raw ) {
918 918
 			$formatted_date = $date_string;
919
-		} elseif( $is_timestamp ) {
919
+		} elseif ( $is_timestamp ) {
920 920
 			$formatted_date = $date_local_timestamp;
921 921
 		} elseif ( $is_diff ) {
922 922
 			$formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) );
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 
951 951
 		$label = rgar( $field, 'label' );
952 952
 
953
-		if( floor( $field_id ) !== floatval( $field_id ) ) {
953
+		if ( floor( $field_id ) !== floatval( $field_id ) ) {
954 954
 			$label = GFFormsModel::get_choice_text( $field, $field_value, $field_id );
955 955
 		}
956 956
 
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
 			$form = GFAPI::get_form( $form );
979 979
 		}
980 980
 
981
-		if ( class_exists( 'GFFormsModel' ) ){
981
+		if ( class_exists( 'GFFormsModel' ) ) {
982 982
 			return GFFormsModel::get_field( $form, $field_id );
983 983
 		} else {
984 984
 			return null;
@@ -1025,19 +1025,19 @@  discard block
 block discarded – undo
1025 1025
 			$shortcodes = array();
1026 1026
 
1027 1027
 			preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
1028
-			if ( empty( $matches ) ){
1028
+			if ( empty( $matches ) ) {
1029 1029
 				return false;
1030 1030
 			}
1031 1031
 
1032 1032
 			foreach ( $matches as $shortcode ) {
1033
-				if ( $tag === $shortcode[2] ) {
1033
+				if ( $tag === $shortcode[ 2 ] ) {
1034 1034
 
1035 1035
 					// Changed this to $shortcode instead of true so we get the parsed atts.
1036
-					$shortcodes[] = $shortcode;
1036
+					$shortcodes[ ] = $shortcode;
1037 1037
 
1038
-				} else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) {
1039
-					foreach( $results as $result ) {
1040
-						$shortcodes[] = $result;
1038
+				} else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) {
1039
+					foreach ( $results as $result ) {
1040
+						$shortcodes[ ] = $result;
1041 1041
 					}
1042 1042
 				}
1043 1043
 			}
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 	public static function get_directory_fields( $post_id, $apply_filter = true ) {
1182 1182
 		$fields = get_post_meta( $post_id, '_gravityview_directory_fields', true );
1183 1183
 
1184
-		if( $apply_filter ) {
1184
+		if ( $apply_filter ) {
1185 1185
 			/**
1186 1186
 			 * @filter `gravityview/configuration/fields` Filter the View fields' configuration array
1187 1187
 			 * @since 1.6.5
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 	 * @return string         html
1205 1205
 	 */
1206 1206
 	public static function get_sortable_fields( $formid, $current = '' ) {
1207
-		$output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>';
1207
+		$output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>';
1208 1208
 
1209 1209
 		if ( empty( $formid ) ) {
1210 1210
 			return $output;
@@ -1217,11 +1217,11 @@  discard block
 block discarded – undo
1217 1217
 			$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null );
1218 1218
 
1219 1219
 			foreach ( $fields as $id => $field ) {
1220
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
1220
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1221 1221
 					continue;
1222 1222
 				}
1223 1223
 
1224
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>';
1224
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>';
1225 1225
 			}
1226 1226
 		}
1227 1227
 
@@ -1256,9 +1256,9 @@  discard block
 block discarded – undo
1256 1256
 		$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL );
1257 1257
 
1258 1258
 		// TODO: Convert to using array_filter
1259
-		foreach( $fields as $id => $field ) {
1259
+		foreach ( $fields as $id => $field ) {
1260 1260
 
1261
-			if( in_array( $field['type'], $blacklist_field_types ) ) {
1261
+			if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1262 1262
 				unset( $fields[ $id ] );
1263 1263
 			}
1264 1264
 		}
@@ -1299,14 +1299,14 @@  discard block
 block discarded – undo
1299 1299
 	 * @param  int|array  $field field key or field array
1300 1300
 	 * @return boolean
1301 1301
 	 */
1302
-	public static function is_field_numeric(  $form = null, $field = '' ) {
1302
+	public static function is_field_numeric( $form = null, $field = '' ) {
1303 1303
 
1304 1304
 		if ( ! is_array( $form ) && ! is_array( $field ) ) {
1305 1305
 			$form = self::get_form( $form );
1306 1306
 		}
1307 1307
 
1308 1308
 		// If entry meta, it's a string. Otherwise, numeric
1309
-		if( ! is_numeric( $field ) && is_string( $field ) ) {
1309
+		if ( ! is_numeric( $field ) && is_string( $field ) ) {
1310 1310
 			$type = $field;
1311 1311
 		} else {
1312 1312
 			$type = self::get_field_type( $form, $field );
@@ -1320,9 +1320,9 @@  discard block
 block discarded – undo
1320 1320
 		$numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) );
1321 1321
 
1322 1322
 		// Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true
1323
-		if( $gv_field = GravityView_Fields::get( $type ) ) {
1324
-			if( true === $gv_field->is_numeric ) {
1325
-				$numeric_types[] = $gv_field->is_numeric;
1323
+		if ( $gv_field = GravityView_Fields::get( $type ) ) {
1324
+			if ( true === $gv_field->is_numeric ) {
1325
+				$numeric_types[ ] = $gv_field->is_numeric;
1326 1326
 			}
1327 1327
 		}
1328 1328
 
@@ -1472,18 +1472,18 @@  discard block
 block discarded – undo
1472 1472
 		$final_atts = array_filter( $final_atts );
1473 1473
 
1474 1474
 		// If the href wasn't passed as an attribute, use the value passed to the function
1475
-		if ( empty( $final_atts['href'] ) && ! empty( $href ) ) {
1476
-			$final_atts['href'] = $href;
1475
+		if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) {
1476
+			$final_atts[ 'href' ] = $href;
1477 1477
 		}
1478 1478
 
1479
-		$final_atts['href'] = esc_url_raw( $href );
1479
+		$final_atts[ 'href' ] = esc_url_raw( $href );
1480 1480
 
1481 1481
 		/**
1482 1482
 		 * Fix potential security issue with target=_blank
1483 1483
 		 * @see https://dev.to/ben/the-targetblank-vulnerability-by-example
1484 1484
 		 */
1485
-		if( '_blank' === rgar( $final_atts, 'target' ) ) {
1486
-			$final_atts['rel'] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' );
1485
+		if ( '_blank' === rgar( $final_atts, 'target' ) ) {
1486
+			$final_atts[ 'rel' ] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' );
1487 1487
 		}
1488 1488
 
1489 1489
 		// Sort the attributes alphabetically, to help testing
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
 			$output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) );
1496 1496
 		}
1497 1497
 
1498
-		if( '' !== $output ) {
1498
+		if ( '' !== $output ) {
1499 1499
 			$output = '<a' . $output . '>' . $anchor_text . '</a>';
1500 1500
 		}
1501 1501
 
@@ -1522,7 +1522,7 @@  discard block
 block discarded – undo
1522 1522
 			if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
1523 1523
 				$merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );
1524 1524
 			} else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) {
1525
-				$merged[] = $value;
1525
+				$merged[ ] = $value;
1526 1526
 			} else {
1527 1527
 				$merged[ $key ] = $value;
1528 1528
 			}
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
 		 * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..)
1556 1556
 		 * @param array $settings Settings array, with `number` key defining the # of users to display
1557 1557
 		 */
1558
-		$get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1558
+		$get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1559 1559
 
1560 1560
 		return get_users( $get_users_settings );
1561 1561
 	}
@@ -1575,11 +1575,11 @@  discard block
 block discarded – undo
1575 1575
     public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) {
1576 1576
 
1577 1577
     	// If $cap is defined, only show notice if user has capability
1578
-    	if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) {
1578
+    	if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) {
1579 1579
     		return '';
1580 1580
 	    }
1581 1581
 
1582
-        return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>';
1582
+        return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>';
1583 1583
     }
1584 1584
 
1585 1585
 	/**
Please login to merge, or discard this patch.