Timber\URLHelper::get_rel_url PHP Method

get_rel_url() public static method

public static get_rel_url ( string $url, boolean $force = false ) : string
$url string
$force boolean
return string
    public static function get_rel_url($url, $force = false)
    {
        $url_info = parse_url($url);
        if (isset($url_info['host']) && $url_info['host'] != self::get_host() && !$force) {
            return $url;
        }
        $link = '';
        if (isset($url_info['path'])) {
            $link = $url_info['path'];
        }
        if (isset($url_info['query']) && strlen($url_info['query'])) {
            $link .= '?' . $url_info['query'];
        }
        if (isset($url_info['fragment']) && strlen($url_info['fragment'])) {
            $link .= '#' . $url_info['fragment'];
        }
        $link = self::remove_double_slashes($link);
        return $link;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @api
  * @return  string the relative path to the theme (ex: `/wp-content/themes/my-timber-theme`)
  */
 public function path()
 {
     return URLHelper::get_rel_url($this->link());
 }
All Usage Examples Of Timber\URLHelper::get_rel_url