Completed
Push — develop ( ee2e4d...c08328 )
by Zack
04:51
created
includes/class-common.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -167,7 +167,6 @@  discard block
 block discarded – undo
167 167
 	 * Returns the list of available forms
168 168
 	 *
169 169
 	 * @access public
170
-	 * @param mixed $form_id
171 170
 	 * @return array Empty array if GFAPI isn't available or no forms. Otherwise, associative array with id, title keys
172 171
 	 */
173 172
 	public static function get_forms() {
@@ -188,7 +187,7 @@  discard block
 block discarded – undo
188 187
 	 * Return array of fields' id and label, for a given Form ID
189 188
 	 *
190 189
 	 * @access public
191
-	 * @param string|array $form_id (default: '') or $form object
190
+	 * @param string|array $form (default: '') or $form object
192 191
 	 * @return array
193 192
 	 */
194 193
 	public static function get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) {
Please login to merge, or discard this patch.
Spacing   +293 added lines, -293 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 /** If this file is called directly, abort. */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	die;
17 17
 }
18 18
 
@@ -25,18 +25,18 @@  discard block
 block discarded – undo
25 25
 	 * @param mixed $form_id
26 26
 	 * @return mixed False: no form ID specified or Gravity Forms isn't active. Array: Form returned from Gravity Forms
27 27
 	 */
28
-	public static function get_form( $form_id ) {
29
-		if ( empty( $form_id ) ) {
28
+	public static function get_form($form_id) {
29
+		if (empty($form_id)) {
30 30
 			return false;
31 31
 		}
32 32
 
33 33
 		// Only get_form_meta is cached. ::facepalm::
34
-		if ( class_exists( 'RGFormsModel' ) ) {
35
-			return GFFormsModel::get_form_meta( $form_id );
34
+		if (class_exists('RGFormsModel')) {
35
+			return GFFormsModel::get_form_meta($form_id);
36 36
 		}
37 37
 
38
-		if ( class_exists( 'GFAPI' ) ) {
39
-			return GFAPI::get_form( $form_id );
38
+		if (class_exists('GFAPI')) {
39
+			return GFAPI::get_form($form_id);
40 40
 		}
41 41
 
42 42
 		return false;
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return bool True: user has at least one passed capability; False: user does not have any defined capabilities
57 57
 	 */
58
-	public static function has_cap( $caps = '', $object_id = null, $user_id = null ) {
59
-		return GravityView_Roles_Capabilities::has_cap( $caps, $object_id, $user_id );
58
+	public static function has_cap($caps = '', $object_id = null, $user_id = null) {
59
+		return GravityView_Roles_Capabilities::has_cap($caps, $object_id, $user_id);
60 60
 	}
61 61
 
62 62
 	/**
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 	 * @param array|GF_Fields $field Gravity Forms field or array
68 68
 	 * @return array Array version of $field
69 69
 	 */
70
-	public static function get_field_array( $field ) {
70
+	public static function get_field_array($field) {
71 71
 
72
-		if ( class_exists( 'GF_Fields' ) ) {
72
+		if (class_exists('GF_Fields')) {
73 73
 
74
-			$field_object = GF_Fields::create( $field );
74
+			$field_object = GF_Fields::create($field);
75 75
 
76 76
 			// Convert the field object in 1.9 to an array for backward compatibility
77
-			$field_array = get_object_vars( $field_object );
77
+			$field_array = get_object_vars($field_object);
78 78
 
79 79
 		} else {
80 80
 			$field_array = $field;
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @return array Array of Views as `WP_Post`. Empty array if none found.
95 95
 	 */
96
-	public static function get_all_views( $args = array() ) {
96
+	public static function get_all_views($args = array()) {
97 97
 
98 98
 		$default_params = array(
99 99
 			'post_type' => 'gravityview',
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 			'post_status' => 'publish',
102 102
 		);
103 103
 
104
-		$params = wp_parse_args( $args, $default_params );
104
+		$params = wp_parse_args($args, $default_params);
105 105
 
106 106
 		/**
107 107
 		 * @filter `gravityview/get_all_views/params` Modify the parameters sent to get all views.
108 108
 		 * @param[in,out]  array $params Array of parameters to pass to `get_posts()`
109 109
 		 */
110
-		$views_params = apply_filters( 'gravityview/get_all_views/params', $params );
110
+		$views_params = apply_filters('gravityview/get_all_views/params', $params);
111 111
 
112
-		$views = get_posts( $views_params );
112
+		$views = get_posts($views_params);
113 113
 
114 114
 		return $views;
115 115
 	}
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 	 * @param  int|string $entry_slug Entry slug
121 121
 	 * @return array           Gravity Forms form array
122 122
 	 */
123
-	public static function get_form_from_entry_id( $entry_slug ) {
123
+	public static function get_form_from_entry_id($entry_slug) {
124 124
 
125
-		$entry = self::get_entry( $entry_slug, true );
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
 	}
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * @param  string $slug The entry slug, as returned by GravityView_API::get_entry_slug()
137 137
 	 * @return int|null       The entry ID, if exists; `NULL` if not
138 138
 	 */
139
-	public static function get_entry_id_from_slug( $slug ) {
139
+	public static function get_entry_id_from_slug($slug) {
140 140
 		global $wpdb;
141 141
 
142 142
 		$search_criteria = array(
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 			'page_size' => 1,
156 156
 		);
157 157
 
158
-		$results = GFAPI::get_entries( 0, $search_criteria, null, $paging );
158
+		$results = GFAPI::get_entries(0, $search_criteria, null, $paging);
159 159
 
160
-		$result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null;
160
+		$result = (!empty($results) && !empty($results[0]['id'])) ? $results[0]['id'] : null;
161 161
 
162 162
 		return $result;
163 163
 	}
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	public static function get_forms() {
174 174
 		$forms = array();
175
-		if ( class_exists( 'GFAPI' ) ) {
175
+		if (class_exists('GFAPI')) {
176 176
 			$gf_forms = GFAPI::get_forms();
177
-			foreach ( $gf_forms as $form ) {
177
+			foreach ($gf_forms as $form) {
178 178
 				$forms[] = array(
179 179
 					'id' => $form['id'],
180 180
 					'title' => $form['title'],
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
 	 * @param string|array $form_id (default: '') or $form object
192 192
 	 * @return array
193 193
 	 */
194
-	public static function get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) {
194
+	public static function get_form_fields($form = '', $add_default_properties = false, $include_parent_field = true) {
195 195
 
196
-		if ( ! is_array( $form ) ) {
197
-			$form = self::get_form( $form );
196
+		if (!is_array($form)) {
197
+			$form = self::get_form($form);
198 198
 		}
199 199
 
200 200
 		$fields = array();
@@ -204,56 +204,56 @@  discard block
 block discarded – undo
204 204
 		$has_poll_fields = false;
205 205
 
206 206
 		// If GF_Field exists, we're using GF 1.9+, where add_default_properties has been deprecated.
207
-		if ( false === class_exists( 'GF_Field' ) && $add_default_properties ) {
208
-			$form = RGFormsModel::add_default_properties( $form );
207
+		if (false === class_exists('GF_Field') && $add_default_properties) {
208
+			$form = RGFormsModel::add_default_properties($form);
209 209
 		}
210 210
 
211
-		if ( $form ) {
212
-			foreach ( $form['fields'] as $field ) {
213
-				if ( $include_parent_field || empty( $field['inputs'] ) ) {
214
-					$fields[ $field['id'] ] = array(
215
-						'label' => rgar( $field, 'label' ),
211
+		if ($form) {
212
+			foreach ($form['fields'] as $field) {
213
+				if ($include_parent_field || empty($field['inputs'])) {
214
+					$fields[$field['id']] = array(
215
+						'label' => rgar($field, 'label'),
216 216
 						'parent' => null,
217
-						'type' => rgar( $field, 'type' ),
218
-						'adminLabel' => rgar( $field, 'adminLabel' ),
219
-						'adminOnly' => rgar( $field, 'adminOnly' ),
217
+						'type' => rgar($field, 'type'),
218
+						'adminLabel' => rgar($field, 'adminLabel'),
219
+						'adminOnly' => rgar($field, 'adminOnly'),
220 220
 					);
221 221
 				}
222 222
 
223
-				if ( $add_default_properties && ! empty( $field['inputs'] ) ) {
224
-					foreach ( $field['inputs'] as $input ) {
223
+				if ($add_default_properties && !empty($field['inputs'])) {
224
+					foreach ($field['inputs'] as $input) {
225 225
                         /**
226 226
                          * @hack
227 227
                          * In case of email/email confirmation, the input for email has the same id as the parent field
228 228
                          */
229
-                        if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) {
229
+                        if ('email' == rgar($field, 'type') && false === strpos($input['id'], '.')) {
230 230
                             continue;
231 231
                         }
232
-						$fields[ (string)$input['id'] ] = array(
233
-							'label' => rgar( $input, 'label' ),
234
-							'customLabel' => rgar( $input, 'customLabel' ),
232
+						$fields[(string)$input['id']] = array(
233
+							'label' => rgar($input, 'label'),
234
+							'customLabel' => rgar($input, 'customLabel'),
235 235
 							'parent' => $field,
236
-							'type' => rgar( $field, 'type' ),
237
-							'adminLabel' => rgar( $field, 'adminLabel' ),
238
-							'adminOnly' => rgar( $field, 'adminOnly' ),
236
+							'type' => rgar($field, 'type'),
237
+							'adminLabel' => rgar($field, 'adminLabel'),
238
+							'adminOnly' => rgar($field, 'adminOnly'),
239 239
 						);
240 240
 					}
241 241
 				}
242 242
 
243 243
 				/** @since 1.14 */
244
-				if( 'list' === $field['type'] && !empty( $field['enableColumns'] ) ) {
244
+				if ('list' === $field['type'] && !empty($field['enableColumns'])) {
245 245
 
246
-					foreach ( (array)$field['choices'] as $key => $input ) {
246
+					foreach ((array)$field['choices'] as $key => $input) {
247 247
 
248
-						$input_id = sprintf( '%d.%d', $field['id'], $key ); // {field_id}.{column_key}
248
+						$input_id = sprintf('%d.%d', $field['id'], $key); // {field_id}.{column_key}
249 249
 
250
-						$fields[ $input_id ] = array(
251
-							'label'       => rgar( $input, 'text' ),
250
+						$fields[$input_id] = array(
251
+							'label'       => rgar($input, 'text'),
252 252
 							'customLabel' => '',
253 253
 							'parent'      => $field,
254
-							'type'        => rgar( $field, 'type' ),
255
-							'adminLabel'  => rgar( $field, 'adminLabel' ),
256
-							'adminOnly'   => rgar( $field, 'adminOnly' ),
254
+							'type'        => rgar($field, 'type'),
255
+							'adminLabel'  => rgar($field, 'adminLabel'),
256
+							'adminOnly'   => rgar($field, 'adminOnly'),
257 257
 						);
258 258
 					}
259 259
 				}
@@ -261,27 +261,27 @@  discard block
 block discarded – undo
261 261
 				/**
262 262
 				 * @since 1.8
263 263
 				 */
264
-				if( 'quiz' === $field['type'] ) {
264
+				if ('quiz' === $field['type']) {
265 265
 					$has_quiz_fields = true;
266 266
 				}
267 267
 
268 268
 				/**
269 269
 				 * @since 1.8
270 270
 				 */
271
-				if( 'poll' === $field['type'] ) {
271
+				if ('poll' === $field['type']) {
272 272
 					$has_poll_fields = true;
273 273
 				}
274 274
 
275
-				if( GFCommon::is_product_field( $field['type'] ) ){
275
+				if (GFCommon::is_product_field($field['type'])) {
276 276
 					$has_product_fields = true;
277 277
 				}
278 278
 
279 279
 				/**
280 280
 				 * @hack Version 1.9
281 281
 				 */
282
-				$field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object) $field : (array) $field;
282
+				$field_for_is_post_field = class_exists('GF_Fields') ? (object)$field : (array)$field;
283 283
 
284
-				if ( GFCommon::is_post_field( $field_for_is_post_field ) ) {
284
+				if (GFCommon::is_post_field($field_for_is_post_field)) {
285 285
 					$has_post_fields = true;
286 286
 				}
287 287
 			}
@@ -290,47 +290,47 @@  discard block
 block discarded – undo
290 290
 		/**
291 291
 		 * @since 1.7
292 292
 		 */
293
-		if ( $has_post_fields ) {
293
+		if ($has_post_fields) {
294 294
 			$fields['post_id'] = array(
295
-				'label' => __( 'Post ID', 'gravityview' ),
295
+				'label' => __('Post ID', 'gravityview'),
296 296
 				'type' => 'post_id',
297 297
 			);
298 298
 		}
299 299
 
300
-		if ( $has_product_fields ) {
300
+		if ($has_product_fields) {
301 301
 
302 302
 			$fields['payment_status'] = array(
303
-				'label' => __( 'Payment Status', 'gravityview' ),
303
+				'label' => __('Payment Status', 'gravityview'),
304 304
 				'type' => 'payment_status',
305 305
 			);
306 306
 
307 307
 			$fields['payment_date'] = array(
308
-				'label' => __( 'Payment Date', 'gravityview' ),
308
+				'label' => __('Payment Date', 'gravityview'),
309 309
 				'type' => 'payment_date',
310 310
 			);
311 311
 
312 312
 			$fields['payment_amount'] = array(
313
-				'label' => __( 'Payment Amount', 'gravityview' ),
313
+				'label' => __('Payment Amount', 'gravityview'),
314 314
 				'type' => 'payment_amount',
315 315
 			);
316 316
 
317 317
 			$fields['payment_method'] = array(
318
-				'label' => __( 'Payment Method', 'gravityview' ),
318
+				'label' => __('Payment Method', 'gravityview'),
319 319
 				'type' => 'payment_method',
320 320
 			);
321 321
 
322 322
 			$fields['is_fulfilled'] = array(
323
-				'label' => __( 'Is Fulfilled', 'gravityview' ),
323
+				'label' => __('Is Fulfilled', 'gravityview'),
324 324
 				'type' => 'is_fulfilled',
325 325
 			);
326 326
 
327 327
 			$fields['transaction_id'] = array(
328
-				'label' => __( 'Transaction ID', 'gravityview' ),
328
+				'label' => __('Transaction ID', 'gravityview'),
329 329
 				'type' => 'transaction_id',
330 330
 			);
331 331
 
332 332
 			$fields['transaction_type'] = array(
333
-				'label' => __( 'Transaction Type', 'gravityview' ),
333
+				'label' => __('Transaction Type', 'gravityview'),
334 334
 				'type' => 'transaction_type',
335 335
 			);
336 336
 
@@ -339,27 +339,27 @@  discard block
 block discarded – undo
339 339
 		/**
340 340
 		 * @since 1.8
341 341
 		 */
342
-		if( $has_quiz_fields ) {
342
+		if ($has_quiz_fields) {
343 343
 
344
-			$fields['gquiz_score']   = array(
345
-				'label' => __( 'Quiz Score Total', 'gravityview' ),
344
+			$fields['gquiz_score'] = array(
345
+				'label' => __('Quiz Score Total', 'gravityview'),
346 346
 				'type'  => 'quiz_score',
347
-				'desc'  => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ),
347
+				'desc'  => __('Displays the number of correct Quiz answers the user submitted.', 'gravityview'),
348 348
 			);
349 349
 			$fields['gquiz_percent'] = array(
350
-				'label' => __( 'Quiz Percentage Grade', 'gravityview' ),
350
+				'label' => __('Quiz Percentage Grade', 'gravityview'),
351 351
 				'type'  => 'quiz_percent',
352
-				'desc'  => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ),
352
+				'desc'  => __('Displays the percentage of correct Quiz answers the user submitted.', 'gravityview'),
353 353
 			);
354
-			$fields['gquiz_grade']   = array(
355
-				'label' => __( 'Quiz Letter Grade', 'gravityview' ),
354
+			$fields['gquiz_grade'] = array(
355
+				'label' => __('Quiz Letter Grade', 'gravityview'),
356 356
 				'type'  => 'quiz_grade',
357
-				'desc'  => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ),
357
+				'desc'  => __('Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview'),
358 358
 			);
359 359
 			$fields['gquiz_is_pass'] = array(
360
-				'label' => __( 'Quiz Pass/Fail', 'gravityview' ),
360
+				'label' => __('Quiz Pass/Fail', 'gravityview'),
361 361
 				'type'  => 'quiz_is_pass',
362
-				'desc'  => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ),
362
+				'desc'  => __('Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview'),
363 363
 			);
364 364
 		}
365 365
 
@@ -373,15 +373,15 @@  discard block
 block discarded – undo
373 373
 	 * @param  string $form_id (default: '')
374 374
 	 * @return array
375 375
 	 */
376
-	public static function get_entry_meta( $form_id, $only_default_column = true ) {
376
+	public static function get_entry_meta($form_id, $only_default_column = true) {
377 377
 
378
-		$extra_fields = GFFormsModel::get_entry_meta( $form_id );
378
+		$extra_fields = GFFormsModel::get_entry_meta($form_id);
379 379
 
380 380
 		$fields = array();
381 381
 
382
-		foreach ( $extra_fields as $key => $field ){
383
-			if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) {
384
-				$fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' );
382
+		foreach ($extra_fields as $key => $field) {
383
+			if (!empty($only_default_column) && !empty($field['is_default_column'])) {
384
+				$fields[$key] = array('label' => $field['label'], 'type' => 'entry_meta');
385 385
 			}
386 386
 		}
387 387
 
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
 	 * @since  1.1.6
398 398
 	 * @return array          Array of entry IDs
399 399
 	 */
400
-	public static function get_entry_ids( $form_id, $search_criteria = array() ) {
400
+	public static function get_entry_ids($form_id, $search_criteria = array()) {
401 401
 
402
-		if ( ! class_exists( 'GFFormsModel' ) ) {
402
+		if (!class_exists('GFFormsModel')) {
403 403
 			return;
404 404
 		}
405 405
 
406
-		return GFFormsModel::search_lead_ids( $form_id, $search_criteria );
406
+		return GFFormsModel::search_lead_ids($form_id, $search_criteria);
407 407
 	}
408 408
 
409 409
 	/**
@@ -415,33 +415,33 @@  discard block
 block discarded – undo
415 415
 	 * @param null $form_ids array Gravity Forms form IDs
416 416
 	 * @return array|mixed|void
417 417
 	 */
418
-	public static function calculate_get_entries_criteria( $passed_criteria = null, $form_ids = null ) {
418
+	public static function calculate_get_entries_criteria($passed_criteria = null, $form_ids = null) {
419 419
 
420 420
 		$search_criteria_defaults = array(
421 421
 			'search_criteria' => null,
422 422
 			'sorting' => null,
423 423
 			'paging' => null,
424
-			'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true),
424
+			'cache' => (isset($passed_criteria['cache']) ? $passed_criteria['cache'] : true),
425 425
 		);
426 426
 
427
-		$criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults );
427
+		$criteria = wp_parse_args($passed_criteria, $search_criteria_defaults);
428 428
 
429
-		if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) {
430
-			foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) {
429
+		if (!empty($criteria['search_criteria']['field_filters'])) {
430
+			foreach ($criteria['search_criteria']['field_filters'] as &$filter) {
431 431
 
432
-				if ( ! is_array( $filter ) ) {
432
+				if (!is_array($filter)) {
433 433
 					continue;
434 434
 				}
435 435
 
436 436
 				// By default, we want searches to be wildcard for each field.
437
-				$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
437
+				$filter['operator'] = empty($filter['operator']) ? 'contains' : $filter['operator'];
438 438
 
439 439
 				/**
440 440
 				 * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc)
441 441
 				 * @param string $operator Existing search operator
442 442
 				 * @param array $filter array with `key`, `value`, `operator`, `type` keys
443 443
 				 */
444
-				$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter );
444
+				$filter['operator'] = apply_filters('gravityview_search_operator', $filter['operator'], $filter);
445 445
 			}
446 446
 		}
447 447
 
@@ -449,32 +449,32 @@  discard block
 block discarded – undo
449 449
 		 * Prepare date formats to be in Gravity Forms DB format;
450 450
 		 * $passed_criteria may include date formats incompatible with Gravity Forms.
451 451
 		 */
452
-		foreach ( array('start_date', 'end_date' ) as $key ) {
452
+		foreach (array('start_date', 'end_date') as $key) {
453 453
 
454
-			if ( ! empty( $criteria['search_criteria'][ $key ] ) ) {
454
+			if (!empty($criteria['search_criteria'][$key])) {
455 455
 
456 456
 				// Use date_create instead of new DateTime so it returns false if invalid date format.
457
-				$date = date_create( $criteria['search_criteria'][ $key ] );
457
+				$date = date_create($criteria['search_criteria'][$key]);
458 458
 
459
-				if ( $date ) {
459
+				if ($date) {
460 460
 					// Gravity Forms wants dates in the `Y-m-d H:i:s` format.
461
-					$criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' );
461
+					$criteria['search_criteria'][$key] = $date->format('Y-m-d H:i:s');
462 462
 				} else {
463 463
 					// If it's an invalid date, unset it. Gravity Forms freaks out otherwise.
464
-					unset( $criteria['search_criteria'][ $key ] );
464
+					unset($criteria['search_criteria'][$key]);
465 465
 
466
-					do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] );
466
+					do_action('gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][$key]);
467 467
 				}
468 468
 			}
469 469
 		}
470 470
 
471 471
 
472 472
 		// When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter
473
-		if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) {
473
+		if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry()) {
474 474
 			$criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id();
475
-		} elseif ( 'delete' === RGForms::get( 'action' ) ) {
476
-			$criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null;
477
-		} elseif( !isset( $criteria['context_view_id'] ) ) {
475
+		} elseif ('delete' === RGForms::get('action')) {
476
+			$criteria['context_view_id'] = isset($_GET['view_id']) ? $_GET['view_id'] : null;
477
+		} elseif (!isset($criteria['context_view_id'])) {
478 478
             // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget)
479 479
 			$criteria['context_view_id'] = null;
480 480
 		}
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 		 * @param array $form_ids Forms to search
486 486
 		 * @param int $view_id ID of the view being used to search
487 487
 		 */
488
-		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] );
488
+		$criteria = apply_filters('gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id']);
489 489
 
490 490
 		return $criteria;
491 491
 
@@ -503,32 +503,32 @@  discard block
 block discarded – undo
503 503
 	 * @param mixed &$total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate the total count. (default: null)
504 504
 	 * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays
505 505
 	 */
506
-	public static function get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) {
506
+	public static function get_entries($form_ids = null, $passed_criteria = null, &$total = null) {
507 507
 
508 508
 		// Filter the criteria before query (includes Adv Filter)
509
-		$criteria = self::calculate_get_entries_criteria( $passed_criteria, $form_ids );
509
+		$criteria = self::calculate_get_entries_criteria($passed_criteria, $form_ids);
510 510
 
511
-		do_action( 'gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria );
511
+		do_action('gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria);
512 512
 
513 513
 		// Return value
514 514
 		$return = null;
515 515
 
516
-		if ( ! empty( $criteria['cache'] ) ) {
516
+		if (!empty($criteria['cache'])) {
517 517
 
518
-			$Cache = new GravityView_Cache( $form_ids, $criteria );
518
+			$Cache = new GravityView_Cache($form_ids, $criteria);
519 519
 
520
-			if ( $entries = $Cache->get() ) {
520
+			if ($entries = $Cache->get()) {
521 521
 
522 522
 				// Still update the total count when using cached results
523
-				if ( ! is_null( $total ) ) {
524
-					$total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] );
523
+				if (!is_null($total)) {
524
+					$total = GFAPI::count_entries($form_ids, $criteria['search_criteria']);
525 525
 				}
526 526
 
527 527
 				$return = $entries;
528 528
 			}
529 529
 		}
530 530
 
531
-		if ( is_null( $return ) && class_exists( 'GFAPI' ) && ( is_numeric( $form_ids ) || is_array( $form_ids ) ) ) {
531
+		if (is_null($return) && class_exists('GFAPI') && (is_numeric($form_ids) || is_array($form_ids))) {
532 532
 
533 533
 			/**
534 534
 			 * @filter `gravityview_pre_get_entries` Define entries to be used before GFAPI::get_entries() is called
@@ -538,24 +538,24 @@  discard block
 block discarded – undo
538 538
 			 * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()`
539 539
 			 * @param  int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate
540 540
 			 */
541
-			$entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total );
541
+			$entries = apply_filters('gravityview_before_get_entries', null, $criteria, $passed_criteria, $total);
542 542
 
543 543
 			// No entries returned from gravityview_before_get_entries
544
-			if( is_null( $entries ) ) {
544
+			if (is_null($entries)) {
545 545
 
546
-				$entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total );
546
+				$entries = GFAPI::get_entries($form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total);
547 547
 
548
-				if ( is_wp_error( $entries ) ) {
549
-					do_action( 'gravityview_log_error', $entries->get_error_message(), $entries );
548
+				if (is_wp_error($entries)) {
549
+					do_action('gravityview_log_error', $entries->get_error_message(), $entries);
550 550
 
551 551
 					return false;
552 552
 				}
553 553
 			}
554 554
 
555
-			if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) {
555
+			if (!empty($criteria['cache']) && isset($Cache)) {
556 556
 
557 557
 				// Cache results
558
-				$Cache->set( $entries, 'entries' );
558
+				$Cache->set($entries, 'entries');
559 559
 
560 560
 			}
561 561
 
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 		 * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()`
570 570
 		 * @param  int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate
571 571
 		 */
572
-		$return = apply_filters( 'gravityview_entries', $return, $criteria, $passed_criteria, $total );
572
+		$return = apply_filters('gravityview_entries', $return, $criteria, $passed_criteria, $total);
573 573
 
574 574
 		return $return;
575 575
 	}
@@ -586,15 +586,15 @@  discard block
 block discarded – undo
586 586
 	 * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true. {@since 1.14}
587 587
 	 * @return array|boolean
588 588
 	 */
589
-	public static function get_entry( $entry_slug, $force_allow_ids = false, $check_entry_display = true ) {
589
+	public static function get_entry($entry_slug, $force_allow_ids = false, $check_entry_display = true) {
590 590
 
591
-		if ( class_exists( 'GFAPI' ) && ! empty( $entry_slug ) ) {
591
+		if (class_exists('GFAPI') && !empty($entry_slug)) {
592 592
 
593 593
 			/**
594 594
 			 * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs.
595 595
 			 * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default)
596 596
 			 */
597
-			$custom_slug = apply_filters( 'gravityview_custom_entry_slug', false );
597
+			$custom_slug = apply_filters('gravityview_custom_entry_slug', false);
598 598
 
599 599
 			/**
600 600
 			 * @filter `gravityview_custom_entry_slug_allow_id` When using a custom slug, allow access to the entry using the original slug (the Entry ID).
@@ -602,38 +602,38 @@  discard block
 block discarded – undo
602 602
 			 * - If enabled, you could access using the custom slug OR the entry id (example: `/entry/custom-slug/` OR `/entry/123/`)
603 603
 			 * @param boolean $custom_slug_id_access True: allow accessing the slug by ID; False: only use the slug passed to the method.
604 604
 			 */
605
-			$custom_slug_id_access = $force_allow_ids || apply_filters( 'gravityview_custom_entry_slug_allow_id', false );
605
+			$custom_slug_id_access = $force_allow_ids || apply_filters('gravityview_custom_entry_slug_allow_id', false);
606 606
 
607 607
 			/**
608 608
 			 * If we're using custom entry slugs, we do a meta value search
609 609
 			 * instead of doing a straightup ID search.
610 610
 			 */
611
-			if ( $custom_slug ) {
611
+			if ($custom_slug) {
612 612
 
613
-				$entry_id = self::get_entry_id_from_slug( $entry_slug );
613
+				$entry_id = self::get_entry_id_from_slug($entry_slug);
614 614
 
615 615
 			}
616 616
 
617 617
 			// If custom slug is off, search using the entry ID
618 618
 			// ID allow ID access is on, also use entry ID as a backup
619
-			if ( empty( $custom_slug ) || ! empty( $custom_slug_id_access ) ) {
619
+			if (empty($custom_slug) || !empty($custom_slug_id_access)) {
620 620
 				// Search for IDs matching $entry_slug
621 621
 				$entry_id = $entry_slug;
622 622
 			}
623 623
 
624
-			if ( empty( $entry_id ) ) {
624
+			if (empty($entry_id)) {
625 625
 				return false;
626 626
 			}
627 627
 
628 628
 			// fetch the entry
629
-			$entry = GFAPI::get_entry( $entry_id );
629
+			$entry = GFAPI::get_entry($entry_id);
630 630
 
631
-			if( $check_entry_display ) {
631
+			if ($check_entry_display) {
632 632
 				// Is the entry allowed
633
-				$entry = self::check_entry_display( $entry );
633
+				$entry = self::check_entry_display($entry);
634 634
 			}
635 635
 
636
-			return is_wp_error( $entry ) ? false : $entry;
636
+			return is_wp_error($entry) ? false : $entry;
637 637
 
638 638
 		}
639 639
 
@@ -657,51 +657,51 @@  discard block
 block discarded – undo
657 657
 	 *
658 658
 	 * @return bool True: matches, false: not matches
659 659
 	 */
660
-	public static function matches_operation( $val1, $val2, $operation ) {
660
+	public static function matches_operation($val1, $val2, $operation) {
661 661
 
662 662
 		$value = false;
663 663
 
664
-		if( 'context' === $val1 ) {
664
+		if ('context' === $val1) {
665 665
 
666
-			$matching_contexts = array( $val2 );
666
+			$matching_contexts = array($val2);
667 667
 
668 668
 			// We allow for non-standard contexts.
669
-			switch( $val2 ) {
669
+			switch ($val2) {
670 670
 				// Check for either single or edit
671 671
 				case 'singular':
672
-					$matching_contexts = array( 'single', 'edit' );
672
+					$matching_contexts = array('single', 'edit');
673 673
 					break;
674 674
 				// Use multiple as alias for directory for consistency
675 675
 				case 'multiple':
676
-					$matching_contexts = array( 'directory' );
676
+					$matching_contexts = array('directory');
677 677
 					break;
678 678
 			}
679 679
 
680
-			$val1 = in_array( gravityview_get_context(), $matching_contexts ) ? $val2 : false;
680
+			$val1 = in_array(gravityview_get_context(), $matching_contexts) ? $val2 : false;
681 681
 		}
682 682
 
683
-		switch ( $operation ) {
683
+		switch ($operation) {
684 684
 			case 'equals':
685
-				$value = GFFormsModel::matches_operation( $val1, $val2, 'is' );
685
+				$value = GFFormsModel::matches_operation($val1, $val2, 'is');
686 686
 				break;
687 687
 			case 'greater_than_or_is':
688 688
 			case 'greater_than_or_equals':
689
-				$is    = GFFormsModel::matches_operation( $val1, $val2, 'is' );
690
-				$gt    = GFFormsModel::matches_operation( $val1, $val2, 'greater_than' );
691
-				$value = ( $is || $gt );
689
+				$is    = GFFormsModel::matches_operation($val1, $val2, 'is');
690
+				$gt    = GFFormsModel::matches_operation($val1, $val2, 'greater_than');
691
+				$value = ($is || $gt);
692 692
 				break;
693 693
 			case 'less_than_or_is':
694 694
 			case 'less_than_or_equals':
695
-				$is    = GFFormsModel::matches_operation( $val1, $val2, 'is' );
696
-				$gt    = GFFormsModel::matches_operation( $val1, $val2, 'less_than' );
697
-				$value = ( $is || $gt );
695
+				$is    = GFFormsModel::matches_operation($val1, $val2, 'is');
696
+				$gt    = GFFormsModel::matches_operation($val1, $val2, 'less_than');
697
+				$value = ($is || $gt);
698 698
 				break;
699 699
 			case 'not_contains':
700
-				$contains = GFFormsModel::matches_operation( $val1, $val2, 'contains' );
701
-				$value    = ! $contains;
700
+				$contains = GFFormsModel::matches_operation($val1, $val2, 'contains');
701
+				$value    = !$contains;
702 702
 				break;
703 703
 			default:
704
-				$value = GFFormsModel::matches_operation( $val1, $val2, $operation );
704
+				$value = GFFormsModel::matches_operation($val1, $val2, $operation);
705 705
 		}
706 706
 
707 707
 		return $value;
@@ -719,41 +719,41 @@  discard block
 block discarded – undo
719 719
 	 * @param array $entry Gravity Forms Entry object
720 720
 	 * @return bool|array Returns 'false' if entry is not valid according to the view search filters (Adv Filter)
721 721
 	 */
722
-	public static function check_entry_display( $entry ) {
722
+	public static function check_entry_display($entry) {
723 723
 
724
-		if ( ! $entry || is_wp_error( $entry ) ) {
725
-			do_action( 'gravityview_log_debug', __METHOD__ . ' Entry was not found.', $entry );
724
+		if (!$entry || is_wp_error($entry)) {
725
+			do_action('gravityview_log_debug', __METHOD__.' Entry was not found.', $entry);
726 726
 			return false;
727 727
 		}
728 728
 
729
-		if ( empty( $entry['form_id'] ) ) {
730
-			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry );
729
+		if (empty($entry['form_id'])) {
730
+			do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry);
731 731
 			return false;
732 732
 		}
733 733
 
734 734
 		$criteria = self::calculate_get_entries_criteria();
735 735
 
736 736
 		// Make sure the current View is connected to the same form as the Entry
737
-		if( ! empty( $criteria['context_view_id'] ) ) {
738
-			$context_view_id = intval( $criteria['context_view_id'] );
739
-			$context_form_id = gravityview_get_form_id( $context_view_id );
740
-			if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) {
741
-				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'] );
737
+		if (!empty($criteria['context_view_id'])) {
738
+			$context_view_id = intval($criteria['context_view_id']);
739
+			$context_form_id = gravityview_get_form_id($context_view_id);
740
+			if (intval($context_form_id) !== intval($entry['form_id'])) {
741
+				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']);
742 742
 				return false;
743 743
 			}
744 744
 		}
745 745
 
746
-		if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) {
747
-			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria );
746
+		if (empty($criteria['search_criteria']) || !is_array($criteria['search_criteria'])) {
747
+			do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria);
748 748
 			return $entry;
749 749
 		}
750 750
 
751 751
 		$search_criteria = $criteria['search_criteria'];
752
-		unset( $criteria );
752
+		unset($criteria);
753 753
 
754 754
 		// check entry status
755
-		if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) {
756
-			do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria );
755
+		if (array_key_exists('status', $search_criteria) && $search_criteria['status'] != $entry['status']) {
756
+			do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status']), $search_criteria);
757 757
 			return false;
758 758
 		}
759 759
 
@@ -761,53 +761,53 @@  discard block
 block discarded – undo
761 761
 		// @todo: Does it make sense to apply the Date create filters to the single entry?
762 762
 
763 763
 		// field_filters
764
-		if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) {
765
-			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria );
764
+		if (empty($search_criteria['field_filters']) || !is_array($search_criteria['field_filters'])) {
765
+			do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria);
766 766
 			return $entry;
767 767
 		}
768 768
 
769 769
 		$filters = $search_criteria['field_filters'];
770
-		unset( $search_criteria );
770
+		unset($search_criteria);
771 771
 
772
-		$mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all';
773
-		unset( $filters['mode'] );
772
+		$mode = array_key_exists('mode', $filters) ? strtolower($filters['mode']) : 'all';
773
+		unset($filters['mode']);
774 774
 
775
-		$form = self::get_form( $entry['form_id'] );
775
+		$form = self::get_form($entry['form_id']);
776 776
 
777
-		foreach ( $filters as $filter ) {
777
+		foreach ($filters as $filter) {
778 778
 
779
-			if ( ! isset( $filter['key'] ) ) {
779
+			if (!isset($filter['key'])) {
780 780
 				continue;
781 781
 			}
782 782
 
783 783
 			$k = $filter['key'];
784 784
 
785
-			if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) {
786
-				$field_value = $entry[ $k ];
785
+			if (in_array($k, array('created_by', 'payment_status'))) {
786
+				$field_value = $entry[$k];
787 787
 				$field = null;
788 788
 			} else {
789
-				$field = self::get_field( $form, $k );
790
-				$field_value  = GFFormsModel::get_lead_field_value( $entry, $field );
789
+				$field = self::get_field($form, $k);
790
+				$field_value = GFFormsModel::get_lead_field_value($entry, $field);
791 791
 			}
792 792
 
793
-			$operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is';
794
-			$is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field );
793
+			$operator = isset($filter['operator']) ? strtolower($filter['operator']) : 'is';
794
+			$is_value_match = GFFormsModel::is_value_match($field_value, $filter['value'], $operator, $field);
795 795
 
796 796
 			// verify if we are already free to go!
797
-			if ( ! $is_value_match && 'all' === $mode ) {
798
-				do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter );
797
+			if (!$is_value_match && 'all' === $mode) {
798
+				do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter);
799 799
 				return false;
800
-			} elseif ( $is_value_match && 'any' === $mode ) {
800
+			} elseif ($is_value_match && 'any' === $mode) {
801 801
 				return $entry;
802 802
 			}
803 803
 		}
804 804
 
805 805
 		// at this point, if in ALL mode, then entry is approved - all conditions were met.
806 806
 		// Or, for ANY mode, means none of the conditions were satisfied, so entry is not approved
807
-		if ( 'all' === $mode ) {
807
+		if ('all' === $mode) {
808 808
 			return $entry;
809 809
 		} else {
810
-			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters );
810
+			do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters);
811 811
 			return false;
812 812
 		}
813 813
 
@@ -822,14 +822,14 @@  discard block
 block discarded – undo
822 822
 	 * @param string $field_id
823 823
 	 * @return string
824 824
 	 */
825
-	public static function get_field_label( $form = array(), $field_id = '' ) {
825
+	public static function get_field_label($form = array(), $field_id = '') {
826 826
 
827
-		if ( empty( $form ) || empty( $field_id ) ) {
827
+		if (empty($form) || empty($field_id)) {
828 828
 			return '';
829 829
 		}
830 830
 
831
-		$field = self::get_field( $form, $field_id );
832
-		return isset( $field['label'] ) ?  $field['label'] : '';
831
+		$field = self::get_field($form, $field_id);
832
+		return isset($field['label']) ? $field['label'] : '';
833 833
 
834 834
 	}
835 835
 
@@ -846,9 +846,9 @@  discard block
 block discarded – undo
846 846
 	 * @param string|int $field_id
847 847
 	 * @return array|null Array: Gravity Forms field array; NULL: Gravity Forms GFFormsModel does not exist
848 848
 	 */
849
-	public static function get_field( $form, $field_id ) {
850
-		if ( class_exists( 'GFFormsModel' ) ){
851
-			return GFFormsModel::get_field( $form, $field_id );
849
+	public static function get_field($form, $field_id) {
850
+		if (class_exists('GFFormsModel')) {
851
+			return GFFormsModel::get_field($form, $field_id);
852 852
 		} else {
853 853
 			return null;
854 854
 		}
@@ -864,16 +864,16 @@  discard block
 block discarded – undo
864 864
 	 * @param  WP_Post      $post WordPress post object
865 865
 	 * @return boolean           True: yep, GravityView; No: not!
866 866
 	 */
867
-	public static function has_gravityview_shortcode( $post = null ) {
868
-		if ( ! is_a( $post, 'WP_Post' ) ) {
867
+	public static function has_gravityview_shortcode($post = null) {
868
+		if (!is_a($post, 'WP_Post')) {
869 869
 			return false;
870 870
 		}
871 871
 
872
-		if ( 'gravityview' === get_post_type( $post ) ) {
872
+		if ('gravityview' === get_post_type($post)) {
873 873
 			return true;
874 874
 		}
875 875
 
876
-		return self::has_shortcode_r( $post->post_content, 'gravityview' ) ? true : false;
876
+		return self::has_shortcode_r($post->post_content, 'gravityview') ? true : false;
877 877
 
878 878
 	}
879 879
 
@@ -884,27 +884,27 @@  discard block
 block discarded – undo
884 884
 	 * @param string $content Content to check whether there's a shortcode
885 885
 	 * @param string $tag Current shortcode tag
886 886
 	 */
887
-	public static function has_shortcode_r( $content, $tag = 'gravityview' ) {
888
-		if ( false === strpos( $content, '[' ) ) {
887
+	public static function has_shortcode_r($content, $tag = 'gravityview') {
888
+		if (false === strpos($content, '[')) {
889 889
 			return false;
890 890
 		}
891 891
 
892
-		if ( shortcode_exists( $tag ) ) {
892
+		if (shortcode_exists($tag)) {
893 893
 
894 894
 			$shortcodes = array();
895 895
 
896
-			preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
897
-			if ( empty( $matches ) ){
896
+			preg_match_all('/'.get_shortcode_regex().'/s', $content, $matches, PREG_SET_ORDER);
897
+			if (empty($matches)) {
898 898
 				return false;
899 899
 			}
900 900
 
901
-			foreach ( $matches as $shortcode ) {
902
-				if ( $tag === $shortcode[2] ) {
901
+			foreach ($matches as $shortcode) {
902
+				if ($tag === $shortcode[2]) {
903 903
 
904 904
 					// Changed this to $shortcode instead of true so we get the parsed atts.
905 905
 					$shortcodes[] = $shortcode;
906 906
 
907
-				} else if ( isset( $shortcode[5] ) && $result = self::has_shortcode_r( $shortcode[5], $tag ) ) {
907
+				} else if (isset($shortcode[5]) && $result = self::has_shortcode_r($shortcode[5], $tag)) {
908 908
 					$shortcodes = $result;
909 909
 				}
910 910
 			}
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	 *
929 929
 	 * @return array          Array with view details, as returned by get_posts()
930 930
 	 */
931
-	public static function get_connected_views( $form_id, $args = array() ) {
931
+	public static function get_connected_views($form_id, $args = array()) {
932 932
 
933 933
 		$defaults = array(
934 934
 			'post_type' => 'gravityview',
@@ -937,9 +937,9 @@  discard block
 block discarded – undo
937 937
 			'meta_value' => (int)$form_id,
938 938
 		);
939 939
 
940
-		$args = wp_parse_args( $args, $defaults );
940
+		$args = wp_parse_args($args, $defaults);
941 941
 
942
-		$views = get_posts( $args );
942
+		$views = get_posts($args);
943 943
 
944 944
 		return $views;
945 945
 	}
@@ -951,8 +951,8 @@  discard block
 block discarded – undo
951 951
 	 *
952 952
 	 * @return string ID of the connected Form, if exists. Empty string if not.
953 953
 	 */
954
-	public static function get_meta_form_id( $view_id ) {
955
-		return get_post_meta( $view_id, '_gravityview_form_id', true );
954
+	public static function get_meta_form_id($view_id) {
955
+		return get_post_meta($view_id, '_gravityview_form_id', true);
956 956
 	}
957 957
 
958 958
 	/**
@@ -964,8 +964,8 @@  discard block
 block discarded – undo
964 964
 	 *
965 965
 	 * @return string GravityView_Template::template_id value. Empty string if not.
966 966
 	 */
967
-	public static function get_meta_template_id( $view_id ) {
968
-		return get_post_meta( $view_id, '_gravityview_directory_template', true );
967
+	public static function get_meta_template_id($view_id) {
968
+		return get_post_meta($view_id, '_gravityview_directory_template', true);
969 969
 	}
970 970
 
971 971
 
@@ -976,15 +976,15 @@  discard block
 block discarded – undo
976 976
 	 * @param  int $post_id View ID
977 977
 	 * @return array          Associative array of settings with plugin defaults used if not set by the View
978 978
 	 */
979
-	public static function get_template_settings( $post_id ) {
979
+	public static function get_template_settings($post_id) {
980 980
 
981
-		$settings = get_post_meta( $post_id, '_gravityview_template_settings', true );
981
+		$settings = get_post_meta($post_id, '_gravityview_template_settings', true);
982 982
 
983
-		if ( class_exists( 'GravityView_View_Data' ) ) {
983
+		if (class_exists('GravityView_View_Data')) {
984 984
 
985 985
 			$defaults = GravityView_View_Data::get_default_args();
986 986
 
987
-			return wp_parse_args( (array)$settings, $defaults );
987
+			return wp_parse_args((array)$settings, $defaults);
988 988
 
989 989
 		}
990 990
 
@@ -1001,12 +1001,12 @@  discard block
 block discarded – undo
1001 1001
 	 * @param  string $key     Key for the setting
1002 1002
 	 * @return mixed|null          Setting value, or NULL if not set.
1003 1003
 	 */
1004
-	public static function get_template_setting( $post_id, $key ) {
1004
+	public static function get_template_setting($post_id, $key) {
1005 1005
 
1006
-		$settings = self::get_template_settings( $post_id );
1006
+		$settings = self::get_template_settings($post_id);
1007 1007
 
1008
-		if ( isset( $settings[ $key ] ) ) {
1009
-			return $settings[ $key ];
1008
+		if (isset($settings[$key])) {
1009
+			return $settings[$key];
1010 1010
 		}
1011 1011
 
1012 1012
 		return null;
@@ -1042,8 +1042,8 @@  discard block
 block discarded – undo
1042 1042
 	 * @param  int $post_id View ID
1043 1043
 	 * @return array          Multi-array of fields with first level being the field zones. See code comment.
1044 1044
 	 */
1045
-	public static function get_directory_fields( $post_id ) {
1046
-		return get_post_meta( $post_id, '_gravityview_directory_fields', true );
1045
+	public static function get_directory_fields($post_id) {
1046
+		return get_post_meta($post_id, '_gravityview_directory_fields', true);
1047 1047
 	}
1048 1048
 
1049 1049
 
@@ -1054,25 +1054,25 @@  discard block
 block discarded – undo
1054 1054
 	 * @param  int $formid Form ID
1055 1055
 	 * @return string         html
1056 1056
 	 */
1057
-	public static function get_sortable_fields( $formid, $current = '' ) {
1058
-		$output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>';
1057
+	public static function get_sortable_fields($formid, $current = '') {
1058
+		$output = '<option value="" '.selected('', $current, false).'>'.esc_html__('Default', 'gravityview').'</option>';
1059 1059
 
1060
-		if ( empty( $formid ) ) {
1060
+		if (empty($formid)) {
1061 1061
 			return $output;
1062 1062
 		}
1063 1063
 
1064
-		$fields = self::get_sortable_fields_array( $formid );
1064
+		$fields = self::get_sortable_fields_array($formid);
1065 1065
 
1066
-		if ( ! empty( $fields ) ) {
1066
+		if (!empty($fields)) {
1067 1067
 
1068
-			$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null );
1068
+			$blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array('list', 'textarea'), null);
1069 1069
 
1070
-			foreach ( $fields as $id => $field ) {
1071
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
1070
+			foreach ($fields as $id => $field) {
1071
+				if (in_array($field['type'], $blacklist_field_types)) {
1072 1072
 					continue;
1073 1073
 				}
1074 1074
 
1075
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>';
1075
+				$output .= '<option value="'.$id.'" '.selected($id, $current, false).'>'.esc_attr($field['label']).'</option>';
1076 1076
 			}
1077 1077
 		}
1078 1078
 
@@ -1090,27 +1090,27 @@  discard block
 block discarded – undo
1090 1090
 	 *
1091 1091
 	 * @return array
1092 1092
 	 */
1093
-	public static function get_sortable_fields_array( $formid, $blacklist = array( 'list', 'textarea' ) ) {
1093
+	public static function get_sortable_fields_array($formid, $blacklist = array('list', 'textarea')) {
1094 1094
 
1095 1095
 		// Get fields with sub-inputs and no parent
1096
-		$fields = self::get_form_fields( $formid, true, false );
1096
+		$fields = self::get_form_fields($formid, true, false);
1097 1097
 
1098 1098
 		$date_created = array(
1099 1099
 			'date_created' => array(
1100 1100
 				'type' => 'date_created',
1101
-				'label' => __( 'Date Created', 'gravityview' ),
1101
+				'label' => __('Date Created', 'gravityview'),
1102 1102
 			),
1103 1103
 		);
1104 1104
 
1105 1105
         $fields = $date_created + $fields;
1106 1106
 
1107
-		$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL );
1107
+		$blacklist_field_types = apply_filters('gravityview_blacklist_field_types', $blacklist, NULL);
1108 1108
 
1109 1109
 		// TODO: Convert to using array_filter
1110
-		foreach( $fields as $id => $field ) {
1110
+		foreach ($fields as $id => $field) {
1111 1111
 
1112
-			if( in_array( $field['type'], $blacklist_field_types ) ) {
1113
-				unset( $fields[ $id ] );
1112
+			if (in_array($field['type'], $blacklist_field_types)) {
1113
+				unset($fields[$id]);
1114 1114
 			}
1115 1115
 		}
1116 1116
 
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
          * @param array $fields Sub-set of GF form fields that are sortable
1121 1121
          * @param int $formid The Gravity Forms form ID that the fields are from
1122 1122
          */
1123
-        $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid );
1123
+        $fields = apply_filters('gravityview/common/sortable_fields', $fields, $formid);
1124 1124
 
1125 1125
 		return $fields;
1126 1126
 	}
@@ -1131,15 +1131,15 @@  discard block
 block discarded – undo
1131 1131
 	 * @param  mixed $field_id Field ID or Field array
1132 1132
 	 * @return string field type
1133 1133
 	 */
1134
-	public static function get_field_type( $form = null, $field_id = '' ) {
1134
+	public static function get_field_type($form = null, $field_id = '') {
1135 1135
 
1136
-		if ( ! empty( $field_id ) && ! is_array( $field_id ) ) {
1137
-			$field = self::get_field( $form, $field_id );
1136
+		if (!empty($field_id) && !is_array($field_id)) {
1137
+			$field = self::get_field($form, $field_id);
1138 1138
 		} else {
1139 1139
 			$field = $field_id;
1140 1140
 		}
1141 1141
 
1142
-		return class_exists( 'RGFormsModel' ) ? RGFormsModel::get_input_type( $field ) : '';
1142
+		return class_exists('RGFormsModel') ? RGFormsModel::get_input_type($field) : '';
1143 1143
 
1144 1144
 	}
1145 1145
 
@@ -1150,22 +1150,22 @@  discard block
 block discarded – undo
1150 1150
 	 * @param  int|array  $field field key or field array
1151 1151
 	 * @return boolean
1152 1152
 	 */
1153
-	public static function is_field_numeric(  $form = null, $field = '' ) {
1153
+	public static function is_field_numeric($form = null, $field = '') {
1154 1154
 
1155 1155
 		/**
1156 1156
 		 * @filter `gravityview/common/numeric_types` What types of fields are numeric?
1157 1157
 		 * @since 1.5.2
1158 1158
 		 * @param array $numeric_types Fields that are numeric. Default: `[ number, time ]`
1159 1159
 		 */
1160
-		$numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) );
1160
+		$numeric_types = apply_filters('gravityview/common/numeric_types', array('number', 'time'));
1161 1161
 
1162
-		if ( ! is_array( $form ) && ! is_array( $field ) ) {
1163
-			$form = self::get_form( $form );
1162
+		if (!is_array($form) && !is_array($field)) {
1163
+			$form = self::get_form($form);
1164 1164
 		}
1165 1165
 
1166
-		$type = self::get_field_type( $form, $field );
1166
+		$type = self::get_field_type($form, $field);
1167 1167
 
1168
-		return in_array( $type, $numeric_types );
1168
+		return in_array($type, $numeric_types);
1169 1169
 
1170 1170
 	}
1171 1171
 
@@ -1183,19 +1183,19 @@  discard block
 block discarded – undo
1183 1183
 	 *
1184 1184
 	 * @return string Content, encrypted
1185 1185
 	 */
1186
-	public static function js_encrypt( $content, $message = '' ) {
1186
+	public static function js_encrypt($content, $message = '') {
1187 1187
 
1188 1188
 		$output = $content;
1189 1189
 
1190
-		if ( ! class_exists( 'StandalonePHPEnkoder' ) ) {
1191
-			include_once( GRAVITYVIEW_DIR . 'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php' );
1190
+		if (!class_exists('StandalonePHPEnkoder')) {
1191
+			include_once(GRAVITYVIEW_DIR.'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php');
1192 1192
 		}
1193 1193
 
1194
-		if ( class_exists( 'StandalonePHPEnkoder' ) ) {
1194
+		if (class_exists('StandalonePHPEnkoder')) {
1195 1195
 
1196 1196
 			$enkoder = new StandalonePHPEnkoder;
1197 1197
 
1198
-			$message = empty( $message ) ? __( 'Email hidden; Javascript is required.', 'gravityview' ) : $message;
1198
+			$message = empty($message) ? __('Email hidden; Javascript is required.', 'gravityview') : $message;
1199 1199
 
1200 1200
 			/**
1201 1201
 			 * @filter `gravityview/phpenkoder/msg` Modify the message shown when Javascript is disabled and an encrypted email field is displayed
@@ -1203,9 +1203,9 @@  discard block
 block discarded – undo
1203 1203
 			 * @param string $message Existing message
1204 1204
 			 * @param string $content Content to encrypt
1205 1205
 			 */
1206
-			$enkoder->enkode_msg = apply_filters( 'gravityview/phpenkoder/msg', $message, $content );
1206
+			$enkoder->enkode_msg = apply_filters('gravityview/phpenkoder/msg', $message, $content);
1207 1207
 
1208
-			$output = $enkoder->enkode( $content );
1208
+			$output = $enkoder->enkode($content);
1209 1209
 		}
1210 1210
 
1211 1211
 		return $output;
@@ -1222,25 +1222,25 @@  discard block
 block discarded – undo
1222 1222
 	 *
1223 1223
 	 * @author rubo77 at https://gist.github.com/rubo77/6821632
1224 1224
 	 **/
1225
-	public static function gv_parse_str( $string, &$result ) {
1226
-		if ( empty( $string ) ) {
1225
+	public static function gv_parse_str($string, &$result) {
1226
+		if (empty($string)) {
1227 1227
 			return false;
1228 1228
 		}
1229 1229
 
1230 1230
 		$result = array();
1231 1231
 
1232 1232
 		// find the pairs "name=value"
1233
-		$pairs = explode( '&', $string );
1233
+		$pairs = explode('&', $string);
1234 1234
 
1235
-		foreach ( $pairs as $pair ) {
1235
+		foreach ($pairs as $pair) {
1236 1236
 			// use the original parse_str() on each element
1237
-			parse_str( $pair, $params );
1237
+			parse_str($pair, $params);
1238 1238
 
1239
-			$k = key( $params );
1240
-			if ( ! isset( $result[ $k ] ) ) {
1239
+			$k = key($params);
1240
+			if (!isset($result[$k])) {
1241 1241
 				$result += $params;
1242
-			} elseif ( array_key_exists( $k, $params ) && is_array( $params[ $k ] ) ) {
1243
-				$result[ $k ] = self::array_merge_recursive_distinct( $result[ $k ], $params[ $k ] );
1242
+			} elseif (array_key_exists($k, $params) && is_array($params[$k])) {
1243
+				$result[$k] = self::array_merge_recursive_distinct($result[$k], $params[$k]);
1244 1244
 			}
1245 1245
 		}
1246 1246
 		return true;
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
 	 *
1263 1263
 	 * @return string HTML output of anchor link. If empty $href, returns NULL
1264 1264
 	 */
1265
-	public static function get_link_html( $href = '', $anchor_text = '', $atts = array() ) {
1265
+	public static function get_link_html($href = '', $anchor_text = '', $atts = array()) {
1266 1266
 
1267 1267
 		// Supported attributes for anchor tags. HREF left out intentionally.
1268 1268
 		$allowed_atts = array(
@@ -1298,31 +1298,31 @@  discard block
 block discarded – undo
1298 1298
 		 * @filter `gravityview/get_link/allowed_atts` Modify the attributes that are allowed to be used in generating links
1299 1299
 		 * @param array $allowed_atts Array of attributes allowed
1300 1300
 		 */
1301
-		$allowed_atts = apply_filters( 'gravityview/get_link/allowed_atts', $allowed_atts );
1301
+		$allowed_atts = apply_filters('gravityview/get_link/allowed_atts', $allowed_atts);
1302 1302
 
1303 1303
 		// Make sure the attributes are formatted as array
1304
-		$passed_atts = wp_parse_args( $atts );
1304
+		$passed_atts = wp_parse_args($atts);
1305 1305
 
1306 1306
 		// Make sure the allowed attributes are only the ones in the $allowed_atts list
1307
-		$final_atts = shortcode_atts( $allowed_atts, $passed_atts );
1307
+		$final_atts = shortcode_atts($allowed_atts, $passed_atts);
1308 1308
 
1309 1309
 		// Remove attributes with empty values
1310
-		$final_atts = array_filter( $final_atts );
1310
+		$final_atts = array_filter($final_atts);
1311 1311
 
1312 1312
 		// If the href wasn't passed as an attribute, use the value passed to the function
1313
-		if ( empty( $final_atts['href'] ) && ! empty( $href ) ) {
1313
+		if (empty($final_atts['href']) && !empty($href)) {
1314 1314
 			$final_atts['href'] = $href;
1315 1315
 		}
1316 1316
 
1317
-		$final_atts['href'] = esc_url_raw( $href );
1317
+		$final_atts['href'] = esc_url_raw($href);
1318 1318
 
1319 1319
 		// For each attribute, generate the code
1320 1320
 		$output = '';
1321
-		foreach ( $final_atts as $attr => $value ) {
1322
-			$output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) );
1321
+		foreach ($final_atts as $attr => $value) {
1322
+			$output .= sprintf(' %s="%s"', $attr, esc_attr($value));
1323 1323
 		}
1324 1324
 
1325
-		$output = '<a'. $output .'>'. $anchor_text .'</a>';
1325
+		$output = '<a'.$output.'>'.$anchor_text.'</a>';
1326 1326
 
1327 1327
 		return $output;
1328 1328
 	}
@@ -1341,14 +1341,14 @@  discard block
 block discarded – undo
1341 1341
 	 * @author Daniel <daniel (at) danielsmedegaardbuus (dot) dk>
1342 1342
 	 * @author Gabriel Sobrinho <gabriel (dot) sobrinho (at) gmail (dot) com>
1343 1343
 	 */
1344
-	public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) {
1344
+	public static function array_merge_recursive_distinct(array &$array1, array &$array2) {
1345 1345
 		$merged = $array1;
1346 1346
 
1347
-		foreach ( $array2 as $key => &$value )  {
1348
-			if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
1349
-				$merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value );
1347
+		foreach ($array2 as $key => &$value) {
1348
+			if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
1349
+				$merged[$key] = self::array_merge_recursive_distinct($merged[$key], $value);
1350 1350
 			} else {
1351
-				$merged[ $key ] = $value;
1351
+				$merged[$key] = $value;
1352 1352
 			}
1353 1353
 		}
1354 1354
 
@@ -1362,26 +1362,26 @@  discard block
 block discarded – undo
1362 1362
 	 * @param array $args Arguments to modify the user query. See get_users() {@since 1.14}
1363 1363
 	 * @return array Array of WP_User objects.
1364 1364
 	 */
1365
-	public static function get_users( $context = 'change_entry_creator', $args = array() ) {
1365
+	public static function get_users($context = 'change_entry_creator', $args = array()) {
1366 1366
 
1367 1367
 		$default_args = array(
1368 1368
 			'number' => 2000,
1369 1369
 			'orderby' => 'display_name',
1370 1370
 			'order' => 'ASC',
1371
-			'fields' => array( 'ID', 'display_name', 'user_login', 'user_nicename' )
1371
+			'fields' => array('ID', 'display_name', 'user_login', 'user_nicename')
1372 1372
 		);
1373 1373
 
1374 1374
 		// Merge in the passed arg
1375
-		$get_users_settings = wp_parse_args( $args, $default_args );
1375
+		$get_users_settings = wp_parse_args($args, $default_args);
1376 1376
 
1377 1377
 		/**
1378 1378
 		 * @filter `gravityview/get_users/{$context}` There are issues with too many users using [get_users()](http://codex.wordpress.org/Function_Reference/get_users) where it breaks the select. We try to keep it at a reasonable number. \n
1379 1379
 		 * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..)
1380 1380
 		 * @param array $settings Settings array, with `number` key defining the # of users to display
1381 1381
 		 */
1382
-		$get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1382
+		$get_users_settings = apply_filters('gravityview/get_users/'.$context, apply_filters('gravityview_change_entry_creator_user_parameters', $get_users_settings));
1383 1383
 
1384
-		return get_users( $get_users_settings );
1384
+		return get_users($get_users_settings);
1385 1385
 	}
1386 1386
 
1387 1387
 
@@ -1393,8 +1393,8 @@  discard block
 block discarded – undo
1393 1393
      *
1394 1394
      * @return string
1395 1395
      */
1396
-    public static function generate_notice( $notice, $class = '' ) {
1397
-        return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>';
1396
+    public static function generate_notice($notice, $class = '') {
1397
+        return '<div class="gv-notice '.gravityview_sanitize_html_class($class).'">'.$notice.'</div>';
1398 1398
     }
1399 1399
 
1400 1400
 
@@ -1416,6 +1416,6 @@  discard block
 block discarded – undo
1416 1416
  *
1417 1417
  * @return string HTML output of anchor link. If empty $href, returns NULL
1418 1418
  */
1419
-function gravityview_get_link( $href = '', $anchor_text = '', $atts = array() ) {
1420
-	return GVCommon::get_link_html( $href, $anchor_text, $atts );
1419
+function gravityview_get_link($href = '', $anchor_text = '', $atts = array()) {
1420
+	return GVCommon::get_link_html($href, $anchor_text, $atts);
1421 1421
 }
Please login to merge, or discard this patch.