Make WordPress Core

Ticket #32787: 32787.patch

File 32787.patch, 4.8 KB (added by johnjamesjacoby, 9 years ago)
  • src/wp-includes/default-filters.php

    diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
    index f7bfeb5..32fa8f6 100644
     
    117117        add_filter( $filter, 'shortcode_unautop');
    118118}
    119119
     120// Clickables
     121add_filter( 'make_clickable', 'make_urls_clickable_filter',   2 );
     122add_filter( 'make_clickable', 'make_ftps_clickable_filter',   4 );
     123add_filter( 'make_clickable', 'make_emails_clickable_filter', 6 );
     124
    120125// Format for RSS
    121126add_filter( 'term_name_rss', 'convert_chars' );
    122127
  • src/wp-includes/formatting.php

    diff --git src/wp-includes/formatting.php src/wp-includes/formatting.php
    index d285239..3c04b4a 100644
     
    22202220                                }
    22212221                        }
    22222222                } else {
    2223                         $ret = " $piece "; // Pad with whitespace to simplify the regexes
    2224 
    2225                         $url_clickable = '~
    2226                                 ([\\s(<.,;:!?])                                        # 1: Leading whitespace, or punctuation
    2227                                 (                                                      # 2: URL
    2228                                         [\\w]{1,20}+://                                # Scheme and hier-part prefix
    2229                                         (?=\S{1,2000}\s)                               # Limit to URLs less than about 2000 characters long
    2230                                         [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+         # Non-punctuation URL character
    2231                                         (?:                                            # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character
    2232                                                 [\'.,;:!?)]                            # Punctuation URL character
    2233                                                 [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character
    2234                                         )*
    2235                                 )
    2236                                 (\)?)                                                  # 3: Trailing closing parenthesis (for parethesis balancing post processing)
    2237                         ~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character.
    2238                               // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.
    2239 
    2240                         $ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret );
    2241 
    2242                         $ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );
    2243                         $ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret );
    2244 
     2223                        $ret = " {$piece} "; // Pad with whitespace to simplify the regexes
     2224                        $ret = apply_filters( 'make_clickable', $ret, $text );
    22452225                        $ret = substr( $ret, 1, -1 ); // Remove our whitespace padding.
    22462226                        $r .= $ret;
    22472227                }
     
    22522232}
    22532233
    22542234/**
     2235 * Make URLs clickable in content areas
     2236 *
     2237 * @since 4.6.0
     2238 * @access private
     2239 *
     2240 * @param  string $text
     2241 * @return string
     2242 */
     2243function make_urls_clickable_filter( $text = '' ) {
     2244        $url_clickable = '~
     2245                ([\\s(<.,;:!?])                                # 1: Leading whitespace, or punctuation
     2246                (                                              # 2: URL
     2247                        [\\w]{1,20}+://                            # Scheme and hier-part prefix
     2248                        (?=\S{1,2000}\s)                           # Limit to URLs less than about 2000 characters long
     2249                        [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+     # Non-punctuation URL character
     2250                        (?:                                        # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character
     2251                                [\'.,;:!?)]                            # Punctuation URL character
     2252                                [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character
     2253                        )*
     2254                )
     2255                (\)?)                                          # 3: Trailing closing parenthesis (for parethesis balancing post processing)
     2256        ~xS';
     2257
     2258        // The regex is a non-anchored pattern and does not have a single fixed starting character.
     2259        // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.
     2260        return preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $text );
     2261}
     2262
     2263/**
     2264 * Make FTP clickable in content areas
     2265 *
     2266 * @since 4.6.0
     2267 * @access private
     2268 *
     2269 * @param  string $text
     2270 * @return string
     2271 */
     2272function make_ftps_clickable_filter( $text = '' ) {
     2273        return preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $text );
     2274}
     2275
     2276/**
     2277 * Make emails clickable in content areas
     2278 *
     2279 * @since 4.6.0
     2280 * @access private
     2281 *
     2282 * @param  string $text
     2283 * @return string
     2284 */
     2285function make_emails_clickable_filter( $text = '' ) {
     2286        return preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $text );
     2287}
     2288
     2289/**
    22552290 * Breaks a string into chunks by splitting at whitespace characters.
    22562291 * The length of each returned chunk is as close to the specified length goal as possible,
    22572292 * with the caveat that each chunk includes its trailing delimiter.