Completed
Push — develop ( b4d866...7c2b33 )
by Zack
25:32 queued 21:53
created
includes/class-common.php 1 patch
Spacing   +110 added lines, -110 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
 			);
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
 			foreach ( $payment_fields as $payment_field ) {
352 352
 
353 353
 				// Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key
354
-				if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) {
354
+				if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) {
355 355
 					continue;
356 356
 				}
357 357
 
358
-				$fields["{$payment_field->name}"] = array(
358
+				$fields[ "{$payment_field->name}" ] = array(
359 359
 					'label' => $payment_field->label,
360 360
 					'desc' => $payment_field->description,
361 361
 					'type' => $payment_field->name,
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
 
388 388
 		$fields = array();
389 389
 
390
-		foreach ( $extra_fields as $key => $field ){
391
-			if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) {
392
-				$fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' );
390
+		foreach ( $extra_fields as $key => $field ) {
391
+			if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) {
392
+				$fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' );
393 393
 			}
394 394
 		}
395 395
 
@@ -429,32 +429,32 @@  discard block
 block discarded – undo
429 429
 			'search_criteria' => null,
430 430
 			'sorting' => null,
431 431
 			'paging' => null,
432
-			'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true),
432
+			'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ),
433 433
 		);
434 434
 
435 435
 		$criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults );
436 436
 
437
-		if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) {
438
-			foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) {
437
+		if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) {
438
+			foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) {
439 439
 
440 440
 				if ( ! is_array( $filter ) ) {
441 441
 					continue;
442 442
 				}
443 443
 
444 444
 				// By default, we want searches to be wildcard for each field.
445
-				$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
445
+				$filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];
446 446
 
447 447
 				/**
448 448
 				 * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc)
449 449
 				 * @param string $operator Existing search operator
450 450
 				 * @param array $filter array with `key`, `value`, `operator`, `type` keys
451 451
 				 */
452
-				$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter );
452
+				$filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter );
453 453
 			}
454 454
 
455 455
 			// don't send just the [mode] without any field filter.
456
-			if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) {
457
-				unset( $criteria['search_criteria']['field_filters']['mode'] );
456
+			if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) {
457
+				unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] );
458 458
 			}
459 459
 
460 460
 		}
@@ -465,21 +465,21 @@  discard block
 block discarded – undo
465 465
 		 * Prepare date formats to be in Gravity Forms DB format;
466 466
 		 * $passed_criteria may include date formats incompatible with Gravity Forms.
467 467
 		 */
468
-		foreach ( array('start_date', 'end_date' ) as $key ) {
468
+		foreach ( array( 'start_date', 'end_date' ) as $key ) {
469 469
 
470
-			if ( ! empty( $criteria['search_criteria'][ $key ] ) ) {
470
+			if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) {
471 471
 
472 472
 				// Use date_create instead of new DateTime so it returns false if invalid date format.
473
-				$date = date_create( $criteria['search_criteria'][ $key ] );
473
+				$date = date_create( $criteria[ 'search_criteria' ][ $key ] );
474 474
 
475 475
 				if ( $date ) {
476 476
 					// Gravity Forms wants dates in the `Y-m-d H:i:s` format.
477
-					$criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' );
477
+					$criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' );
478 478
 				} else {
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
 					// If it's an invalid date, unset it. Gravity Forms freaks out otherwise.
482
-					unset( $criteria['search_criteria'][ $key ] );
482
+					unset( $criteria[ 'search_criteria' ][ $key ] );
483 483
 				}
484 484
 			}
485 485
 		}
@@ -498,14 +498,14 @@  discard block
 block discarded – undo
498 498
 
499 499
 		// Calculate the context view id and send it to the advanced filter
500 500
 		if ( GravityView_frontend::getInstance()->getSingleEntry() ) {
501
-			$criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id();
501
+			$criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id();
502 502
 		} elseif ( $multiple_original ) {
503
-			$criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id();
503
+			$criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id();
504 504
 		} elseif ( 'delete' === GFForms::get( 'action' ) ) {
505
-			$criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null;
506
-		} elseif( !isset( $criteria['context_view_id'] ) ) {
505
+			$criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null;
506
+		} elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) {
507 507
             // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget)
508
-			$criteria['context_view_id'] = null;
508
+			$criteria[ 'context_view_id' ] = null;
509 509
 		}
510 510
 
511 511
 		/**
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 		 * @param array $form_ids Forms to search
515 515
 		 * @param int $view_id ID of the view being used to search
516 516
 		 */
517
-		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] );
517
+		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] );
518 518
 
519 519
 		return (array)$criteria;
520 520
 	}
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 		/** Reduce # of database calls */
545 545
 		add_filter( 'gform_is_encrypted_field', '__return_false' );
546 546
 
547
-		if ( ! empty( $criteria['cache'] ) ) {
547
+		if ( ! empty( $criteria[ 'cache' ] ) ) {
548 548
 
549 549
 			$Cache = new GravityView_Cache( $form_ids, $criteria );
550 550
 
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 
553 553
 				// Still update the total count when using cached results
554 554
 				if ( ! is_null( $total ) ) {
555
-					$total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] );
555
+					$total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] );
556 556
 				}
557 557
 
558 558
 				$return = $entries;
@@ -572,9 +572,9 @@  discard block
 block discarded – undo
572 572
 			$entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total );
573 573
 
574 574
 			// No entries returned from gravityview_before_get_entries
575
-			if( is_null( $entries ) ) {
575
+			if ( is_null( $entries ) ) {
576 576
 
577
-				$entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total );
577
+				$entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total );
578 578
 
579 579
 				if ( is_wp_error( $entries ) ) {
580 580
 					do_action( 'gravityview_log_error', $entries->get_error_message(), $entries );
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 				}
584 584
 			}
585 585
 
586
-			if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) {
586
+			if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) {
587 587
 
588 588
 				// Cache results
589 589
 				$Cache->set( $entries, 'entries' );
@@ -688,12 +688,12 @@  discard block
 block discarded – undo
688 688
 			 */
689 689
 			$check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry );
690 690
 
691
-			if( $check_entry_display ) {
691
+			if ( $check_entry_display ) {
692 692
 				// Is the entry allowed
693 693
 				$entry = self::check_entry_display( $entry );
694 694
 			}
695 695
 
696
-			if( is_wp_error( $entry ) ) {
696
+			if ( is_wp_error( $entry ) ) {
697 697
 				do_action( 'gravityview_log_error', __METHOD__ . ': ' . $entry->get_error_message() );
698 698
 				return false;
699 699
 			}
@@ -725,12 +725,12 @@  discard block
 block discarded – undo
725 725
 
726 726
 		$value = false;
727 727
 
728
-		if( 'context' === $val1 ) {
728
+		if ( 'context' === $val1 ) {
729 729
 
730 730
 			$matching_contexts = array( $val2 );
731 731
 
732 732
 			// We allow for non-standard contexts.
733
-			switch( $val2 ) {
733
+			switch ( $val2 ) {
734 734
 				// Check for either single or edit
735 735
 				case 'singular':
736 736
 					$matching_contexts = array( 'single', 'edit' );
@@ -786,76 +786,76 @@  discard block
 block discarded – undo
786 786
 	public static function check_entry_display( $entry ) {
787 787
 
788 788
 		if ( ! $entry || is_wp_error( $entry ) ) {
789
-			return new WP_Error('entry_not_found', 'Entry was not found.', $entry );
789
+			return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry );
790 790
 		}
791 791
 
792
-		if ( empty( $entry['form_id'] ) ) {
792
+		if ( empty( $entry[ 'form_id' ] ) ) {
793 793
 			return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry );
794 794
 		}
795 795
 
796 796
 		$criteria = self::calculate_get_entries_criteria();
797 797
 
798
-		if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) {
798
+		if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) {
799 799
 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria );
800 800
 			return $entry;
801 801
 		}
802 802
 
803 803
 		// Make sure the current View is connected to the same form as the Entry
804
-		if( ! empty( $criteria['context_view_id'] ) ) {
805
-			$context_view_id = intval( $criteria['context_view_id'] );
804
+		if ( ! empty( $criteria[ 'context_view_id' ] ) ) {
805
+			$context_view_id = intval( $criteria[ 'context_view_id' ] );
806 806
 			$context_form_id = gravityview_get_form_id( $context_view_id );
807
-			if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) {
808
-				return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] );
807
+			if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) {
808
+				return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] );
809 809
 			}
810 810
 		}
811 811
 
812
-		$search_criteria = $criteria['search_criteria'];
812
+		$search_criteria = $criteria[ 'search_criteria' ];
813 813
 
814 814
 		// check entry status
815
-		if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) {
816
-			return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria );
815
+		if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) {
816
+			return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria );
817 817
 		}
818 818
 
819 819
 		// check entry date
820 820
 		// @todo: Does it make sense to apply the Date create filters to the single entry?
821 821
 
822 822
 		// field_filters
823
-		if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) {
823
+		if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) {
824 824
 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria );
825 825
 			return $entry;
826 826
 		}
827 827
 
828
-		$filters = $search_criteria['field_filters'];
828
+		$filters = $search_criteria[ 'field_filters' ];
829 829
 
830
-		$mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all';
830
+		$mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all';
831 831
 
832 832
 		// Prevent the mode from being processed below
833
-		unset( $filters['mode'] );
833
+		unset( $filters[ 'mode' ] );
834 834
 
835
-		$form = self::get_form( $entry['form_id'] );
835
+		$form = self::get_form( $entry[ 'form_id' ] );
836 836
 
837 837
 		foreach ( $filters as $filter ) {
838 838
 
839
-			if ( ! isset( $filter['key'] ) ) {
839
+			if ( ! isset( $filter[ 'key' ] ) ) {
840 840
 				do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Filter key not set', $filter );
841 841
 				continue;
842 842
 			}
843 843
 
844
-			$k = $filter['key'];
844
+			$k = $filter[ 'key' ];
845 845
 
846 846
 			$field = self::get_field( $form, $k );
847 847
 
848 848
 			if ( is_null( $field ) ) {
849 849
 				$field_value = isset( $entry[ $k ] ) ? $entry[ $k ] : null;
850 850
 			} else {
851
-				$field_value  = GFFormsModel::get_lead_field_value( $entry, $field );
851
+				$field_value = GFFormsModel::get_lead_field_value( $entry, $field );
852 852
 				 // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it
853 853
 				$field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? rgar( $field_value, $k ) : $field_value;
854 854
 			}
855 855
 
856
-			$operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is';
856
+			$operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is';
857 857
 
858
-			$is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field );
858
+			$is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field );
859 859
 
860 860
 			// Any match is all we need to know
861 861
 			if ( $is_value_match && 'any' === $mode ) {
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 
865 865
 			// Any failed match is a total fail
866 866
 			if ( ! $is_value_match && 'all' === $mode ) {
867
-				return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter );
867
+				return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter );
868 868
 			}
869 869
 		}
870 870
 
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved: all conditions were met' );
875 875
 			return $entry;
876 876
 		} else {
877
-			return new WP_Error('failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters );
877
+			return new WP_Error( 'failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters );
878 878
 		}
879 879
 
880 880
 	}
@@ -915,18 +915,18 @@  discard block
 block discarded – undo
915 915
 		 * Gravity Forms code to adjust date to locally-configured Time Zone
916 916
 		 * @see GFCommon::format_date() for original code
917 917
 		 */
918
-		$date_gmt_time   = mysql2date( 'G', $date_string );
918
+		$date_gmt_time = mysql2date( 'G', $date_string );
919 919
 		$date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time );
920 920
 
921
-		$format  = rgar( $atts, 'format' );
922
-		$is_human  = ! empty( $atts['human'] );
923
-		$is_diff  = ! empty( $atts['diff'] );
924
-		$is_raw = ! empty( $atts['raw'] );
925
-		$is_timestamp = ! empty( $atts['timestamp'] );
926
-		$include_time = ! empty( $atts['time'] );
921
+		$format = rgar( $atts, 'format' );
922
+		$is_human = ! empty( $atts[ 'human' ] );
923
+		$is_diff = ! empty( $atts[ 'diff' ] );
924
+		$is_raw = ! empty( $atts[ 'raw' ] );
925
+		$is_timestamp = ! empty( $atts[ 'timestamp' ] );
926
+		$include_time = ! empty( $atts[ 'time' ] );
927 927
 
928 928
 		// If we're using time diff, we want to have a different default format
929
-		if( empty( $format ) ) {
929
+		if ( empty( $format ) ) {
930 930
 			/* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */
931 931
 			$format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' );
932 932
 		}
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 		// If raw was specified, don't modify the stored value
935 935
 		if ( $is_raw ) {
936 936
 			$formatted_date = $date_string;
937
-		} elseif( $is_timestamp ) {
937
+		} elseif ( $is_timestamp ) {
938 938
 			$formatted_date = $date_local_timestamp;
939 939
 		} elseif ( $is_diff ) {
940 940
 			$formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) );
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 
969 969
 		$label = rgar( $field, 'label' );
970 970
 
971
-		if( floor( $field_id ) !== floatval( $field_id ) ) {
971
+		if ( floor( $field_id ) !== floatval( $field_id ) ) {
972 972
 			$label = GFFormsModel::get_choice_text( $field, $field_value, $field_id );
973 973
 		}
974 974
 
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 			$form = GFAPI::get_form( $form );
997 997
 		}
998 998
 
999
-		if ( class_exists( 'GFFormsModel' ) ){
999
+		if ( class_exists( 'GFFormsModel' ) ) {
1000 1000
 			return GFFormsModel::get_field( $form, $field_id );
1001 1001
 		} else {
1002 1002
 			return null;
@@ -1043,19 +1043,19 @@  discard block
 block discarded – undo
1043 1043
 			$shortcodes = array();
1044 1044
 
1045 1045
 			preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
1046
-			if ( empty( $matches ) ){
1046
+			if ( empty( $matches ) ) {
1047 1047
 				return false;
1048 1048
 			}
1049 1049
 
1050 1050
 			foreach ( $matches as $shortcode ) {
1051
-				if ( $tag === $shortcode[2] ) {
1051
+				if ( $tag === $shortcode[ 2 ] ) {
1052 1052
 
1053 1053
 					// Changed this to $shortcode instead of true so we get the parsed atts.
1054
-					$shortcodes[] = $shortcode;
1054
+					$shortcodes[ ] = $shortcode;
1055 1055
 
1056
-				} else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) {
1057
-					foreach( $results as $result ) {
1058
-						$shortcodes[] = $result;
1056
+				} else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) {
1057
+					foreach ( $results as $result ) {
1058
+						$shortcodes[ ] = $result;
1059 1059
 					}
1060 1060
 				}
1061 1061
 			}
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 	public static function get_directory_fields( $post_id, $apply_filter = true ) {
1200 1200
 		$fields = get_post_meta( $post_id, '_gravityview_directory_fields', true );
1201 1201
 
1202
-		if( $apply_filter ) {
1202
+		if ( $apply_filter ) {
1203 1203
 			/**
1204 1204
 			 * @filter `gravityview/configuration/fields` Filter the View fields' configuration array
1205 1205
 			 * @since 1.6.5
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 	 * @return string         html
1223 1223
 	 */
1224 1224
 	public static function get_sortable_fields( $formid, $current = '' ) {
1225
-		$output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>';
1225
+		$output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>';
1226 1226
 
1227 1227
 		if ( empty( $formid ) ) {
1228 1228
 			return $output;
@@ -1235,11 +1235,11 @@  discard block
 block discarded – undo
1235 1235
 			$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null );
1236 1236
 
1237 1237
 			foreach ( $fields as $id => $field ) {
1238
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
1238
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1239 1239
 					continue;
1240 1240
 				}
1241 1241
 
1242
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>';
1242
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>';
1243 1243
 			}
1244 1244
 		}
1245 1245
 
@@ -1274,9 +1274,9 @@  discard block
 block discarded – undo
1274 1274
 		$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL );
1275 1275
 
1276 1276
 		// TODO: Convert to using array_filter
1277
-		foreach( $fields as $id => $field ) {
1277
+		foreach ( $fields as $id => $field ) {
1278 1278
 
1279
-			if( in_array( $field['type'], $blacklist_field_types ) ) {
1279
+			if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1280 1280
 				unset( $fields[ $id ] );
1281 1281
 			}
1282 1282
 		}
@@ -1317,14 +1317,14 @@  discard block
 block discarded – undo
1317 1317
 	 * @param  int|array  $field field key or field array
1318 1318
 	 * @return boolean
1319 1319
 	 */
1320
-	public static function is_field_numeric(  $form = null, $field = '' ) {
1320
+	public static function is_field_numeric( $form = null, $field = '' ) {
1321 1321
 
1322 1322
 		if ( ! is_array( $form ) && ! is_array( $field ) ) {
1323 1323
 			$form = self::get_form( $form );
1324 1324
 		}
1325 1325
 
1326 1326
 		// If entry meta, it's a string. Otherwise, numeric
1327
-		if( ! is_numeric( $field ) && is_string( $field ) ) {
1327
+		if ( ! is_numeric( $field ) && is_string( $field ) ) {
1328 1328
 			$type = $field;
1329 1329
 		} else {
1330 1330
 			$type = self::get_field_type( $form, $field );
@@ -1338,9 +1338,9 @@  discard block
 block discarded – undo
1338 1338
 		$numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) );
1339 1339
 
1340 1340
 		// Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true
1341
-		if( $gv_field = GravityView_Fields::get( $type ) ) {
1342
-			if( true === $gv_field->is_numeric ) {
1343
-				$numeric_types[] = $gv_field->is_numeric;
1341
+		if ( $gv_field = GravityView_Fields::get( $type ) ) {
1342
+			if ( true === $gv_field->is_numeric ) {
1343
+				$numeric_types[ ] = $gv_field->is_numeric;
1344 1344
 			}
1345 1345
 		}
1346 1346
 
@@ -1490,18 +1490,18 @@  discard block
 block discarded – undo
1490 1490
 		$final_atts = array_filter( $final_atts );
1491 1491
 
1492 1492
 		// If the href wasn't passed as an attribute, use the value passed to the function
1493
-		if ( empty( $final_atts['href'] ) && ! empty( $href ) ) {
1494
-			$final_atts['href'] = $href;
1493
+		if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) {
1494
+			$final_atts[ 'href' ] = $href;
1495 1495
 		}
1496 1496
 
1497
-		$final_atts['href'] = esc_url_raw( $href );
1497
+		$final_atts[ 'href' ] = esc_url_raw( $href );
1498 1498
 
1499 1499
 		/**
1500 1500
 		 * Fix potential security issue with target=_blank
1501 1501
 		 * @see https://dev.to/ben/the-targetblank-vulnerability-by-example
1502 1502
 		 */
1503
-		if( '_blank' === rgar( $final_atts, 'target' ) ) {
1504
-			$final_atts['rel'] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' );
1503
+		if ( '_blank' === rgar( $final_atts, 'target' ) ) {
1504
+			$final_atts[ 'rel' ] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' );
1505 1505
 		}
1506 1506
 
1507 1507
 		// Sort the attributes alphabetically, to help testing
@@ -1513,7 +1513,7 @@  discard block
 block discarded – undo
1513 1513
 			$output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) );
1514 1514
 		}
1515 1515
 
1516
-		if( '' !== $output ) {
1516
+		if ( '' !== $output ) {
1517 1517
 			$output = '<a' . $output . '>' . $anchor_text . '</a>';
1518 1518
 		}
1519 1519
 
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
 			if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
1541 1541
 				$merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );
1542 1542
 			} else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) {
1543
-				$merged[] = $value;
1543
+				$merged[ ] = $value;
1544 1544
 			} else {
1545 1545
 				$merged[ $key ] = $value;
1546 1546
 			}
@@ -1573,7 +1573,7 @@  discard block
 block discarded – undo
1573 1573
 		 * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..)
1574 1574
 		 * @param array $settings Settings array, with `number` key defining the # of users to display
1575 1575
 		 */
1576
-		$get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1576
+		$get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1577 1577
 
1578 1578
 		return get_users( $get_users_settings );
1579 1579
 	}
@@ -1593,11 +1593,11 @@  discard block
 block discarded – undo
1593 1593
     public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) {
1594 1594
 
1595 1595
     	// If $cap is defined, only show notice if user has capability
1596
-    	if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) {
1596
+    	if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) {
1597 1597
     		return '';
1598 1598
 	    }
1599 1599
 
1600
-        return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>';
1600
+        return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>';
1601 1601
     }
1602 1602
 
1603 1603
 	/**
Please login to merge, or discard this patch.