You appear to be a bot. Output may be restricted
Description
Store a sitemap of given type and index in the database.
Note that the timestamp is reencoded as 'Y-m-d H:i:s'. If a sitemap with that type and name does not exist, create it. If a sitemap with that type and name does exist, update it.
Usage
Jetpack_Sitemap_Librarian::store_sitemap_data( $index, $type, $contents, $timestamp );
Parameters
- $index
- ( string ) required – Index of the sitemap to be stored.
- $type
- ( string ) required – Type of the sitemap to be stored.
- $contents
- ( string ) required – Contents of the sitemap to be stored.
- $timestamp
- ( string ) required – Timestamp of the sitemap to be stored, in 'YYYY-MM-DD hh:mm:ss' format.
Returns
void
Source
File name: jetpack/modules/sitemaps/sitemap-librarian.php
Lines:
1 to 28 of 28
public function store_sitemap_data( $index, $type, $contents, $timestamp ) { $name = jp_sitemap_filename( $type, $index ); $the_post = $this->read_sitemap_data( $name, $type ); if ( null === $the_post ) { // Post does not exist. wp_insert_post( array( 'post_title' => $name, 'post_content' => base64_encode( $contents ), 'post_type' => $type, 'post_date' => date( 'Y-m-d H:i:s', strtotime( $timestamp ) ), ) ); } else { // Post does exist. wp_insert_post( array( 'ID' => $the_post['id'], 'post_title' => $name, 'post_content' => base64_encode( $contents ), 'post_type' => $type, 'post_date' => date( 'Y-m-d H:i:s', strtotime( $timestamp ) ), ) ); } }