: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Filters the maximum number of words in a post excerpt.
* @param int $number The maximum number of words. Default 55.
$excerpt_length = (int) apply_filters( 'excerpt_length', $excerpt_length );
* Filters the string in the "more" link displayed after a trimmed excerpt.
* @param string $more_string The string shown within the more link.
$excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' );
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
* Filters the trimmed excerpt string.
* @param string $text The trimmed text.
* @param string $raw_excerpt The text prior to trimming.
return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt );
* Trims text to a certain number of words.
* This function is localized. For languages that count 'words' by the individual
* character (such as East Asian languages), the $num_words argument will apply
* to the number of individual characters.
* @param string $text Text to trim.
* @param int $num_words Number of words. Default 55.
* @param string $more Optional. What to append if $text needs to be trimmed. Default '…'.
* @return string Trimmed text.
function wp_trim_words( $text, $num_words = 55, $more = null ) {
$more = __( '…' );
$text = wp_strip_all_tags( $text );
$num_words = (int) $num_words;
if ( str_starts_with( wp_get_word_count_type(), 'characters' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
$text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' );
preg_match_all( '/./u', $text, $words_array );
$words_array = array_slice( $words_array[0], 0, $num_words + 1 );
$words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );
if ( count( $words_array ) > $num_words ) {
array_pop( $words_array );
$text = implode( $sep, $words_array );
$text = implode( $sep, $words_array );
* Filters the text content after words have been trimmed.
* @param string $text The trimmed text.
* @param int $num_words The number of words to trim the text to. Default 55.
* @param string $more An optional string to append to the end of the trimmed text, e.g. ….
* @param string $original_text The text before it was trimmed.
return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text );
* Converts named entities into numbered entities.
* @param string $text The text within which entities will be converted.
* @return string Text with converted entities.
function ent2ncr( $text ) {
* Filters text before named entities are converted into numbered entities.
* A non-null string must be returned for the filter to be evaluated.
* @param string|null $converted_text The text to be converted. Default null.
* @param string $text The text prior to entity conversion.
$filtered = apply_filters( 'pre_ent2ncr', null, $text );
if ( null !== $filtered ) {
'ϑ' => 'ϑ',
'ℵ' => 'ℵ',
return str_replace( array_keys( $to_ncr ), array_values( $to_ncr ), $text );
* Formats text for the editor.
* Generally the browsers treat everything inside a textarea as text, but
* it is still a good idea to HTML entity encode `<`, `>` and `&` in the content.
* The filter {@see 'format_for_editor'} is applied here. If `$text` is empty the
* filter will be applied to an empty string.
* @see _WP_Editors::editor()
* @param string $text The text to be formatted.
* @param string $default_editor The default editor for the current user.
* It is usually either 'html' or 'tinymce'.
* @return string The formatted text after filter is applied.
function format_for_editor( $text, $default_editor = null ) {
$text = htmlspecialchars( $text, ENT_NOQUOTES, get_option( 'blog_charset' ) );
* Filters the text after it is formatted for the editor.
* @param string $text The formatted text.
* @param string $default_editor The default editor for the current user.
* It is usually either 'html' or 'tinymce'.
return apply_filters( 'format_for_editor', $text, $default_editor );
* Performs a deep string replace operation to ensure the values in $search are no longer present.
* Repeats the replacement operation until it no longer replaces anything to remove "nested" values
* e.g. $subject = '%0%0%0DDD', $search ='%0D', $result ='' rather than the '%0%0DD' that
* str_replace would return
* @param string|array $search The value being searched for, otherwise known as the needle.
* An array may be used to designate multiple needles.
* @param string $subject The string being searched and replaced on, otherwise known as the haystack.
* @return string The string with the replaced values.
function _deep_replace( $search, $subject ) {
$subject = (string) $subject;
$subject = str_replace( $search, '', $subject, $count );
* Escapes data for use in a MySQL query.
* Usually you should prepare queries using wpdb::prepare().
* Sometimes, spot-escaping is required or useful. One example
* is preparing an array for use in an IN clause.
* NOTE: Since 4.8.3, '%' characters will be replaced with a placeholder string,
* this prevents certain SQLi attacks from taking place. This change in behavior
* may cause issues for code that expects the return value of esc_sql() to be usable
* @global wpdb $wpdb WordPress database abstraction object.
* @param string|array $data Unescaped data.
* @return string|array Escaped data, in the same type as supplied.
function esc_sql( $data ) {
return $wpdb->_escape( $data );
* Checks and cleans a URL.
* A number of characters are removed from the URL. If the URL is for displaying
* (the default behavior) ampersands are also replaced. The {@see 'clean_url'} filter
* is applied to the returned cleaned URL.
* @param string $url The URL to be cleaned.
* @param string[] $protocols Optional. An array of acceptable protocols.
* Defaults to return value of wp_allowed_protocols().
* @param string $_context Private. Use sanitize_url() for database usage.
* @return string The cleaned URL after the {@see 'clean_url'} filter is applied.
* An empty string is returned if `$url` specifies a protocol other than
* those in `$protocols`, or if `$url` contains an empty string.
function esc_url( $url, $protocols = null, $_context = 'display' ) {
$url = str_replace( ' ', '%20', ltrim( $url ) );
$url = preg_replace( '|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url );
if ( 0 !== stripos( $url, 'mailto:' ) ) {
$strip = array( '%0d', '%0a', '%0D', '%0A' );
$url = _deep_replace( $strip, $url );
$url = str_replace( ';//', '://', $url );
* If the URL doesn't appear to contain a scheme, we presume
* it needs http:// prepended (unless it's a relative link
* starting with /, # or ?, or a PHP file).
if ( ! str_contains( $url, ':' ) && ! in_array( $url[0], array( '/', '#', '?' ), true ) &&