Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions lib/WordPressHTTPS.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php
/**
* WordPress HTTPS
*
Expand Down Expand Up @@ -32,7 +32,7 @@ class WordPressHTTPS extends Mvied_Plugin_Modular {

/**
* Plugin Settings
*
*
* setting_name => default_value
*
* @var multitype:multitype
Expand All @@ -56,12 +56,13 @@ class WordPressHTTPS extends Mvied_Plugin_Modular {
'path_cache' => array(), // Cache of URL paths to Post IDs
'blog_cache' => array(), // Cache of URL paths to Blog IDs
'version' => '', // Version of the plugin this blog has installed
'hosts' => array(),
);

/**
* File extensions to be loaded securely.
* File type => Array of extensions
*
*
* @var multitype:multitype
*/
protected $_file_extensions = array(
Expand Down Expand Up @@ -126,7 +127,7 @@ class WordPressHTTPS extends Mvied_Plugin_Modular {

/**
* Get File Extensions to Secure
*
*
* @param none
* @return array
*/
Expand All @@ -136,7 +137,7 @@ public function getFileExtensions() {

/**
* Get HTTP Url
*
*
* @param none
* @return Mvied_Url
*/
Expand All @@ -149,7 +150,7 @@ public function getHttpUrl() {

/**
* Get HTTPS Url
*
*
* @param none
* @return Mvied_Url
*/
Expand Down Expand Up @@ -184,28 +185,34 @@ public function getHttpsUrl() {

/**
* Get domains local to the WordPress installation.
*
*
* @param none
* @return array $hosts Array of domains local to the WordPress installation.
*/
public function getLocalDomains() {
$hosts = $this->getSetting( 'hosts' );

if ( ! empty( $hosts ) )
return $hosts;

global $wpdb;
$hosts = array(
$this->getHttpUrl()->getHost(),
$this->getHttpsUrl()->getHost()
$this->getHttpsUrl()->getHost(),
);

if ( is_multisite() && is_subdomain_install() ) {
$multisite_hosts = $wpdb->get_col($wpdb->prepare("SELECT domain FROM %d", $wpdb->blogs));
$hosts = array_merge($hosts, $multisite_hosts);
$multisite_hosts = $wpdb->get_col($wpdb->prepare( "SELECT domain FROM %d", $wpdb->blogs ) );
$hosts = array_merge( $hosts, $multisite_hosts );
}

if ( function_exists('domain_mapping_siteurl') ) {
if ( $mapped_host = parse_url(domain_mapping_siteurl(false), PHP_URL_HOST) ) {
if ( function_exists( 'domain_mapping_siteurl' ) ) {
if ( $mapped_host = parse_url( domain_mapping_siteurl( false ), PHP_URL_HOST ) )
$hosts[] = $mapped_host;
}
}

$this->setSetting( 'hosts', $hosts );

return $hosts;
}

Expand All @@ -231,7 +238,7 @@ public function init() {

/**
* Install
*
*
* @param none
* @return void
*/
Expand Down Expand Up @@ -312,7 +319,7 @@ public function install() {
$this->setSetting('unsecure_external_urls', $this->_settings['unsecure_external_urls'], $blog_id);
$this->setSetting('path_cache', $this->_settings['path_cache'], $blog_id);
$this->setSetting('blog_cache', $this->_settings['blog_cache'], $blog_id);

// Set default URL Mapping
if ( $this->getSetting('ssl_host_mapping', $blog_id) == array() ) {
$this->setSetting('ssl_host_mapping', WordPressHTTPS::$ssl_host_mapping, $blog_id);
Expand All @@ -335,7 +342,7 @@ public function install() {

/**
* Is Local URL
*
*
* Determines if URL is local or external
*
* @param string $url
Expand Down Expand Up @@ -534,7 +541,7 @@ public function isSsl() {
}
return apply_filters('is_ssl', $is_ssl);
}

/**
* Maintained for backwards compatibility.
*
Expand Down Expand Up @@ -606,7 +613,7 @@ public function getDirectories() {
$scannedDirectories[$directory]['name'] = $directory;
if ( is_readable($directory) && ($files = scandir($directory)) ) {
$scannedDirectories[$directory]['files'] = $files;
unset($files);
unset($files);
} else {
$scannedDirectories[$directory]['error'] = "Unable to read directory.";
}
Expand Down