PHP Class Jetpack_SEO_Titles, jetpack

ファイルを表示 Open project: automattic/jetpack Class Usage Examples

Public Methods

Method Description
are_valid_title_formats ( array $title_formats ) : boolean Checks if a given format conforms to predefined SEO title templates.
get_allowed_tokens ( ) : array Returns tokens that are currently supported for each page type.
get_custom_title ( string $default_title = '' ) : string Used to modify the default title with custom SEO title.
get_custom_title_formats ( ) : array Retrieves custom title formats from site option.
get_date_for_title ( ) : string Returns the value that should be used as a replacement for the date token, depending on the archive path specified.
get_page_type ( ) : string | boolean Returns page type for current page. We need this helper in order to determine what user defined title format should be used for custom title.
get_token_value ( string $token_name ) : string Returns string value for given token.
is_conflicted_theme ( ) : boolean Checks if current theme is defining custom title that won't work nicely with our custom SEO title override.
update_title_formats ( array $new_formats ) : array Combines the previous values of title formats, stored as array in site options, with the new values that are provided.

Method Details

are_valid_title_formats() public static method

Every format type and token must be whitelisted.
See also: get_allowed_tokens()
public static are_valid_title_formats ( array $title_formats ) : boolean
$title_formats array Template of SEO title to check.
return boolean True if the formats are valid, false otherwise.

get_allowed_tokens() public static method

Returns tokens that are currently supported for each page type.
public static get_allowed_tokens ( ) : array
return array Array of allowed token strings.

get_custom_title() public static method

Used to modify the default title with custom SEO title.
public static get_custom_title ( string $default_title = '' ) : string
$default_title string Default title for current page.
return string Custom title with replaced tokens or default title.

get_custom_title_formats() public static method

Retrieves custom title formats from site option.
public static get_custom_title_formats ( ) : array
return array Array of custom title formats, or empty array.

get_date_for_title() public static method

Returns the value that should be used as a replacement for the date token, depending on the archive path specified.
public static get_date_for_title ( ) : string
return string Token replacement for a given date, or empty string if no date is specified.

get_page_type() public static method

Returns page type for current page. We need this helper in order to determine what user defined title format should be used for custom title.
public static get_page_type ( ) : string | boolean
return string | boolean Type of current page or false if unsupported.

get_token_value() public static method

Returns string value for given token.
public static get_token_value ( string $token_name ) : string
$token_name string The token name value that should be replaced.
return string Token replacement for current site, or empty string for unknown token name.

is_conflicted_theme() public static method

Checks if current theme is defining custom title that won't work nicely with our custom SEO title override.
public static is_conflicted_theme ( ) : boolean
return boolean True if current theme sets custom title, false otherwise.

update_title_formats() public static method

Combines the previous values of title formats, stored as array in site options, with the new values that are provided.
public static update_title_formats ( array $new_formats ) : array
$new_formats array Array containing new title formats.
return array $result Array of updated title formats, or empty array if no update was performed.