Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/google-site-kit/includes/Core/Util/Sanitize.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
/**
3
+
* Class Google\Site_Kit\Core\Util\Sanitize
4
+
*
5
+
* @package Google\Site_Kit\Core\Util
6
+
* @copyright 2023 Google LLC
7
+
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
8
+
* @link https://sitekit.withgoogle.com
9
+
*/
10
+
11
+
namespace Google\Site_Kit\Core\Util;
12
+
13
+
/**
14
+
* Utility class for sanitizing data.
15
+
*
16
+
* @since 1.93.0
17
+
* @access private
18
+
* @ignore
19
+
*/
20
+
class Sanitize {
21
+
22
+
/**
23
+
* Filters empty or non-string elements from a given array.
24
+
*
25
+
* @since 1.93.0
26
+
*
27
+
* @param array $elements Array to check.
28
+
* @return array Empty array or a filtered array containing only non-empty strings.
29
+
*/
30
+
public static function sanitize_string_list( $elements = array() ) {
31
+
if ( ! is_array( $elements ) ) {
32
+
$elements = array( $elements );
33
+
}
34
+
35
+
if ( empty( $elements ) ) {
36
+
return array();
37
+
}
38
+
39
+
$filtered_elements = array_filter(
40
+
$elements,
41
+
function ( $element ) {
42
+
return is_string( $element ) && ! empty( $element );
43
+
}
44
+
);
45
+
// Avoid index gaps for filtered values.
46
+
return array_values( $filtered_elements );
47
+
}
48
+
}
49
+