Completed
Pull Request — develop (#660)
by
unknown
20:13
created
includes/class-common.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
 		$entry = self::get_entry( $entry_slug, true );
126 126
 
127
-		$form = self::get_form( $entry['form_id'] );
127
+		$form = self::get_form( $entry[ 'form_id' ] );
128 128
 
129 129
 		return $form;
130 130
 	}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 
176 176
 		$results = GFAPI::get_entries( 0, $search_criteria, null, $paging );
177 177
 
178
-		$result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null;
178
+		$result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null;
179 179
 
180 180
 		return $result;
181 181
 	}
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 		if ( class_exists( 'GFAPI' ) ) {
194 194
 			$gf_forms = GFAPI::get_forms();
195 195
 			foreach ( $gf_forms as $form ) {
196
-				$forms[] = array(
197
-					'id' => $form['id'],
198
-					'title' => $form['title'],
196
+				$forms[ ] = array(
197
+					'id' => $form[ 'id' ],
198
+					'title' => $form[ 'title' ],
199 199
 				);
200 200
 			}
201 201
 		}
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 		}
228 228
 
229 229
 		if ( $form ) {
230
-			foreach ( $form['fields'] as $field ) {
231
-				if ( $include_parent_field || empty( $field['inputs'] ) ) {
232
-					$fields[ $field['id'] ] = array(
230
+			foreach ( $form[ 'fields' ] as $field ) {
231
+				if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) {
232
+					$fields[ $field[ 'id' ] ] = array(
233 233
 						'label' => rgar( $field, 'label' ),
234 234
 						'parent' => null,
235 235
 						'type' => rgar( $field, 'type' ),
@@ -238,16 +238,16 @@  discard block
 block discarded – undo
238 238
 					);
239 239
 				}
240 240
 
241
-				if ( $add_default_properties && ! empty( $field['inputs'] ) ) {
242
-					foreach ( $field['inputs'] as $input ) {
241
+				if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) {
242
+					foreach ( $field[ 'inputs' ] as $input ) {
243 243
                         /**
244 244
                          * @hack
245 245
                          * In case of email/email confirmation, the input for email has the same id as the parent field
246 246
                          */
247
-                        if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) {
247
+                        if ( 'email' == rgar( $field, 'type' ) && false === strpos( $input[ 'id' ], '.' ) ) {
248 248
                             continue;
249 249
                         }
250
-						$fields[ (string)$input['id'] ] = array(
250
+						$fields[ (string)$input[ 'id' ] ] = array(
251 251
 							'label' => rgar( $input, 'label' ),
252 252
 							'customLabel' => rgar( $input, 'customLabel' ),
253 253
 							'parent' => $field,
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 				}
260 260
 
261 261
 				/** @since 1.14 */
262
-				if( 'list' === $field['type'] && !empty( $field['enableColumns'] ) ) {
262
+				if ( 'list' === $field[ 'type' ] && ! empty( $field[ 'enableColumns' ] ) ) {
263 263
 
264
-					foreach ( (array)$field['choices'] as $key => $input ) {
264
+					foreach ( (array)$field[ 'choices' ] as $key => $input ) {
265 265
 
266
-						$input_id = sprintf( '%d.%d', $field['id'], $key ); // {field_id}.{column_key}
266
+						$input_id = sprintf( '%d.%d', $field[ 'id' ], $key ); // {field_id}.{column_key}
267 267
 
268 268
 						$fields[ $input_id ] = array(
269 269
 							'label'       => rgar( $input, 'text' ),
@@ -279,25 +279,25 @@  discard block
 block discarded – undo
279 279
 				/**
280 280
 				 * @since 1.8
281 281
 				 */
282
-				if( 'quiz' === $field['type'] ) {
282
+				if ( 'quiz' === $field[ 'type' ] ) {
283 283
 					$has_quiz_fields = true;
284 284
 				}
285 285
 
286 286
 				/**
287 287
 				 * @since 1.8
288 288
 				 */
289
-				if( 'poll' === $field['type'] ) {
289
+				if ( 'poll' === $field[ 'type' ] ) {
290 290
 					$has_poll_fields = true;
291 291
 				}
292 292
 
293
-				if( GFCommon::is_product_field( $field['type'] ) ){
293
+				if ( GFCommon::is_product_field( $field[ 'type' ] ) ) {
294 294
 					$has_product_fields = true;
295 295
 				}
296 296
 
297 297
 				/**
298 298
 				 * @hack Version 1.9
299 299
 				 */
300
-				$field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object) $field : (array) $field;
300
+				$field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object)$field : (array)$field;
301 301
 
302 302
 				if ( GFCommon::is_post_field( $field_for_is_post_field ) ) {
303 303
 					$has_post_fields = true;
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 		 * @since 1.7
310 310
 		 */
311 311
 		if ( $has_post_fields ) {
312
-			$fields['post_id'] = array(
312
+			$fields[ 'post_id' ] = array(
313 313
 				'label' => __( 'Post ID', 'gravityview' ),
314 314
 				'type' => 'post_id',
315 315
 			);
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
 			$payment_fields = GravityView_Fields::get_all( 'pricing' );
321 321
 
322 322
 			foreach ( $payment_fields as $payment_field ) {
323
-				if( isset( $fields["{$payment_field->name}"] ) ) {
323
+				if ( isset( $fields[ "{$payment_field->name}" ] ) ) {
324 324
 					continue;
325 325
 				}
326
-				$fields["{$payment_field->name}"] = array(
326
+				$fields[ "{$payment_field->name}" ] = array(
327 327
 					'label' => $payment_field->label,
328 328
 					'desc' => $payment_field->description,
329 329
 					'type' => $payment_field->name,
@@ -334,24 +334,24 @@  discard block
 block discarded – undo
334 334
 		/**
335 335
 		 * @since 1.8
336 336
 		 */
337
-		if( $has_quiz_fields ) {
337
+		if ( $has_quiz_fields ) {
338 338
 
339
-			$fields['gquiz_score']   = array(
339
+			$fields[ 'gquiz_score' ] = array(
340 340
 				'label' => __( 'Quiz Score Total', 'gravityview' ),
341 341
 				'type'  => 'quiz_score',
342 342
 				'desc'  => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ),
343 343
 			);
344
-			$fields['gquiz_percent'] = array(
344
+			$fields[ 'gquiz_percent' ] = array(
345 345
 				'label' => __( 'Quiz Percentage Grade', 'gravityview' ),
346 346
 				'type'  => 'quiz_percent',
347 347
 				'desc'  => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ),
348 348
 			);
349
-			$fields['gquiz_grade']   = array(
349
+			$fields[ 'gquiz_grade' ] = array(
350 350
 				'label' => __( 'Quiz Letter Grade', 'gravityview' ),
351 351
 				'type'  => 'quiz_grade',
352 352
 				'desc'  => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ),
353 353
 			);
354
-			$fields['gquiz_is_pass'] = array(
354
+			$fields[ 'gquiz_is_pass' ] = array(
355 355
 				'label' => __( 'Quiz Pass/Fail', 'gravityview' ),
356 356
 				'type'  => 'quiz_is_pass',
357 357
 				'desc'  => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ),
@@ -373,9 +373,9 @@  discard block
 block discarded – undo
373 373
 
374 374
 		$fields = array();
375 375
 
376
-		foreach ( $extra_fields as $key => $field ){
377
-			if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) {
378
-				$fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' );
376
+		foreach ( $extra_fields as $key => $field ) {
377
+			if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) {
378
+				$fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' );
379 379
 			}
380 380
 		}
381 381
 
@@ -415,32 +415,32 @@  discard block
 block discarded – undo
415 415
 			'search_criteria' => null,
416 416
 			'sorting' => null,
417 417
 			'paging' => null,
418
-			'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true),
418
+			'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? $passed_criteria[ 'cache' ] : true ),
419 419
 		);
420 420
 
421 421
 		$criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults );
422 422
 
423
-		if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) {
424
-			foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) {
423
+		if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) {
424
+			foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) {
425 425
 
426 426
 				if ( ! is_array( $filter ) ) {
427 427
 					continue;
428 428
 				}
429 429
 
430 430
 				// By default, we want searches to be wildcard for each field.
431
-				$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
431
+				$filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];
432 432
 
433 433
 				/**
434 434
 				 * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc)
435 435
 				 * @param string $operator Existing search operator
436 436
 				 * @param array $filter array with `key`, `value`, `operator`, `type` keys
437 437
 				 */
438
-				$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter );
438
+				$filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter );
439 439
 			}
440 440
 
441 441
 			// don't send just the [mode] without any field filter.
442
-			if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) {
443
-				unset( $criteria['search_criteria']['field_filters']['mode'] );
442
+			if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) {
443
+				unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] );
444 444
 			}
445 445
 
446 446
 		}
@@ -451,21 +451,21 @@  discard block
 block discarded – undo
451 451
 		 * Prepare date formats to be in Gravity Forms DB format;
452 452
 		 * $passed_criteria may include date formats incompatible with Gravity Forms.
453 453
 		 */
454
-		foreach ( array('start_date', 'end_date' ) as $key ) {
454
+		foreach ( array( 'start_date', 'end_date' ) as $key ) {
455 455
 
456
-			if ( ! empty( $criteria['search_criteria'][ $key ] ) ) {
456
+			if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) {
457 457
 
458 458
 				// Use date_create instead of new DateTime so it returns false if invalid date format.
459
-				$date = date_create( $criteria['search_criteria'][ $key ] );
459
+				$date = date_create( $criteria[ 'search_criteria' ][ $key ] );
460 460
 
461 461
 				if ( $date ) {
462 462
 					// Gravity Forms wants dates in the `Y-m-d H:i:s` format.
463
-					$criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' );
463
+					$criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' );
464 464
 				} else {
465 465
 					// If it's an invalid date, unset it. Gravity Forms freaks out otherwise.
466
-					unset( $criteria['search_criteria'][ $key ] );
466
+					unset( $criteria[ 'search_criteria' ][ $key ] );
467 467
 
468
-					do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] );
468
+					do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] );
469 469
 				}
470 470
 			}
471 471
 		}
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
 
474 474
 		// When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter
475 475
 		if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) {
476
-			$criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id();
476
+			$criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id();
477 477
 		} elseif ( 'delete' === RGForms::get( 'action' ) ) {
478
-			$criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null;
479
-		} elseif( !isset( $criteria['context_view_id'] ) ) {
478
+			$criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? $_GET[ 'view_id' ] : null;
479
+		} elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) {
480 480
             // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget)
481
-			$criteria['context_view_id'] = null;
481
+			$criteria[ 'context_view_id' ] = null;
482 482
 		}
483 483
 
484 484
 		/**
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 		 * @param array $form_ids Forms to search
488 488
 		 * @param int $view_id ID of the view being used to search
489 489
 		 */
490
-		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] );
490
+		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] );
491 491
 
492 492
 		return (array)$criteria;
493 493
 
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 		/** Reduce # of database calls */
519 519
 		add_filter( 'gform_is_encrypted_field', '__return_false' );
520 520
 
521
-		if ( ! empty( $criteria['cache'] ) ) {
521
+		if ( ! empty( $criteria[ 'cache' ] ) ) {
522 522
 
523 523
 			$Cache = new GravityView_Cache( $form_ids, $criteria );
524 524
 
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 
527 527
 				// Still update the total count when using cached results
528 528
 				if ( ! is_null( $total ) ) {
529
-					$total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] );
529
+					$total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] );
530 530
 				}
531 531
 
532 532
 				$return = $entries;
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 			$entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total );
547 547
 
548 548
 			// No entries returned from gravityview_before_get_entries
549
-			if( is_null( $entries ) ) {
549
+			if ( is_null( $entries ) ) {
550 550
 
551
-				$entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total );
551
+				$entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total );
552 552
 
553 553
 				if ( is_wp_error( $entries ) ) {
554 554
 					do_action( 'gravityview_log_error', $entries->get_error_message(), $entries );
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 				}
558 558
 			}
559 559
 
560
-			if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) {
560
+			if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) {
561 561
 
562 562
 				// Cache results
563 563
 				$Cache->set( $entries, 'entries' );
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 			 */
645 645
 			$check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry );
646 646
 
647
-			if( $check_entry_display ) {
647
+			if ( $check_entry_display ) {
648 648
 				// Is the entry allowed
649 649
 				$entry = self::check_entry_display( $entry );
650 650
 			}
@@ -677,12 +677,12 @@  discard block
 block discarded – undo
677 677
 
678 678
 		$value = false;
679 679
 
680
-		if( 'context' === $val1 ) {
680
+		if ( 'context' === $val1 ) {
681 681
 
682 682
 			$matching_contexts = array( $val2 );
683 683
 
684 684
 			// We allow for non-standard contexts.
685
-			switch( $val2 ) {
685
+			switch ( $val2 ) {
686 686
 				// Check for either single or edit
687 687
 				case 'singular':
688 688
 					$matching_contexts = array( 'single', 'edit' );
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 			return false;
743 743
 		}
744 744
 
745
-		if ( empty( $entry['form_id'] ) ) {
745
+		if ( empty( $entry[ 'form_id' ] ) ) {
746 746
 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry );
747 747
 			return false;
748 748
 		}
@@ -750,26 +750,26 @@  discard block
 block discarded – undo
750 750
 		$criteria = self::calculate_get_entries_criteria();
751 751
 
752 752
 		// Make sure the current View is connected to the same form as the Entry
753
-		if( ! empty( $criteria['context_view_id'] ) ) {
754
-			$context_view_id = intval( $criteria['context_view_id'] );
753
+		if ( ! empty( $criteria[ 'context_view_id' ] ) ) {
754
+			$context_view_id = intval( $criteria[ 'context_view_id' ] );
755 755
 			$context_form_id = gravityview_get_form_id( $context_view_id );
756
-			if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) {
757
-				do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] );
756
+			if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) {
757
+				do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] );
758 758
 				return false;
759 759
 			}
760 760
 		}
761 761
 
762
-		if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) {
762
+		if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) {
763 763
 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria );
764 764
 			return $entry;
765 765
 		}
766 766
 
767
-		$search_criteria = $criteria['search_criteria'];
767
+		$search_criteria = $criteria[ 'search_criteria' ];
768 768
 		unset( $criteria );
769 769
 
770 770
 		// check entry status
771
-		if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) {
772
-			do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria );
771
+		if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) {
772
+			do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria );
773 773
 			return false;
774 774
 		}
775 775
 
@@ -777,37 +777,37 @@  discard block
 block discarded – undo
777 777
 		// @todo: Does it make sense to apply the Date create filters to the single entry?
778 778
 
779 779
 		// field_filters
780
-		if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) {
780
+		if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) {
781 781
 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria );
782 782
 			return $entry;
783 783
 		}
784 784
 
785
-		$filters = $search_criteria['field_filters'];
785
+		$filters = $search_criteria[ 'field_filters' ];
786 786
 		unset( $search_criteria );
787 787
 
788
-		$mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all';
789
-		unset( $filters['mode'] );
788
+		$mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all';
789
+		unset( $filters[ 'mode' ] );
790 790
 
791
-		$form = self::get_form( $entry['form_id'] );
791
+		$form = self::get_form( $entry[ 'form_id' ] );
792 792
 
793 793
 		foreach ( $filters as $filter ) {
794 794
 
795
-			if ( ! isset( $filter['key'] ) ) {
795
+			if ( ! isset( $filter[ 'key' ] ) ) {
796 796
 				continue;
797 797
 			}
798 798
 
799
-			$k = $filter['key'];
799
+			$k = $filter[ 'key' ];
800 800
 
801 801
 			if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) {
802 802
 				$field_value = $entry[ $k ];
803 803
 				$field = null;
804 804
 			} else {
805 805
 				$field = self::get_field( $form, $k );
806
-				$field_value  = GFFormsModel::get_lead_field_value( $entry, $field );
806
+				$field_value = GFFormsModel::get_lead_field_value( $entry, $field );
807 807
 			}
808 808
 
809
-			$operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is';
810
-			$is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field );
809
+			$operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is';
810
+			$is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field );
811 811
 
812 812
 			// verify if we are already free to go!
813 813
 			if ( ! $is_value_match && 'all' === $mode ) {
@@ -865,25 +865,25 @@  discard block
 block discarded – undo
865 865
 		 * Gravity Forms code to adjust date to locally-configured Time Zone
866 866
 		 * @see GFCommon::format_date() for original code
867 867
 		 */
868
-		$date_gmt_time   = mysql2date( 'G', $date_string );
868
+		$date_gmt_time = mysql2date( 'G', $date_string );
869 869
 		$date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time );
870 870
 
871
-		$format  = rgar( $atts, 'format' );
872
-		$is_human  = ! empty( $atts['human'] );
873
-		$is_diff  = ! empty( $atts['diff'] );
874
-		$is_raw = ! empty( $atts['raw'] );
875
-		$is_timestamp = ! empty( $atts['timestamp'] );
876
-		$include_time = ! empty( $atts['time'] );
871
+		$format = rgar( $atts, 'format' );
872
+		$is_human = ! empty( $atts[ 'human' ] );
873
+		$is_diff = ! empty( $atts[ 'diff' ] );
874
+		$is_raw = ! empty( $atts[ 'raw' ] );
875
+		$is_timestamp = ! empty( $atts[ 'timestamp' ] );
876
+		$include_time = ! empty( $atts[ 'time' ] );
877 877
 
878 878
 		// If we're using time diff, we want to have a different default format
879
-		if( empty( $format ) ) {
879
+		if ( empty( $format ) ) {
880 880
 			$format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' );
881 881
 		}
882 882
 
883 883
 		// If raw was specified, don't modify the stored value
884 884
 		if ( $is_raw ) {
885 885
 			$formatted_date = $date_string;
886
-		} elseif( $is_timestamp ) {
886
+		} elseif ( $is_timestamp ) {
887 887
 			$formatted_date = $date_local_timestamp;
888 888
 		} elseif ( $is_diff ) {
889 889
 			$formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) );
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
 		}
912 912
 
913 913
 		$field = self::get_field( $form, $field_id );
914
-		return isset( $field['label'] ) ?  $field['label'] : '';
914
+		return isset( $field[ 'label' ] ) ? $field[ 'label' ] : '';
915 915
 
916 916
 	}
917 917
 
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 	 * @return array|null Array: Gravity Forms field array; NULL: Gravity Forms GFFormsModel does not exist
930 930
 	 */
931 931
 	public static function get_field( $form, $field_id ) {
932
-		if ( class_exists( 'GFFormsModel' ) ){
932
+		if ( class_exists( 'GFFormsModel' ) ) {
933 933
 			return GFFormsModel::get_field( $form, $field_id );
934 934
 		} else {
935 935
 			return null;
@@ -976,20 +976,20 @@  discard block
 block discarded – undo
976 976
 			$shortcodes = array();
977 977
 
978 978
 			preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
979
-			if ( empty( $matches ) ){
979
+			if ( empty( $matches ) ) {
980 980
 				return false;
981 981
 			}
982 982
 
983 983
 			foreach ( $matches as $shortcode ) {
984
-				if ( $tag === $shortcode[2] ) {
984
+				if ( $tag === $shortcode[ 2 ] ) {
985 985
 
986 986
 					// Changed this to $shortcode instead of true so we get the parsed atts.
987
-					$shortcodes[] = $shortcode;
987
+					$shortcodes[ ] = $shortcode;
988 988
 
989
-				} else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) {
990
-					if( is_array( $results ) ) {
991
-						foreach( $results as $result ) {
992
-							$shortcodes[] = $result;
989
+				} else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) {
990
+					if ( is_array( $results ) ) {
991
+						foreach ( $results as $result ) {
992
+							$shortcodes[ ] = $result;
993 993
 						}
994 994
 					}
995 995
 
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
 	 * @return string         html
1143 1143
 	 */
1144 1144
 	public static function get_sortable_fields( $formid, $current = '' ) {
1145
-		$output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>';
1145
+		$output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>';
1146 1146
 
1147 1147
 		if ( empty( $formid ) ) {
1148 1148
 			return $output;
@@ -1155,11 +1155,11 @@  discard block
 block discarded – undo
1155 1155
 			$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null );
1156 1156
 
1157 1157
 			foreach ( $fields as $id => $field ) {
1158
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
1158
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1159 1159
 					continue;
1160 1160
 				}
1161 1161
 
1162
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>';
1162
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>';
1163 1163
 			}
1164 1164
 		}
1165 1165
 
@@ -1194,9 +1194,9 @@  discard block
 block discarded – undo
1194 1194
 		$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL );
1195 1195
 
1196 1196
 		// TODO: Convert to using array_filter
1197
-		foreach( $fields as $id => $field ) {
1197
+		foreach ( $fields as $id => $field ) {
1198 1198
 
1199
-			if( in_array( $field['type'], $blacklist_field_types ) ) {
1199
+			if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1200 1200
 				unset( $fields[ $id ] );
1201 1201
 			}
1202 1202
 		}
@@ -1237,14 +1237,14 @@  discard block
 block discarded – undo
1237 1237
 	 * @param  int|array  $field field key or field array
1238 1238
 	 * @return boolean
1239 1239
 	 */
1240
-	public static function is_field_numeric(  $form = null, $field = '' ) {
1240
+	public static function is_field_numeric( $form = null, $field = '' ) {
1241 1241
 
1242 1242
 		if ( ! is_array( $form ) && ! is_array( $field ) ) {
1243 1243
 			$form = self::get_form( $form );
1244 1244
 		}
1245 1245
 
1246 1246
 		// If entry meta, it's a string. Otherwise, numeric
1247
-		if( ! is_numeric( $field ) && is_string( $field ) ) {
1247
+		if ( ! is_numeric( $field ) && is_string( $field ) ) {
1248 1248
 			$type = $field;
1249 1249
 		} else {
1250 1250
 			$type = self::get_field_type( $form, $field );
@@ -1258,9 +1258,9 @@  discard block
 block discarded – undo
1258 1258
 		$numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) );
1259 1259
 
1260 1260
 		// Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true
1261
-		if( $gv_field = GravityView_Fields::get( $type ) ) {
1262
-			if( true === $gv_field->is_numeric ) {
1263
-				$numeric_types[] = $gv_field->is_numeric;
1261
+		if ( $gv_field = GravityView_Fields::get( $type ) ) {
1262
+			if ( true === $gv_field->is_numeric ) {
1263
+				$numeric_types[ ] = $gv_field->is_numeric;
1264 1264
 			}
1265 1265
 		}
1266 1266
 
@@ -1410,11 +1410,11 @@  discard block
 block discarded – undo
1410 1410
 		$final_atts = array_filter( $final_atts );
1411 1411
 
1412 1412
 		// If the href wasn't passed as an attribute, use the value passed to the function
1413
-		if ( empty( $final_atts['href'] ) && ! empty( $href ) ) {
1414
-			$final_atts['href'] = $href;
1413
+		if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) {
1414
+			$final_atts[ 'href' ] = $href;
1415 1415
 		}
1416 1416
 
1417
-		$final_atts['href'] = esc_url_raw( $href );
1417
+		$final_atts[ 'href' ] = esc_url_raw( $href );
1418 1418
 
1419 1419
 		// Sort the attributes alphabetically, to help testing
1420 1420
 		ksort( $final_atts );
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
 			$output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) );
1426 1426
 		}
1427 1427
 
1428
-		if( '' !== $output ) {
1428
+		if ( '' !== $output ) {
1429 1429
 			$output = '<a' . $output . '>' . $anchor_text . '</a>';
1430 1430
 		}
1431 1431
 
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 	public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) {
1450 1450
 		$merged = $array1;
1451 1451
 
1452
-		foreach ( $array2 as $key => &$value )  {
1452
+		foreach ( $array2 as $key => &$value ) {
1453 1453
 			if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
1454 1454
 				$merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );
1455 1455
 			} else {
@@ -1484,7 +1484,7 @@  discard block
 block discarded – undo
1484 1484
 		 * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..)
1485 1485
 		 * @param array $settings Settings array, with `number` key defining the # of users to display
1486 1486
 		 */
1487
-		$get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1487
+		$get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1488 1488
 
1489 1489
 		return get_users( $get_users_settings );
1490 1490
 	}
@@ -1499,7 +1499,7 @@  discard block
 block discarded – undo
1499 1499
      * @return string
1500 1500
      */
1501 1501
     public static function generate_notice( $notice, $class = '' ) {
1502
-        return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>';
1502
+        return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>';
1503 1503
     }
1504 1504
 
1505 1505
 
Please login to merge, or discard this patch.