Completed
Push — develop ( 50c7f0...099a5a )
by Gennady
06:39
created
includes/class-common.php 1 patch
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 
126 126
 		$form = false;
127 127
 
128
-		if( $entry ) {
129
-			$form = GFAPI::get_form( $entry['form_id'] );
128
+		if ( $entry ) {
129
+			$form = GFAPI::get_form( $entry[ 'form_id' ] );
130 130
 		}
131 131
 
132 132
 		return $form;
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 			}
203 203
 		}
204 204
 
205
-		return (bool) $has_transaction_data;
205
+		return (bool)$has_transaction_data;
206 206
 	}
207 207
 
208 208
 	/**
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
 		$results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging );
242 242
 
243
-		$result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null;
243
+		$result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null;
244 244
 
245 245
 		return $result;
246 246
 	}
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 	 *
258 258
 	 * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms
259 259
 	 */
260
-	public static function get_forms(  $active = true, $trash = false ) {
260
+	public static function get_forms( $active = true, $trash = false ) {
261 261
 		$forms = array();
262 262
 		if ( class_exists( 'GFAPI' ) ) {
263
-			if( 'any' === $active ) {
263
+			if ( 'any' === $active ) {
264 264
 				$active_forms = GFAPI::get_forms( true, $trash );
265 265
 				$inactive_forms = GFAPI::get_forms( false, $trash );
266 266
 				$forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) );
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
 		$has_post_fields = false;
292 292
 
293 293
 		if ( $form ) {
294
-			foreach ( $form['fields'] as $field ) {
295
-				if ( $include_parent_field || empty( $field['inputs'] ) ) {
296
-					$fields["{$field['id']}"] = array(
294
+			foreach ( $form[ 'fields' ] as $field ) {
295
+				if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) {
296
+					$fields[ "{$field[ 'id' ]}" ] = array(
297 297
 						'label' => \GV\Utils::get( $field, 'label' ),
298 298
 						'parent' => null,
299 299
 						'type' => \GV\Utils::get( $field, 'type' ),
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 					);
303 303
 				}
304 304
 
305
-				if ( $add_default_properties && ! empty( $field['inputs'] ) ) {
306
-					foreach ( $field['inputs'] as $input ) {
305
+				if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) {
306
+					foreach ( $field[ 'inputs' ] as $input ) {
307 307
 
308
-						if( ! empty( $input['isHidden'] ) ) {
308
+						if ( ! empty( $input[ 'isHidden' ] ) ) {
309 309
 							continue;
310 310
 						}
311 311
 
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
                          * @hack
314 314
                          * In case of email/email confirmation, the input for email has the same id as the parent field
315 315
                          */
316
-						if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) {
316
+						if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) {
317 317
                             continue;
318 318
                         }
319
-						$fields["{$input['id']}"] = array(
319
+						$fields[ "{$input[ 'id' ]}" ] = array(
320 320
 							'label' => \GV\Utils::get( $input, 'label' ),
321 321
 							'customLabel' => \GV\Utils::get( $input, 'customLabel' ),
322 322
 							'parent' => $field,
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 				}
329 329
 
330 330
 
331
-				if( GFCommon::is_product_field( $field['type'] ) ){
331
+				if ( GFCommon::is_product_field( $field[ 'type' ] ) ) {
332 332
 					$has_product_fields = true;
333 333
 				}
334 334
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 		 * @since 1.7
343 343
 		 */
344 344
 		if ( $has_post_fields ) {
345
-			$fields['post_id'] = array(
345
+			$fields[ 'post_id' ] = array(
346 346
 				'label' => __( 'Post ID', 'gravityview' ),
347 347
 				'type' => 'post_id',
348 348
 			);
@@ -355,11 +355,11 @@  discard block
 block discarded – undo
355 355
 			foreach ( $payment_fields as $payment_field ) {
356 356
 
357 357
 				// Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key
358
-				if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) {
358
+				if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) {
359 359
 					continue;
360 360
 				}
361 361
 
362
-				$fields["{$payment_field->name}"] = array(
362
+				$fields[ "{$payment_field->name}" ] = array(
363 363
 					'label' => $payment_field->label,
364 364
 					'desc' => $payment_field->description,
365 365
 					'type' => $payment_field->name,
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
 
392 392
 		$fields = array();
393 393
 
394
-		foreach ( $extra_fields as $key => $field ){
395
-			if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) {
396
-				$fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' );
394
+		foreach ( $extra_fields as $key => $field ) {
395
+			if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) {
396
+				$fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' );
397 397
 			}
398 398
 		}
399 399
 
@@ -433,33 +433,33 @@  discard block
 block discarded – undo
433 433
 			'search_criteria' => null,
434 434
 			'sorting' => null,
435 435
 			'paging' => null,
436
-			'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true),
436
+			'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ),
437 437
 			'context_view_id' => null,
438 438
 		);
439 439
 
440 440
 		$criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults );
441 441
 
442
-		if ( ! empty( $criteria['search_criteria']['field_filters'] ) && is_array( $criteria['search_criteria']['field_filters'] ) ) {
443
-			foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) {
442
+		if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) && is_array( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) {
443
+			foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) {
444 444
 
445 445
 				if ( ! is_array( $filter ) ) {
446 446
 					continue;
447 447
 				}
448 448
 
449 449
 				// By default, we want searches to be wildcard for each field.
450
-				$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
450
+				$filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];
451 451
 
452 452
 				/**
453 453
 				 * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc)
454 454
 				 * @param string $operator Existing search operator
455 455
 				 * @param array $filter array with `key`, `value`, `operator`, `type` keys
456 456
 				 */
457
-				$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter );
457
+				$filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter );
458 458
 			}
459 459
 
460 460
 			// don't send just the [mode] without any field filter.
461
-			if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) {
462
-				unset( $criteria['search_criteria']['field_filters']['mode'] );
461
+			if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) {
462
+				unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] );
463 463
 			}
464 464
 
465 465
 		}
@@ -470,33 +470,33 @@  discard block
 block discarded – undo
470 470
 		 * Prepare date formats to be in Gravity Forms DB format;
471 471
 		 * $passed_criteria may include date formats incompatible with Gravity Forms.
472 472
 		 */
473
-		foreach ( array('start_date', 'end_date' ) as $key ) {
473
+		foreach ( array( 'start_date', 'end_date' ) as $key ) {
474 474
 
475
-			if ( ! empty( $criteria['search_criteria'][ $key ] ) ) {
475
+			if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) {
476 476
 
477 477
 				// Use date_create instead of new DateTime so it returns false if invalid date format.
478
-				$date = date_create( $criteria['search_criteria'][ $key ] );
478
+				$date = date_create( $criteria[ 'search_criteria' ][ $key ] );
479 479
 
480 480
 				if ( $date ) {
481 481
 					// Gravity Forms wants dates in the `Y-m-d H:i:s` format.
482
-					$criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' );
482
+					$criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' );
483 483
 				} else {
484
-					gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria['search_criteria'][ $key ] ) );
484
+					gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria[ 'search_criteria' ][ $key ] ) );
485 485
 
486 486
 					// If it's an invalid date, unset it. Gravity Forms freaks out otherwise.
487
-					unset( $criteria['search_criteria'][ $key ] );
487
+					unset( $criteria[ 'search_criteria' ][ $key ] );
488 488
 				}
489 489
 			}
490 490
 		}
491 491
 
492
-		if ( empty( $criteria['context_view_id'] ) ) {
492
+		if ( empty( $criteria[ 'context_view_id' ] ) ) {
493 493
 			// Calculate the context view id and send it to the advanced filter
494 494
 			if ( GravityView_frontend::getInstance()->getSingleEntry() ) {
495
-				$criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id();
495
+				$criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id();
496 496
 			} else if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) {
497
-				$criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id();
497
+				$criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id();
498 498
 			} else if ( 'delete' === GFForms::get( 'action' ) ) {
499
-				$criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null;
499
+				$criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null;
500 500
 			}
501 501
 		}
502 502
 
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 		 * @param array $form_ids Forms to search
507 507
 		 * @param int $view_id ID of the view being used to search
508 508
 		 */
509
-		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] );
509
+		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] );
510 510
 
511 511
 		return (array)$criteria;
512 512
 	}
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 		/** Reduce # of database calls */
542 542
 		add_filter( 'gform_is_encrypted_field', '__return_false' );
543 543
 
544
-		if ( ! empty( $criteria['cache'] ) ) {
544
+		if ( ! empty( $criteria[ 'cache' ] ) ) {
545 545
 
546 546
 			$Cache = new GravityView_Cache( $form_ids, $criteria );
547 547
 
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 
550 550
 				// Still update the total count when using cached results
551 551
 				if ( ! is_null( $total ) ) {
552
-					$total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] );
552
+					$total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] );
553 553
 				}
554 554
 
555 555
 				$return = $entries;
@@ -571,9 +571,9 @@  discard block
 block discarded – undo
571 571
 			$entries = apply_filters_ref_array( 'gravityview_before_get_entries', array( null, $criteria, $passed_criteria, &$total ) );
572 572
 
573 573
 			// No entries returned from gravityview_before_get_entries
574
-			if( is_null( $entries ) ) {
574
+			if ( is_null( $entries ) ) {
575 575
 
576
-				$entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total );
576
+				$entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total );
577 577
 
578 578
 				if ( is_wp_error( $entries ) ) {
579 579
 					gravityview()->log->error( '{error}', array( 'error' => $entries->get_error_message(), 'data' => $entries ) );
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 				}
585 585
 			}
586 586
 
587
-			if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) {
587
+			if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) {
588 588
 
589 589
 				// Cache results
590 590
 				$Cache->set( $entries, 'entries' );
@@ -695,12 +695,12 @@  discard block
 block discarded – undo
695 695
 		 */
696 696
 		$check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry, $view );
697 697
 
698
-		if( $check_entry_display ) {
698
+		if ( $check_entry_display ) {
699 699
 			// Is the entry allowed
700 700
 			$entry = self::check_entry_display( $entry, $view );
701 701
 		}
702 702
 
703
-		if( is_wp_error( $entry ) ) {
703
+		if ( is_wp_error( $entry ) ) {
704 704
 			gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) );
705 705
 			return false;
706 706
 		}
@@ -734,12 +734,12 @@  discard block
 block discarded – undo
734 734
 
735 735
 		$value = false;
736 736
 
737
-		if( 'context' === $val1 ) {
737
+		if ( 'context' === $val1 ) {
738 738
 
739 739
 			$matching_contexts = array( $val2 );
740 740
 
741 741
 			// We allow for non-standard contexts.
742
-			switch( $val2 ) {
742
+			switch ( $val2 ) {
743 743
 				// Check for either single or edit
744 744
 				case 'singular':
745 745
 					$matching_contexts = array( 'single', 'edit' );
@@ -782,18 +782,18 @@  discard block
 block discarded – undo
782 782
 				$json_val_1 = json_decode( $val1, true );
783 783
 				$json_val_2 = json_decode( $val2, true );
784 784
 
785
-				if( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) {
785
+				if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) {
786 786
 
787 787
 					$json_in = false;
788
-					$json_val_1 = $json_val_1 ? (array) $json_val_1 : array( $val1 );
789
-					$json_val_2 = $json_val_2 ? (array) $json_val_2 : array( $val2 );
788
+					$json_val_1 = $json_val_1 ? (array)$json_val_1 : array( $val1 );
789
+					$json_val_2 = $json_val_2 ? (array)$json_val_2 : array( $val2 );
790 790
 
791 791
 					// For JSON, we want to compare as "in" or "not in" rather than "contains"
792 792
 					foreach ( $json_val_1 as $item_1 ) {
793 793
 						foreach ( $json_val_2 as $item_2 ) {
794 794
 							$json_in = self::matches_operation( $item_1, $item_2, 'is' );
795 795
 
796
-							if( $json_in ) {
796
+							if ( $json_in ) {
797 797
 								break 2;
798 798
 							}
799 799
 						}
@@ -845,10 +845,10 @@  discard block
 block discarded – undo
845 845
 	public static function check_entry_display( $entry, $view = null ) {
846 846
 
847 847
 		if ( ! $entry || is_wp_error( $entry ) ) {
848
-			return new WP_Error('entry_not_found', 'Entry was not found.', $entry );
848
+			return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry );
849 849
 		}
850 850
 
851
-		if ( empty( $entry['form_id'] ) ) {
851
+		if ( empty( $entry[ 'form_id' ] ) ) {
852 852
 			return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry );
853 853
 		}
854 854
 
@@ -864,12 +864,12 @@  discard block
 block discarded – undo
864 864
 		$view_form_id = $view->form->ID;
865 865
 
866 866
 		if ( $view->joins ) {
867
-			if ( in_array( (int)$entry['form_id'], array_keys( $view::get_joined_forms( $view->ID ) ), true ) ) {
868
-				$view_form_id = $entry['form_id'];
867
+			if ( in_array( (int)$entry[ 'form_id' ], array_keys( $view::get_joined_forms( $view->ID ) ), true ) ) {
868
+				$view_form_id = $entry[ 'form_id' ];
869 869
 			}
870 870
 		}
871 871
 
872
-		if ( $view_form_id != $entry['form_id'] ) {
872
+		if ( $view_form_id != $entry[ 'form_id' ] ) {
873 873
 			return new WP_Error( 'view_id_not_match', 'View form source does not match entry form source ID.', $entry );
874 874
 		}
875 875
 
@@ -877,13 +877,13 @@  discard block
 block discarded – undo
877 877
 		 * Check whether the entry is in the entries subset by running a modified query.
878 878
 		 */
879 879
 		add_action( 'gravityview/view/query', $entry_subset_callback = function( &$query, $view, $request ) use ( $entry, $view_form_id ) {
880
-			$_tmp_query       = new \GF_Query( $view_form_id, array(
880
+			$_tmp_query = new \GF_Query( $view_form_id, array(
881 881
 				'field_filters' => array(
882 882
 					'mode' => 'all',
883 883
 					array(
884 884
 						'key' => 'id',
885 885
 						'operation' => 'is',
886
-						'value' => $entry['id']
886
+						'value' => $entry[ 'id' ]
887 887
 					)
888 888
 				)
889 889
 			) );
@@ -893,14 +893,14 @@  discard block
 block discarded – undo
893 893
 			/** @var \GF_Query $query */
894 894
 			$query_parts      = $query->_introspect();
895 895
 
896
-			$query->where( \GF_Query_Condition::_and( $_tmp_query_parts['where'], $query_parts['where'] ) );
896
+			$query->where( \GF_Query_Condition::_and( $_tmp_query_parts[ 'where' ], $query_parts[ 'where' ] ) );
897 897
 
898 898
 		}, 10, 3 );
899 899
 
900 900
 		// Prevent page offset from being applied to the single entry query; it's used to return to the referring page number
901 901
 		add_filter( 'gravityview_search_criteria', $remove_pagenum = function( $criteria ) {
902 902
 
903
-			$criteria['paging'] = array(
903
+			$criteria[ 'paging' ] = array(
904 904
 				'offset' => 0,
905 905
 				'page_size' => 25
906 906
 			);
@@ -919,20 +919,20 @@  discard block
 block discarded – undo
919 919
 		}
920 920
 
921 921
 		// This entry is on a View with joins
922
-		if ( $entries[0]->is_multi() ) {
922
+		if ( $entries[ 0 ]->is_multi() ) {
923 923
 
924 924
 			$multi_entry_ids = array();
925 925
 
926
-			foreach ( $entries[0]->entries as $multi_entry ) {
927
-				$multi_entry_ids[] = (int) $multi_entry->ID;
926
+			foreach ( $entries[ 0 ]->entries as $multi_entry ) {
927
+				$multi_entry_ids[ ] = (int)$multi_entry->ID;
928 928
 			}
929 929
 
930
-			if ( ! in_array( (int) $entry['id'], $multi_entry_ids, true ) ) {
930
+			if ( ! in_array( (int)$entry[ 'id' ], $multi_entry_ids, true ) ) {
931 931
 				remove_action( 'gravityview/view/query', $entry_subset_callback );
932 932
 				return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' );
933 933
 			}
934 934
 
935
-		} elseif ( (int) $entries[0]->ID !== (int) $entry['id'] ) {
935
+		} elseif ( (int)$entries[ 0 ]->ID !== (int)$entry[ 'id' ] ) {
936 936
 			remove_action( 'gravityview/view/query', $entry_subset_callback );
937 937
 			return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' );
938 938
 		}
@@ -977,18 +977,18 @@  discard block
 block discarded – undo
977 977
 		 * Gravity Forms code to adjust date to locally-configured Time Zone
978 978
 		 * @see GFCommon::format_date() for original code
979 979
 		 */
980
-		$date_gmt_time   = mysql2date( 'G', $date_string );
980
+		$date_gmt_time = mysql2date( 'G', $date_string );
981 981
 		$date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time );
982 982
 
983
-		$format  = \GV\Utils::get( $atts, 'format' );
984
-		$is_human  = ! empty( $atts['human'] );
985
-		$is_diff  = ! empty( $atts['diff'] );
986
-		$is_raw = ! empty( $atts['raw'] );
987
-		$is_timestamp = ! empty( $atts['timestamp'] );
988
-		$include_time = ! empty( $atts['time'] );
983
+		$format = \GV\Utils::get( $atts, 'format' );
984
+		$is_human = ! empty( $atts[ 'human' ] );
985
+		$is_diff = ! empty( $atts[ 'diff' ] );
986
+		$is_raw = ! empty( $atts[ 'raw' ] );
987
+		$is_timestamp = ! empty( $atts[ 'timestamp' ] );
988
+		$include_time = ! empty( $atts[ 'time' ] );
989 989
 
990 990
 		// If we're using time diff, we want to have a different default format
991
-		if( empty( $format ) ) {
991
+		if ( empty( $format ) ) {
992 992
 			/* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */
993 993
 			$format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' );
994 994
 		}
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 		// If raw was specified, don't modify the stored value
997 997
 		if ( $is_raw ) {
998 998
 			$formatted_date = $date_string;
999
-		} elseif( $is_timestamp ) {
999
+		} elseif ( $is_timestamp ) {
1000 1000
 			$formatted_date = $date_local_timestamp;
1001 1001
 		} elseif ( $is_diff ) {
1002 1002
 			$formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) );
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 
1031 1031
 		$label = \GV\Utils::get( $field, 'label' );
1032 1032
 
1033
-		if( floor( $field_id ) !== floatval( $field_id ) ) {
1033
+		if ( floor( $field_id ) !== floatval( $field_id ) ) {
1034 1034
 			$label = GFFormsModel::get_choice_text( $field, $field_value, $field_id );
1035 1035
 		}
1036 1036
 
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 			$form = GFAPI::get_form( $form );
1059 1059
 		}
1060 1060
 
1061
-		if ( class_exists( 'GFFormsModel' ) ){
1061
+		if ( class_exists( 'GFFormsModel' ) ) {
1062 1062
 			return GFFormsModel::get_field( $form, $field_id );
1063 1063
 		} else {
1064 1064
 			return null;
@@ -1105,19 +1105,19 @@  discard block
 block discarded – undo
1105 1105
 			$shortcodes = array();
1106 1106
 
1107 1107
 			preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
1108
-			if ( empty( $matches ) ){
1108
+			if ( empty( $matches ) ) {
1109 1109
 				return false;
1110 1110
 			}
1111 1111
 
1112 1112
 			foreach ( $matches as $shortcode ) {
1113
-				if ( $tag === $shortcode[2] ) {
1113
+				if ( $tag === $shortcode[ 2 ] ) {
1114 1114
 
1115 1115
 					// Changed this to $shortcode instead of true so we get the parsed atts.
1116
-					$shortcodes[] = $shortcode;
1116
+					$shortcodes[ ] = $shortcode;
1117 1117
 
1118
-				} else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) {
1119
-					foreach( $results as $result ) {
1120
-						$shortcodes[] = $result;
1118
+				} else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) {
1119
+					foreach ( $results as $result ) {
1120
+						$shortcodes[ ] = $result;
1121 1121
 					}
1122 1122
 				}
1123 1123
 			}
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 			'post_type'      => 'gravityview',
1150 1150
 			'posts_per_page' => 100,
1151 1151
 			'meta_key'       => '_gravityview_form_id',
1152
-			'meta_value'     => (int) $form_id,
1152
+			'meta_value'     => (int)$form_id,
1153 1153
 		);
1154 1154
 		$args     = wp_parse_args( $args, $defaults );
1155 1155
 		$views    = get_posts( $args );
@@ -1161,21 +1161,21 @@  discard block
 block discarded – undo
1161 1161
 
1162 1162
 			$data = unserialize( $view->meta_value );
1163 1163
 
1164
-			if( ! $data || ! is_array( $data ) ) {
1164
+			if ( ! $data || ! is_array( $data ) ) {
1165 1165
 				continue;
1166 1166
 			}
1167 1167
 
1168 1168
 			foreach ( $data as $datum ) {
1169
-				if ( ! empty( $datum[2] ) && (int) $datum[2] === (int) $form_id ) {
1170
-					$joined_forms[] = $view->post_id;
1169
+				if ( ! empty( $datum[ 2 ] ) && (int)$datum[ 2 ] === (int)$form_id ) {
1170
+					$joined_forms[ ] = $view->post_id;
1171 1171
 				}
1172 1172
 			}
1173 1173
 		}
1174 1174
 
1175 1175
 		if ( $joined_forms ) {
1176
-			$joined_args  = array(
1176
+			$joined_args = array(
1177 1177
 				'post_type'      => 'gravityview',
1178
-				'posts_per_page' => $args['posts_per_page'],
1178
+				'posts_per_page' => $args[ 'posts_per_page' ],
1179 1179
 				'post__in'       => $joined_forms,
1180 1180
 			);
1181 1181
 			$views = array_merge( $views, get_posts( $joined_args ) );
@@ -1331,7 +1331,7 @@  discard block
 block discarded – undo
1331 1331
 
1332 1332
 		$directory_widgets = wp_parse_args( $view_widgets, $defaults );
1333 1333
 
1334
-		if( $json_decode ) {
1334
+		if ( $json_decode ) {
1335 1335
 			$directory_widgets = gv_map_deep( $directory_widgets, 'gv_maybe_json_decode' );
1336 1336
 		}
1337 1337
 
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
 	 * @return string         html
1348 1348
 	 */
1349 1349
 	public static function get_sortable_fields( $formid, $current = '' ) {
1350
-		$output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>';
1350
+		$output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>';
1351 1351
 
1352 1352
 		if ( empty( $formid ) ) {
1353 1353
 			return $output;
@@ -1360,11 +1360,11 @@  discard block
 block discarded – undo
1360 1360
 			$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null );
1361 1361
 
1362 1362
 			foreach ( $fields as $id => $field ) {
1363
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
1363
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1364 1364
 					continue;
1365 1365
 				}
1366 1366
 
1367
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>';
1367
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>';
1368 1368
 			}
1369 1369
 		}
1370 1370
 
@@ -1399,16 +1399,16 @@  discard block
 block discarded – undo
1399 1399
 		$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL );
1400 1400
 
1401 1401
 		// TODO: Convert to using array_filter
1402
-		foreach( $fields as $id => $field ) {
1402
+		foreach ( $fields as $id => $field ) {
1403 1403
 
1404
-			if( in_array( $field['type'], $blacklist_field_types ) ) {
1404
+			if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1405 1405
 				unset( $fields[ $id ] );
1406 1406
 			}
1407 1407
 
1408 1408
 			/**
1409 1409
 			 * Merge date and time subfields.
1410 1410
 			 */
1411
-			if ( in_array( $field['type'], array( 'date', 'time' ) ) && ! empty( $field['parent'] ) ) {
1411
+			if ( in_array( $field[ 'type' ], array( 'date', 'time' ) ) && ! empty( $field[ 'parent' ] ) ) {
1412 1412
 				$fields[ intval( $id ) ] = array(
1413 1413
 					'label' => \GV\Utils::get( $field, 'parent/label' ),
1414 1414
 					'parent' => null,
@@ -1458,14 +1458,14 @@  discard block
 block discarded – undo
1458 1458
 	 * @param  int|array  $field field key or field array
1459 1459
 	 * @return boolean
1460 1460
 	 */
1461
-	public static function is_field_numeric(  $form = null, $field = '' ) {
1461
+	public static function is_field_numeric( $form = null, $field = '' ) {
1462 1462
 
1463 1463
 		if ( ! is_array( $form ) && ! is_array( $field ) ) {
1464 1464
 			$form = self::get_form( $form );
1465 1465
 		}
1466 1466
 
1467 1467
 		// If entry meta, it's a string. Otherwise, numeric
1468
-		if( ! is_numeric( $field ) && is_string( $field ) ) {
1468
+		if ( ! is_numeric( $field ) && is_string( $field ) ) {
1469 1469
 			$type = $field;
1470 1470
 		} else {
1471 1471
 			$type = self::get_field_type( $form, $field );
@@ -1479,9 +1479,9 @@  discard block
 block discarded – undo
1479 1479
 		$numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) );
1480 1480
 
1481 1481
 		// Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true
1482
-		if( $gv_field = GravityView_Fields::get( $type ) ) {
1483
-			if( true === $gv_field->is_numeric ) {
1484
-				$numeric_types[] = $gv_field->is_numeric;
1482
+		if ( $gv_field = GravityView_Fields::get( $type ) ) {
1483
+			if ( true === $gv_field->is_numeric ) {
1484
+				$numeric_types[ ] = $gv_field->is_numeric;
1485 1485
 			}
1486 1486
 		}
1487 1487
 
@@ -1631,18 +1631,18 @@  discard block
 block discarded – undo
1631 1631
 		$final_atts = array_filter( $final_atts );
1632 1632
 
1633 1633
 		// If the href wasn't passed as an attribute, use the value passed to the function
1634
-		if ( empty( $final_atts['href'] ) && ! empty( $href ) ) {
1635
-			$final_atts['href'] = $href;
1634
+		if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) {
1635
+			$final_atts[ 'href' ] = $href;
1636 1636
 		}
1637 1637
 
1638
-		$final_atts['href'] = esc_url_raw( $href );
1638
+		$final_atts[ 'href' ] = esc_url_raw( $href );
1639 1639
 
1640 1640
 		/**
1641 1641
 		 * Fix potential security issue with target=_blank
1642 1642
 		 * @see https://dev.to/ben/the-targetblank-vulnerability-by-example
1643 1643
 		 */
1644
-		if( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) {
1645
-			$final_atts['rel'] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' );
1644
+		if ( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) {
1645
+			$final_atts[ 'rel' ] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' );
1646 1646
 		}
1647 1647
 
1648 1648
 		// Sort the attributes alphabetically, to help testing
@@ -1654,7 +1654,7 @@  discard block
 block discarded – undo
1654 1654
 			$output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) );
1655 1655
 		}
1656 1656
 
1657
-		if( '' !== $output ) {
1657
+		if ( '' !== $output ) {
1658 1658
 			$output = '<a' . $output . '>' . $anchor_text . '</a>';
1659 1659
 		}
1660 1660
 
@@ -1681,7 +1681,7 @@  discard block
 block discarded – undo
1681 1681
 			if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
1682 1682
 				$merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );
1683 1683
 			} else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) {
1684
-				$merged[] = $value;
1684
+				$merged[ ] = $value;
1685 1685
 			} else {
1686 1686
 				$merged[ $key ] = $value;
1687 1687
 			}
@@ -1714,7 +1714,7 @@  discard block
 block discarded – undo
1714 1714
 		 * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..)
1715 1715
 		 * @param array $settings Settings array, with `number` key defining the # of users to display
1716 1716
 		 */
1717
-		$get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1717
+		$get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1718 1718
 
1719 1719
 		return get_users( $get_users_settings );
1720 1720
 	}
@@ -1734,11 +1734,11 @@  discard block
 block discarded – undo
1734 1734
     public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) {
1735 1735
 
1736 1736
     	// If $cap is defined, only show notice if user has capability
1737
-    	if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) {
1737
+    	if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) {
1738 1738
     		return '';
1739 1739
 	    }
1740 1740
 
1741
-        return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>';
1741
+        return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>';
1742 1742
     }
1743 1743
 
1744 1744
 	/**
Please login to merge, or discard this patch.