WordPress.org

Make WordPress Core

Ticket #32444: 32444.4.diff

File 32444.4.diff, 31.1 KB (added by wonderboymusic, 6 years ago)
  • src/wp-includes/formatting.php

     
    2121 * Code within certain html blocks are skipped.
    2222 *
    2323 * @since 0.71
    24  * @uses $wp_cockneyreplace Array of formatted entities for certain common phrases
    2524 *
     25 * @global array $wp_cockneyreplace Array of formatted entities for certain common phrases
     26 * @global array $shortcode_tags
     27 * @staticvar array $static_characters
     28 * @staticvar array $static_replacements
     29 * @staticvar array $dynamic_characters
     30 * @staticvar array $dynamic_replacements
     31 * @staticvar array $default_no_texturize_tags
     32 * @staticvar array $default_no_texturize_shortcodes
     33 * @staticvar bool  $run_texturize
     34 *
    2635 * @param string $text The text to be formatted
    27  * @param bool $reset Set to true for unit testing. Translated patterns will reset.
     36 * @param bool   $reset Set to true for unit testing. Translated patterns will reset.
    2837 * @return string The string replaced with html entities
    2938 */
    30 function wptexturize($text, $reset = false) {
     39function wptexturize( $text, $reset = false ) {
    3140        global $wp_cockneyreplace, $shortcode_tags;
    3241        static $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements,
    3342                $default_no_texturize_tags, $default_no_texturize_shortcodes, $run_texturize = true;
     
    297306        $text = implode( '', $textarr );
    298307
    299308        // Replace each & with & unless it already looks like an entity.
    300         $text = preg_replace('/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $text);
    301 
    302         return $text;
     309        return preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $text );
    303310}
    304311
    305312/**
     
    313320 * @access private
    314321 *
    315322 * @param string $text Text to check. Must be a tag like `<html>` or `[shortcode]`.
    316  * @param array $stack List of open tag elements.
    317  * @param array $disabled_elements The tag names to match against. Spaces are not allowed in tag names.
     323 * @param array  $stack List of open tag elements.
     324 * @param array  $disabled_elements The tag names to match against. Spaces are not allowed in tag names.
    318325 */
    319 function _wptexturize_pushpop_element($text, &$stack, $disabled_elements) {
     326function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) {
    320327        // Is it an opening tag or closing tag?
    321328        if ( '/' !== $text[1] ) {
    322329                $opening_tag = true;
     
    370377 *                    after paragraphing. Default true.
    371378 * @return string Text which has been converted into correct paragraph tags.
    372379 */
    373 function wpautop($pee, $br = true) {
     380function wpautop( $pee, $br = true ) {
    374381        $pre_tags = array();
    375382
    376383        if ( trim($pee) === '' )
     
    419426        $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
    420427
    421428        // Standardize newline characters to "\n".
    422         $pee = str_replace(array("\r\n", "\r"), "\n", $pee); 
     429        $pee = str_replace(array("\r\n", "\r"), "\n", $pee);
    423430
    424431        // Collapse line breaks before and after <option> elements so they don't get autop'd.
    425432        if ( strpos( $pee, '<option' ) !== false ) {
     
    462469        }
    463470
    464471        // Under certain strange conditions it could create a P of entirely whitespace.
    465         $pee = preg_replace('|<p>\s*</p>|', '', $pee); 
     472        $pee = preg_replace('|<p>\s*</p>|', '', $pee);
    466473
    467474        // Add a closing <p> inside <div>, <address>, or <form> tag if missing.
    468475        $pee = preg_replace('!<p>([^<]+)</(div|address|form)>!', "<p>$1</p></$2>", $pee);
    469        
     476
    470477        // If an opening or closing block element tag is wrapped in a <p>, unwrap it.
    471         $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); 
    472        
     478        $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
     479
    473480        // In some cases <li> may get wrapped in <p>, fix them.
    474         $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); 
    475        
     481        $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee);
     482
    476483        // If a <blockquote> is wrapped with a <p>, move it inside the <blockquote>.
    477484        $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
    478485        $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
    479        
     486
    480487        // If an opening or closing block element tag is preceded by an opening <p> tag, remove it.
    481488        $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
    482        
     489
    483490        // If an opening or closing block element tag is followed by a closing <p> tag, remove it.
    484491        $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
    485492
     
    489496                $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee);
    490497
    491498                // Replace any new line characters that aren't preceded by a <br /> with a <br />.
    492                 $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); 
     499                $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee);
    493500
    494501                // Replace newline placeholders with newlines.
    495502                $pee = str_replace('<WPPreserveNewline />', "\n", $pee);
     
    497504
    498505        // If a <br /> tag is after an opening or closing block tag, remove it.
    499506        $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);
    500        
     507
    501508        // If a <br /> tag is before a subset of opening or closing block tags, remove it.
    502509        $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
    503510        $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
     
    519526 * @return string
    520527 */
    521528function _autop_newline_preservation_helper( $matches ) {
    522         return str_replace("\n", "<WPPreserveNewline />", $matches[0]);
     529        return str_replace( "\n", "<WPPreserveNewline />", $matches[0] );
    523530}
    524531
    525532/**
     
    529536 *
    530537 * @since 2.9.0
    531538 *
     539 * @global array $shortcode_tags
     540 *
    532541 * @param string $pee The content.
    533542 * @return string The filtered content.
    534543 */
     
    589598 * @param string $str The string to be checked
    590599 * @return bool True if $str fits a UTF-8 model, false otherwise.
    591600 */
    592 function seems_utf8($str) {
     601function seems_utf8( $str ) {
    593602        mbstring_binary_safe_encoding();
    594603        $length = strlen($str);
    595604        reset_mbstring_encoding();
     
    621630 * @since 1.2.2
    622631 * @access private
    623632 *
    624  * @param string $string The text which is to be encoded.
    625  * @param int $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
    626  * @param string $charset Optional. The character encoding of the string. Default is false.
    627  * @param boolean $double_encode Optional. Whether to encode existing html entities. Default is false.
     633 * @staticvar string|false $_charset
     634 *
     635 * @param string $string         The text which is to be encoded.
     636 * @param int    $quote_style    Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
     637 * @param string $charset        Optional. The character encoding of the string. Default is false.
     638 * @param bool   $double_encode  Optional. Whether to encode existing html entities. Default is false.
    628639 * @return string The encoded text with HTML entities.
    629640 */
    630641function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {
     
    701712 *
    702713 * @since 2.8.0
    703714 *
    704  * @param string $string The text which is to be decoded.
    705  * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old _wp_specialchars() values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.
     715 * @param string     $string The text which is to be decoded.
     716 * @param string|int $quote_style Optional. Converts double quotes if set to ENT_COMPAT,
     717 *                                both single and double if set to ENT_QUOTES or
     718 *                                none if set to ENT_NOQUOTES.
     719 *                                Also compatible with old _wp_specialchars() values;
     720 *                                converting single quotes if set to 'single',
     721 *                                double if set to 'double' or both if otherwise set.
     722 *                                Default is ENT_NOQUOTES.
    706723 * @return string The decoded text without HTML entities.
    707724 */
    708725function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) {
     
    758775 *
    759776 * @since 2.8.0
    760777 *
    761  * @param string $string The text which is to be checked.
    762  * @param boolean $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
     778 * @staticvar bool $is_utf8
     779 * @staticvar bool $utf8_pcre
     780 *
     781 * @param string  $string The text which is to be checked.
     782 * @param bool    $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.
    763783 * @return string The checked text.
    764784 */
    765785function wp_check_invalid_utf8( $string, $strip = false ) {
     
    807827 * @since 1.5.0
    808828 *
    809829 * @param string $utf8_string
    810  * @param int $length Max length of the string
     830 * @param int    $length Max length of the string
    811831 * @return string String with Unicode encoded for URI.
    812832 */
    813833function utf8_uri_encode( $utf8_string, $length = 0 ) {
     
    870890 * @param string $string Text that might have accent characters
    871891 * @return string Filtered string with replaced "nice" characters.
    872892 */
    873 function remove_accents($string) {
     893function remove_accents( $string ) {
    874894        if ( !preg_match('/[\x80-\xff]/', $string) )
    875895                return $string;
    876896
     
    11871207 * @since 2.0.0
    11881208 *
    11891209 * @param string $username The username to be sanitized.
    1190  * @param bool $strict If set limits $username to specific characters. Default false.
     1210 * @param bool   $strict  If set limits $username to specific characters. Default false.
    11911211 * @return string The sanitized username, after passing through filters.
    11921212 */
    11931213function sanitize_user( $username, $strict = false ) {
     
    12531273 *
    12541274 * @since 1.0.0
    12551275 *
    1256  * @param string $title The string to be sanitized.
     1276 * @param string $title          The string to be sanitized.
    12571277 * @param string $fallback_title Optional. A title to use if $title is empty.
    1258  * @param string $context Optional. The operation for which the string is sanitized
     1278 * @param string $context        Optional. The operation for which the string is sanitized
    12591279 * @return string The sanitized string.
    12601280 */
    12611281function sanitize_title( $title, $fallback_title = '', $context = 'save' ) {
     
    13031323 *
    13041324 * @since 1.2.0
    13051325 *
    1306  * @param string $title The title to be sanitized.
     1326 * @param string $title     The title to be sanitized.
    13071327 * @param string $raw_title Optional. Not used.
    1308  * @param string $context Optional. The operation for which the string is sanitized.
     1328 * @param string $context   Optional. The operation for which the string is sanitized.
    13091329 * @return string The sanitized title.
    13101330 */
    13111331function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'display' ) {
     
    13721392 * @since 2.5.1
    13731393 *
    13741394 * @param string $orderby Order by clause to be validated.
    1375  * @return string|bool Returns $orderby if valid, false otherwise.
     1395 * @return string|false Returns $orderby if valid, false otherwise.
    13761396 */
    13771397function sanitize_sql_orderby( $orderby ) {
    13781398        if ( preg_match( '/^\s*(([a-z0-9_]+|`[a-z0-9_]+`)(\s+(ASC|DESC))?\s*(,\s*(?=[a-z0-9_`])|$))+$/i', $orderby ) || preg_match( '/^\s*RAND\(\s*\)\s*$/i', $orderby ) ) {
     
    13911411 *
    13921412 * @since 2.8.0
    13931413 *
    1394  * @param string $class The classname to be sanitized
     1414 * @param string $class    The classname to be sanitized
    13951415 * @param string $fallback Optional. The value to return if the sanitization ends up as an empty string.
    13961416 *      Defaults to an empty string.
    13971417 * @return string The sanitized value
     
    14271447 *
    14281448 * @since 0.71
    14291449 *
    1430  * @param string $content String of characters to be converted.
     1450 * @param string $content    String of characters to be converted.
    14311451 * @param string $deprecated Not used.
    14321452 * @return string Converted string.
    14331453 */
    1434 function convert_chars($content, $deprecated = '') {
     1454function convert_chars( $content, $deprecated = '' ) {
    14351455        if ( !empty( $deprecated ) )
    14361456                _deprecated_argument( __FUNCTION__, '0.71' );
    14371457
     
    14931513 *
    14941514 * @since 0.71
    14951515 *
    1496  * @param string $text Text to be balanced
    1497  * @param bool $force If true, forces balancing, ignoring the value of the option. Default false.
     1516 * @param string $text  Text to be balanced
     1517 * @param bool   $force If true, forces balancing, ignoring the value of the option. Default false.
    14981518 * @return string Balanced text
    14991519 */
    15001520function balanceTags( $text, $force = false ) {
     
    16451665 *
    16461666 * @since 0.71
    16471667 *
    1648  * @param string $content The text about to be edited.
    1649  * @param bool $richedit Whether the $content should not pass through htmlspecialchars(). Default false (meaning it will be passed).
     1668 * @param string $content  The text about to be edited.
     1669 * @param bool   $richedit Whether the $content should not pass through htmlspecialchars(). Default false (meaning it will be passed).
    16501670 * @return string The text after the filter (and possibly htmlspecialchars()) has been run.
    16511671 */
    16521672function format_to_edit( $content, $richedit = false ) {
     
    16761696 *
    16771697 * @since 0.71
    16781698 *
    1679  * @param mixed $number Number to append zeros to if not greater than threshold.
    1680  * @param int $threshold Digit places number needs to be to not have zeros added.
     1699 * @param int $number    Number to append zeros to if not greater than threshold.
     1700 * @param int $threshold  Digit places number needs to be to not have zeros added.
    16811701 * @return string Adds leading zeros to number if needed.
    16821702 */
    1683 function zeroise($number, $threshold) {
    1684         return sprintf('%0'.$threshold.'s', $number);
     1703function zeroise( $number, $threshold ) {
     1704        return sprintf( '%0' . $threshold . 's', $number );
    16851705}
    16861706
    16871707/**
     
    16921712 * @param string $string Value to which backslashes will be added.
    16931713 * @return string String with backslashes inserted.
    16941714 */
    1695 function backslashit($string) {
     1715function backslashit( $string ) {
    16961716        if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' )
    16971717                $string = '\\\\' . $string;
    16981718        return addcslashes( $string, 'A..Za..z' );
     
    17601780 * @param mixed $value The value to be stripped.
    17611781 * @return mixed Stripped value.
    17621782 */
    1763 function stripslashes_deep($value) {
     1783function stripslashes_deep( $value ) {
    17641784        if ( is_array($value) ) {
    17651785                $value = array_map('stripslashes_deep', $value);
    17661786        } elseif ( is_object($value) ) {
     
    17841804 * @param array|string $value The array or string to be encoded.
    17851805 * @return array|string $value The encoded array (or string from the callback).
    17861806 */
    1787 function urlencode_deep($value) {
    1788         $value = is_array($value) ? array_map('urlencode_deep', $value) : urlencode($value);
    1789         return $value;
     1807function urlencode_deep( $value ) {
     1808        return is_array( $value ) ? array_map( 'urlencode_deep', $value ) : urlencode( $value );
    17901809}
    17911810
    17921811/**
     
    18071826 * @since 0.71
    18081827 *
    18091828 * @param string $email_address Email address.
    1810  * @param int $hex_encoding Optional. Set to 1 to enable hex encoding.
     1829 * @param int    $hex_encoding Optional. Set to 1 to enable hex encoding.
    18111830 * @return string Converted email address.
    18121831 */
    18131832function antispambot( $email_address, $hex_encoding = 0 ) {
     
    18231842                }
    18241843        }
    18251844
    1826         $email_no_spam_address = str_replace( '@', '&#64;', $email_no_spam_address );
    1827 
    1828         return $email_no_spam_address;
     1845        return str_replace( '@', '&#64;', $email_no_spam_address );
    18291846}
    18301847
    18311848/**
     
    18401857 * @param array $matches Single Regex Match.
    18411858 * @return string HTML A element with URI address.
    18421859 */
    1843 function _make_url_clickable_cb($matches) {
     1860function _make_url_clickable_cb( $matches ) {
    18441861        $url = $matches[2];
    18451862
    18461863        if ( ')' == $matches[3] && strpos( $url, '(' ) ) {
     
    18771894 * @param array $matches Single Regex Match.
    18781895 * @return string HTML A element with URL address.
    18791896 */
    1880 function _make_web_ftp_clickable_cb($matches) {
     1897function _make_web_ftp_clickable_cb( $matches ) {
    18811898        $ret = '';
    18821899        $dest = $matches[2];
    18831900        $dest = 'http://' . $dest;
     
    19051922 * @param array $matches Single Regex Match.
    19061923 * @return string HTML A element with email address.
    19071924 */
    1908 function _make_email_clickable_cb($matches) {
     1925function _make_email_clickable_cb( $matches ) {
    19091926        $email = $matches[2] . '@' . $matches[3];
    19101927        return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
    19111928}
     
    19761993        }
    19771994
    19781995        // Cleanup of accidental links within links
    1979         $r = preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
    1980         return $r;
     1996        return preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r );
    19811997}
    19821998
    19831999/**
     
    20062022 * @access private
    20072023 *
    20082024 * @param string $string The string to split.
    2009  * @param int $goal The desired chunk length.
     2025 * @param int    $goal  The desired chunk length.
    20102026 * @return array Numeric array of chunks.
    20112027 */
    20122028function _split_str_by_whitespace( $string, $goal ) {
     
    20482064        // This is a pre save filter, so text is already escaped.
    20492065        $text = stripslashes($text);
    20502066        $text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text);
    2051         $text = wp_slash($text);
    2052         return $text;
     2067        return wp_slash( $text );
    20532068}
    20542069
    20552070/**
     
    20762091 * Looks up one smiley code in the $wpsmiliestrans global array and returns an
    20772092 * `<img>` string for that smiley.
    20782093 *
    2079  * @global array $wpsmiliestrans
    20802094 * @since 2.8.0
    20812095 *
     2096 * @global array $wpsmiliestrans
     2097 *
    20822098 * @param array $matches Single match. Smiley code to convert to image.
    20832099 * @return string Image string for smiley.
    20842100 */
     
    21212137 * used in the function isn't empty.
    21222138 *
    21232139 * @since 0.71
    2124  * @uses $wp_smiliessearch
    21252140 *
     2141 * @global string|array $wp_smiliessearch
     2142 *
    21262143 * @param string $text Content to convert smilies from text.
    21272144 * @return string Converted content with text smilies replaced with images.
    21282145 */
     
    21722189 *
    21732190 * @since 0.71
    21742191 *
    2175  * @param string $email Email address to verify.
    2176  * @param boolean $deprecated Deprecated.
     2192 * @param string $email      Email address to verify.
     2193 * @param bool  $deprecated Deprecated.
    21772194 * @return string|bool Either false or the valid email address.
    21782195 */
    21792196function is_email( $email, $deprecated = false ) {
     
    22652282 * @param string $string Subject line
    22662283 * @return string Converted string to ASCII
    22672284 */
    2268 function wp_iso_descrambler($string) {
     2285function wp_iso_descrambler( $string ) {
    22692286        /* this may only work with iso-8859-1, I'm afraid */
    22702287        if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) {
    22712288                return $string;
    22722289        } else {
    22732290                $subject = str_replace('_', ' ', $matches[2]);
    2274                 $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject);
    2275                 return $subject;
     2291                return preg_replace_callback( '#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject );
    22762292        }
    22772293}
    22782294
     
    23592375 * @param string $timezone Either 'Z' for 0 offset or '±hhmm'.
    23602376 * @return int|float The offset in seconds.
    23612377 */
    2362 function iso8601_timezone_to_offset($timezone) {
     2378function iso8601_timezone_to_offset( $timezone ) {
    23632379        // $timezone is either 'Z' or '[+|-]hhmm'
    23642380        if ($timezone == 'Z') {
    23652381                $offset = 0;
     
    23782394 * @since 1.5.0
    23792395 *
    23802396 * @param string $date_string Date and time in ISO 8601 format {@link http://en.wikipedia.org/wiki/ISO_8601}.
    2381  * @param string $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'.
     2397 * @param string $timezone    Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'.
    23822398 * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s.
    23832399 */
    2384 function iso8601_to_datetime($date_string, $timezone = 'user') {
     2400function iso8601_to_datetime( $date_string, $timezone = 'user' ) {
    23852401        $timezone = strtolower($timezone);
    23862402
    23872403        if ($timezone == 'gmt') {
     
    24162432 * @param string $text Content to replace links to open in a new window.
    24172433 * @return string Content that has filtered links.
    24182434 */
    2419 function popuplinks($text) {
     2435function popuplinks( $text ) {
    24202436        $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text);
    24212437        return $text;
    24222438}
     
    25322548 * @since 1.5.0
    25332549 *
    25342550 * @param int $from Unix timestamp from which the difference begins.
    2535  * @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set.
     2551 * @param int $to   Optional. Unix timestamp to end the time difference. Default becomes time() if not set.
    25362552 * @return string Human readable time difference.
    25372553 */
    25382554function human_time_diff( $from, $to = '' ) {
     
    26032619 * @param string $text Optional. The excerpt. If set to empty, an excerpt is generated.
    26042620 * @return string The excerpt.
    26052621 */
    2606 function wp_trim_excerpt($text = '') {
     2622function wp_trim_excerpt( $text = '' ) {
    26072623        $raw_excerpt = $text;
    26082624        if ( '' == $text ) {
    26092625                $text = get_the_content('');
     
    26522668 *
    26532669 * @since 3.3.0
    26542670 *
    2655  * @param string $text Text to trim.
    2656  * @param int $num_words Number of words. Default 55.
    2657  * @param string $more Optional. What to append if $text needs to be trimmed. Default '&hellip;'.
     2671 * @param string $text      Text to trim.
     2672 * @param int    $num_words Number of words. Default 55.
     2673 * @param string $more      Optional. What to append if $text needs to be trimmed. Default '&hellip;'.
    26582674 * @return string Trimmed text.
    26592675 */
    26602676function wp_trim_words( $text, $num_words = 55, $more = null ) {
     
    27012717 * @param string $text The text within which entities will be converted.
    27022718 * @return string Text with converted entities.
    27032719 */
    2704 function ent2ncr($text) {
     2720function ent2ncr( $text ) {
    27052721
    27062722        /**
    27072723         * Filter text before named entities are converted into numbered entities.
     
    29903006 * @param string $text The text to be formatted.
    29913007 * @return string The formatted text after filter is applied.
    29923008 */
    2993 function wp_richedit_pre($text) {
     3009function wp_richedit_pre( $text ) {
    29943010        if ( empty( $text ) ) {
    29953011                /**
    29963012                 * Filter text returned for the rich text editor.
     
    30283044 * @param string $output The text to be formatted.
    30293045 * @return string Formatted text after filter applied.
    30303046 */
    3031 function wp_htmledit_pre($output) {
     3047function wp_htmledit_pre( $output ) {
    30323048        if ( !empty($output) )
    30333049                $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > &
    30343050
     
    30523068 * @since 2.8.1
    30533069 * @access private
    30543070 *
    3055  * @param string|array $search The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
    3056  * @param string $subject The string being searched and replaced on, otherwise known as the haystack.
     3071 * @param string|array $search  The value being searched for, otherwise known as the needle.
     3072 *                              An array may be used to designate multiple needles.
     3073 * @param string       $subject The string being searched and replaced on, otherwise known as the haystack.
    30573074 * @return string The string with the replaced svalues.
    30583075 */
    30593076function _deep_replace( $search, $subject ) {
     
    30753092 * is preparing an array for use in an IN clause.
    30763093 *
    30773094 * @since 2.8.0
     3095 *
     3096 * @global wpdb $wpdb
     3097 *
    30783098 * @param string|array $data Unescaped data
    30793099 * @return string|array Escaped data
    30803100 */
     
    30923112 *
    30933113 * @since 2.8.0
    30943114 *
    3095  * @param string $url The URL to be cleaned.
    3096  * @param array $protocols Optional. An array of acceptable protocols.
    3097  *              Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn' if not set.
    3098  * @param string $_context Private. Use esc_url_raw() for database usage.
     3115 * @param string $url       The URL to be cleaned.
     3116 * @param array  $protocols Optional. An array of acceptable protocols.
     3117 *                                  Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto',
     3118 *                          'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms',
     3119 *                          'rtsp', 'svn' if not set.
     3120 * @param string $_context  Private. Use esc_url_raw() for database usage.
    30993121 * @return string The cleaned $url after the 'clean_url' filter is applied.
    31003122 */
    31013123function esc_url( $url, $protocols = null, $_context = 'display' ) {
     
    31493171 *
    31503172 * @since 2.8.0
    31513173 *
    3152  * @param string $url The URL to be cleaned.
    3153  * @param array $protocols An array of acceptable protocols.
     3174 * @param string $url       The URL to be cleaned.
     3175 * @param array  $protocols An array of acceptable protocols.
    31543176 * @return string The cleaned URL.
    31553177 */
    31563178function esc_url_raw( $url, $protocols = null ) {
     
    31673189 * @param string $myHTML The text to be converted.
    31683190 * @return string Converted text.
    31693191 */
    3170 function htmlentities2($myHTML) {
     3192function htmlentities2( $myHTML ) {
    31713193        $translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES );
    31723194        $translation_table[chr(38)] = '&';
    31733195        return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&amp;", strtr($myHTML, $translation_table) );
     
    32843306 * @param string $tag_name
    32853307 * @return string
    32863308 */
    3287 function tag_escape($tag_name) {
     3309function tag_escape( $tag_name ) {
    32883310        $safe_tag = strtolower( preg_replace('/[^a-zA-Z0-9_:]/', '', $tag_name) );
    32893311        /**
    32903312         * Filter a string cleaned and escaped for output as an HTML tag.
     
    33213343 *
    33223344 * @since 2.0.5
    33233345 *
     3346 * @global wpdb $wpdb
     3347 *
    33243348 * @param string $option The name of the option.
    3325  * @param string $value The unsanitised value.
     3349 * @param string $value  The unsanitised value.
    33263350 * @return string Sanitized value.
    33273351 */
    3328 function sanitize_option($option, $value) {
     3352function sanitize_option( $option, $value ) {
    33293353        global $wpdb;
    33303354
    33313355        $original_value = $value;
     
    35233547         * @param string $option         The option name.
    35243548         * @param string $original_value The original value passed to the function.
    35253549         */
    3526         $value = apply_filters( "sanitize_option_{$option}", $value, $option, $original_value );
    3527 
    3528         return $value;
     3550        return apply_filters( "sanitize_option_{$option}", $value, $option, $original_value );
    35293551}
    35303552
    35313553/**
     
    35373559 * @since 2.2.1
    35383560 *
    35393561 * @param string $string The string to be parsed.
    3540  * @param array $array Variables will be stored in this array.
     3562 * @param array  $array Variables will be stored in this array.
    35413563 */
    35423564function wp_parse_str( $string, &$array ) {
    35433565        parse_str( $string, $array );
     
    35873609 * @since 2.5.0
    35883610 * @link http://www.php.net/sprintf
    35893611 *
    3590  * @param string $pattern The string which formatted args are inserted.
     3612 * @param string $pattern   The string which formatted args are inserted.
    35913613 * @param mixed  $args ,... Arguments to be formatted into the $pattern string.
    35923614 * @return string The formatted string.
    35933615 */
     
    36623684 * @since 2.5.0
    36633685 *
    36643686 * @param string $pattern Content containing '%l' at the beginning.
    3665  * @param array $args List items to prepend to the content and replace '%l'.
     3687 * @param array  $args    List items to prepend to the content and replace '%l'.
    36663688 * @return string Localized list items and rest of the content.
    36673689 */
    3668 function wp_sprintf_l($pattern, $args) {
     3690function wp_sprintf_l( $pattern, $args ) {
    36693691        // Not a match
    36703692        if ( substr($pattern, 0, 2) != '%l' )
    36713693                return $pattern;
     
    37203742 *
    37213743 * @since 2.5.0
    37223744 *
    3723  * @param string $str String to get the excerpt from.
    3724  * @param integer $count Maximum number of characters to take.
    3725  * @param string $more Optional. What to append if $str needs to be trimmed. Defaults to empty string.
     3745 * @param string $str   String to get the excerpt from.
     3746 * @param int    $count Maximum number of characters to take.
     3747 * @param string $more  Optional. What to append if $str needs to be trimmed. Defaults to empty string.
    37263748 * @return string The excerpt.
    37273749 */
    37283750function wp_html_excerpt( $str, $count, $more = null ) {
     
    37453767 *
    37463768 * @since 2.7.0
    37473769 *
     3770 * @global string $_links_add_base
     3771 *
    37483772 * @param string $content String to search for links in.
    3749  * @param string $base The base URL to prefix to links.
    3750  * @param array $attrs The attributes which should be processed.
     3773 * @param string $base    The base URL to prefix to links.
     3774 * @param array  $attrs  The attributes which should be processed.
    37513775 * @return string The processed content.
    37523776 */
    37533777function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) {
     
    37633787 * @since 2.7.0
    37643788 * @access private
    37653789 *
     3790 * @global string $_links_add_base
     3791 *
    37663792 * @param string $m The matched link.
    37673793 * @return string The processed link.
    37683794 */
    3769 function _links_add_base($m) {
     3795function _links_add_base( $m ) {
    37703796        global $_links_add_base;
    37713797        //1 = attribute name  2 = quotation mark  3 = URL
    37723798        return $m[1] . '=' . $m[2] .
     
    37873813 *
    37883814 * @since 2.7.0
    37893815 *
     3816 * @global string $_links_add_target
     3817 *
    37903818 * @param string $content String to search for links in.
    3791  * @param string $target The Target to add to the links.
    3792  * @param array $tags An array of tags to apply to.
     3819 * @param string $target  The Target to add to the links.
     3820 * @param array  $tags    An array of tags to apply to.
    37933821 * @return string The processed content.
    37943822 */
    37953823function links_add_target( $content, $target = '_blank', $tags = array('a') ) {
     
    38053833 * @since 2.7.0
    38063834 * @access private
    38073835 *
     3836 * @global string $_links_add_target
     3837 *
    38083838 * @param string $m The matched link.
    38093839 * @return string The processed link.
    38103840 */
     
    38393869 *
    38403870 * @since 2.9.0
    38413871 *
    3842  * @param string $string String containing HTML tags
    3843  * @param bool $remove_breaks optional Whether to remove left over line breaks and white space chars
     3872 * @param string $string        String containing HTML tags
     3873 * @param bool   $remove_breaks Optional. Whether to remove left over line breaks and white space chars
    38443874 * @return string The processed string.
    38453875 */
    38463876function wp_strip_all_tags($string, $remove_breaks = false) {
     
    38673897 * @param string $str
    38683898 * @return string
    38693899 */
    3870 function sanitize_text_field($str) {
     3900function sanitize_text_field( $str ) {
    38713901        $filtered = wp_check_invalid_utf8( $str );
    38723902
    38733903        if ( strpos($filtered, '<') !== false ) {
     
    39053935 *
    39063936 * @since 3.1.0
    39073937 *
    3908  * @param string $path A path.
     3938 * @param string $path   A path.
    39093939 * @param string $suffix If the filename ends in suffix this will also be cut off.
    39103940 * @return string
    39113941 */
     
    39193949 * Violating our coding standards for a good function name.
    39203950 *
    39213951 * @since 3.0.0
     3952 *
     3953 * @staticvar string|false $dblq
    39223954 */
    39233955function capital_P_dangit( $text ) {
    39243956        // Simple replacement for titles
     
    40354067 * @since 3.6.0
    40364068 *
    40374069 * @param string $content A string which might contain a URL.
    4038  * @return string The found URL.
     4070 * @return string|false The found URL.
    40394071 */
    40404072function get_url_in_content( $content ) {
    40414073        if ( empty( $content ) ) {
     
    40584090 *
    40594091 * @since 4.0.0
    40604092 *
     4093 * @staticvar string $spaces
     4094 *
    40614095 * @return string The spaces regexp.
    40624096 */
    40634097function wp_spaces_regexp() {
     
    40864120 * Print the important emoji-related styles.
    40874121 *
    40884122 * @since 4.2.0
     4123 *
     4124 * @staticvar bool $printed
    40894125 */
    40904126function print_emoji_styles() {
    40914127        static $printed = false;
     
    41134149<?php
    41144150}
    41154151
     4152/**
     4153 *
     4154 * @global string $wp_version
     4155 * @staticvar bool $printed
     4156 */
    41164157function print_emoji_detection_script() {
    41174158        global $wp_version;
    41184159        static $printed = false;