Skip to content

Commit

Permalink
Updated Parser to be aware of multisite blog settings when fixing lin…
Browse files Browse the repository at this point in the history
…ks and forms.
  • Loading branch information
Mike Ems committed Feb 17, 2013
1 parent f2a547c commit e6f01f5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/WordPressHTTPS.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ public function install() {
foreach ( $this->getSettings() as $option => $value ) {
if ( is_multisite() ) {
if ( add_blog_option($blog_id, $option, $value) && isset($defaults[$option]) ) {
$value = $defaults[$option];
if ( $option == 'ssl_host' ) {
$value = 'https://' . $value;
} else {
$value = $defaults[$option];
}
$this->setSetting($option, $value, $blog_id);
}
} else {
Expand Down
26 changes: 23 additions & 3 deletions lib/WordPressHTTPS/Module/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,20 @@ public function fixLinksAndForms() {
}

if ( !is_null($blog_id) && $blog_id != $wpdb->blogid ) {
// URL Filters
if ( sizeof((array)$this->getPlugin()->getSetting('secure_filter', $blog_id)) > 0 ) {
foreach( $this->getPlugin()->getSetting('secure_filter', $blog_id) as $filter ) {
if ( preg_match('/' . str_replace('/', '\/', $filter) . '/', $url) === 1 ) {
$force_ssl = true;
}
}
}
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() ) ) ) {
$force_ssl = true;
} else if ( $this->getPlugin()->getSetting('exclusive_https', $blog_id) ) {
} else if ( is_null($force_ssl) && $this->getPlugin()->getSetting('exclusive_https', $blog_id) ) {
$force_ssl = false;
} else if ( strpos($url, 'https://') === 0 ) {
$force_ssl = true;
}
}
}
Expand All @@ -376,10 +386,20 @@ public function fixLinksAndForms() {
}

if ( $force_ssl == true ) {
$updated = $this->getPlugin()->makeUrlHttps($url);
if ( is_null($blog_id) ) {
$updated = $this->getPlugin()->makeUrlHttps($url);
} else {
if ( $ssl_host = $this->getPlugin()->getSetting('ssl_host', $blog_id) ) {
$updated = str_replace($url_parts['scheme'] . '://' . $url_parts['host'] . '/', $ssl_host, $url);
}
}
$this->_html = str_replace($html, str_replace($url, $updated, $html), $this->_html);
} else if ( !is_null($force_ssl) && !$force_ssl ) {
$updated = $this->getPlugin()->makeUrlHttp($url);
if ( is_null($blog_id) ) {
$updated = $this->getPlugin()->makeUrlHttp($url);
} else {
$updated = str_replace($url_parts['scheme'] . '://' . $url_parts['host'] . '/', get_home_url($blog_id, '/'), $url);
}
$this->_html = str_replace($html, str_replace($url, $updated, $html), $this->_html);
}

Expand Down

0 comments on commit e6f01f5

Please sign in to comment.