Validate::sanitize_description( null|string $value = null )
Description #
Sanitize description field.
Remove more, encode contents of code and pre tag. Replace square brackets so that shortcode don’t get rendered.
Parameters #
- $valuenull | string (Optional) String to sanitize. Default value: null
Source #
File: lib/class-validate.php
public static function sanitize_description( $value = null ) { if ( ! empty( $value ) ) { /** * Filter called before applying sanitization to a description fields. * * @param string $value Value. * @since 4.1.9 */ $new_value = apply_filters( 'ap_pre_sanitize_description', $value ); $new_value = str_replace( '<!--more-->', '', $new_value ); $patt = get_shortcode_regex(); $new_value = preg_replace_callback( "/$patt/", array( __CLASS__, 'whitelist_shortcodes' ), $new_value ); $new_value = preg_replace_callback( '/<pre(.*?)>(.*?)<\/pre>/imsu', array( __CLASS__, 'pre_content' ), $new_value ); $new_value = preg_replace_callback( '/<code.*?>(.*?)<\/code>/imsu', array( __CLASS__, 'code_content' ), $new_value ); // Remove multiple new lines. $new_value = str_replace( "\r\n", "\n", $new_value ); $new_value = preg_replace( '/\n\s*\n/', "\n\n", $new_value ); // Remove single white single space in line. $new_value = preg_replace( '/ /', "\n", $new_value ); return $new_value; } }
Expand full source code Collapse full source code View on GitHub: lib/class-validate.php:180
Add your comment