Completed
Push — develop ( 5b5c67...50c7f0 )
by Gennady
06:16
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' );
@@ -693,12 +693,12 @@  discard block
 block discarded – undo
693 693
 		 */
694 694
 		$check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry );
695 695
 
696
-		if( $check_entry_display ) {
696
+		if ( $check_entry_display ) {
697 697
 			// Is the entry allowed
698 698
 			$entry = self::check_entry_display( $entry );
699 699
 		}
700 700
 
701
-		if( is_wp_error( $entry ) ) {
701
+		if ( is_wp_error( $entry ) ) {
702 702
 			gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) );
703 703
 			return false;
704 704
 		}
@@ -732,12 +732,12 @@  discard block
 block discarded – undo
732 732
 
733 733
 		$value = false;
734 734
 
735
-		if( 'context' === $val1 ) {
735
+		if ( 'context' === $val1 ) {
736 736
 
737 737
 			$matching_contexts = array( $val2 );
738 738
 
739 739
 			// We allow for non-standard contexts.
740
-			switch( $val2 ) {
740
+			switch ( $val2 ) {
741 741
 				// Check for either single or edit
742 742
 				case 'singular':
743 743
 					$matching_contexts = array( 'single', 'edit' );
@@ -780,18 +780,18 @@  discard block
 block discarded – undo
780 780
 				$json_val_1 = json_decode( $val1, true );
781 781
 				$json_val_2 = json_decode( $val2, true );
782 782
 
783
-				if( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) {
783
+				if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) {
784 784
 
785 785
 					$json_in = false;
786
-					$json_val_1 = $json_val_1 ? (array) $json_val_1 : array( $val1 );
787
-					$json_val_2 = $json_val_2 ? (array) $json_val_2 : array( $val2 );
786
+					$json_val_1 = $json_val_1 ? (array)$json_val_1 : array( $val1 );
787
+					$json_val_2 = $json_val_2 ? (array)$json_val_2 : array( $val2 );
788 788
 
789 789
 					// For JSON, we want to compare as "in" or "not in" rather than "contains"
790 790
 					foreach ( $json_val_1 as $item_1 ) {
791 791
 						foreach ( $json_val_2 as $item_2 ) {
792 792
 							$json_in = self::matches_operation( $item_1, $item_2, 'is' );
793 793
 
794
-							if( $json_in ) {
794
+							if ( $json_in ) {
795 795
 								break 2;
796 796
 							}
797 797
 						}
@@ -843,10 +843,10 @@  discard block
 block discarded – undo
843 843
 	public static function check_entry_display( $entry, $view = null ) {
844 844
 
845 845
 		if ( ! $entry || is_wp_error( $entry ) ) {
846
-			return new WP_Error('entry_not_found', 'Entry was not found.', $entry );
846
+			return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry );
847 847
 		}
848 848
 
849
-		if ( empty( $entry['form_id'] ) ) {
849
+		if ( empty( $entry[ 'form_id' ] ) ) {
850 850
 			return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry );
851 851
 		}
852 852
 
@@ -862,12 +862,12 @@  discard block
 block discarded – undo
862 862
 		$view_form_id = $view->form->ID;
863 863
 
864 864
 		if ( $view->joins ) {
865
-			if ( in_array( (int)$entry['form_id'], array_keys( $view::get_joined_forms( $view->ID ) ), true ) ) {
866
-				$view_form_id = $entry['form_id'];
865
+			if ( in_array( (int)$entry[ 'form_id' ], array_keys( $view::get_joined_forms( $view->ID ) ), true ) ) {
866
+				$view_form_id = $entry[ 'form_id' ];
867 867
 			}
868 868
 		}
869 869
 
870
-		if ( $view_form_id != $entry['form_id'] ) {
870
+		if ( $view_form_id != $entry[ 'form_id' ] ) {
871 871
 			return new WP_Error( 'view_id_not_match', 'View form source does not match entry form source ID.', $entry );
872 872
 		}
873 873
 
@@ -875,13 +875,13 @@  discard block
 block discarded – undo
875 875
 		 * Check whether the entry is in the entries subset by running a modified query.
876 876
 		 */
877 877
 		add_action( 'gravityview/view/query', $entry_subset_callback = function( &$query, $view, $request ) use ( $entry, $view_form_id ) {
878
-			$_tmp_query       = new \GF_Query( $view_form_id, array(
878
+			$_tmp_query = new \GF_Query( $view_form_id, array(
879 879
 				'field_filters' => array(
880 880
 					'mode' => 'all',
881 881
 					array(
882 882
 						'key' => 'id',
883 883
 						'operation' => 'is',
884
-						'value' => $entry['id']
884
+						'value' => $entry[ 'id' ]
885 885
 					)
886 886
 				)
887 887
 			) );
@@ -891,14 +891,14 @@  discard block
 block discarded – undo
891 891
 			/** @var \GF_Query $query */
892 892
 			$query_parts      = $query->_introspect();
893 893
 
894
-			$query->where( \GF_Query_Condition::_and( $_tmp_query_parts['where'], $query_parts['where'] ) );
894
+			$query->where( \GF_Query_Condition::_and( $_tmp_query_parts[ 'where' ], $query_parts[ 'where' ] ) );
895 895
 
896 896
 		}, 10, 3 );
897 897
 
898 898
 		// Prevent page offset from being applied to the single entry query; it's used to return to the referring page number
899 899
 		add_filter( 'gravityview_search_criteria', $remove_pagenum = function( $criteria ) {
900 900
 
901
-			$criteria['paging'] = array(
901
+			$criteria[ 'paging' ] = array(
902 902
 				'offset' => 0,
903 903
 				'page_size' => 25
904 904
 			);
@@ -917,20 +917,20 @@  discard block
 block discarded – undo
917 917
 		}
918 918
 
919 919
 		// This entry is on a View with joins
920
-		if ( $entries[0]->is_multi() ) {
920
+		if ( $entries[ 0 ]->is_multi() ) {
921 921
 
922 922
 			$multi_entry_ids = array();
923 923
 
924
-			foreach ( $entries[0]->entries as $multi_entry ) {
925
-				$multi_entry_ids[] = (int) $multi_entry->ID;
924
+			foreach ( $entries[ 0 ]->entries as $multi_entry ) {
925
+				$multi_entry_ids[ ] = (int)$multi_entry->ID;
926 926
 			}
927 927
 
928
-			if ( ! in_array( (int) $entry['id'], $multi_entry_ids, true ) ) {
928
+			if ( ! in_array( (int)$entry[ 'id' ], $multi_entry_ids, true ) ) {
929 929
 				remove_action( 'gravityview/view/query', $entry_subset_callback );
930 930
 				return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' );
931 931
 			}
932 932
 
933
-		} elseif ( (int) $entries[0]->ID !== (int) $entry['id'] ) {
933
+		} elseif ( (int)$entries[ 0 ]->ID !== (int)$entry[ 'id' ] ) {
934 934
 			remove_action( 'gravityview/view/query', $entry_subset_callback );
935 935
 			return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' );
936 936
 		}
@@ -975,18 +975,18 @@  discard block
 block discarded – undo
975 975
 		 * Gravity Forms code to adjust date to locally-configured Time Zone
976 976
 		 * @see GFCommon::format_date() for original code
977 977
 		 */
978
-		$date_gmt_time   = mysql2date( 'G', $date_string );
978
+		$date_gmt_time = mysql2date( 'G', $date_string );
979 979
 		$date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time );
980 980
 
981
-		$format  = \GV\Utils::get( $atts, 'format' );
982
-		$is_human  = ! empty( $atts['human'] );
983
-		$is_diff  = ! empty( $atts['diff'] );
984
-		$is_raw = ! empty( $atts['raw'] );
985
-		$is_timestamp = ! empty( $atts['timestamp'] );
986
-		$include_time = ! empty( $atts['time'] );
981
+		$format = \GV\Utils::get( $atts, 'format' );
982
+		$is_human = ! empty( $atts[ 'human' ] );
983
+		$is_diff = ! empty( $atts[ 'diff' ] );
984
+		$is_raw = ! empty( $atts[ 'raw' ] );
985
+		$is_timestamp = ! empty( $atts[ 'timestamp' ] );
986
+		$include_time = ! empty( $atts[ 'time' ] );
987 987
 
988 988
 		// If we're using time diff, we want to have a different default format
989
-		if( empty( $format ) ) {
989
+		if ( empty( $format ) ) {
990 990
 			/* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */
991 991
 			$format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' );
992 992
 		}
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 		// If raw was specified, don't modify the stored value
995 995
 		if ( $is_raw ) {
996 996
 			$formatted_date = $date_string;
997
-		} elseif( $is_timestamp ) {
997
+		} elseif ( $is_timestamp ) {
998 998
 			$formatted_date = $date_local_timestamp;
999 999
 		} elseif ( $is_diff ) {
1000 1000
 			$formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) );
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 
1029 1029
 		$label = \GV\Utils::get( $field, 'label' );
1030 1030
 
1031
-		if( floor( $field_id ) !== floatval( $field_id ) ) {
1031
+		if ( floor( $field_id ) !== floatval( $field_id ) ) {
1032 1032
 			$label = GFFormsModel::get_choice_text( $field, $field_value, $field_id );
1033 1033
 		}
1034 1034
 
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
 			$form = GFAPI::get_form( $form );
1057 1057
 		}
1058 1058
 
1059
-		if ( class_exists( 'GFFormsModel' ) ){
1059
+		if ( class_exists( 'GFFormsModel' ) ) {
1060 1060
 			return GFFormsModel::get_field( $form, $field_id );
1061 1061
 		} else {
1062 1062
 			return null;
@@ -1103,19 +1103,19 @@  discard block
 block discarded – undo
1103 1103
 			$shortcodes = array();
1104 1104
 
1105 1105
 			preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
1106
-			if ( empty( $matches ) ){
1106
+			if ( empty( $matches ) ) {
1107 1107
 				return false;
1108 1108
 			}
1109 1109
 
1110 1110
 			foreach ( $matches as $shortcode ) {
1111
-				if ( $tag === $shortcode[2] ) {
1111
+				if ( $tag === $shortcode[ 2 ] ) {
1112 1112
 
1113 1113
 					// Changed this to $shortcode instead of true so we get the parsed atts.
1114
-					$shortcodes[] = $shortcode;
1114
+					$shortcodes[ ] = $shortcode;
1115 1115
 
1116
-				} else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) {
1117
-					foreach( $results as $result ) {
1118
-						$shortcodes[] = $result;
1116
+				} else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) {
1117
+					foreach ( $results as $result ) {
1118
+						$shortcodes[ ] = $result;
1119 1119
 					}
1120 1120
 				}
1121 1121
 			}
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 			'post_type'      => 'gravityview',
1148 1148
 			'posts_per_page' => 100,
1149 1149
 			'meta_key'       => '_gravityview_form_id',
1150
-			'meta_value'     => (int) $form_id,
1150
+			'meta_value'     => (int)$form_id,
1151 1151
 		);
1152 1152
 		$args     = wp_parse_args( $args, $defaults );
1153 1153
 		$views    = get_posts( $args );
@@ -1159,21 +1159,21 @@  discard block
 block discarded – undo
1159 1159
 
1160 1160
 			$data = unserialize( $view->meta_value );
1161 1161
 
1162
-			if( ! $data || ! is_array( $data ) ) {
1162
+			if ( ! $data || ! is_array( $data ) ) {
1163 1163
 				continue;
1164 1164
 			}
1165 1165
 
1166 1166
 			foreach ( $data as $datum ) {
1167
-				if ( ! empty( $datum[2] ) && (int) $datum[2] === (int) $form_id ) {
1168
-					$joined_forms[] = $view->post_id;
1167
+				if ( ! empty( $datum[ 2 ] ) && (int)$datum[ 2 ] === (int)$form_id ) {
1168
+					$joined_forms[ ] = $view->post_id;
1169 1169
 				}
1170 1170
 			}
1171 1171
 		}
1172 1172
 
1173 1173
 		if ( $joined_forms ) {
1174
-			$joined_args  = array(
1174
+			$joined_args = array(
1175 1175
 				'post_type'      => 'gravityview',
1176
-				'posts_per_page' => $args['posts_per_page'],
1176
+				'posts_per_page' => $args[ 'posts_per_page' ],
1177 1177
 				'post__in'       => $joined_forms,
1178 1178
 			);
1179 1179
 			$views = array_merge( $views, get_posts( $joined_args ) );
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
 
1330 1330
 		$directory_widgets = wp_parse_args( $view_widgets, $defaults );
1331 1331
 
1332
-		if( $json_decode ) {
1332
+		if ( $json_decode ) {
1333 1333
 			$directory_widgets = gv_map_deep( $directory_widgets, 'gv_maybe_json_decode' );
1334 1334
 		}
1335 1335
 
@@ -1345,7 +1345,7 @@  discard block
 block discarded – undo
1345 1345
 	 * @return string         html
1346 1346
 	 */
1347 1347
 	public static function get_sortable_fields( $formid, $current = '' ) {
1348
-		$output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>';
1348
+		$output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>';
1349 1349
 
1350 1350
 		if ( empty( $formid ) ) {
1351 1351
 			return $output;
@@ -1358,11 +1358,11 @@  discard block
 block discarded – undo
1358 1358
 			$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null );
1359 1359
 
1360 1360
 			foreach ( $fields as $id => $field ) {
1361
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
1361
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1362 1362
 					continue;
1363 1363
 				}
1364 1364
 
1365
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>';
1365
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>';
1366 1366
 			}
1367 1367
 		}
1368 1368
 
@@ -1397,16 +1397,16 @@  discard block
 block discarded – undo
1397 1397
 		$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL );
1398 1398
 
1399 1399
 		// TODO: Convert to using array_filter
1400
-		foreach( $fields as $id => $field ) {
1400
+		foreach ( $fields as $id => $field ) {
1401 1401
 
1402
-			if( in_array( $field['type'], $blacklist_field_types ) ) {
1402
+			if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1403 1403
 				unset( $fields[ $id ] );
1404 1404
 			}
1405 1405
 
1406 1406
 			/**
1407 1407
 			 * Merge date and time subfields.
1408 1408
 			 */
1409
-			if ( in_array( $field['type'], array( 'date', 'time' ) ) && ! empty( $field['parent'] ) ) {
1409
+			if ( in_array( $field[ 'type' ], array( 'date', 'time' ) ) && ! empty( $field[ 'parent' ] ) ) {
1410 1410
 				$fields[ intval( $id ) ] = array(
1411 1411
 					'label' => \GV\Utils::get( $field, 'parent/label' ),
1412 1412
 					'parent' => null,
@@ -1456,14 +1456,14 @@  discard block
 block discarded – undo
1456 1456
 	 * @param  int|array  $field field key or field array
1457 1457
 	 * @return boolean
1458 1458
 	 */
1459
-	public static function is_field_numeric(  $form = null, $field = '' ) {
1459
+	public static function is_field_numeric( $form = null, $field = '' ) {
1460 1460
 
1461 1461
 		if ( ! is_array( $form ) && ! is_array( $field ) ) {
1462 1462
 			$form = self::get_form( $form );
1463 1463
 		}
1464 1464
 
1465 1465
 		// If entry meta, it's a string. Otherwise, numeric
1466
-		if( ! is_numeric( $field ) && is_string( $field ) ) {
1466
+		if ( ! is_numeric( $field ) && is_string( $field ) ) {
1467 1467
 			$type = $field;
1468 1468
 		} else {
1469 1469
 			$type = self::get_field_type( $form, $field );
@@ -1477,9 +1477,9 @@  discard block
 block discarded – undo
1477 1477
 		$numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) );
1478 1478
 
1479 1479
 		// Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true
1480
-		if( $gv_field = GravityView_Fields::get( $type ) ) {
1481
-			if( true === $gv_field->is_numeric ) {
1482
-				$numeric_types[] = $gv_field->is_numeric;
1480
+		if ( $gv_field = GravityView_Fields::get( $type ) ) {
1481
+			if ( true === $gv_field->is_numeric ) {
1482
+				$numeric_types[ ] = $gv_field->is_numeric;
1483 1483
 			}
1484 1484
 		}
1485 1485
 
@@ -1629,18 +1629,18 @@  discard block
 block discarded – undo
1629 1629
 		$final_atts = array_filter( $final_atts );
1630 1630
 
1631 1631
 		// If the href wasn't passed as an attribute, use the value passed to the function
1632
-		if ( empty( $final_atts['href'] ) && ! empty( $href ) ) {
1633
-			$final_atts['href'] = $href;
1632
+		if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) {
1633
+			$final_atts[ 'href' ] = $href;
1634 1634
 		}
1635 1635
 
1636
-		$final_atts['href'] = esc_url_raw( $href );
1636
+		$final_atts[ 'href' ] = esc_url_raw( $href );
1637 1637
 
1638 1638
 		/**
1639 1639
 		 * Fix potential security issue with target=_blank
1640 1640
 		 * @see https://dev.to/ben/the-targetblank-vulnerability-by-example
1641 1641
 		 */
1642
-		if( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) {
1643
-			$final_atts['rel'] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' );
1642
+		if ( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) {
1643
+			$final_atts[ 'rel' ] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' );
1644 1644
 		}
1645 1645
 
1646 1646
 		// Sort the attributes alphabetically, to help testing
@@ -1652,7 +1652,7 @@  discard block
 block discarded – undo
1652 1652
 			$output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) );
1653 1653
 		}
1654 1654
 
1655
-		if( '' !== $output ) {
1655
+		if ( '' !== $output ) {
1656 1656
 			$output = '<a' . $output . '>' . $anchor_text . '</a>';
1657 1657
 		}
1658 1658
 
@@ -1679,7 +1679,7 @@  discard block
 block discarded – undo
1679 1679
 			if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
1680 1680
 				$merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );
1681 1681
 			} else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) {
1682
-				$merged[] = $value;
1682
+				$merged[ ] = $value;
1683 1683
 			} else {
1684 1684
 				$merged[ $key ] = $value;
1685 1685
 			}
@@ -1712,7 +1712,7 @@  discard block
 block discarded – undo
1712 1712
 		 * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..)
1713 1713
 		 * @param array $settings Settings array, with `number` key defining the # of users to display
1714 1714
 		 */
1715
-		$get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1715
+		$get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1716 1716
 
1717 1717
 		return get_users( $get_users_settings );
1718 1718
 	}
@@ -1732,11 +1732,11 @@  discard block
 block discarded – undo
1732 1732
     public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) {
1733 1733
 
1734 1734
     	// If $cap is defined, only show notice if user has capability
1735
-    	if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) {
1735
+    	if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) {
1736 1736
     		return '';
1737 1737
 	    }
1738 1738
 
1739
-        return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>';
1739
+        return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>';
1740 1740
     }
1741 1741
 
1742 1742
 	/**
Please login to merge, or discard this patch.
future/includes/class-gv-view.php 1 patch
Spacing   +79 added lines, -80 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		$supports = array( 'title', 'revisions' );
126 126
 
127 127
 		if ( $is_hierarchical ) {
128
-			$supports[] = 'page-attributes';
128
+			$supports[ ] = 'page-attributes';
129 129
 		}
130 130
 
131 131
 		/**
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
 		$rule = array( sprintf( '%s/([^/]+)/csv/?', $slug ), 'index.php?gravityview=$matches[1]&csv=1', 'top' );
228 228
 
229 229
 		add_filter( 'query_vars', function( $query_vars ) { 
230
-			$query_vars[] = 'csv';
230
+			$query_vars[ ] = 'csv';
231 231
 			return $query_vars;
232 232
 		} );
233 233
 
234
-		if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[0] ] ) ) {
234
+		if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[ 0 ] ] ) ) {
235 235
 			call_user_func_array( 'add_rewrite_rule', $rule );
236 236
 		}
237 237
 	}
@@ -308,13 +308,13 @@  discard block
 block discarded – undo
308 308
 			return $content;
309 309
 		}
310 310
 
311
-		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID );
311
+		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID );
312 312
 
313 313
 		/**
314 314
 		 * Editing a single entry.
315 315
 		 */
316 316
 		if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) {
317
-			if ( $entry['status'] != 'active' ) {
317
+			if ( $entry[ 'status' ] != 'active' ) {
318 318
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
319 319
 				return __( 'You are not allowed to view this content.', 'gravityview' );
320 320
 			}
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 			}
326 326
 
327 327
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
328
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
328
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
329 329
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
330 330
 					return __( 'You are not allowed to view this content.', 'gravityview' );
331 331
 				}
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 
349 349
 			foreach ( $entryset as $e ) {
350 350
 
351
-				if ( 'active' !== $e['status'] ) {
351
+				if ( 'active' !== $e[ 'status' ] ) {
352 352
 					gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) );
353 353
 					return __( 'You are not allowed to view this content.', 'gravityview' );
354 354
 				}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 				}
360 360
 
361 361
 				if ( $show_only_approved && ! $is_admin_and_can_view ) {
362
-					if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
362
+					if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
363 363
 						gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) );
364 364
 						return __( 'You are not allowed to view this content.', 'gravityview' );
365 365
 					}
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 			$join_column    = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field::by_id( $join_column );
535 535
 			$join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field::by_id( $join_on_column );
536 536
 
537
-			$joins [] = new Join( $join, $join_column, $join_on, $join_on_column );
537
+			$joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column );
538 538
 		}
539 539
 
540 540
 		return $joins;
@@ -624,13 +624,13 @@  discard block
 block discarded – undo
624 624
 			}
625 625
 
626 626
 			foreach ( $_fields as $field ) {
627
-				if ( ! empty( $field['unions'] ) ) {
628
-					foreach ( $field['unions'] as $form_id => $field_id ) {
627
+				if ( ! empty( $field[ 'unions' ] ) ) {
628
+					foreach ( $field[ 'unions' ] as $form_id => $field_id ) {
629 629
 						if ( ! isset( $unions[ $form_id ] ) ) {
630 630
 							$unions[ $form_id ] = array();
631 631
 						}
632 632
 
633
-						$unions[ $form_id ][ $field['id'] ] =
633
+						$unions[ $form_id ][ $field[ 'id' ] ] =
634 634
 							is_numeric( $field_id ) ? \GV\GF_Field::by_id( \GV\GF_Form::by_id( $form_id ), $field_id ) : \GV\Internal_Field::by_id( $field_id );
635 635
 					}
636 636
 				}
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 		if ( ! $view->form ) {
686 686
 			gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array(
687 687
 				'view_id' => $view->ID,
688
-				'form_id' => $view->_gravityview_form_id ? : 0,
688
+				'form_id' => $view->_gravityview_form_id ?: 0,
689 689
 			) );
690 690
 		}
691 691
 
@@ -924,11 +924,11 @@  discard block
 block discarded – undo
924 924
 			 * Remove multiple sorting before calling legacy filters.
925 925
 			 * This allows us to fake it till we make it.
926 926
 			 */
927
-			if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) {
927
+			if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) {
928 928
 				$has_multisort = true;
929
-				$parameters['sort_field'] = reset( $parameters['sort_field'] );
930
-				if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) {
931
-					$parameters['sort_direction'] = reset( $parameters['sort_direction'] );
929
+				$parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] );
930
+				if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) {
931
+					$parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] );
932 932
 				}
933 933
 			}
934 934
 
@@ -937,31 +937,30 @@  discard block
 block discarded – undo
937 937
 			 */
938 938
 			$parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID );
939 939
 
940
-			$parameters['context_view_id'] = $this->ID;
940
+			$parameters[ 'context_view_id' ] = $this->ID;
941 941
 			$parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID );
942 942
 
943 943
 			if ( ! is_array( $parameters ) ) {
944 944
 				$parameters = array();
945 945
 			}
946 946
 
947
-			if ( ! is_array( $parameters['search_criteria'] ) ) {
948
-				$parameters['search_criteria'] = array();
947
+			if ( ! is_array( $parameters[ 'search_criteria' ] ) ) {
948
+				$parameters[ 'search_criteria' ] = array();
949 949
 			}
950 950
 
951
-			if ( ( ! isset( $parameters['search_criteria']['field_filters'] ) ) || ( ! is_array( $parameters['search_criteria']['field_filters'] ) ) ) {
952
-				$parameters['search_criteria']['field_filters'] = array();
951
+			if ( ( ! isset( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) || ( ! is_array( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) ) {
952
+				$parameters[ 'search_criteria' ][ 'field_filters' ] = array();
953 953
 			}
954 954
 
955 955
 			if ( $request instanceof REST\Request ) {
956 956
 				$atts = $this->settings->as_atts();
957 957
 				$paging_parameters = wp_parse_args( $request->get_paging(), array(
958
-						'paging' => array( 'page_size' => $atts['page_size'] ),
958
+						'paging' => array( 'page_size' => $atts[ 'page_size' ] ),
959 959
 					) );
960
-				$parameters['paging'] = $paging_parameters['paging'];
960
+				$parameters[ 'paging' ] = $paging_parameters[ 'paging' ];
961 961
 			}
962 962
 
963
-			$page = Utils::get( $parameters['paging'], 'current_page' ) ?
964
-				: ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 );
963
+			$page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 );
965 964
 
966 965
 			/**
967 966
 			 * Cleanup duplicate field_filter parameters to simplify the query.
@@ -969,14 +968,14 @@  discard block
 block discarded – undo
969 968
 			$unique_field_filters = array();
970 969
 			foreach ( Utils::get( $parameters, 'search_criteria/field_filters', array() ) as $key => $filter ) {
971 970
 				if ( 'mode' === $key ) {
972
-					$unique_field_filters['mode'] = $filter;
971
+					$unique_field_filters[ 'mode' ] = $filter;
973 972
 				} else if ( ! in_array( $filter, $unique_field_filters ) ) {
974
-					$unique_field_filters[] = $filter;
973
+					$unique_field_filters[ ] = $filter;
975 974
 				}
976 975
 			}
977
-			$parameters['search_criteria']['field_filters'] = $unique_field_filters;
976
+			$parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters;
978 977
 
979
-			if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) {
978
+			if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) {
980 979
 				gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' );
981 980
 			}
982 981
 
@@ -985,7 +984,7 @@  discard block
 block discarded – undo
985 984
 				$query_class = $this->get_query_class();
986 985
 
987 986
 				/** @var \GF_Query $query */
988
-				$query = new $query_class( $this->form->ID, $parameters['search_criteria'], Utils::get( $parameters, 'sorting' ) );
987
+				$query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], Utils::get( $parameters, 'sorting' ) );
989 988
 
990 989
 				/**
991 990
 				 * Apply multisort.
@@ -996,15 +995,15 @@  discard block
 block discarded – undo
996 995
 					$view_setting_sort_field_ids = \GV\Utils::get( $atts, 'sort_field', array() );
997 996
 					$view_setting_sort_directions = \GV\Utils::get( $atts, 'sort_direction', array() );
998 997
 
999
-					$has_sort_query_param = ! empty( $_GET['sort'] ) && is_array( $_GET['sort'] );
998
+					$has_sort_query_param = ! empty( $_GET[ 'sort' ] ) && is_array( $_GET[ 'sort' ] );
1000 999
 
1001
-					if( $has_sort_query_param ) {
1002
-						$has_sort_query_param = array_filter( array_values( $_GET['sort'] ) );
1000
+					if ( $has_sort_query_param ) {
1001
+						$has_sort_query_param = array_filter( array_values( $_GET[ 'sort' ] ) );
1003 1002
 					}
1004 1003
 
1005 1004
 					if ( $this->settings->get( 'sort_columns' ) && $has_sort_query_param ) {
1006
-						$sort_field_ids = array_keys( $_GET['sort'] );
1007
-						$sort_directions = array_values( $_GET['sort'] );
1005
+						$sort_field_ids = array_keys( $_GET[ 'sort' ] );
1006
+						$sort_directions = array_values( $_GET[ 'sort' ] );
1008 1007
 					} else {
1009 1008
 						$sort_field_ids = $view_setting_sort_field_ids;
1010 1009
 						$sort_directions = $view_setting_sort_directions;
@@ -1012,7 +1011,7 @@  discard block
 block discarded – undo
1012 1011
 
1013 1012
 					$skip_first = false;
1014 1013
 
1015
-					foreach ( (array) $sort_field_ids as $key => $sort_field_id ) {
1014
+					foreach ( (array)$sort_field_ids as $key => $sort_field_id ) {
1016 1015
 
1017 1016
 						if ( ! $skip_first && ! $has_sort_query_param ) {
1018 1017
 							$skip_first = true; // Skip the first one, it's already in the query
@@ -1042,15 +1041,15 @@  discard block
 block discarded – undo
1042 1041
 
1043 1042
 					$merged_time = false;
1044 1043
 
1045
-					foreach ( $q['order'] as $oid => $order ) {
1046
-						if ( $order[0] instanceof \GF_Query_Column ) {
1047
-							$column = $order[0];
1048
-						} else if ( $order[0] instanceof \GF_Query_Call ) {
1049
-							if ( count( $order[0]->columns ) != 1 || ! $order[0]->columns[0] instanceof \GF_Query_Column ) {
1044
+					foreach ( $q[ 'order' ] as $oid => $order ) {
1045
+						if ( $order[ 0 ] instanceof \GF_Query_Column ) {
1046
+							$column = $order[ 0 ];
1047
+						} else if ( $order[ 0 ] instanceof \GF_Query_Call ) {
1048
+							if ( count( $order[ 0 ]->columns ) != 1 || ! $order[ 0 ]->columns[ 0 ] instanceof \GF_Query_Column ) {
1050 1049
 								$orders[ $oid ] = $order;
1051 1050
 								continue; // Need something that resembles a single sort
1052 1051
 							}
1053
-							$column = $order[0]->columns[0];
1052
+							$column = $order[ 0 ]->columns[ 0 ];
1054 1053
 						}
1055 1054
 
1056 1055
 						if ( ( ! $field = \GFAPI::get_field( $column->source, $column->field_id ) ) || $field->type !== 'time' ) {
@@ -1064,7 +1063,7 @@  discard block
 block discarded – undo
1064 1063
 
1065 1064
 						$orders[ $oid ] = array(
1066 1065
 							new \GV\Mocks\GF_Query_Call_TIMESORT( 'timesort', array( $column, $sql ) ),
1067
-							$order[1] // Mock it!
1066
+							$order[ 1 ] // Mock it!
1068 1067
 						);
1069 1068
 
1070 1069
 						$merged_time = true;
@@ -1075,15 +1074,15 @@  discard block
 block discarded – undo
1075 1074
 						 * ORDER again.
1076 1075
 						 */
1077 1076
 						if ( ! empty( $orders ) && $_orders = $query->_order_generate( $orders ) ) {
1078
-							$sql['order'] = 'ORDER BY ' . implode( ', ', $_orders );
1077
+							$sql[ 'order' ] = 'ORDER BY ' . implode( ', ', $_orders );
1079 1078
 						}
1080 1079
 					}
1081 1080
 
1082 1081
 					return $sql;
1083 1082
 				} );
1084 1083
 
1085
-				$query->limit( $parameters['paging']['page_size'] )
1086
-					->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) );
1084
+				$query->limit( $parameters[ 'paging' ][ 'page_size' ] )
1085
+					->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) );
1087 1086
 
1088 1087
 				/**
1089 1088
 				 * Any joins?
@@ -1106,7 +1105,7 @@  discard block
 block discarded – undo
1106 1105
 
1107 1106
 							$query_parameters = $query->_introspect();
1108 1107
 
1109
-							$query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) );
1108
+							$query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) );
1110 1109
 						}
1111 1110
 
1112 1111
 						/**
@@ -1140,7 +1139,7 @@  discard block
 block discarded – undo
1140 1139
 						}
1141 1140
 
1142 1141
 						$q = $query->_introspect();
1143
-						$query->where( \GF_Query_Condition::_and( $q['where'], $condition ) );
1142
+						$query->where( \GF_Query_Condition::_and( $q[ 'where' ], $condition ) );
1144 1143
 
1145 1144
 						if ( $this->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
1146 1145
 
@@ -1165,7 +1164,7 @@  discard block
 block discarded – undo
1165 1164
 
1166 1165
 							$query_parameters = $query->_introspect();
1167 1166
 
1168
-							$query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) );
1167
+							$query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) );
1169 1168
 						}
1170 1169
 					}
1171 1170
 				
@@ -1189,7 +1188,7 @@  discard block
 block discarded – undo
1189 1188
 							$conditions = array();
1190 1189
 
1191 1190
 							foreach ( $condition->expressions as $_condition ) {
1192
-								$conditions[] = $recurse( $_condition, $fields, $recurse );
1191
+								$conditions[ ] = $recurse( $_condition, $fields, $recurse );
1193 1192
 							}
1194 1193
 
1195 1194
 							return call_user_func_array(
@@ -1218,10 +1217,10 @@  discard block
 block discarded – undo
1218 1217
 						$q = new $query_class( $form_id );
1219 1218
 
1220 1219
 						// Copy the WHERE clauses but substitute the field_ids to the respective ones
1221
-						$q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) );
1220
+						$q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) );
1222 1221
 
1223 1222
 						// Copy the ORDER clause and substitute the field_ids to the respective ones
1224
-						foreach ( $query_parameters['order'] as $order ) {
1223
+						foreach ( $query_parameters[ 'order' ] as $order ) {
1225 1224
 							list( $column, $_order ) = $order;
1226 1225
 
1227 1226
 							if ( $column && $column instanceof \GF_Query_Column ) {
@@ -1235,15 +1234,15 @@  discard block
 block discarded – undo
1235 1234
 
1236 1235
 						add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) {
1237 1236
 							// Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses
1238
-							$select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] );
1237
+							$select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] );
1239 1238
 
1240 1239
 							// Record the SQL
1241
-							$unions_sql[] = array(
1240
+							$unions_sql[ ] = array(
1242 1241
 								// Remove columns, we'll rebuild them
1243 1242
 								'select'  => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ),
1244
-								'from'    => $sql['from'],
1245
-								'join'    => $sql['join'],
1246
-								'where'   => $sql['where'],
1243
+								'from'    => $sql[ 'from' ],
1244
+								'join'    => $sql[ 'join' ],
1245
+								'where'   => $sql[ 'where' ],
1247 1246
 								// Remove order and limit
1248 1247
 							);
1249 1248
 
@@ -1260,11 +1259,11 @@  discard block
 block discarded – undo
1260 1259
 
1261 1260
 					add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) {
1262 1261
 						// Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses
1263
-						$sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] );
1262
+						$sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] );
1264 1263
 
1265 1264
 						// Remove columns, we'll rebuild them
1266
-						preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match );
1267
-						$sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] );
1265
+						preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match );
1266
+						$sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] );
1268 1267
 
1269 1268
 						$unions = array();
1270 1269
 
@@ -1275,30 +1274,30 @@  discard block
 block discarded – undo
1275 1274
 						};
1276 1275
 
1277 1276
 						// Add all the order columns into the selects, so we can order by the whole union group
1278
-						preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches );
1277
+						preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches );
1279 1278
 						
1280 1279
 						$columns = array(
1281
-							sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) )
1280
+							sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) )
1282 1281
 						);
1283 1282
 
1284 1283
 						foreach ( array_slice( $order_matches, 1 ) as $match ) {
1285
-							$columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) );
1284
+							$columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) );
1286 1285
 
1287 1286
 							// Rewrite the order columns to the shared aliases
1288
-							$sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] );
1287
+							$sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] );
1289 1288
 						}
1290 1289
 
1291 1290
 						$columns = array_unique( $columns );
1292 1291
 
1293 1292
 						// Add the columns to every UNION
1294 1293
 						foreach ( $unions_sql as $union_sql ) {
1295
-							$union_sql['select'] .= implode( ', ', $columns );
1296
-							$unions []= implode( ' ', $union_sql );
1294
+							$union_sql[ 'select' ] .= implode( ', ', $columns );
1295
+							$unions [ ] = implode( ' ', $union_sql );
1297 1296
 						}
1298 1297
 
1299 1298
 						// Add the columns to the main SELECT, but only grab the entry id column
1300
-						$sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns );
1301
-						$sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order'];
1299
+						$sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns );
1300
+						$sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ];
1302 1301
 
1303 1302
 						return $sql;
1304 1303
 					} );
@@ -1343,20 +1342,20 @@  discard block
 block discarded – undo
1343 1342
 				} );
1344 1343
 			} else {
1345 1344
 				$entries = $this->form->entries
1346
-					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) )
1345
+					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) )
1347 1346
 					->offset( $this->settings->get( 'offset' ) )
1348
-					->limit( $parameters['paging']['page_size'] )
1347
+					->limit( $parameters[ 'paging' ][ 'page_size' ] )
1349 1348
 					->page( $page );
1350 1349
 
1351
-				if ( ! empty( $parameters['sorting'] ) && is_array( $parameters['sorting'] && ! isset( $parameters['sorting']['key'] ) ) ) {
1350
+				if ( ! empty( $parameters[ 'sorting' ] ) && is_array( $parameters[ 'sorting' ] && ! isset( $parameters[ 'sorting' ][ 'key' ] ) ) ) {
1352 1351
 					// Pluck off multisort arrays
1353
-					$parameters['sorting'] = $parameters['sorting'][0];
1352
+					$parameters[ 'sorting' ] = $parameters[ 'sorting' ][ 0 ];
1354 1353
 				}
1355 1354
 
1356
-				if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) {
1355
+				if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) {
1357 1356
 					$field = new \GV\Field();
1358
-					$field->ID = $parameters['sorting']['key'];
1359
-					$direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
1357
+					$field->ID = $parameters[ 'sorting' ][ 'key' ];
1358
+					$direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
1360 1359
 					$entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) );
1361 1360
 				}
1362 1361
 			}
@@ -1431,7 +1430,7 @@  discard block
 block discarded – undo
1431 1430
 		$allowed = $headers = array();
1432 1431
 
1433 1432
 		foreach ( $view->fields->by_position( "directory_*" )->by_visible( $view )->all() as $id => $field ) {
1434
-			$allowed[] = $field;
1433
+			$allowed[ ] = $field;
1435 1434
 		}
1436 1435
 
1437 1436
 		$renderer = new Field_Renderer();
@@ -1453,17 +1452,17 @@  discard block
 block discarded – undo
1453 1452
 			} );
1454 1453
 
1455 1454
 			foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) {
1456
-				$allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id );
1455
+				$allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id );
1457 1456
 			}
1458 1457
 
1459 1458
 			foreach ( $allowed as $field ) {
1460 1459
 				$source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source();
1461 1460
 
1462
-				$return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' );
1461
+				$return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' );
1463 1462
 
1464 1463
 				if ( ! $headers_done ) {
1465 1464
 					$label = $field->get_label( $view, $source, $entry );
1466
-					$headers[] = $label ? $label : $field->ID;
1465
+					$headers[ ] = $label ? $label : $field->ID;
1467 1466
 				}
1468 1467
 			}
1469 1468
 
Please login to merge, or discard this patch.