/**
  * Get HTTPS Url
  * 
  * @param none
  * @return WordPressHTTPS_Url
  */
 public function getHttpsUrl()
 {
     if (!isset($this->_https_url)) {
         $this->_https_url = clone $this->getHttpUrl();
         $this->_https_url->setScheme('https');
         if (is_string($this->getSetting('ssl_host')) && $this->getSetting('ssl_host') != '') {
             $ssl_host = rtrim($this->getSetting('ssl_host'), '/') . '/';
             // If using a different host for SSL
             if ($ssl_host != $this->_https_url->toString()) {
                 // Assign HTTPS URL to SSL Host
                 $this->setSetting('ssl_host_diff', 1);
                 if (strpos($ssl_host, 'http://') === false && strpos($ssl_host, 'https://') === false) {
                     $ssl_host = 'https://' . $ssl_host;
                 }
                 $this->_https_url = WordPressHTTPS_Url::fromString($ssl_host);
             } else {
                 $this->setSetting('ssl_host_diff', 0);
             }
         }
         // Prepend SSL Host path
         if (strpos($this->_https_url->getPath(), $this->getHttpUrl()->getPath()) === false) {
             $this->_https_url->setPath($this->_https_url->getPath() . $this->getHttpUrl()->getPath());
         }
         // Add SSL Port to HTTPS URL
         $this->_https_url->setPort($this->getSetting('ssl_port'));
     }
     return $this->_https_url;
 }
Beispiel #2
0
 /**
  * Factory object from a string that contains a URL
  * 
  * Example of usage:
  * $site_url = WordPressHTTPS_Url::fromString( site_url() );
  *
  * @param string $string
  * @return $url WordPressHTTPS_Url
  */
 public static function fromString($string)
 {
     $url = new WordPressHTTPS_Url();
     @preg_match_all('/((http|https):\\/\\/[^\'"]+)[\'"\\)]?/i', $string, $url_parts);
     if (isset($url_parts[1][0])) {
         if ($url_parts = parse_url($url_parts[1][0])) {
             $url->setScheme(@$url_parts['scheme']);
             $url->setUser(@$url_parts['user']);
             $url->setPass(@$url_parts['pass']);
             $url->setHost(@$url_parts['host']);
             $url->setPort(@$url_parts['port']);
             $url->setPath(@$url_parts['path']);
             $url->setQuery(@$url_parts['query']);
             $url->setFragment(@$url_parts['fragment']);
             return $url;
         }
     } else {
         return false;
     }
     return $url;
 }