PHP Class The_SEO_Framework\Generate_Url

Generates URL and permalink SEO data based on content.
Since: 2.7.1
Inheritance: extends Generate_Title
Show file Open project: sybrew/the-seo-framework

Protected Properties

Property Type Description
$current_host Holds current HTTP host.
$url_slashit Whether to slash the url or not. Used when query vars are in url.

Public Methods

Method Description
add_url_host ( string $path = '' ) : string Create full valid URL with parsed host.
add_url_subdomain ( string $url = '' ) : string Adds subdomain to input URL.
build_singular_relative_url ( integer $post_id = null, array $args = [] ) : relative Generates relative URL for the Homepage and Singular Posts.
generate_url_path ( array $args = [] ) : string Generate URL from arguments.
get_current_subdomain ( null | string $set = null, boolean $unset = false ) : string | boolean Fetches current subdomain set by $this->set_current_subdomain();
get_home_host ( ) : string Fetches home URL host. Like "wordpress.org".
get_home_path ( ) : string Fetches home URL subdirectory path. Like "wordpress.org/plugins/".
get_paged_post_url ( integer $i, integer $post_id, string $pos = 'prev' ) : string Returns the special URL of a paged post.
get_paged_url ( string $prev_next = 'next', integer $post_id ) : string | null Generates Previous and Next links.
get_relative_qtranslate_url ( string $path = '', integer $post_id = '' ) Generates qtranslate URL.
get_relative_term_url ( object $term = null, array | boolean $args = [] ) : Relative Generates relative URL for current term.
get_relative_wmpl_url ( string $path = '', integer $post_id = '' ) : relative Generate relative WPML url.
get_shortlink ( integer $post_id ) : string | null Generates shortlink URL.
get_translation_path ( string $path = '', integer $post_id = null, boolean $external = false ) : relative Generates relative URL for current post_ID for translation plugins.
make_fully_qualified_url ( string $url ) : string Makes a fully qualified URL from input. Always uses http to fix.
parse_url_args ( array $args = [], array $defaults = [], boolean $get_defaults = false ) : array Parse and sanitize url args.
permalink_structure ( ) : string Cached WordPress permalink structure settings.
reparse_url_args ( array $args = [] ) : array Reparse URL args.
set_current_subdomain ( string $subdomain = '' ) : string Sets current working subdomain.
set_url_scheme ( string $url, string $scheme = null, boolean $use_filter = true ) : string Sets URL scheme for input URL.
set_url_scheme_filter ( string $url, $current_scheme ) Set URL scheme based on filter.
the_url ( string $url = '', array $args = [] ) : string Creates canonical URL.
the_url_donncha_domainmap ( string $path, boolean $get_scheme = false ) : string | array | void Try to get an canonical URL when Donncha Domain Mapping is active.
the_url_wpmudev_domainmap ( string $path, boolean $get_scheme = false ) : string | array | void Creates a full canonical URL when WPMUdev Domain Mapping is active from path.
unset_current_subdomain ( ) Unsets current working subdomain.

Protected Methods

Method Description
__construct ( ) Constructor, load parent constructor and set up variables.
maybe_get_paged ( integer $paged, boolean $singular = false, boolean $plural = true ) : integer | boolean Add $paged if Paginated and allowed through arguments.

Method Details

__construct() protected method

Constructor, load parent constructor and set up variables.
protected __construct ( )

add_url_host() public method

Don't forget to use set_url_scheme() afterwards. Note: will return $path if no host can be found.
Since: 2.6.5
public add_url_host ( string $path = '' ) : string
$path string Current path.
return string Full valid URL with http host.

add_url_subdomain() public method

Adds subdomain to input URL.
Since: 2.6.5
public add_url_subdomain ( string $url = '' ) : string
$url string The current URL without subdomain.
return string $url Fully qualified URL with possible subdomain.

build_singular_relative_url() public method

Generates relative URL for the Homepage and Singular Posts.
Since: 2.6.5
public build_singular_relative_url ( integer $post_id = null, array $args = [] ) : relative
$post_id integer The ID.
$args array The URL arguments.
return relative Post or Page url.

generate_url_path() public method

Generate URL from arguments.
Since: 2.6.0
public generate_url_path ( array $args = [] ) : string
$args array the URL args.
return string $path

get_current_subdomain() public method

Fetches current subdomain set by $this->set_current_subdomain();
Since: 2.7.0
public get_current_subdomain ( null | string $set = null, boolean $unset = false ) : string | boolean
$set null | string Whether to set a new subdomain.
$unset boolean Whether to remove subdomain from cache.
return string | boolean The set subdomain, false if none is set.

get_home_host() public method

If this fails, you're going to have a bad time.
Since: 2.7.0
public get_home_host ( ) : string
return string The home URL host.

get_home_path() public method

Fetches home URL subdirectory path. Like "wordpress.org/plugins/".
Since: 2.7.0
public get_home_path ( ) : string
return string The home URL path.

get_paged_post_url() public method

Taken from _wp_link_page() in WordPress core, but instead of anchor markup, just return the URL. Also adds WPMUdev Domain Mapping support and is optimized for speed.
Since: 2.2.4
public get_paged_post_url ( integer $i, integer $post_id, string $pos = 'prev' ) : string
$i integer The page number to generate the URL from.
$post_id integer The post ID
$pos string Which url to get, accepts next|prev
return string Unescaped URL

get_paged_url() public method

Generates Previous and Next links.
Since: 2.2.4
public get_paged_url ( string $prev_next = 'next', integer $post_id ) : string | null
$prev_next string Previous or next page link.
$post_id integer The post ID.
return string | null Escaped site Pagination URL

get_relative_qtranslate_url() public method

Generates qtranslate URL.
Since: 2.6.0
public get_relative_qtranslate_url ( string $path = '', integer $post_id = '' )
$path string The current path.
$post_id integer The Post ID. Unused until qTranslate provides external URL forgery.

get_relative_term_url() public method

Generates relative URL for current term.
Since: 2.4.2
Since: 2.7.0 Added home directory to output.
public get_relative_term_url ( object $term = null, array | boolean $args = [] ) : Relative
$term object The term object.
$args array | boolean { 'external' : Whether to fetch the WP Request or get the permalink by Post Object. 'paged' : Whether to add pagination for all types. 'paged_plural' : Whether to add pagination for the second or later page. }
return Relative term or taxonomy URL.

get_relative_wmpl_url() public method

Generate relative WPML url.
Since: 2.4.3
public get_relative_wmpl_url ( string $path = '', integer $post_id = '' ) : relative
$path string The current path.
$post_id integer The Post ID.
return relative path for WPML urls.

get_translation_path() public method

Generates relative URL for current post_ID for translation plugins.
Since: 2.6.0
public get_translation_path ( string $path = '', integer $post_id = null, boolean $external = false ) : relative
$path string the current URL path.
$post_id integer The post ID.
$external boolean Whether the request for URL generation is external.
return relative Post or Page url.

make_fully_qualified_url() public method

Makes a fully qualified URL from input. Always uses http to fix.
Since: 2.6.5
public make_fully_qualified_url ( string $url ) : string
$url string Required the current maybe not fully qualified URL.
return string $url

maybe_get_paged() protected method

Add $paged if Paginated and allowed through arguments.
Since: 2.6.0
protected maybe_get_paged ( integer $paged, boolean $singular = false, boolean $plural = true ) : integer | boolean
$paged integer
$singular boolean Whether to allow plural and singular.
$plural boolean Whether to allow plural regardless.
return integer | boolean $paged. False if not allowed. Int if allowed.

parse_url_args() public method

Parse and sanitize url args.
Since: 2.4.2
Since: 2.5.0:
public parse_url_args ( array $args = [], array $defaults = [], boolean $get_defaults = false ) : array
$args array required The passed arguments.
$defaults array The default arguments.
$get_defaults boolean Return the default arguments. Ignoring $args.
return array $args parsed args.

reparse_url_args() public method

Reparse URL args.
Since: 2.6.2
public reparse_url_args ( array $args = [] ) : array
$args array required The passed arguments.
return array $args parsed args.

set_current_subdomain() public method

Sets current working subdomain.
Since: 2.7.0
public set_current_subdomain ( string $subdomain = '' ) : string
$subdomain string The current subdomain.
return string The set subdomain.

set_url_scheme() public method

WordPress core function, without filter.
Since: 2.4.2
public set_url_scheme ( string $url, string $scheme = null, boolean $use_filter = true ) : string
$url string Absolute url that includes a scheme.
$scheme string optional. Scheme to give $url. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.
$use_filter boolean Whether to parse filters.
return string url with chosen scheme.

set_url_scheme_filter() public method

Set URL scheme based on filter.
Since: 2.6.0
public set_url_scheme_filter ( string $url, $current_scheme )
$url string The url with scheme.

the_url() public method

Creates canonical URL.
Since: 2.4.2
Since: 2.0.0
public the_url ( string $url = '', array $args = [] ) : string
$url string the url
$args array : accepted args : { @param bool $paged Return current page URL without pagination if false @param bool $paged_plural Whether to add pagination for the second or later page. @param bool $from_option Get the canonical uri option @param object $post The Post Object. @param bool $external Whether to fetch the current WP Request or get the permalink by Post Object. @param bool $is_term Fetch url for term. @param object $term The term object. @param bool $home Fetch home URL. @param bool $forceslash Fetch home URL and slash it, always. @param int $id The Page or Term ID. }
return string Escape url.

the_url_donncha_domainmap() public method

Try to get an canonical URL when Donncha Domain Mapping is active.
Since: 2.4.0
public the_url_donncha_domainmap ( string $path, boolean $get_scheme = false ) : string | array | void
$path string The post relative path.
$get_scheme boolean Output array with scheme.
return string | array | void The unescaped URL, the scheme

the_url_wpmudev_domainmap() public method

Creates a full canonical URL when WPMUdev Domain Mapping is active from path.
Since: 2.3.0
Since: 2.4.0 Added $get_scheme parameter.
public the_url_wpmudev_domainmap ( string $path, boolean $get_scheme = false ) : string | array | void
$path string The post relative path.
$get_scheme boolean Output array with scheme.
return string | array | void The unescaped URL, the scheme

unset_current_subdomain() public method

Unsets current working subdomain.
Since: 2.7.0

Property Details

$current_host protected property

Holds current HTTP host.
Since: 2.6.5
protected $current_host

$url_slashit protected property

Whether to slash the url or not. Used when query vars are in url.
Since: 2.6.0
protected $url_slashit