• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Jetpack a2z

Jetpack a2z

Jetpack a2z

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Jetpack_Sitemap_Librarian::store_sitemap_data() – Store a sitemap of given type and index in the database.

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 ) ),
        )
      );
    }
  }
 

 View on GitHub View on Trac

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Related

Published: 27 November 2019 | Last updated: 27 November 2019

Primary Sidebar

Information

Function name: Jetpack_Sitemap_Librarian::store_sitemap_data
Class ref: Jetpack_Sitemap_Librarian
Plugin ref: Jetpack
Version: 9.2
Sourcefile: modules/sitemaps/sitemap-librarian.php
File ref: modules/sitemaps/sitemap-librarian.php
Deprecated?: No
API Letters: J,L,S

Footer

Jetpack a2z
Jetpack a2z
Jetpack a2z
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  jetpack.wp-a2z.org
© Copyright Jetpack a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites