WordPress.org

Make WordPress Core

Ticket #33756: 33756.3.diff

File 33756.3.diff, 1.9 KB (added by gma992, 3 years ago)

Rephrasing what sanitize_title() does

  • src/wp-includes/formatting.php

     
    18511851        $username = remove_accents( $username );
    18521852        // Kill octets
    18531853        $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );
    1854         $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities
     1854        // Remove HTML entities.
     1855        $username = preg_replace( '/&.+?;/', '', $username );
    18551856
    18561857        // If strict, reduce to ASCII for max portability.
    18571858        if ( $strict )
     
    19001901}
    19011902
    19021903/**
    1903  * Sanitizes a title, or returns a fallback title.
     1904 * Sanitizes a string, HTML and PHP tags are stripped, and accents are removed, for use as a slug in a URL.
    19041905 *
    1905  * Specifically, HTML and PHP tags are stripped. Further actions can be added
    1906  * via the plugin API. If $title is empty and $fallback_title is set, the latter
    1907  * will be used.
     1906 * Further actions can be added
     1907 * via the plugin API. If the sanitized version of $title is empty, and `$fallback_title` is set,
     1908 * `$fallback_title` will be returned.
    19081909 *
    19091910 * @since 1.0.0
    19101911 *
     
    19511952}
    19521953
    19531954/**
    1954  * Sanitizes a title, replacing whitespace and a few other characters with dashes.
     1955 * Sanitizes a string
    19551956 *
    1956  * Limits the output to alphanumeric characters, underscore (_) and dash (-).
    1957  * Whitespace becomes a dash.
     1957 * Output is limited to to alphanumeric characters, underscore (_) and dash (-).
     1958 * Various characters (including whitespace) are convered to dashes.
    19581959 *
    19591960 * @since 1.2.0
    19601961 *
     
    20082009                $title = str_replace( '%c3%97', 'x', $title );
    20092010        }
    20102011
    2011         $title = preg_replace('/&.+?;/', '', $title); // kill entities
     2012        // Remove HTML entities.
     2013        $title = preg_replace('/&.+?;/', '', $title);
    20122014        $title = str_replace('.', '-', $title);
    20132015
    20142016        $title = preg_replace('/[^%a-z0-9 _-]/', '', $title);