PHP Class Metro_Sitemap, vip-mu-plugins-public

显示文件 Open project: Automattic/vip-mu-plugins-public Class Usage Examples

Public Methods

Method Description
add_admin_scripts ( )
ajax_get_sitemap_counts ( )
build_individual_sitemap_xml ( $year, $month, $day ) Get XML for individual day
build_root_sitemap_xml ( ) Build Root sitemap XML - currently all days
build_xml ( $request = [] ) Build XML for output to clean up the template file
check_year_has_posts ( ) : int[] Get every year that has valid posts in a range
count_sitemaps ( ) : integer Counts the number of sitemaps that have been generated.
create_post_type ( ) Register our CPT
date_range_has_posts ( string $start_date, string $end_date ) : integer | false Does a current date range have posts?
delete_sitemap_by_id ( $sitemap_id )
delete_sitemap_for_date ( $sitemap_date )
disable_canonical_redirects_for_sitemap_xml ( string $redirect_url, string $requested_url ) : string Disable canonical redirects for the sitemap file
find_valid_days ( $year )
generate_sitemap_for_date ( string $sitemap_date ) Generate sitemap for a date; this is where XML is rendered.
get_date_stamp ( integer $year, integer $month, integer $day ) : string Get properly formatted data stamp from year, month, and day
get_indexed_url_count ( $year, $month, $day ) Gets the number of URLs indexed for the given sitemap.
get_last_modified_posts ( ) : object[] Get posts modified within the last hour
get_post_dates ( object[] $posts ) : string[] Get dates for an array of posts
get_post_ids_for_date ( string $sitemap_date, $limit = 500 ) : array Get a list of support post_type IDs for a given date
get_post_year_range ( ) : int[] Return range of years for posts in the database
get_recent_sitemap_url_counts ( integer $n = 7 ) : array Returns the $n most recent sitemap indexed url counts.
get_sitemap_post_id ( $year, $month, $day )
get_supported_post_types ( )
get_total_indexed_url_count ( ) : integer Gets the current number of URLs indexed by msm-sitemap accross all sitemaps.
is_blog_public ( )
load_sitemap_template ( $template ) Trigger rendering of the actual sitemap
metro_sitemap_menu ( ) Register admin menu for sitemap
render_sitemap_options_page ( ) Render admin options page
robots_txt ( $output, $public ) Add entry to the bottom of robots.txt
setup ( ) Register actions for our hook
show_action_message ( str $message, $level = 'notice' ) Displays a notice, error or warning to the user
sitemap_15_min_cron_interval ( array[] $schedules ) : array[] Register 15 minute cron interval for latest articles
sitemap_init ( ) Register endpoint for sitemap and other hooks
sitemap_init_cron ( ) Add cron jobs required to generate these sitemaps
update_sitemap_from_modified_posts ( ) Update the sitemap with changes from recently modified posts

Private Methods

Method Description
get_supported_post_types_in ( )

Method Details

add_admin_scripts() public static method

public static add_admin_scripts ( )

ajax_get_sitemap_counts() public static method

public static ajax_get_sitemap_counts ( )

build_individual_sitemap_xml() public static method

Get XML for individual day
public static build_individual_sitemap_xml ( $year, $month, $day )

build_root_sitemap_xml() public static method

Build Root sitemap XML - currently all days
public static build_root_sitemap_xml ( )

build_xml() public static method

Build XML for output to clean up the template file
public static build_xml ( $request = [] )

check_year_has_posts() public static method

Get every year that has valid posts in a range
public static check_year_has_posts ( ) : int[]
return int[] years with posts

count_sitemaps() public static method

Counts the number of sitemaps that have been generated.
public static count_sitemaps ( ) : integer
return integer The number of sitemaps that have been generated

create_post_type() public static method

Register our CPT
public static create_post_type ( )

date_range_has_posts() public static method

Does a current date range have posts?
public static date_range_has_posts ( string $start_date, string $end_date ) : integer | false
$start_date string
$end_date string
return integer | false

delete_sitemap_by_id() public static method

public static delete_sitemap_by_id ( $sitemap_id )

delete_sitemap_for_date() public static method

public static delete_sitemap_for_date ( $sitemap_date )

disable_canonical_redirects_for_sitemap_xml() public static method

Disable canonical redirects for the sitemap file
See also: http://codex.wordpress.org/Function_Reference/redirect_canonical
public static disable_canonical_redirects_for_sitemap_xml ( string $redirect_url, string $requested_url ) : string
$redirect_url string
$requested_url string
return string URL to redirect

find_valid_days() public static method

public static find_valid_days ( $year )

generate_sitemap_for_date() public static method

Generate sitemap for a date; this is where XML is rendered.
public static generate_sitemap_for_date ( string $sitemap_date )
$sitemap_date string

get_date_stamp() public static method

Get properly formatted data stamp from year, month, and day
public static get_date_stamp ( integer $year, integer $month, integer $day ) : string
$year integer
$month integer
$day integer
return string formatted stamp

get_indexed_url_count() public static method

Gets the number of URLs indexed for the given sitemap.
public static get_indexed_url_count ( $year, $month, $day )

get_last_modified_posts() public static method

Get posts modified within the last hour
public static get_last_modified_posts ( ) : object[]
return object[] modified posts

get_post_dates() public static method

Get dates for an array of posts
public static get_post_dates ( object[] $posts ) : string[]
$posts object[]
return string[] unique dates of each post.

get_post_ids_for_date() public static method

Get a list of support post_type IDs for a given date
public static get_post_ids_for_date ( string $sitemap_date, $limit = 500 ) : array
$sitemap_date string Date in Y-m-d
return array IDs of posts

get_post_year_range() public static method

Return range of years for posts in the database
public static get_post_year_range ( ) : int[]
return int[] valid years

get_recent_sitemap_url_counts() public static method

Returns the $n most recent sitemap indexed url counts.
public static get_recent_sitemap_url_counts ( integer $n = 7 ) : array
$n integer The number of days of sitemap stats to grab.
return array An array of sitemap stats

get_sitemap_post_id() public static method

public static get_sitemap_post_id ( $year, $month, $day )

get_supported_post_types() public static method

public static get_supported_post_types ( )

get_total_indexed_url_count() public static method

Gets the current number of URLs indexed by msm-sitemap accross all sitemaps.
public static get_total_indexed_url_count ( ) : integer
return integer The number of total number URLs indexed

is_blog_public() public static method

public static is_blog_public ( )

load_sitemap_template() public static method

Trigger rendering of the actual sitemap
public static load_sitemap_template ( $template )

metro_sitemap_menu() public static method

Register admin menu for sitemap
public static metro_sitemap_menu ( )

render_sitemap_options_page() public static method

Render admin options page
public static render_sitemap_options_page ( )

robots_txt() public static method

Add entry to the bottom of robots.txt
public static robots_txt ( $output, $public )

setup() public static method

Register actions for our hook
public static setup ( )

show_action_message() public static method

Displays a notice, error or warning to the user
public static show_action_message ( str $message, $level = 'notice' )
$message str The message to show to the user

sitemap_15_min_cron_interval() public static method

Register 15 minute cron interval for latest articles
public static sitemap_15_min_cron_interval ( array[] $schedules ) : array[]
$schedules array[]
return array[] modified schedules

sitemap_init() public static method

Register endpoint for sitemap and other hooks
public static sitemap_init ( )

sitemap_init_cron() public static method

Add cron jobs required to generate these sitemaps
public static sitemap_init_cron ( )

update_sitemap_from_modified_posts() public static method

Update the sitemap with changes from recently modified posts