sanitization-helper.php
1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace Yoast\WP\SEO\Helpers;
use WPSEO_Utils;
/**
* A helper object for sanitization.
*/
class Sanitization_Helper {
/**
* Emulate the WP native sanitize_text_field function in a %%variable%% safe way.
*
* @codeCoverageIgnore We have to write test when this method contains own code.
*
* @param string $value String value to sanitize.
*
* @return string The sanitized string.
*/
public function sanitize_text_field( $value ) {
return WPSEO_Utils::sanitize_text_field( $value );
}
/**
* Sanitize a url for saving to the database.
* Not to be confused with the old native WP function.
*
* @codeCoverageIgnore We have to write test when this method contains own code.
*
* @param string $value String URL value to sanitize.
* @param array $allowed_protocols Optional set of allowed protocols.
*
* @return string The sanitized URL.
*/
public function sanitize_url( $value, $allowed_protocols = [ 'http', 'https' ] ) {
return WPSEO_Utils::sanitize_url( $value, $allowed_protocols );
}
}