Skip to content

Commit

Permalink
Enhanced multisite URL detection in Parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Ems committed Feb 17, 2013
1 parent 48d9092 commit 8977a4e
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions lib/WordPressHTTPS/Module/Parser.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ public function fixLinksAndForms() {
$scheme = $matches[3][$i]; $scheme = $matches[3][$i];
$updated = false; $updated = false;
$post_id = null; $post_id = null;
$blog_id = null;
$force_ssl = null;


if ( !$this->getPlugin()->isUrlLocal($url) ) { if ( !$this->getPlugin()->isUrlLocal($url) ) {
continue; continue;
Expand Down Expand Up @@ -334,33 +336,37 @@ public function fixLinksAndForms() {
} }


if ( is_multisite() && isset($url_parts['host']) ) { if ( is_multisite() && isset($url_parts['host']) ) {
$blog_id = false; if ( is_subdomain_install() ) {
$url_path = '/'; $blog_id = get_blog_id_from_url( $url_parts['host'], '/');
$url_path_segments = explode('/', $url_parts['path']); } else {
if ( sizeof($url_path_segments) > 1 ) { $url_path = '';
foreach( $url_path_segments as $url_path_segment ) { $url_path_segments = explode('/', $url_parts['path']);
if ( !$blog_id && $url_path_segment != '' ) { if ( sizeof($url_path_segments) > 1 ) {
$url_path .= '/' . $url_path_segment . '/'; foreach( $url_path_segments as $url_path_segment ) {
if ( $blog_id = get_blog_id_from_url( $url_parts['host'], $url_path) ) { if ( is_null($blog_id) && $url_path_segment != '' ) {
break; $url_path .= '/' . $url_path_segment . '/';
if ( $blog_id = get_blog_id_from_url( $url_parts['host'], $url_path) ) {
break;
}
} }
} }
} }
} }
if ( !$blog_id ) {
$blog_id = get_blog_id_from_url( $url_parts['host'], '/'); if ( !is_null($blog_id) && $blog_id != $wpdb->blogid ) {
} if ( $this->getPlugin()->getSetting('ssl_admin', $blog_id) && strpos($url_parts['path'], 'wp-admin') !== false && ( ! $this->getPlugin()->getSetting('ssl_host_diff', $blog_id) || ( $this->getPlugin()->getSetting('ssl_host_diff', $blog_id) && function_exists('is_user_logged_in') && is_user_logged_in() ) ) ) {
if ( $blog_id && $blog_id != $wpdb->blogid ) {
if ( $this->getPlugin()->getSetting('ssl_admin', $blog_id) && ( ! $this->getPlugin()->getSetting('ssl_host_diff', $blog_id) || ( $this->getPlugin()->getSetting('ssl_host_diff', $blog_id) && function_exists('is_user_logged_in') && is_user_logged_in() ) ) ) {
$force_ssl = true; $force_ssl = true;
} else { } else if ( $this->getPlugin()->getSetting('exclusive_https', $blog_id) ) {
$force_ssl = false; $force_ssl = false;
} }
} }
} }
} }


$force_ssl = apply_filters('force_ssl', null, ( isset($post_id) ? $post_id : 0 ), $url ); // Only apply force_ssl filters for current blog
if ( is_null($blog_id) ) {
$force_ssl = apply_filters('force_ssl', null, ( isset($post_id) ? $post_id : 0 ), $url );
}


if ( $force_ssl == true ) { if ( $force_ssl == true ) {
$updated = $this->getPlugin()->makeUrlHttps($url); $updated = $this->getPlugin()->makeUrlHttps($url);
Expand Down

0 comments on commit 8977a4e

Please sign in to comment.