WordPress开启整站HTTPS协议

//WordPress SSL HTTPS 绝对链接替换
add_filter('get_header', 'fanly_ssl');
function fanly_ssl(){
    if( is_ssl() ){
        function fanly_ssl_main ($content){
            $siteurl = get_option('siteurl');
            $upload_dir = wp_upload_dir();
            $content = str_replace( 'http:'.strstr($siteurl, '//'), 'https:'.strstr($siteurl, '//'), $content);
            $content = str_replace( 'http:'.strstr($upload_dir['baseurl'], '//'), 'https:'.strstr($upload_dir['baseurl'], '//'), $content);
            return $content;
        }
        ob_start("fanly_ssl_main");
    }
}

你可能感兴趣的:(WordPress开启整站HTTPS协议)