Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated isLocalUrl to also check for multisite domains.

  • Loading branch information...
commit 1923296010701a79644c16e029d6c4744242c66f 1 parent 6042e01
@mvied authored
Showing with 22 additions and 2 deletions.
  1. +22 −2 lib/WordPressHTTPS.php
View
24 lib/WordPressHTTPS.php
@@ -121,7 +121,26 @@ public function getHttpsUrl() {
return $this->_https_url;
}
-
+
+ /**
+ * Get domains local to the WordPress installation.
+ *
+ * @param none
+ * @return array $hosts Array of domains local to the WordPress installation.
+ */
+ public function getLocalDomains() {
+ global $wpdb;
+ $hosts = array(
+ $this->getHttpUrl()->getHost(),
+ $this->getHttpsUrl()->getHost()
+ );
+
+ if ( is_multisite() && is_subdomain_install() ) {
+ $multisite_hosts = $wpdb->get_col($wpdb->prepare("SELECT domain FROM " . $wpdb->blogs, NULL));
+ $hosts = array_merge($hosts, $multisite_hosts);
+ }
+ return $hosts;
+ }
/**
* Initialize
*
@@ -210,7 +229,8 @@ public function install() {
* @return boolean
*/
public function isUrlLocal($url) {
- if ( ($url_parts = parse_url($url)) && isset($url_parts['host']) && $this->getHttpUrl()->getHost() != $url_parts['host'] && $this->getHttpsUrl()->getHost() != $url_parts['host'] ) {
+ $hosts = $this->getLocalDomains();
+ if ( ($url_parts = parse_url($url)) && isset($url_parts['host']) && !in_array($url_parts['host'], $hosts) ) {
return false;
}
return true;
Please sign in to comment.
Something went wrong with that request. Please try again.