Properties

$type

$type : string

Sitemap type, either 'url', 'news', or 'index'

Type

string

$requested

$requested : string

The actual requested sitemap module

Type

string

$freq_to_pri

$freq_to_pri : array

Priority mapping

Type

array

$comment_count

$comment_count : 

$now

$now : 

$offset

$offset : 

$url_sofar

$url_sofar : 

$circle

$circle : 

$perma_struct

$perma_struct : 

$post_type

$post_type : 

$limit

$limit : 

$sort_column

$sort_column : string

Column to sort sitemap items by

Type

string

$module_data

$module_data : array

Hold module data coming from main GXS class

Type

array

$part

$part : integer

Requested sitemap part, used for split sitemaps

Type

integer

$data

$data : array

Holds sitemap items

Type

array

$image_allowed

$image_allowed : boolean

Type

boolean

Methods

__construct()

__construct() 

build_sitemap_data()

build_sitemap_data() 

Generate sitemap data based on requested input and current module data

This is meant to be called from main class. To remain back-compat with custom modules, this function must check whether data has already been generated.

set_current_time()

set_current_time() 

set_sort_column()

set_sort_column(  $sort_column) 

Parameters

$sort_column

set_module_data()

set_module_data(  $module_data) 

Parameters

$module_data

is_post_module()

is_post_module() 

Whether this is a post-based module

is_image_allowed()

is_image_allowed() : boolean

Whether this module allows Google image tag

Returns

boolean

get_data()

get_data() 

get_type()

get_type() 

init_module_properties()

init_module_properties() 

get_image_ids_from_posts()

get_image_ids_from_posts(array<mixed,\WP_Post>  $posts) : array

Get ids of the images attached with latest posts

Parameters

array<mixed,\WP_Post> $posts

Returns

array

get_image_data()

get_image_data(integer  $image_id) : mixed

Get actual image data from a single post

Parameters

integer $image_id

Returns

mixed

null|array that should have 'location', 'title' and 'caption'

generate_data()

generate_data() 

This is the main function that generates our data.

Since we are dealing with heavy queries here, it's better that you use generate_data() which will get called by build_data(). This way you will query for no more than the SQL limit configurable in this plugin's option page. If you happen to use LIMIT in your SQL statement for other reasons then use build_data() instead.

init_data()

init_data(array  $pre_data = array()) : array

Allows you to init the current item with previous item’s data.

Parameters

array $pre_data

Previous item's data

Returns

array

get_xml_link()

get_xml_link(  $slug) 

Parameters

$slug

get_sitemap_url()

get_sitemap_url(string  $slug) : string

Get a sitemap's URL based on its slug.

Parameters

string $slug

The sitemap slug, which is actually your module's name (e.g. 'post', 'post_movie', etc.)

Returns

string

A valid sitemap URL with .xml extension appended.

cal_frequency()

cal_frequency(object|null  $item = null, string|null  $lastmod = null) 

Calculate change frequency.

This allows you to calculate change frequency based on item's last modified time or a specific last modified time.

Parameters

object|null $item
string|null $lastmod

Last modified datetime in local timezone. This parameter is only used when $item is not set.

cal_priority()

cal_priority(object  $item, string  $freq = 'daily') 

Calculate the priority for a specific item.

Allows you to calculate priority based on item's freshness, comment count, and change frequency.

Parameters

object $item
string $freq

The calculated change frequency.

get_datetime_from_post()

get_datetime_from_post(object  $post, boolean  $publish = false) : string

Get datetime from a post object's field

Parameters

object $post
boolean $publish

whether to get the publish date or the last modified date, default to false

Returns

string

get_lastmod()

get_lastmod(object  $post) 

Get formatted last modified datetime of a post

This allows you to get the proper last modified date from a post object.

Parameters

object $post

get_published_datetime()

get_published_datetime(object  $post) 

Get formatted published datetime of a post

Parameters

object $post

format_datetime()

format_datetime(  $datetime) 

Format a provided datetime with correct timezone info

Parameters

$datetime

format_local_datetime()

format_local_datetime(string|integer|\DateTime  $datetime) 

Format a local datetime with correct timezone info.

Parameters

string|integer|\DateTime $datetime

Datetime of all formats that PHP supports, for example you can use 1215282385 (Unix Timestamp) or 2015-12-12. See http://php.net/manual/en/datetime.formats.php for more info. This parameter is expected in local timezone.

format_lastmod()

format_lastmod(integer  $lastmod) 

This function is here to remain BC only, and is not used in any default modules

Parameters

integer $lastmod

last modified datetime in unix timestamp, expected in local time

post_type_uses()

post_type_uses(  $post_type,   $taxonomy_object) 

Parameters

$post_type
$taxonomy_object

get_post_by_post_type()

get_post_by_post_type(  $post_type,   $result) 

Parameters

$post_type
$result

sort_data_by()

sort_data_by(  $column = 'lastmod') 

Parameters

$column

using_permalinks()

using_permalinks() 

get_term_link()

get_term_link(  $term,   $taxonomy = '') 

Get term links without using any SQL queries and the cache.

Parameters

$term
$taxonomy

get_post_permalink()

get_post_permalink(  $leavename = false,   $sample = false) 

Parameters

$leavename
$sample

get_permalink()

get_permalink(  $leavename = false) 

Parameters

$leavename

get_results()

get_results(  $query_str) 

Always call this function when you query for something.

$query_str should be already escaped using either $wpdb->escape() or $wpdb->prepare().

Parameters

$query_str

query_posts()

query_posts(  $query_str) 

Always call this function when you query for something.

$query_str should be similar to what WP_Query accepts.

Parameters

$query_str

init_properties()

init_properties() 

Init any properties that are used in building data

This must be called after module has been set and right before building actual sitemap data

build_data()

build_data()