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