PHP Class WPSEO_Metabox, wordpress-seo

Inheritance: extends WPSEO_Meta
Show file Open project: yoast/wordpress-seo Class Usage Examples

Protected Properties

Property Type Description
$analysis_readability WPSEO_Metabox_Analysis_Readability
$analysis_seo WPSEO_Metabox_Analysis_SEO
$social_admin WPSEO_Social_Admin

Public Methods

Method Description
__construct ( ) Class constructor
aasort ( array &$array, string $key )
add_custom_box ( ) Adds the Yoast SEO box
add_meta_box ( ) Adds the Yoast SEO meta box to the edit boxes in the edit post, page, attachment, and custom post types pages.
calculate_results ( object $post ) : array | WP_Error
check_double_focus_keyword ( array $job, array &$results )
column_content ( string $column_name, integer $post_id )
column_heading ( array $columns ) : array
column_hidden ( array | false $result, string $option, WP_User $user ) : array | false
column_sort ( array $columns ) : array
column_sort_orderby ( array $vars ) : array
do_meta_box ( array $meta_field_def, string $key = '' ) : string Adds a line in the meta box
do_tab ( string $id, string $heading, string $content ) Output a tab in the Yoast SEO Metabox
enqueue ( ) Enqueues all the needed JS and CSS.
get_anchor_count ( object &$xpath ) : array
get_anchor_texts ( object &$xpath ) : array
get_body ( object $post ) : string
get_first_paragraph ( string $body ) : string
get_headings ( string $postcontent ) : array
get_images_alt_text ( integer $post_id, string $body, array $imgs ) : array
get_meta_boxes ( string $post_type = 'post' ) : array Retrieve the meta boxes for the given post type.
get_metadesc_template ( object $post ) : string
get_post_date ( WP_Post $post ) : string
get_sample_permalink ( WP_Post $post ) : array
get_title_template ( object $post ) : string
is_meta_value_disabled ( string $key ) : boolean Determines if the given meta value key is disabled
is_metabox_hidden ( string $post_type = null ) : boolean Test whether the metabox should be hidden either by choice of the admin or because the post type is not a public post type
is_post_edit ( string $page ) : boolean
is_post_overview ( string $page ) : boolean
linkdex_output ( object $post ) : string
localize_media_script ( ) : array Pass some variables to js for upload module.
localize_post_scraper_script ( ) : array Pass variables to js for use with the post-scraper
localize_replace_vars_script ( ) Pass some variables to js for replacing variables.
localize_script ( ) : array
localize_shortcode_plugin_script ( ) : array Pass some variables to js for the edit / post page overview, snippet preview, etc.
meta_box ( ) Output the meta box
page_title ( integer $post_id ) : string
posts_filter_dropdown ( )
publish_box ( ) Outputs the page analysis score in the Publish Box.
save_postdata ( integer $post_id ) : boolean | void Save the WP SEO metadata for posts.
save_score_result ( array &$results, integer $scoreValue, string $scoreMessage, string $scoreLabel, string $rawScore = null )
score_anchor_texts ( array $job, array &$results, array $anchor_texts, array $count )
score_body ( array $job, array &$results, string $body, string $firstp )
score_description ( array $job, array &$results, string $description, integer $maxlength = 155 )
score_headings ( array $job, array &$results, array $headings )
score_images_alt_text ( array $job, array &$results, array $imgs )
score_keyword ( string $keyword, array &$results )
score_title ( array $job, array &$results )
score_url ( array $job, array &$results )
script ( ) Pass some variables to js
seo_score_posts_where ( string $where ) : string
setup_page_analysis ( ) Sets up all the functionality related to the prominence of the page analysis functionality.
snippet ( ) : string
strip_separators_and_fold ( string $inputString, boolean $removeOptionalCharacters ) : string
strtolower_utf8 ( string $string ) : string
template_generic_tab ( ) Generic tab.
template_keyword_tab ( ) Keyword tab for enabling analysis of multiple keywords.
traffic_light_svg ( ) Return the SVG for the traffic light in the metabox.
translate_meta_boxes ( ) Translate text strings for use in the meta box
wpseo_metabox_class ( array $classes ) : array Adds CSS classes to the meta box.

Protected Methods

Method Description
get_metabox_post ( ) Returns post in metabox context

Private Methods

Method Description
create_content_box ( string $content, string $hidden_help_name, string $help_button, string $help_panel ) : string Creates a sections specific row.
determine_scope ( ) : string Determines the scope based on the post type.
get_addons_meta_section ( ) : WPSEO_Metabox_Section Returns a metabox section dedicated to hosting metabox tabs that have been added by other plugins through the wpseo_tab_header and wpseo_tab_content actions.
get_advanced_meta_section ( ) : WPSEO_Metabox_Section Returns the metabox section for the advanced settings.
get_buy_premium_link ( ) : string Returns a link to activate the Buy Premium tab.
get_buy_premium_section ( ) : WPSEO_Metabox_Section Returns the metabox section for the Premium section.
get_content_meta_section ( ) : WPSEO_Metabox_Section Returns the metabox section for the content analysis.
get_content_sections ( ) : WPSEO_Metabox_Section[] Returns the relevant metabox sections for the current view.
get_custom_fields_replace_vars ( WP_Post $post ) : array Gets the custom replace variables for custom fields.
get_custom_replace_vars ( WP_Post $post ) : array Gets the custom replace variables for custom taxonomies and fields.
get_custom_taxonomies_replace_vars ( WP_Post $post ) : array Gets the custom replace variables for custom taxonomies.
get_replace_vars ( ) : array Prepares the replace vars for localization.
get_tab_content ( string $tab_name ) : string Gets the table contents for the metabox tab.
get_valid_shortcode_tags ( ) : array Returns an array with shortcode tags for all registered shortcodes.

Method Details

__construct() public method

Class constructor
public __construct ( )

aasort() public method

Deprecation: 3.0
public aasort ( array &$array, string $key )
$array array Array to sort, array is returned sorted.
$key string Key to sort array by.

add_custom_box() public method

Adds the Yoast SEO box
See also: WPSEO_Meta::add_meta_box()
Deprecation: 1.4.24
Deprecation: use WPSEO_Metabox::add_meta_box()
public add_custom_box ( )

add_meta_box() public method

Adds the Yoast SEO meta box to the edit boxes in the edit post, page, attachment, and custom post types pages.
public add_meta_box ( )

calculate_results() public method

Deprecation: 3.0
public calculate_results ( object $post ) : array | WP_Error
$post object Post to calculate the results for.
return array | WP_Error

check_double_focus_keyword() public method

Deprecation: 3.0
public check_double_focus_keyword ( array $job, array &$results )
$job array Job data array.
$results array Results set by reference.

column_content() public method

Deprecation: 3.0 Use WPSEO_Meta_Columns::column_content instead.
public column_content ( string $column_name, integer $post_id )
$column_name string Column to display the content for.
$post_id integer Post to display the column content for.

column_heading() public method

Deprecation: 3.0 Use WPSEO_Meta_Columns::column_heading instead.
public column_heading ( array $columns ) : array
$columns array Already existing columns.
return array

column_hidden() public method

Deprecation: 3.0 Use WPSEO_Meta_Columns::column_hidden instead.
public column_hidden ( array | false $result, string $option, WP_User $user ) : array | false
$result array | false The hidden columns.
$option string The option name used to set which columns should be hidden.
$user WP_User The User.
return array | false $result

column_sort() public method

Deprecation: 3.0 Use WPSEO_Meta_Columns::column_sort instead.
public column_sort ( array $columns ) : array
$columns array appended with their orderby variable.
return array

column_sort_orderby() public method

Deprecation: 3.0 Use WPSEO_Meta_Columns::column_sort_orderby instead.
public column_sort_orderby ( array $vars ) : array
$vars array Query variables.
return array

do_meta_box() public method

Adds a line in the meta box
public do_meta_box ( array $meta_field_def, string $key = '' ) : string
$meta_field_def array Contains the vars based on which output is generated.
$key string Internal key (without prefix).
return string

do_tab() public method

Output a tab in the Yoast SEO Metabox
public do_tab ( string $id, string $heading, string $content )
$id string CSS ID of the tab.
$heading string Heading for the tab.
$content string Content of the tab. This content should be escaped.

enqueue() public method

Enqueues all the needed JS and CSS.
public enqueue ( )

get_anchor_count() public method

Deprecation: 3.0
public get_anchor_count ( object &$xpath ) : array
$xpath object An XPATH object of the current document.
return array

get_anchor_texts() public method

Deprecation: 3.0
public get_anchor_texts ( object &$xpath ) : array
$xpath object An XPATH object of the current document.
return array

get_body() public method

Deprecation: 3.0
public get_body ( object $post ) : string
$post object The post object.
return string The post content.

get_first_paragraph() public method

Deprecation: 3.0
public get_first_paragraph ( string $body ) : string
$body string The post content to retrieve the first paragraph from.
return string

get_headings() public method

Deprecation: 3.0
public get_headings ( string $postcontent ) : array
$postcontent string Post content to find headings in.
return array Array of heading texts.

get_images_alt_text() public method

Deprecation: 3.0
public get_images_alt_text ( integer $post_id, string $body, array $imgs ) : array
$post_id integer The post to find images in.
$body string The post content to find images in.
$imgs array The array holding the image information.
return array The updated images array.

get_meta_boxes() public method

Retrieve the meta boxes for the given post type.
See also: WPSEO_Meta::get_meta_field_defs()
Deprecation: 1.5.0
Deprecation: use WPSEO_Meta::get_meta_field_defs()
public get_meta_boxes ( string $post_type = 'post' ) : array
$post_type string The post type for which to get the meta fields.
return array

get_metabox_post() protected method

Returns post in metabox context
protected get_metabox_post ( )

get_metadesc_template() public static method

Deprecation: 3.2 Retrieves the metadesc template.
public static get_metadesc_template ( object $post ) : string
$post object metabox post.
return string

get_post_date() public method

Deprecation: 3.2 Retrieve a post date when post is published, or return current date when it's not.
public get_post_date ( WP_Post $post ) : string
$post WP_Post The post for which to retrieve the post date.
return string

get_title_template() public static method

Deprecation: 3.2 Retrieves the title template.
public static get_title_template ( object $post ) : string
$post object metabox post.
return string

is_meta_value_disabled() public method

Determines if the given meta value key is disabled
public is_meta_value_disabled ( string $key ) : boolean
$key string The key of the meta value.
return boolean Whether the given meta value key is disabled.

is_metabox_hidden() public method

Test whether the metabox should be hidden either by choice of the admin or because the post type is not a public post type
Since: 1.5.0
public is_metabox_hidden ( string $post_type = null ) : boolean
$post_type string (optional) The post type to test, defaults to the current post post_type.
return boolean Whether or not the meta box (and associated columns etc) should be hidden

is_post_edit() public static method

public static is_post_edit ( string $page ) : boolean
$page string The page to check for the post edit page.
return boolean Whether or not the given page is the post edit page.

is_post_overview() public static method

public static is_post_overview ( string $page ) : boolean
$page string The page to check for the post overview page.
return boolean Whether or not the given page is the post overview page.

linkdex_output() public method

Deprecation: 3.0
public linkdex_output ( object $post ) : string
$post object Post to output the page analysis results for.
return string

localize_media_script() public method

Pass some variables to js for upload module.
public localize_media_script ( ) : array
return array

localize_post_scraper_script() public method

Pass variables to js for use with the post-scraper

localize_replace_vars_script() public method

Pass some variables to js for replacing variables.

localize_script() public method

Deprecation: 3.0 Removed.
public localize_script ( ) : array
return array

localize_shortcode_plugin_script() public method

Pass some variables to js for the edit / post page overview, snippet preview, etc.

meta_box() public method

Output the meta box
public meta_box ( )

page_title() public method

Deprecation: 3.0 Removed.
public page_title ( integer $post_id ) : string
$post_id integer Post to retrieve the title for.
return string

posts_filter_dropdown() public method

Deprecation: 3.0 Use WPSEO_Meta_Columns::posts_filter_dropdown instead.

publish_box() public method

Outputs the page analysis score in the Publish Box.
public publish_box ( )

save_postdata() public method

Save the WP SEO metadata for posts.
public save_postdata ( integer $post_id ) : boolean | void
$post_id integer Post ID.
return boolean | void Boolean false if invalid save post request

save_score_result() public method

Deprecation: 3.0
public save_score_result ( array &$results, integer $scoreValue, string $scoreMessage, string $scoreLabel, string $rawScore = null )
$results array The results array used to store results.
$scoreValue integer The score value.
$scoreMessage string The score message.
$scoreLabel string The label of the score to use in the results array.
$rawScore string The raw score, to be used by other filters.

score_anchor_texts() public method

Deprecation: 3.0
public score_anchor_texts ( array $job, array &$results, array $anchor_texts, array $count )
$job array The job array holding both the keyword versions.
$results array The results array.
$anchor_texts array The array holding all anchors in the document.
$count array The number of anchors in the document, grouped by type.

score_body() public method

Deprecation: 3.0
public score_body ( array $job, array &$results, string $body, string $firstp )
$job array The array holding the keywords.
$results array The results array.
$body string The body.
$firstp string The first paragraph.

score_description() public method

Deprecation: 3.0
public score_description ( array $job, array &$results, string $description, integer $maxlength = 155 )
$job array The array holding the keywords.
$results array The results array.
$description string The meta description.
$maxlength integer The maximum length of the meta description.

score_headings() public method

Deprecation: 3.0
public score_headings ( array $job, array &$results, array $headings )
$job array The array holding the keywords.
$results array The results array.
$headings array The headings found in the document.

score_images_alt_text() public method

Deprecation: 3.0
public score_images_alt_text ( array $job, array &$results, array $imgs )
$job array The job array holding both the keyword versions.
$results array The results array.
$imgs array The array with images alt texts.

score_keyword() public method

Deprecation: 3.0
public score_keyword ( string $keyword, array &$results )
$keyword string The keyword to check for stopwords.
$results array The results array.

score_title() public method

Deprecation: 3.0
public score_title ( array $job, array &$results )
$job array The job array holding both the keyword versions.
$results array The results array.

score_url() public method

Deprecation: 3.0
public score_url ( array $job, array &$results )
$job array The job array holding both the keyword and the URLs.
$results array The results array.

script() public method

Pass some variables to js
See also: WPSEO_Meta::localize_script()
Deprecation: 1.5.0
Deprecation: use WPSEO_Meta::localize_script()
public script ( )

seo_score_posts_where() public method

Deprecation: 3.0 Use WPSEO_Meta_Columns::seo_score_posts_where instead.
public seo_score_posts_where ( string $where ) : string
$where string Where clause.
return string

setup_page_analysis() public method

Sets up all the functionality related to the prominence of the page analysis functionality.
public setup_page_analysis ( )

snippet() public method

Deprecation: 3.0 Removed, use javascript functions instead.
public snippet ( ) : string
return string

strip_separators_and_fold() public method

Deprecation: 3.0
public strip_separators_and_fold ( string $inputString, boolean $removeOptionalCharacters ) : string
$inputString string String to clean up.
$removeOptionalCharacters boolean Whether or not to do a cleanup of optional chars too.
return string

strtolower_utf8() public method

Deprecation: 3.0 Removed, use javascript functions instead
public strtolower_utf8 ( string $string ) : string
$string string Deprecated.
return string

template_generic_tab() public method

Generic tab.

template_keyword_tab() public method

Keyword tab for enabling analysis of multiple keywords.

traffic_light_svg() public method

Return the SVG for the traffic light in the metabox.
public traffic_light_svg ( )

translate_meta_boxes() public static method

IMPORTANT: if you want to add a new string (option) somewhere, make sure you add that array key to the main meta box definition array in the class WPSEO_Meta() as well!!!!
public static translate_meta_boxes ( )

wpseo_metabox_class() public method

Adds CSS classes to the meta box.
public wpseo_metabox_class ( array $classes ) : array
$classes array An array of postbox CSS classes.
return array

Property Details

$analysis_readability protected property

protected WPSEO_Metabox_Analysis_Readability $analysis_readability
return WPSEO_Metabox_Analysis_Readability

$analysis_seo protected property

protected WPSEO_Metabox_Analysis_SEO $analysis_seo
return WPSEO_Metabox_Analysis_SEO

$social_admin protected property

protected WPSEO_Social_Admin $social_admin
return WPSEO_Social_Admin