PHP Class The_SEO_Framework\Generate_Description

Generates Description SEO data based on content.
Since: 2.7.1
Inheritance: extends Generate
Show file Open project: sybrew/the-seo-framework

Public Methods

Method Description
add_description_additions ( integer $id = '', object | string $term = '' ) : boolean Determines whether to add description additions. (╯°□°)╯︵ ┻━┻
description_from_custom_field ( array $args = [], boolean $escape = true ) : string | mixed Creates description from custom fields.
escape_description ( string $description = '' ) : string Escapes and beautifies description.
generate_description ( string $description = '', array $args = [] ) : string Creates description. Base function.
generate_description_additions ( integer $id = '', object | empty $term = '', boolean $ignore = false ) : array Generates description additions.
generate_description_from_id ( array $args = [], boolean $escape = true ) : string Generates description from content while parsing filters.
generate_description_title ( integer $id = '', void | object $term = '', boolean $page_on_front = false ) : string Generates the Title for description.
generate_excerpt ( integer | string $page_id, object | null $term = '', integer $max_char_length = 155 ) Generates the excerpt.
generate_home_page_description ( boolean $custom_field = true, boolean $escape = true ) : string Generates the home page description.
get_description_separator ( ) : string Gets Description Separator.
parse_description_args ( array $args = [], array $defaults = [], boolean $get_defaults = false ) : array Parses and sanitizes description arguments.
reparse_description_args ( array $args = [] ) : array Reparses description args.
trim_excerpt ( string $excerpt, integer $excerpt_length, integer $max_char_length ) : string Trims the excerpt by word and determines sentence stops.

Protected Methods

Method Description
__construct ( ) Constructor, loads parent constructor.
generate_the_description ( array $args, boolean $escape = true ) : string Generates description from content.
get_custom_archive_description ( array $args ) : string Fetch Archive Description from custom field.
get_custom_homepage_description ( array $args ) : string Fetches HomePage Description from custom field.
get_custom_singular_description ( integer $id ) : string Fetches Singular Description from custom field.

Method Details

__construct() protected method

Constructor, loads parent constructor.
protected __construct ( )

add_description_additions() public method

Determines whether to add description additions. (╯°□°)╯︵ ┻━┻
Since: 2.6.0
Since: 2.7.0 Removed cache. Whether an excerpt is available is no longer part of this check.
public add_description_additions ( integer $id = '', object | string $term = '' ) : boolean
$id integer The current page or post ID.
$term object | string The current Term.
return boolean Whether to add description additions.

description_from_custom_field() public method

Creates description from custom fields.
Since: 2.4.1
public description_from_custom_field ( array $args = [], boolean $escape = true ) : string | mixed
$args array description args : { @param int $id the term or page id. @param string $taxonomy taxonomy name. @param bool $is_home We're generating for the home page. }
$escape boolean Escape the output if true.
return string | mixed The description.

escape_description() public method

Escapes and beautifies description.
Since: 2.5.2
public escape_description ( string $description = '' ) : string
$description string The description to escape and beautify.
return string Escaped and beautified description.

generate_description() public method

Creates description. Base function.
Since: 1.0.0
public generate_description ( string $description = '', array $args = [] ) : string
$description string The optional description to simply parse.
$args array description args : { @param int $id the term or page id. @param string $taxonomy taxonomy name. @param bool $is_home We're generating for the home page. @param bool $get_custom_field Do not fetch custom title when false. @param bool $social Generate Social Description when true. }
return string The description

generate_description_additions() public method

Generates description additions.
Since: 2.6.0
public generate_description_additions ( integer $id = '', object | empty $term = '', boolean $ignore = false ) : array
$id integer The post or term ID
$term object | empty The term object
$ignore boolean Whether to ignore options and filters.
return array : { $title => The title $on => The word separator $blogname => The blogname $sep => The separator }

generate_description_from_id() public method

Generates description from content while parsing filters.
Since: 2.3.3
public generate_description_from_id ( array $args = [], boolean $escape = true ) : string
$args array description args : { @param int $id the term or page id. @param string $taxonomy taxonomy name. @param bool $is_home We're generating for the home page. @param bool $get_custom_field Do not fetch custom title when false. @param bool $social Generate Social Description when true. }
$escape boolean Escape output when true.
return string $output The description.

generate_description_title() public method

Generates the Title for description.
Since: 2.5.2
public generate_description_title ( integer $id = '', void | object $term = '', boolean $page_on_front = false ) : string
$id integer The page ID.
$term void | object The term object.
$page_on_front boolean If front page.
return string The description title.

generate_excerpt() public method

Generates the excerpt.
Since: 2.3.4
public generate_excerpt ( integer | string $page_id, object | null $term = '', integer $max_char_length = 155 )
$page_id integer | string required : The Page ID
$term object | null The Taxonomy Term.
$max_char_length integer The maximum excerpt char length.

generate_home_page_description() public method

Generates the home page description.
Since: 2.6.0
public generate_home_page_description ( boolean $custom_field = true, boolean $escape = true ) : string
$custom_field boolean whether to check the Custom Field.
$escape boolean Whether to escape the output.
return string The description.

generate_the_description() protected method

Generates description from content.
Since: 2.6.0
protected generate_the_description ( array $args, boolean $escape = true ) : string
$args array description args : { @param int $id the term or page id. @param string $taxonomy taxonomy name. @param bool $is_home We're generating for the home page. @param bool $get_custom_field Do not fetch custom title when false. @param bool $social Generate Social Description when true. }
$escape boolean Whether to escape the description. NOTE: When this is false, be sure to trim the output.
return string The description.

get_custom_archive_description() protected method

Fetch Archive Description from custom field.
Since: 2.6.0 Use $this->description_from_custom_field() instead.
protected get_custom_archive_description ( array $args ) : string
$args array
return string The Description

get_custom_homepage_description() protected method

Fetches HomePage Description from custom field.
Since: 2.6.0 Use $this->description_from_custom_field() instead.
protected get_custom_homepage_description ( array $args ) : string
$args array Description args.
return string The Description

get_custom_singular_description() protected method

Fetches Singular Description from custom field.
Since: 2.6.0 Use $this->description_from_custom_field() instead.
protected get_custom_singular_description ( integer $id ) : string
$id integer The page ID.
return string The Description

get_description_separator() public method

Applies filters 'the_seo_framework_description_separator' : string
Since: 2.3.9
public get_description_separator ( ) : string
return string The Separator, unescaped.

parse_description_args() public method

Parses and sanitizes description arguments.
Since: 2.5.0
public parse_description_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_description_args() public method

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

trim_excerpt() public method

Trims the excerpt by word and determines sentence stops.
Since: 2.6.0
public trim_excerpt ( string $excerpt, integer $excerpt_length, integer $max_char_length ) : string
$excerpt string The untrimmed excerpt.
$excerpt_length integer The current excerpt length.
$max_char_length integer At what point to shave off the excerpt.
return string The trimmed excerpt.