PHP Класс Timber\URLHelper

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Приватные методы

Метод Описание
is_internal_content ( string $url )

Описание методов

file_system_to_url() публичный статический Метод

public static file_system_to_url ( string $fs )
$fs string

get_current_url() публичный статический Метод

public static get_current_url ( ) : string
Результат string

get_full_path() публичный статический Метод

public static get_full_path ( string $src ) : string
$src string
Результат string

get_host() публичный статический Метод

Some setups like HTTP_HOST, some like SERVER_NAME, it's complicated
public static get_host ( ) : string
Результат string the HTTP_HOST or SERVER_NAME

get_params() публичный статический Метод

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.
Результат array | string

get_path_base() публичный статический Метод

public static get_path_base ( ) : string
Результат string

get_rel_path() публичный статический Метод

public static get_rel_path ( string $src ) : string
$src string
Результат string

get_rel_url() публичный статический Метод

public static get_rel_url ( string $url, boolean $force = false ) : string
$url string
$force boolean
Результат string

get_scheme() публичный статический Метод

Get url scheme
public static get_scheme ( ) : string
Результат string

is_absolute() публичный статический Метод

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
Результат boolean true if $path is an absolute url, false if relative.

is_external() публичный статический Метод

public static is_external ( string $url ) : boolean
$url string
Результат 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() публичный статический Метод

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
Результат boolean if $url points to an external location returns true

is_local() публичный статический Метод

public static is_local ( string $url ) : boolean
$url string
Результат boolean

is_url() публичный статический Метод

public static is_url ( string $url ) : boolean
$url string
Результат boolean

prepend_to_url() публичный статический Метод

public static prepend_to_url ( string $url, string $path ) : string
$url string
$path string
Результат string

preslashit() публичный статический Метод

public static preslashit ( string $path ) : string
$path string
Результат string

remove_double_slashes() публичный статический Метод

public static remove_double_slashes ( string $url ) : string
$url string
Результат string

remove_trailing_slash() публичный статический Метод

Pass links through untrailingslashit unless they are a single /
public static remove_trailing_slash ( string $link ) : string
$link string
Результат string

url_to_file_system() публичный статический Метод

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
Результат string