Completed
Push — develop ( d10900...28abf9 )
by Zack
18:41
created
includes/class-common.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Set of common functions to separate main plugin from Gravity Forms API and other cross-plugin methods
4
- *
5
- * @package   GravityView
6
- * @license   GPL2+
7
- * @author    Katz Web Services, Inc.
8
- * @link      http://gravityview.co
9
- * @copyright Copyright 2014, Katz Web Services, Inc.
10
- *
11
- * @since 1.5.2
12
- */
3
+	 * Set of common functions to separate main plugin from Gravity Forms API and other cross-plugin methods
4
+	 *
5
+	 * @package   GravityView
6
+	 * @license   GPL2+
7
+	 * @author    Katz Web Services, Inc.
8
+	 * @link      http://gravityview.co
9
+	 * @copyright Copyright 2014, Katz Web Services, Inc.
10
+	 *
11
+	 * @since 1.5.2
12
+	 */
13 13
 
14 14
 /** If this file is called directly, abort. */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
 
241 241
 				if ( $add_default_properties && ! empty( $field['inputs'] ) ) {
242 242
 					foreach ( $field['inputs'] as $input ) {
243
-                        /**
244
-                         * @hack
245
-                         * In case of email/email confirmation, the input for email has the same id as the parent field
246
-                         */
247
-                        if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) {
248
-                            continue;
249
-                        }
243
+						/**
244
+						 * @hack
245
+						 * In case of email/email confirmation, the input for email has the same id as the parent field
246
+						 */
247
+						if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) {
248
+							continue;
249
+						}
250 250
 						$fields[ (string)$input['id'] ] = array(
251 251
 							'label' => rgar( $input, 'label' ),
252 252
 							'customLabel' => rgar( $input, 'customLabel' ),
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 		} elseif ( 'delete' === RGForms::get( 'action' ) ) {
470 470
 			$criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null;
471 471
 		} elseif( !isset( $criteria['context_view_id'] ) ) {
472
-            // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget)
472
+			// Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget)
473 473
 			$criteria['context_view_id'] = null;
474 474
 		}
475 475
 
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 			),
1169 1169
 		);
1170 1170
 
1171
-        $fields = $date_created + $fields;
1171
+		$fields = $date_created + $fields;
1172 1172
 
1173 1173
 		$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL );
1174 1174
 
@@ -1180,13 +1180,13 @@  discard block
 block discarded – undo
1180 1180
 			}
1181 1181
 		}
1182 1182
 
1183
-        /**
1184
-         * @filter `gravityview/common/sortable_fields` Filter the sortable fields
1185
-         * @since 1.12
1186
-         * @param array $fields Sub-set of GF form fields that are sortable
1187
-         * @param int $formid The Gravity Forms form ID that the fields are from
1188
-         */
1189
-        $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid );
1183
+		/**
1184
+		 * @filter `gravityview/common/sortable_fields` Filter the sortable fields
1185
+		 * @since 1.12
1186
+		 * @param array $fields Sub-set of GF form fields that are sortable
1187
+		 * @param int $formid The Gravity Forms form ID that the fields are from
1188
+		 */
1189
+		$fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid );
1190 1190
 
1191 1191
 		return $fields;
1192 1192
 	}
@@ -1464,17 +1464,17 @@  discard block
 block discarded – undo
1464 1464
 	}
1465 1465
 
1466 1466
 
1467
-    /**
1468
-     * Display updated/error notice
1469
-     *
1470
-     * @param string $notice text/HTML of notice
1471
-     * @param string $class CSS class for notice (`updated` or `error`)
1472
-     *
1473
-     * @return string
1474
-     */
1475
-    public static function generate_notice( $notice, $class = '' ) {
1476
-        return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>';
1477
-    }
1467
+	/**
1468
+	 * Display updated/error notice
1469
+	 *
1470
+	 * @param string $notice text/HTML of notice
1471
+	 * @param string $class CSS class for notice (`updated` or `error`)
1472
+	 *
1473
+	 * @return string
1474
+	 */
1475
+	public static function generate_notice( $notice, $class = '' ) {
1476
+		return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>';
1477
+	}
1478 1478
 
1479 1479
 
1480 1480
 
Please login to merge, or discard this patch.
Spacing   +109 added lines, -109 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,25 +334,25 @@  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
 				/* translators: This is a field type used by the Gravity Forms Quiz Addon. "A" is 100-90, "B" is 89-80, "C" is 79-70, etc.  */
351 351
 				'label' => __( 'Quiz Letter Grade', 'gravityview' ),
352 352
 				'type'  => 'quiz_grade',
353 353
 				'desc'  => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ),
354 354
 			);
355
-			$fields['gquiz_is_pass'] = array(
355
+			$fields[ 'gquiz_is_pass' ] = array(
356 356
 				'label' => __( 'Quiz Pass/Fail', 'gravityview' ),
357 357
 				'type'  => 'quiz_is_pass',
358 358
 				'desc'  => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ),
@@ -374,9 +374,9 @@  discard block
 block discarded – undo
374 374
 
375 375
 		$fields = array();
376 376
 
377
-		foreach ( $extra_fields as $key => $field ){
378
-			if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) {
379
-				$fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' );
377
+		foreach ( $extra_fields as $key => $field ) {
378
+			if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) {
379
+				$fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' );
380 380
 			}
381 381
 		}
382 382
 
@@ -416,32 +416,32 @@  discard block
 block discarded – undo
416 416
 			'search_criteria' => null,
417 417
 			'sorting' => null,
418 418
 			'paging' => null,
419
-			'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true),
419
+			'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? $passed_criteria[ 'cache' ] : true ),
420 420
 		);
421 421
 
422 422
 		$criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults );
423 423
 
424
-		if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) {
425
-			foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) {
424
+		if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) {
425
+			foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) {
426 426
 
427 427
 				if ( ! is_array( $filter ) ) {
428 428
 					continue;
429 429
 				}
430 430
 
431 431
 				// By default, we want searches to be wildcard for each field.
432
-				$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
432
+				$filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];
433 433
 
434 434
 				/**
435 435
 				 * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc)
436 436
 				 * @param string $operator Existing search operator
437 437
 				 * @param array $filter array with `key`, `value`, `operator`, `type` keys
438 438
 				 */
439
-				$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter );
439
+				$filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter );
440 440
 			}
441 441
 
442 442
 			// don't send just the [mode] without any field filter.
443
-			if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) {
444
-				unset( $criteria['search_criteria']['field_filters']['mode'] );
443
+			if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) {
444
+				unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] );
445 445
 			}
446 446
 
447 447
 		}
@@ -452,21 +452,21 @@  discard block
 block discarded – undo
452 452
 		 * Prepare date formats to be in Gravity Forms DB format;
453 453
 		 * $passed_criteria may include date formats incompatible with Gravity Forms.
454 454
 		 */
455
-		foreach ( array('start_date', 'end_date' ) as $key ) {
455
+		foreach ( array( 'start_date', 'end_date' ) as $key ) {
456 456
 
457
-			if ( ! empty( $criteria['search_criteria'][ $key ] ) ) {
457
+			if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) {
458 458
 
459 459
 				// Use date_create instead of new DateTime so it returns false if invalid date format.
460
-				$date = date_create( $criteria['search_criteria'][ $key ] );
460
+				$date = date_create( $criteria[ 'search_criteria' ][ $key ] );
461 461
 
462 462
 				if ( $date ) {
463 463
 					// Gravity Forms wants dates in the `Y-m-d H:i:s` format.
464
-					$criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' );
464
+					$criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' );
465 465
 				} else {
466 466
 					// If it's an invalid date, unset it. Gravity Forms freaks out otherwise.
467
-					unset( $criteria['search_criteria'][ $key ] );
467
+					unset( $criteria[ 'search_criteria' ][ $key ] );
468 468
 
469
-					do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] );
469
+					do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] );
470 470
 				}
471 471
 			}
472 472
 		}
@@ -474,12 +474,12 @@  discard block
 block discarded – undo
474 474
 
475 475
 		// When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter
476 476
 		if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) {
477
-			$criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id();
477
+			$criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id();
478 478
 		} elseif ( 'delete' === RGForms::get( 'action' ) ) {
479
-			$criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null;
480
-		} elseif( !isset( $criteria['context_view_id'] ) ) {
479
+			$criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? $_GET[ 'view_id' ] : null;
480
+		} elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) {
481 481
             // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget)
482
-			$criteria['context_view_id'] = null;
482
+			$criteria[ 'context_view_id' ] = null;
483 483
 		}
484 484
 
485 485
 		/**
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 		 * @param array $form_ids Forms to search
489 489
 		 * @param int $view_id ID of the view being used to search
490 490
 		 */
491
-		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] );
491
+		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] );
492 492
 
493 493
 		return (array)$criteria;
494 494
 
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 		/** Reduce # of database calls */
520 520
 		add_filter( 'gform_is_encrypted_field', '__return_false' );
521 521
 
522
-		if ( ! empty( $criteria['cache'] ) ) {
522
+		if ( ! empty( $criteria[ 'cache' ] ) ) {
523 523
 
524 524
 			$Cache = new GravityView_Cache( $form_ids, $criteria );
525 525
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 
528 528
 				// Still update the total count when using cached results
529 529
 				if ( ! is_null( $total ) ) {
530
-					$total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] );
530
+					$total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] );
531 531
 				}
532 532
 
533 533
 				$return = $entries;
@@ -547,9 +547,9 @@  discard block
 block discarded – undo
547 547
 			$entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total );
548 548
 
549 549
 			// No entries returned from gravityview_before_get_entries
550
-			if( is_null( $entries ) ) {
550
+			if ( is_null( $entries ) ) {
551 551
 
552
-				$entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total );
552
+				$entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total );
553 553
 
554 554
 				if ( is_wp_error( $entries ) ) {
555 555
 					do_action( 'gravityview_log_error', $entries->get_error_message(), $entries );
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 				}
559 559
 			}
560 560
 
561
-			if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) {
561
+			if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) {
562 562
 
563 563
 				// Cache results
564 564
 				$Cache->set( $entries, 'entries' );
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 			 */
646 646
 			$check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry );
647 647
 
648
-			if( $check_entry_display ) {
648
+			if ( $check_entry_display ) {
649 649
 				// Is the entry allowed
650 650
 				$entry = self::check_entry_display( $entry );
651 651
 			}
@@ -678,12 +678,12 @@  discard block
 block discarded – undo
678 678
 
679 679
 		$value = false;
680 680
 
681
-		if( 'context' === $val1 ) {
681
+		if ( 'context' === $val1 ) {
682 682
 
683 683
 			$matching_contexts = array( $val2 );
684 684
 
685 685
 			// We allow for non-standard contexts.
686
-			switch( $val2 ) {
686
+			switch ( $val2 ) {
687 687
 				// Check for either single or edit
688 688
 				case 'singular':
689 689
 					$matching_contexts = array( 'single', 'edit' );
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
 			return false;
744 744
 		}
745 745
 
746
-		if ( empty( $entry['form_id'] ) ) {
746
+		if ( empty( $entry[ 'form_id' ] ) ) {
747 747
 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry );
748 748
 			return false;
749 749
 		}
@@ -751,26 +751,26 @@  discard block
 block discarded – undo
751 751
 		$criteria = self::calculate_get_entries_criteria();
752 752
 
753 753
 		// Make sure the current View is connected to the same form as the Entry
754
-		if( ! empty( $criteria['context_view_id'] ) ) {
755
-			$context_view_id = intval( $criteria['context_view_id'] );
754
+		if ( ! empty( $criteria[ 'context_view_id' ] ) ) {
755
+			$context_view_id = intval( $criteria[ 'context_view_id' ] );
756 756
 			$context_form_id = gravityview_get_form_id( $context_view_id );
757
-			if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) {
758
-				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'] );
757
+			if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) {
758
+				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' ] );
759 759
 				return false;
760 760
 			}
761 761
 		}
762 762
 
763
-		if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) {
763
+		if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) {
764 764
 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria );
765 765
 			return $entry;
766 766
 		}
767 767
 
768
-		$search_criteria = $criteria['search_criteria'];
768
+		$search_criteria = $criteria[ 'search_criteria' ];
769 769
 		unset( $criteria );
770 770
 
771 771
 		// check entry status
772
-		if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) {
773
-			do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria );
772
+		if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) {
773
+			do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria );
774 774
 			return false;
775 775
 		}
776 776
 
@@ -778,37 +778,37 @@  discard block
 block discarded – undo
778 778
 		// @todo: Does it make sense to apply the Date create filters to the single entry?
779 779
 
780 780
 		// field_filters
781
-		if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) {
781
+		if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) {
782 782
 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria );
783 783
 			return $entry;
784 784
 		}
785 785
 
786
-		$filters = $search_criteria['field_filters'];
786
+		$filters = $search_criteria[ 'field_filters' ];
787 787
 		unset( $search_criteria );
788 788
 
789
-		$mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all';
790
-		unset( $filters['mode'] );
789
+		$mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all';
790
+		unset( $filters[ 'mode' ] );
791 791
 
792
-		$form = self::get_form( $entry['form_id'] );
792
+		$form = self::get_form( $entry[ 'form_id' ] );
793 793
 
794 794
 		foreach ( $filters as $filter ) {
795 795
 
796
-			if ( ! isset( $filter['key'] ) ) {
796
+			if ( ! isset( $filter[ 'key' ] ) ) {
797 797
 				continue;
798 798
 			}
799 799
 
800
-			$k = $filter['key'];
800
+			$k = $filter[ 'key' ];
801 801
 
802 802
 			if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) {
803 803
 				$field_value = $entry[ $k ];
804 804
 				$field = null;
805 805
 			} else {
806 806
 				$field = self::get_field( $form, $k );
807
-				$field_value  = GFFormsModel::get_lead_field_value( $entry, $field );
807
+				$field_value = GFFormsModel::get_lead_field_value( $entry, $field );
808 808
 			}
809 809
 
810
-			$operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is';
811
-			$is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field );
810
+			$operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is';
811
+			$is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field );
812 812
 
813 813
 			// verify if we are already free to go!
814 814
 			if ( ! $is_value_match && 'all' === $mode ) {
@@ -866,18 +866,18 @@  discard block
 block discarded – undo
866 866
 		 * Gravity Forms code to adjust date to locally-configured Time Zone
867 867
 		 * @see GFCommon::format_date() for original code
868 868
 		 */
869
-		$date_gmt_time   = mysql2date( 'G', $date_string );
869
+		$date_gmt_time = mysql2date( 'G', $date_string );
870 870
 		$date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time );
871 871
 
872
-		$format  = rgar( $atts, 'format' );
873
-		$is_human  = ! empty( $atts['human'] );
874
-		$is_diff  = ! empty( $atts['diff'] );
875
-		$is_raw = ! empty( $atts['raw'] );
876
-		$is_timestamp = ! empty( $atts['timestamp'] );
877
-		$include_time = ! empty( $atts['time'] );
872
+		$format = rgar( $atts, 'format' );
873
+		$is_human = ! empty( $atts[ 'human' ] );
874
+		$is_diff = ! empty( $atts[ 'diff' ] );
875
+		$is_raw = ! empty( $atts[ 'raw' ] );
876
+		$is_timestamp = ! empty( $atts[ 'timestamp' ] );
877
+		$include_time = ! empty( $atts[ 'time' ] );
878 878
 
879 879
 		// If we're using time diff, we want to have a different default format
880
-		if( empty( $format ) ) {
880
+		if ( empty( $format ) ) {
881 881
 			/* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */
882 882
 			$format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' );
883 883
 		}
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 		// If raw was specified, don't modify the stored value
886 886
 		if ( $is_raw ) {
887 887
 			$formatted_date = $date_string;
888
-		} elseif( $is_timestamp ) {
888
+		} elseif ( $is_timestamp ) {
889 889
 			$formatted_date = $date_local_timestamp;
890 890
 		} elseif ( $is_diff ) {
891 891
 			$formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) );
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 		}
914 914
 
915 915
 		$field = self::get_field( $form, $field_id );
916
-		return isset( $field['label'] ) ?  $field['label'] : '';
916
+		return isset( $field[ 'label' ] ) ? $field[ 'label' ] : '';
917 917
 
918 918
 	}
919 919
 
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
 	 * @return array|null Array: Gravity Forms field array; NULL: Gravity Forms GFFormsModel does not exist
932 932
 	 */
933 933
 	public static function get_field( $form, $field_id ) {
934
-		if ( class_exists( 'GFFormsModel' ) ){
934
+		if ( class_exists( 'GFFormsModel' ) ) {
935 935
 			return GFFormsModel::get_field( $form, $field_id );
936 936
 		} else {
937 937
 			return null;
@@ -978,19 +978,19 @@  discard block
 block discarded – undo
978 978
 			$shortcodes = array();
979 979
 
980 980
 			preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
981
-			if ( empty( $matches ) ){
981
+			if ( empty( $matches ) ) {
982 982
 				return false;
983 983
 			}
984 984
 
985 985
 			foreach ( $matches as $shortcode ) {
986
-				if ( $tag === $shortcode[2] ) {
986
+				if ( $tag === $shortcode[ 2 ] ) {
987 987
 
988 988
 					// Changed this to $shortcode instead of true so we get the parsed atts.
989
-					$shortcodes[] = $shortcode;
989
+					$shortcodes[ ] = $shortcode;
990 990
 
991
-				} else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) {
992
-					foreach( $results as $result ) {
993
-						$shortcodes[] = $result;
991
+				} else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) {
992
+					foreach ( $results as $result ) {
993
+						$shortcodes[ ] = $result;
994 994
 					}
995 995
 				}
996 996
 			}
@@ -1141,7 +1141,7 @@  discard block
 block discarded – undo
1141 1141
 	 * @return string         html
1142 1142
 	 */
1143 1143
 	public static function get_sortable_fields( $formid, $current = '' ) {
1144
-		$output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>';
1144
+		$output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>';
1145 1145
 
1146 1146
 		if ( empty( $formid ) ) {
1147 1147
 			return $output;
@@ -1154,11 +1154,11 @@  discard block
 block discarded – undo
1154 1154
 			$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null );
1155 1155
 
1156 1156
 			foreach ( $fields as $id => $field ) {
1157
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
1157
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1158 1158
 					continue;
1159 1159
 				}
1160 1160
 
1161
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>';
1161
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>';
1162 1162
 			}
1163 1163
 		}
1164 1164
 
@@ -1193,9 +1193,9 @@  discard block
 block discarded – undo
1193 1193
 		$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL );
1194 1194
 
1195 1195
 		// TODO: Convert to using array_filter
1196
-		foreach( $fields as $id => $field ) {
1196
+		foreach ( $fields as $id => $field ) {
1197 1197
 
1198
-			if( in_array( $field['type'], $blacklist_field_types ) ) {
1198
+			if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
1199 1199
 				unset( $fields[ $id ] );
1200 1200
 			}
1201 1201
 		}
@@ -1236,14 +1236,14 @@  discard block
 block discarded – undo
1236 1236
 	 * @param  int|array  $field field key or field array
1237 1237
 	 * @return boolean
1238 1238
 	 */
1239
-	public static function is_field_numeric(  $form = null, $field = '' ) {
1239
+	public static function is_field_numeric( $form = null, $field = '' ) {
1240 1240
 
1241 1241
 		if ( ! is_array( $form ) && ! is_array( $field ) ) {
1242 1242
 			$form = self::get_form( $form );
1243 1243
 		}
1244 1244
 
1245 1245
 		// If entry meta, it's a string. Otherwise, numeric
1246
-		if( ! is_numeric( $field ) && is_string( $field ) ) {
1246
+		if ( ! is_numeric( $field ) && is_string( $field ) ) {
1247 1247
 			$type = $field;
1248 1248
 		} else {
1249 1249
 			$type = self::get_field_type( $form, $field );
@@ -1257,9 +1257,9 @@  discard block
 block discarded – undo
1257 1257
 		$numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) );
1258 1258
 
1259 1259
 		// Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true
1260
-		if( $gv_field = GravityView_Fields::get( $type ) ) {
1261
-			if( true === $gv_field->is_numeric ) {
1262
-				$numeric_types[] = $gv_field->is_numeric;
1260
+		if ( $gv_field = GravityView_Fields::get( $type ) ) {
1261
+			if ( true === $gv_field->is_numeric ) {
1262
+				$numeric_types[ ] = $gv_field->is_numeric;
1263 1263
 			}
1264 1264
 		}
1265 1265
 
@@ -1409,11 +1409,11 @@  discard block
 block discarded – undo
1409 1409
 		$final_atts = array_filter( $final_atts );
1410 1410
 
1411 1411
 		// If the href wasn't passed as an attribute, use the value passed to the function
1412
-		if ( empty( $final_atts['href'] ) && ! empty( $href ) ) {
1413
-			$final_atts['href'] = $href;
1412
+		if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) {
1413
+			$final_atts[ 'href' ] = $href;
1414 1414
 		}
1415 1415
 
1416
-		$final_atts['href'] = esc_url_raw( $href );
1416
+		$final_atts[ 'href' ] = esc_url_raw( $href );
1417 1417
 
1418 1418
 		// Sort the attributes alphabetically, to help testing
1419 1419
 		ksort( $final_atts );
@@ -1424,7 +1424,7 @@  discard block
 block discarded – undo
1424 1424
 			$output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) );
1425 1425
 		}
1426 1426
 
1427
-		if( '' !== $output ) {
1427
+		if ( '' !== $output ) {
1428 1428
 			$output = '<a' . $output . '>' . $anchor_text . '</a>';
1429 1429
 		}
1430 1430
 
@@ -1448,7 +1448,7 @@  discard block
 block discarded – undo
1448 1448
 	public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) {
1449 1449
 		$merged = $array1;
1450 1450
 
1451
-		foreach ( $array2 as $key => &$value )  {
1451
+		foreach ( $array2 as $key => &$value ) {
1452 1452
 			if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
1453 1453
 				$merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );
1454 1454
 			} else {
@@ -1483,7 +1483,7 @@  discard block
 block discarded – undo
1483 1483
 		 * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..)
1484 1484
 		 * @param array $settings Settings array, with `number` key defining the # of users to display
1485 1485
 		 */
1486
-		$get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1486
+		$get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1487 1487
 
1488 1488
 		return get_users( $get_users_settings );
1489 1489
 	}
@@ -1498,7 +1498,7 @@  discard block
 block discarded – undo
1498 1498
      * @return string
1499 1499
      */
1500 1500
     public static function generate_notice( $notice, $class = '' ) {
1501
-        return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>';
1501
+        return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>';
1502 1502
     }
1503 1503
 
1504 1504
 
Please login to merge, or discard this patch.