WordPress.org

Make WordPress Core

Ticket #19602: 19602.diff

File 19602.diff, 4.8 KB (added by nacin, 4 years ago)
  • wp-includes/formatting.php

     
    2828 */ 
    2929function wptexturize($text) { 
    3030        global $wp_cockneyreplace; 
    31         static $opening_quote, $closing_quote, $en_dash, $em_dash, $default_no_texturize_tags, $default_no_texturize_shortcodes, $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements; 
     31        static $opening_quote, $closing_quote, $opening_single_quote, $closing_single_quote, $en_dash, $em_dash, 
     32                $apos, $prime, $double_prime, $default_no_texturize_tags, $default_no_texturize_shortcodes, 
     33                $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements; 
    3234 
    3335        // No need to set up these static variables more than once 
    3436        if ( empty( $opening_quote ) ) { 
    35                 /* translators: opening curly quote */ 
    36                 $opening_quote = _x('“', 'opening curly quote'); 
    37                 /* translators: closing curly quote */ 
    38                 $closing_quote = _x('”', 'closing curly quote'); 
     37                /* translators: opening curly double quote */ 
     38                $opening_quote = _x( '“', 'opening curly double quote' ); 
     39                /* translators: closing curly double quote */ 
     40                $closing_quote = _x( '”', 'closing curly double quote' ); 
     41 
     42                /* translators: apostrophe, for example in 'cause or can't */ 
     43                $apos = _x( '’', 'apostrophe' ); 
     44 
     45                /* translators: prime, for example in 9' (nine feet) */ 
     46                $prime = _x( '′', 'prime' ); 
     47                /* translators: double prime, for example in 9" (nine inches) */ 
     48                $double_prime = _x( '″', 'double prime' ); 
     49 
     50                /* translators: opening curly single quote */ 
     51                $opening_single_quote = _x( '‘', 'opening curly single quote' ); 
     52                /* translators: closing curly single quote */ 
     53                $closing_single_quote = _x( '’', 'closing curly single quote' ); 
     54 
    3955                /* translators: en dash */ 
    40                 $en_dash = _x('–', 'en dash'); 
     56                $en_dash = _x( '–', 'en dash' ); 
    4157                /* translators: em dash */ 
    42                 $em_dash = _x('—', 'em dash'); 
     58                $em_dash = _x( '—', 'em dash' ); 
    4359 
    4460                $default_no_texturize_tags = array('pre', 'code', 'kbd', 'style', 'script', 'tt'); 
    4561                $default_no_texturize_shortcodes = array('code'); 
     
    4965                        $cockney = array_keys($wp_cockneyreplace); 
    5066                        $cockneyreplace = array_values($wp_cockneyreplace); 
    5167                } else { 
    52                         $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause"); 
    53                         $cockneyreplace = array("’tain’t","’twere","’twas","’tis","’twill","’til","’bout","’nuff","’round","’cause"); 
     68                        $cockney = array( "'tain't", "'twere", "'twas", "'tis", "'twill", "'til", "'bout", "'nuff", "'round", "'cause" ); 
     69                        $cockneyreplace = array( $apos . "tain" . $apos . "t", $apos . "twere", $apos . "twas", $apos . "tis", $apos . "twill", $apos . "til", $apos . "bout", $apos . "nuff", $apos . "round", $apos . "cause" ); 
    5470                } 
    5571 
    56                 $static_characters = array_merge( array('---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)'), $cockney ); 
    57                 $static_replacements = array_merge( array($em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™'), $cockneyreplace ); 
     72                $static_characters = array_merge( array( '---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)' ), $cockney ); 
     73                $static_replacements = array_merge( array( $em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); 
    5874 
    59                 $dynamic_characters = array('/\'(\d\d(?:&#8217;|\')?s)/', '/\'(\d)/', '/(\s|\A|[([{<]|")\'/', '/(\d)"/', '/(\d)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A|[([{<])"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/\b(\d+)x(\d+)\b/'); 
    60                 $dynamic_replacements = array('&#8217;$1','&#8217;$1', '$1&#8216;', '$1&#8243;', '$1&#8242;', '$1&#8217;$2', '$1' . $opening_quote . '$2', $closing_quote . '$1', '&#8217;$1', '$1&#215;$2'); 
     75                $dynamic_characters = array( 
     76                        '/\'(\d\d(?:&#8217;|\')?s)/', // '99's 
     77                        '/\'(\d)/', // '99 (year) 
     78                        '/(\s|\A|[([{<]|")\'/', // opening single quote, even after (, {, <, [, etc. 
     79                        '/(\d)"/', // 9" (double prime) 
     80                        '/(\d)\'/', // 9' (prime) 
     81                        '/(\S)\'([^\'\s])/', // Matt's (apos) 
     82                        '/(\s|\A|[([{<])"(?!\s)/', // opening double quote, even after (, {, <, [, etc. 
     83                        '/"(\s|\S|\Z)/', // closing double quote 
     84                        '/\'([\s.]|\Z)/', // closing single quote 
     85                        '/\b(\d+)x(\d+)\b/' // 9 x 9 (times) 
     86                ); 
     87 
     88                $dynamic_replacements = array( $apos . '$1', $apos . '$1', '$1' . $opening_single_quote, '$1' . $double_prime, '$1' . $prime, 
     89                        '$1' . $apos . '$2', '$1' . $opening_quote . '$2', $closing_quote . '$1', $closing_single_quote . '$1', '$1&#215;$2' ); 
    6190        } 
    6291 
    6392        // Transform into regexp sub-expression used in _wptexturize_pushpop_element