PHP Class Timber\URLHelper

Mostrar archivo Open project: jarednova/timber Class Usage Examples

Public Methods

Method Description
file_system_to_url ( string $fs )
get_current_url ( ) : string
get_full_path ( string $src ) : string
get_host ( ) : string Some setups like HTTP_HOST, some like SERVER_NAME, it's complicated
get_params ( integer $i = false ) : array | string Returns the url parameters, for example for url http://example.org/blog/post/news/2014/whatever this will return array('blog', 'post', 'news', '2014', 'whatever'); OR if sent an integer like: TimberUrlHelper::get_params(2); this will return 'news';
get_path_base ( ) : string
get_rel_path ( string $src ) : string
get_rel_url ( string $url, boolean $force = false ) : string
get_scheme ( ) : string Get url scheme
is_absolute ( string $path ) : boolean This will evaluate wheter a URL is at an aboslute location (like http://example.org/whatever)
is_external ( string $url ) : boolean
is_external_content ( string $url ) : boolean This function is slightly different from the one below in the case of: an image hosted on the same domain BUT on a different site than the Wordpress install will be reported as external content.
is_local ( string $url ) : boolean
is_url ( string $url ) : boolean
prepend_to_url ( string $url, string $path ) : string
preslashit ( string $path ) : string
remove_double_slashes ( string $url ) : string
remove_trailing_slash ( string $link ) : string Pass links through untrailingslashit unless they are a single /
url_to_file_system ( string $url ) : string Takes a url and figures out its place based in the file system based on path NOTE: Not fool-proof, makes a lot of assumptions about the file path matching the URL path

Private Methods

Method Description
is_internal_content ( string $url )

Method Details

file_system_to_url() public static method

public static file_system_to_url ( string $fs )
$fs string

get_current_url() public static method

public static get_current_url ( ) : string
return string

get_full_path() public static method

public static get_full_path ( string $src ) : string
$src string
return string

get_host() public static method

Some setups like HTTP_HOST, some like SERVER_NAME, it's complicated
public static get_host ( ) : string
return string the HTTP_HOST or SERVER_NAME

get_params() public static method

Returns the url parameters, for example for url http://example.org/blog/post/news/2014/whatever this will return array('blog', 'post', 'news', '2014', 'whatever'); OR if sent an integer like: TimberUrlHelper::get_params(2); this will return 'news';
public static get_params ( integer $i = false ) : array | string
$i integer the position of the parameter to grab.
return array | string

get_path_base() public static method

public static get_path_base ( ) : string
return string

get_rel_path() public static method

public static get_rel_path ( string $src ) : string
$src string
return string

get_rel_url() public static method

public static get_rel_url ( string $url, boolean $force = false ) : string
$url string
$force boolean
return string

get_scheme() public static method

Get url scheme
public static get_scheme ( ) : string
return string

is_absolute() public static method

This will evaluate wheter a URL is at an aboslute location (like http://example.org/whatever)
public static is_absolute ( string $path ) : boolean
$path string
return boolean true if $path is an absolute url, false if relative.

is_external() public static method

public static is_external ( string $url ) : boolean
$url string
return boolean true if $path is an external url, false if relative or local. true if it's a subdomain (http://cdn.example.org = true)

is_external_content() public static method

This function is slightly different from the one below in the case of: an image hosted on the same domain BUT on a different site than the Wordpress install will be reported as external content.
public static is_external_content ( string $url ) : boolean
$url string a URL to evaluate against
return boolean if $url points to an external location returns true

is_local() public static method

public static is_local ( string $url ) : boolean
$url string
return boolean

is_url() public static method

public static is_url ( string $url ) : boolean
$url string
return boolean

prepend_to_url() public static method

public static prepend_to_url ( string $url, string $path ) : string
$url string
$path string
return string

preslashit() public static method

public static preslashit ( string $path ) : string
$path string
return string

remove_double_slashes() public static method

public static remove_double_slashes ( string $url ) : string
$url string
return string

remove_trailing_slash() public static method

Pass links through untrailingslashit unless they are a single /
public static remove_trailing_slash ( string $link ) : string
$link string
return string

url_to_file_system() public static method

Takes a url and figures out its place based in the file system based on path NOTE: Not fool-proof, makes a lot of assumptions about the file path matching the URL path
public static url_to_file_system ( string $url ) : string
$url string
return string