PHP Class The_SEO_Framework\Generate_Title

Generates title SEO data based on content.
Since: 2.7.1
Inheritance: extends Generate_Description
ファイルを表示 Open project: sybrew/the-seo-framework

Public Methods

Method Description
add_title_additions ( ) : boolean Determines whether to add or remove title additions.
add_title_pagination ( string $title ) : string Adds title pagination, if paginated.
add_title_protection ( $title, $id ) : string Adds title protection prefixes.
build_title ( string $title = '', string $seplocation = '', array $args = [] ) : string Builds the title based on input and query status.
build_title_doingitwrong ( string $title = '', string $sep = '', string $seplocation = '', array $args = [] ) : string Builds the title based on input and query status for themes that are doing it wrong.
do_title_pre_filter ( string $title, array $args, boolean $escape = true ) : string Filters the title prior to output.
do_title_pro_filter ( string $title, array $args, boolean $escape = true ) : string Filters the title prior to output.
escape_title ( string $title = '', boolean $trim = true ) : string Escapes and beautifies title.
generate_home_title ( boolean $get_custom_field = true, string $seplocation = '', string $deprecated = '', boolean $escape = true, boolean $get_option = true ) : array Generate the title based on conditions for the home page.
generate_title ( array $args = [], boolean $escape = true ) : string Generate the title based on query conditions.
get_custom_field_title ( string $title = '', integer $id = '', string $taxonomy = '' ) : string Returns custom field title.
get_home_title_seplocation ( string $seplocation = '' ) : string Gets Title Seplocation for the homepage.
get_the_404_title ( string $title = '' ) : string Returns 404 title.
get_the_real_archive_title ( object $term = null, array $args = [] ) : string Gets the archive Title, including filter. Also works in admin.
get_the_search_title ( string $title = '', boolean $escape = true ) : string Returns search title.
get_title_separator ( ) : string Gets Title Separator.
get_title_seplocation ( string $seplocation = '', boolean $home = false ) : string Gets Title Seplocation.
home_page_add_title_tagline ( ) : boolean Determines whether to add home page tagline.
parse_title_args ( array $args = [], array $defaults = [], boolean $get_defaults = false ) : array Parse and sanitize title args.
post_title_from_ID ( integer $id, string $title = '' ) : string Returns Post Title from ID.
process_title_additions ( string $title = '', string $blogname = '', string $seplocation = '' ) : string Adds the title additions to the title.
reparse_title_args ( array $args = [] ) : array Reparses title args.
single_term_title ( $prefix = '', $display = true, $term = null ) : string Fetches single term title.
title ( string $title = '', string $sep = '', string $seplocation = '', array $args = [] ) : string Gets the title. Main function.
title_for_home ( string $home_title = '', boolean $get_custom_field = true, boolean $escape = false, boolean $get_option = true ) : string Gets the title for the static home page.
title_for_terms ( array $args = [], boolean $escape = false ) : string Gets the title for Category, Tag or Taxonomy
title_from_custom_field ( string $title = '', boolean $escape = false, integer $id = null, string $taxonomy = null ) : string Gets the title from custom field
title_from_special_fields ( ) : string Fetches title from special fields, like other plugins with special queries.
untitled ( ) : string Returns untitled title.
use_archive_prefix ( object $term = null, array $args = [] ) : boolean Determines whether to use a title prefix or not.

Protected Methods

Method Description
__construct ( ) Constructor, load parent constructor
build_title_notagline ( array $args = [] ) : string Builds the title based on input, without tagline.
get_notagline_title ( array $args = [] ) : string Build the title based on input, without tagline.

Method Details

__construct() protected method

Constructor, load parent constructor
protected __construct ( )

add_title_additions() public method

Determines whether to add or remove title additions.
Since: 2.4.3 Applies filters the_seo_framework_add_blogname_to_title : boolean
Since: 2.6.0:
public add_title_additions ( ) : boolean
return boolean True when additions are allowed.

add_title_pagination() public method

Adds title pagination, if paginated.
Since: 2.6.0
public add_title_pagination ( string $title ) : string
$title string The current Title.
return string Title with maybe pagination added.

add_title_protection() public method

Adds title protection prefixes.
Since: 2.6.0
public add_title_protection ( $title, $id ) : string
$title The current Title.
$id The page ID.
return string $title with possible affixes.

build_title() public method

Builds the title based on input and query status.
Since: 2.4.0
public build_title ( string $title = '', string $seplocation = '', array $args = [] ) : string
$title string The Title to return
$seplocation string The Title sepeartor location ( accepts 'left' or 'right' )
$args array : accepted args : { @param int term_id The Taxonomy Term ID @param string taxonomy The Taxonomy name @param bool page_on_front Page on front condition for example generation @param bool placeholder Generate placeholder, ignoring options. @param bool get_custom_field Do not fetch custom title when false. @param bool is_front_page Fetch front page title. }
return string $title Title

build_title_doingitwrong() public method

Pretty much a duplicate of build_title but contains different variables. Keep this in mind.
Since: 2.4.0
public build_title_doingitwrong ( string $title = '', string $sep = '', string $seplocation = '', array $args = [] ) : string
$title string The Title to return
$sep string The Title sepeartor
$seplocation string The Title sepeartor location ( accepts 'left' or 'right' )
$args array : accepted args : { @param int term_id The Taxonomy Term ID @param string taxonomy The Taxonomy name @param bool placeholder Generate placeholder, ignoring options. @param bool get_custom_field Do not fetch custom title when false. }
return string $title Title

build_title_notagline() protected method

Builds the title based on input, without tagline.
Since: 2.4.0
protected build_title_notagline ( array $args = [] ) : string
$args array : accepted args : { @param int term_id The Taxonomy Term ID @param bool placeholder Generate placeholder, ignoring options. @param bool page_on_front Page on front condition for example generation }
return string Title without tagline.

do_title_pre_filter() public method

Filters the title prior to output.
Since: 2.6.0
public do_title_pre_filter ( string $title, array $args, boolean $escape = true ) : string
$title string The current title.
$args array The title args.
$escape boolean Whether to escape the title.
return string $title

do_title_pro_filter() public method

Filters the title prior to output.
Since: 2.6.0
public do_title_pro_filter ( string $title, array $args, boolean $escape = true ) : string
$title string The current title.
$args array The title args.
$escape boolean Whether to escape the title.
return string $title

escape_title() public method

Escapes and beautifies title.
Since: 2.5.2
public escape_title ( string $title = '', boolean $trim = true ) : string
$title string The title to escape and beautify.
$trim boolean Whether to trim the title from whitespaces.
return string Escaped and beautified title.

generate_home_title() public method

Generate the title based on conditions for the home page.
Since: 2.3.4
public generate_home_title ( boolean $get_custom_field = true, string $seplocation = '', string $deprecated = '', boolean $escape = true, boolean $get_option = true ) : array
$get_custom_field boolean Fetch Title from Custom Fields.
$seplocation string The separator location
$deprecated string Deprecated: The Home Page separator location
$escape boolean Parse Title through saninitation calls.
$get_option boolean Whether to fetch the SEO Settings option.
return array { 'title' => (string) $title : The Generated Title 'blogname' => (string) $blogname : The Generated Blogname 'add_tagline' => (bool) $add_tagline : Whether to add the tagline 'seplocation' => (string) $seplocation : The Separator Location }

generate_title() public method

Generate the title based on query conditions.
Since: 2.3.4
public generate_title ( array $args = [], boolean $escape = true ) : string
$args array The Title Args.
$escape boolean Parse Title through saninitation calls.
return string $title The Generated Title.

get_custom_field_title() public method

Returns custom field title.
Since: 2.6.0
public get_custom_field_title ( string $title = '', integer $id = '', string $taxonomy = '' ) : string
$title string The current title.
$id integer The post or TT ID.
$taxonomy string The TT name.
return string $title The custom field title.

get_home_title_seplocation() public method

Gets Title Seplocation for the homepage.
Since: 2.6.0
public get_home_title_seplocation ( string $seplocation = '' ) : string
$seplocation string The current seplocation.
return string The Seplocation for the homepage.

get_notagline_title() protected method

Note: Not escaped.
Since: 2.6.0
protected get_notagline_title ( array $args = [] ) : string
$args array : accepted args : { @param int term_id The Taxonomy Term ID @param bool placeholder Generate placeholder, ignoring options. @param bool page_on_front Page on front condition for example generation }
return string Title without tagline.

get_the_404_title() public method

Returns 404 title.
Since: 2.6.0
Since: 2.5.2: Applies filters string the_seo_framework_404_title
public get_the_404_title ( string $title = '' ) : string
$title string The current Title
return string 404 Title

get_the_real_archive_title() public method

Gets the archive Title, including filter. Also works in admin.
Since: 2.6.0
public get_the_real_archive_title ( object $term = null, array $args = [] ) : string
$term object The Term object.
$args array The Title arguments.
return string The Archive Title, not escaped.

get_the_search_title() public method

Returns search title.
Since: 2.6.0
public get_the_search_title ( string $title = '', boolean $escape = true ) : string
$title string the current title.
$escape boolean Whether to escape attributes from query.
return string Search Title

get_title_separator() public method

Gets Title Separator.
Since: 2.6.0
Since: 2.3.9: Applies filters the_seo_framework_title_separator
public get_title_separator ( ) : string
return string The Separator, unescaped.

get_title_seplocation() public method

Gets Title Seplocation.
Since: 2.3.9 Applies filters the_seo_framework_title_seplocation : string the title location. Applies filters the_seo_framework_title_seplocation_front : string the home page title location.
Since: 2.6.0:
public get_title_seplocation ( string $seplocation = '', boolean $home = false ) : string
$seplocation string The current seplocation.
$home boolean The home seplocation.
return string The Seplocation

home_page_add_title_tagline() public method

Determines whether to add home page tagline.
Since: 2.6.0

parse_title_args() public method

Parse and sanitize title args.
Since: 2.4.0
public parse_title_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.

post_title_from_ID() public method

Returns Post Title from ID.
Since: 2.6.0
public post_title_from_ID ( integer $id, string $title = '' ) : string
$id integer The Post ID.
$title string Optional. The current/fallback Title.
return string Post Title

process_title_additions() public method

Adds the title additions to the title.
Since: 2.6.0
public process_title_additions ( string $title = '', string $blogname = '', string $seplocation = '' ) : string
$title string The tite.
$blogname string The blogname.
$seplocation string The separator location.
return string Title with possible additions.

reparse_title_args() public method

Reparses title args.
Since: 2.6.0
public reparse_title_args ( array $args = [] ) : array
$args array required The passed arguments.
return array $args parsed args.

single_term_title() public method

Fetches single term title.
Since: 2.6.0
public single_term_title ( $prefix = '', $display = true, $term = null ) : string
return string Single term title.

title() public method

Always use this function for the title unless you're absolutely sure what you're doing. This function is used for all these: Taxonomies and Terms, Posts, Pages, Blog, front page, front-end, back-end.
Since: 1.0.0 Params required wp_title filter :
Since: 2.4.0:
public title ( string $title = '', string $sep = '', string $seplocation = '', array $args = [] ) : string
$title string The Title to return
$sep string The Title sepeartor
$seplocation string The Title sepeartor location ( accepts 'left' or 'right' )
$args array : accepted args : { @param int term_id The Taxonomy Term ID when taxonomy is also filled in. Else post ID. @param string taxonomy The Taxonomy name. @param bool page_on_front Page on front condition for example generation. @param bool placeholder Generate placeholder, ignoring options. @param bool notagline Generate title without tagline. @param bool meta Ignore doing_it_wrong. Used in og:title/twitter:title @param bool get_custom_field Do not fetch custom title when false. @param bool description_title Fetch title for description. @param bool is_front_page Fetch front page title. }
return string $title Title

title_for_home() public method

Essentially falling back to the blogname. Not to be confused with $blogname.
Since: 2.2.8
public title_for_home ( string $home_title = '', boolean $get_custom_field = true, boolean $escape = false, boolean $get_option = true ) : string
$home_title string The fallback title.
$get_custom_field boolean Fetch Title from InPost Custom Fields.
$escape boolean Parse Title through saninitation calls.
$get_option boolean Whether to fetch the SEO Settings option.
return string The Title.

title_for_terms() public method

Gets the title for Category, Tag or Taxonomy
Since: 2.2.8
public title_for_terms ( array $args = [], boolean $escape = false ) : string
$args array The Title arguments.
$escape boolean Parse Title through saninitation calls.
return string The Title.

title_from_custom_field() public method

Gets the title from custom field
Since: 2.2.8
public title_from_custom_field ( string $title = '', boolean $escape = false, integer $id = null, string $taxonomy = null ) : string
$title string the fallback title.
$escape boolean Parse Title through saninitation calls.
$id integer The Post ID.
$taxonomy string The term name.
return string The Title.

title_from_special_fields() public method

Used before and has priority over custom fields. Front end only.
Since: 2.5.2
public title_from_special_fields ( ) : string
return string $title Title from Special Field.

untitled() public method

Returns untitled title.
Since: 2.6.0
public untitled ( ) : string
return string Untitled. Not escaped.

use_archive_prefix() public method

Determines whether to use a title prefix or not.
Since: 2.6.0
public use_archive_prefix ( object $term = null, array $args = [] ) : boolean
$term object The Term object.
$args array The title arguments.
return boolean