Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Update anchor tags to appropriate URL's
- preg_match_all('/\<a[^>]+[\'"]((http|https):\/\/[\/-\w\.#?=&;]+)[^>]+>/im', $buffer, $matches);
- $home_path= parse_url(get_option('home'), PHP_URL_PATH) or $home_path= '/';
- $home_len= strlen($home_path);
- for ($i = 0; $i<sizeof($matches[0]); $i++) { // fix
- $html = $matches[0][$i];
- $url = $matches[1][$i];
- $scheme = $matches[2][$i];
- /////////////////////////////////////////////////
- // this is all borked
- /////////////////////////////////////////////////
- // $url_path = parse_url($url, PHP_URL_PATH);
- // if ($this->shared_ssl) {
- // $url_path = str_replace(parse_url($this->https_url, PHP_URL_PATH), '', $url_path); // wrong, https_url already stripped of path
- // } else {
- // $url_path = str_replace(parse_url(get_option('home'), PHP_URL_PATH), '', $url_path);
- // }
- //
- // if ($url_path == '/') { // wrong, external links can match this
- // $post = get_option('page_on_front');
- // } else {
- // $post = get_page_by_path($url_path); // wrong unless WP installed in root www
- // $post = $post->ID;
- // }
- /////////////////////////////////////////////////
- $scheme= strtolower($scheme);
- $url_start= $scheme . '://' . strtolower(parse_url($url, PHP_URL_HOST));
- if ($url_start == $this->http_url) {
- // ok
- } elseif ($url_start == $this->https_url) {
- // ok
- } else {
- continue; // bail on external links
- }
- $url_path= parse_url($url, PHP_URL_PATH) or $url_path='/';
- if ($home_len <= strlen($url_path) && $home_path == substr($url_path, 0, $home_len)) {
- $url_path= substr($url_path, $home_len);
- } else {
- continue;
- }
- if ($url_path == '') {
- $post = get_option('page_on_front');
- } else {
- $post = get_page_by_path($url_path);
- $post and $post = $post->ID;
- }
- $force_ssl_admin= defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN && is_admin(); // new code
- if ($post) {
- // $force_ssl = get_post_meta($post, 'force_ssl', true); // was
- $force_ssl= $force_ssl_admin || get_post_meta($post, 'force_ssl', true); // now
- if ($force_ssl) {
- if ($scheme=='http') {
- $buffer = str_replace($html, str_replace($this->http_url, $this->https_url, $html), $buffer);
- }
- } else if (get_option('wordpress-https_exclusive_https') == 1) {
- if ($scheme=='https') {
- $buffer = str_replace($html, str_replace($this->https_url, $this->http_url, $html), $buffer);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement