Completed
Push — develop ( b70edf...f41d4e )
by Zack
05:21
created

helper-functions.php ➔ gv_map_deep()   B

Complexity

Conditions 6
Paths 5

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 6
eloc 13
c 2
b 0
f 0
nc 5
nop 2
dl 0
loc 23
rs 8.5906
1
<?php
2
/**
3
 * Functions that don't require GravityView or Gravity Forms API access but are used in the plugin to extend PHP and WP functions
4
 * @since 1.12
5
 */
6
7
/**
8
 * Check whether a variable is not an empty string
9
 *
10
 * @see /templates/fields/product.php Used to check whether the product array is empty or not
11
 *
12
 * @since 1.12
13
 *
14
 * @param mixed $mixed Variable to check
15
 *
16
 * @return bool true: $mixed is *not* an empty string; false: $mixed *is* an empty string
17
 */
18
function gravityview_is_not_empty_string( $mixed = '' ) {
19
	return ( $mixed !== '' );
20
}
21
22
/**
23
 * Get `get_permalink()` without the home_url() prepended to it.
24
 *
25
 * get_permalink() does a lot of good stuff: it gets the correct permalink structure for custom post types, pages,
26
 * posts, etc. Instead of using `?p={id}`, `?page_id={id}`, or `?p={id}&post_type={post_type}`, by using
27
 * get_permalink(), we can use `?p=slug` or `?gravityview={slug}`
28
 *
29
 * We could do this in a cleaner fashion, but this prevents a lot of code duplication, checking for URL structure, etc.
30
 *
31
 * @param int|WP_Post $id        Optional. Post ID or post object. Default current post.
32
 *
33
 * @return array URL args, if exists. Empty array if not.
34
 */
35
function gravityview_get_permalink_query_args( $id = 0 ) {
36
37
	$parsed_permalink = parse_url( get_permalink( $id ) );
38
39
	$permalink_args =  isset( $parsed_permalink['query'] ) ? $parsed_permalink['query'] : false;
0 ignored issues
show
introduced by
Expected 1 space after "="; 2 found
Loading history...
40
41
	if( empty( $permalink_args ) ) {
42
		return array();
43
	}
44
45
	parse_str( $permalink_args, $args );
46
47
	return $args;
48
}
49
50
51
/**
52
 * Similar to the WordPress `selected()`, `checked()`, and `disabled()` functions, except it allows arrays to be passed as current value
53
 *
54
 * @see selected() WordPress core function
55
 *
56
 * @param string $value One of the values to compare
57
 * @param mixed $current (true) The other value to compare if not just true
58
 * @param bool $echo Whether to echo or just return the string
59
 * @param string $type The type of checked|selected|disabled we are doing
60
 *
61
 * @return string html attribute or empty string
62
 */
63
function gv_selected( $value, $current, $echo = true, $type = 'selected' ) {
64
65
	$output = '';
66
	if( is_array( $current ) ) {
67
		if( in_array( $value, $current ) ) {
68
			$output = __checked_selected_helper( true, true, false, $type );
69
		}
70
	} else {
71
		$output = __checked_selected_helper( $value, $current, false, $type );
72
	}
73
74
	if( $echo ) {
75
		echo $output;
0 ignored issues
show
introduced by
Expected next thing to be a escaping function, not '$output'
Loading history...
76
	}
77
78
	return $output;
79
}
80
81
82
if( ! function_exists( 'gravityview_sanitize_html_class' ) ) {
83
84
	/**
85
	 * sanitize_html_class doesn't handle spaces (multiple classes). We remedy that.
86
	 *
87
	 * @uses sanitize_html_class
88
	 *
89
	 * @param  string|array $classes Text or array of classes to sanitize
90
	 *
91
	 * @return string            Sanitized CSS string
92
	 */
93
	function gravityview_sanitize_html_class( $classes ) {
94
95
		if ( is_string( $classes ) ) {
96
			$classes = explode( ' ', $classes );
97
		}
98
99
		// If someone passes something not string or array, we get outta here.
100
		if ( ! is_array( $classes ) ) {
101
			return $classes;
102
		}
103
104
		$classes = array_map( 'trim', $classes );
105
		$classes = array_map( 'sanitize_html_class', $classes );
106
		$classes = array_filter( $classes );
107
108
		return implode( ' ', $classes );
109
	}
110
}
111
112
/**
113
 * Replace multiple newlines, tabs, and spaces with a single space
114
 *
115
 * First, runs normalize_whitespace() on a string. This replaces multiple lines with a single line, and tabs with spaces.
116
 * We then strip any tabs or newlines and replace *those* with a single space.
117
 *
118
 * @see normalize_whitespace()
119
 * @see GravityView_Helper_Functions_Test::test_gravityview_strip_whitespace
120
 * @since 1.13
121
 *
122
 * @param string $string String to strip whitespace from
123
 *
124
 * @return string Stripped string!
125
 */
126
function gravityview_strip_whitespace( $string ) {
127
	$string = normalize_whitespace( $string );
128
	return preg_replace('/[\r\n\t ]+/', ' ', $string );
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
129
}
130
131
/**
132
 * Get the contents of a file using `include()` and `ob_start()`
133
 *
134
 * @since 1.13
135
 * @since 1.15 Added $object param
136
 *
137
 * @param string $file_path Full path to a file
138
 * @param mixed $object Pass pseudo-global to the included file
139
 * @return string Included file contents
140
 */
141
function gravityview_ob_include( $file_path, $object = NULL ) {
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected null, but found NULL.
Loading history...
142
	if( ! file_exists( $file_path ) ) {
143
		do_action( 'gravityview_log_error', __FUNCTION__ . ': File path does not exist. ', $file_path );
144
		return '';
145
	}
146
	ob_start();
147
	include( $file_path );
148
	return ob_get_clean();
149
}
150
151
/**
152
 * Get an image of our intrepid explorer friend
153
 * @since 1.12
154
 * @return string HTML image tag with floaty's cute mug on it
155
 */
156
function gravityview_get_floaty() {
157
158
	if( function_exists('is_rtl') && is_rtl() ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
159
		$style = 'margin:10px 10px 10px 0;';
160
		$class = 'alignright';
161
	} else {
162
		$style = 'margin:10px 10px 10px 0;';
163
		$class = 'alignleft';
164
	}
165
166
	return '<img src="'.plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ).'" class="'.$class.'" height="87" width="66" alt="The GravityView Astronaut Says:" style="'.$style.'" />';
167
}
168
169
/**
170
 * Intelligently format a number
171
 *
172
 * If you don't define the number of decimal places, then it will use the existing number of decimal places. This is done
173
 * in a way that respects the localization of the site.
174
 *
175
 * If you do define decimals, it uses number_format_i18n()
176
 *
177
 * @see number_format_i18n()
178
 *
179
 * @since 1.13
180
 *
181
 * @param int|float|string|double $number A number to format
182
 * @param int|string $decimals Optional. Precision of the number of decimal places. Default '' (use existing number of decimals)
183
 *
184
 * @return string Converted number in string format.
185
 */
186
function gravityview_number_format( $number, $decimals = '' ) {
187
	global $wp_locale;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
188
189
	if( '' === $decimals ) {
190
191
		$decimal_point = isset( $wp_locale ) ? $wp_locale->number_format['decimal_point'] : '.';
192
193
		/**
194
		 * Calculate the position of the decimal point in the number
195
		 * @see http://stackoverflow.com/a/2430144/480856
196
		 */
197
		$decimals = strlen( substr( strrchr( $number, $decimal_point ), 1 ) );
198
	}
199
200
	$number = number_format_i18n( $number, (int)$decimals );
0 ignored issues
show
introduced by
No space after closing casting parenthesis is prohibited
Loading history...
201
202
	return $number;
203
}
204
205
206
/**
207
 * Convert a whole link into a shorter link for display
208
 *
209
 * @since 1.1
210
 *
211
 * @param  string $value Existing URL
212
 * @return string        If parse_url doesn't find a 'host', returns original value. Otherwise, returns formatted link.
213
 */
214
function gravityview_format_link( $value = null ) {
215
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
216
217
	$parts = parse_url( $value );
218
219
	// No domain? Strange...show the original text.
220
	if( empty( $parts['host'] ) ) {
221
		return $value;
222
	}
223
224
	// Start with empty value for the return URL
225
	$return = '';
226
227
	/**
228
	 * @filter `gravityview_anchor_text_striphttp` Strip scheme from the displayed URL?
229
	 * @since 1.5.1
230
	 * @param boolean $enable Whether to strip the scheme. Return false to show scheme. (default: true)\n
231
	 * If true: `http://example.com => example.com`
232
	 */
233
	if( false === apply_filters('gravityview_anchor_text_striphttp', true) ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
234
235
		if( isset( $parts['scheme'] ) ) {
236
			$return .= $parts['scheme'];
237
		}
1 ignored issue
show
introduced by
Blank line found after control structure
Loading history...
238
239
	}
240
241
	// The domain, which may contain a subdomain
242
	$domain = $parts['host'];
243
244
	/**
245
	 * @filter `gravityview_anchor_text_stripwww` Strip www from the domain?
246
	 * @since 1.5.1
247
	 * @param boolean $enable Whether to strip www. Return false to show www. (default: true)\n
248
	 * If true: `www.example.com => example.com`
249
	 */
250
	$strip_www = apply_filters('gravityview_anchor_text_stripwww', true );
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
251
252
	if( $strip_www ) {
253
		$domain = str_replace('www.', '', $domain );
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
254
	}
255
256
	/**
257
	 * @filter `gravityview_anchor_text_nosubdomain` Strip subdomains from the domain?
258
	 * @since 1.5.1
259
	 * @param boolean $enable Whether to strip subdomains. Return false to show subdomains. (default: true)\n
260
	 * If true: `http://demo.example.com => example.com` \n
261
	 * If false: `http://demo.example.com => demo.example.com`
262
	 */
263
	$strip_subdomains = apply_filters('gravityview_anchor_text_nosubdomain', true);
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
264
265
	if( $strip_subdomains ) {
266
267
		$domain = _gravityview_strip_subdomain( $parts['host'] );
268
269
	}
270
271
	// Add the domain
272
	$return .= $domain;
273
274
	/**
275
	 * @filter `gravityview_anchor_text_rootonly` Display link path going only to the base directory, not a sub-directory or file?
276
	 * @since 1.5.1
277
	 * @param boolean $enable Whether to enable "root only". Return false to show full path. (default: true)\n
278
	 * If true: `http://example.com/sub/directory/page.html => example.com`  \n
279
	 * If false: `http://example.com/sub/directory/page.html => example.com/sub/directory/page.html`
280
	 */
281
	$root_only = apply_filters('gravityview_anchor_text_rootonly', true);
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
282
283
	if( empty( $root_only ) ) {
284
285
		if( isset( $parts['path'] ) ) {
286
			$return .= $parts['path'];
287
		}
288
	}
289
290
	/**
291
	 * @filter `gravityview_anchor_text_noquerystring` Strip the query string from the end of the URL?
292
	 * @since 1.5.1
293
	 * @param boolean $enable Whether to enable "root only". Return false to show full path. (default: true)\n
294
	 * If true: `http://example.com/?query=example => example.com`
295
	 */
296
	$strip_query_string = apply_filters('gravityview_anchor_text_noquerystring', true );
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
297
298
	if( empty( $strip_query_string ) ) {
299
300
		if( isset( $parts['query'] ) ) {
301
			$return .= '?'.$parts['query'];
302
		}
1 ignored issue
show
introduced by
Blank line found after control structure
Loading history...
303
304
	}
305
306
	return $return;
307
}
308
309
/**
310
 * Do a _very_ basic match for second-level TLD domains, like `.co.uk`
311
 *
312
 * Ideally, we'd use https://github.com/jeremykendall/php-domain-parser to check for this, but it's too much work for such a basic functionality. Maybe if it's needed more in the future. So instead, we use [Basic matching regex](http://stackoverflow.com/a/12372310).
313
 * @param  string $domain Domain to check if it's a TLD or subdomain
0 ignored issues
show
Documentation introduced by
There is no parameter named $domain. Did you maybe mean $string_maybe_has_subdomain?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
314
 * @return string         Extracted domain if it has a subdomain
315
 */
316
function _gravityview_strip_subdomain( $string_maybe_has_subdomain ) {
317
318
	if( preg_match("/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after opening bracket; 0 found
Loading history...
Coding Style Comprehensibility introduced by
The string literal /(?P<domain>[a-z0-9][a-z...emo\.)?[a-z\.]{2,6})$/i does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
319
		return $matches['domain'];
320
	} else {
321
		return $string_maybe_has_subdomain;
322
	}
323
}
324
325
/**
326
 * Is the value empty?
327
 *
328
 * Allows you to pass a function instead of just a variable, like the empty() function insists upon (until PHP 5.5)
329
 *
330
 * Checks whether `false`, `null`, empty string, empty array, object with no vars defined
331
 *
332
 * @since 1.15.1
333
 * @param  mixed  $value Check whether this is empty
334
 * @param boolean $zero_is_empty Should the number zero be treated as an empty value?
335
 * @param boolean $allow_string_booleans Whether to check if 'yes', 'true' => `true` and 'no', 'false' => `false`
336
 * @return boolean        True: empty; false: not empty
337
 */
338
function gv_empty( $value, $zero_is_empty = true, $allow_string_booleans = true ) {
339
340
	if(
341
		! isset( $value ) // If it's not set, it's empty!
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
342
		|| false === $value
343
		|| null === $value
344
	    || '' === $value // Empty string
345
		|| array() === $value // Empty array
346
		|| ( is_object( $value ) && ! get_object_vars( $value ) ) // Empty object
347
	) {
348
		return true;
349
	}
350
351
	if( is_string( $value ) && $allow_string_booleans ) {
352
353
		$value = trim( $value );
354
		$value = strtolower( $value );
355
356
		if ( in_array( $value, array( 'yes', 'true' ), true ) ) {
357
			$value = true;
358
		} else if( in_array( $value, array( 'no', 'false' ), true ) ) {
359
			$value = false;
360
		}
361
	}
362
363
	// If zero isn't empty, then if $value is a number and it's empty, it's zero. Thus, return false.
364
	if( ! $zero_is_empty && is_numeric( $value ) && empty( $value ) ) {
365
		return false;
366
	}
367
368
	return empty( $value );
369
}
370
371
372
/**
373
 * Maps a function to all non-iterable elements of an array or an object.
374
 *
375
 * @see map_deep() This is an alias of the WP core function `map_deep()`, added in 4.4. Here for legacy purposes.
376
 * @since 1.16.3
377
 *
378
 * @param mixed    $value    The array, object, or scalar.
379
 * @param callable $callback The function to map onto $value.
380
 *
381
 * @return mixed The value with the callback applied to all non-arrays and non-objects inside it.
382
 */
383
function gv_map_deep( $value, $callback ) {
384
385
	// Use the original function, if exists.
386
	if( function_exists( 'map_deep') ) {
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces before closing bracket; 0 found
Loading history...
387
		return map_deep( $value, $callback );
388
	}
389
390
	// Exact copy of map_deep() code below:
391
	if ( is_array( $value ) ) {
392
		foreach ( $value as $index => $item ) {
393
			$value[ $index ] = gv_map_deep( $item, $callback );
394
		}
395
	} elseif ( is_object( $value ) ) {
396
		$object_vars = get_object_vars( $value );
397
		foreach ( $object_vars as $property_name => $property_value ) {
398
			$value->$property_name = gv_map_deep( $property_value, $callback );
399
		}
400
	} else {
401
		$value = call_user_func( $callback, $value );
402
	}
403
404
	return $value;
405
}
406
407
/**
408
 * Check whether a string is a expected date format
409
 *
410
 * @since 1.15.2
411
 *
412
 * @param string $datetime The date to check
413
 * @param string $expected_format Check whether the date is formatted as expected. Default: Y-m-d
414
 *
415
 * @return bool True: it's a valid datetime, formatted as expected. False: it's not a date formatted as expected.
416
 */
417
function gravityview_is_valid_datetime( $datetime, $expected_format = 'Y-m-d' ) {
418
419
	/**
420
	 * @var bool|DateTime False if not a valid date, (like a relative date). DateTime if a date was created.
421
	 */
422
	$formatted_date = DateTime::createFromFormat( $expected_format, $datetime );
0 ignored issues
show
Bug introduced by
The method createFromFormat() does not exist on DateTime. Did you maybe mean format()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
423
424
	/**
425
	 * @see http://stackoverflow.com/a/19271434/480856
426
	 */
427
	return ( $formatted_date && $formatted_date->format( $expected_format ) === $datetime );
428
}
429
430
/**
431
 * Very commonly needed: get the # of the input based on a full field ID.
432
 *
433
 * Example: 12.3 => field #12, input #3. Returns: 3
434
 * Example: 7 => field #7, no input. Returns: 0
435
 *
436
 * @since 1.16.4
437
 *
438
 * @param string $field_id Full ID of field, with or without input ID, like "12.3" or "7".
439
 *
440
 * @return int If field ID has an input, returns that input number. Otherwise, returns 0.
441
 */
442
function gravityview_get_input_id_from_id( $field_id = '' ) {
443
444
	if ( ! is_numeric( $field_id ) ) {
445
		do_action( 'gravityview_log_error', __FUNCTION__ . ': $field_id not numeric', $field_id );
446
		return false;
447
	}
448
449
	$exploded = explode( '.', "{$field_id}" );
450
451
	return isset( $exploded[1] ) ? intval( $exploded[1] ) : 0;
452
}
453
454
/**
455
 * Get categories formatted in a way used by GravityView and Gravity Forms input choices
456
 *
457
 * @since 1.15.3
458
 *
459
 * @see get_terms()
460
 *
461
 * @param array $args Arguments array as used by the get_terms() function. Filtered using `gravityview_get_terms_choices_args` filter. Defaults: { \n
462
 *   @type string $taxonomy Used as first argument in get_terms(). Default: "category"
463
 *   @type string $fields Default: 'id=>name' to only fetch term ID and Name \n
464
 *   @type int $number  Limit the total number of terms to fetch. Default: 1000 \n
465
 * }
466
 *
467
 * @return array Multidimensional array with `text` (Category Name) and `value` (Category ID) keys.
468
 */
469
function gravityview_get_terms_choices( $args = array() ) {
470
471
	$defaults = array(
472
		'type'         => 'post',
473
		'child_of'     => 0,
474
		'number'       => 1000, // Set a reasonable max limit
475
		'orderby'      => 'name',
476
		'order'        => 'ASC',
477
		'hide_empty'   => 0,
478
		'hierarchical' => 1,
479
		'taxonomy'     => 'category',
480
		'fields'       => 'id=>name',
481
	);
482
483
	$args = wp_parse_args( $args, $defaults );
484
485
	/**
486
	 * @filter `gravityview_get_terms_choices_args` Modify the arguments passed to `get_terms()`
487
	 * @see get_terms()
488
	 * @since 1.15.3
489
	 */
490
	$args = apply_filters( 'gravityview_get_terms_choices_args', $args );
491
492
	$terms = get_terms( $args['taxonomy'], $args );
493
494
	$choices = array();
495
496
	if ( is_array( $terms ) ) {
497
		foreach ( $terms as $term_id => $term_name ) {
498
			$choices[] = array(
499
				'text'  => $term_name,
500
				'value' => $term_id
0 ignored issues
show
introduced by
Each line in an array declaration must end in a comma
Loading history...
501
			);
502
		}
503
	}
504
505
	return $choices;
506
}
507
508
/**
509
 * Maybe convert jQuery-serialized fields into array, otherwise return $_POST['fields'] array
510
 *
511
 * Fields are passed as a jQuery-serialized array, created in admin-views.js in the serializeForm method.
512
 *
513
 * @since TODO
514
 *
515
 * @uses GVCommon::gv_parse_str
516
 *
517
 * @return array Array of fields
518
 */
519
function _gravityview_process_posted_fields() {
520
	$fields = array();
521
522
	if( !empty( $_POST['fields'] ) ) {
0 ignored issues
show
introduced by
Expected 1 space after "!"; 0 found
Loading history...
523
		if ( ! is_array( $_POST['fields'] ) ) {
524
525
			// We are not using parse_str() due to max_input_vars limitation with large View configurations
526
			$fields_holder = array();
527
			GVCommon::gv_parse_str( $_POST['fields'], $fields_holder );
0 ignored issues
show
introduced by
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_POST
Loading history...
528
529
			if ( isset( $fields_holder['fields'] ) ) {
530
				$fields = $fields_holder['fields'];
531
			} else {
532
				do_action( 'gravityview_log_error', '[save_postdata] No `fields` key was found after parsing $fields string', $fields_holder );
533
			}
1 ignored issue
show
introduced by
Blank line found after control structure
Loading history...
534
535
		} else {
536
			$fields = $_POST['fields'];
0 ignored issues
show
introduced by
Detected access of super global var $_POST, probably need manual inspection.
Loading history...
introduced by
Detected usage of a non-sanitized input variable: $_POST
Loading history...
537
		}
538
	}
539
540
	return $fields;
541
}
542