Make WordPress Core

Ticket #33691: force-url_scheme-content-for-own-domain.patch

File force-url_scheme-content-for-own-domain.patch, 851 bytes (added by cleggmatt, 9 years ago)
  • wp-includes/post-template.php

     
    308308        if ( $preview ) // Preview fix for JavaScript bug with foreign languages.
    309309                $output =       preg_replace_callback( '/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output );
    310310
     311        //Only do this if using ssl
     312        if ( is_ssl() ) {
     313                //Pass each URL into callback
     314                $output = preg_replace_callback(
     315                        '#(www\.|http://)?[a-z0-9]+\.[a-z0-9]{2,4}\S*#i',
     316                        function($match) {
     317                                $url = $match[0];
     318                                //Only manipulate own urls
     319                                if (strpos($url, get_current_site()->domain) !== false) {
     320                                        return set_url_scheme($url);
     321                                } else {
     322                                        return $url;
     323                                }
     324                        },
     325                        $output
     326                );
     327        }
     328
    311329        return $output;
    312330}
    313331