• 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_Builder::build_next_sitemap_index_of_type() – Build the next sitemap index of a given type and update the state.

You appear to be a bot. Output may be restricted

Description

Build the next sitemap index of a given type and update the state.

Usage

Jetpack_Sitemap_Builder::build_next_sitemap_index_of_type( $index_type, $next_type, $state );

Parameters

$index_type
( string ) required – The type of index being generated.
$next_type
( string ) required – The next type to generate after this one.
$state
( array ) required – A sitemap state.

Returns

void

Source

File name: jetpack/modules/sitemaps/sitemap-builder.php
Lines:

1 to 94 of 94
  private function build_next_sitemap_index_of_type( $index_type, $next_type, $state ) {
    $sitemap_type = jp_sitemap_child_type_of( $index_type );

    // If only 0 or 1 sitemaps were built, advance to the next type and return.
    if ( 1 >= $state['max'][ $sitemap_type ]['number'] ) {
      Jetpack_Sitemap_State::check_in(
        array(
          'sitemap-type'  => $next_type,
          'last-added'    => 0,
          'number'        => 0,
          'last-modified' => '1970-01-01 00:00:00',
        )
      );

      if ( $this->logger ) {
        $this->logger->report( "-- Cleaning Up $index_type" );
      }

      // There are no indices of this type.
      $this->librarian->delete_numbered_sitemap_rows_after(
        0,
        $index_type
      );

      return;
    }

    // Otherwise, try to build a sitemap index.
    $result = $this->build_one_sitemap_index(
      $state['number'] + 1,
      $state['last-added'],
      $state['last-modified'],
      $index_type
    );

    // If no index was built, advance to the next type and return.
    if ( false === $result ) {
      Jetpack_Sitemap_State::check_in(
        array(
          'sitemap-type'  => $next_type,
          'last-added'    => 0,
          'number'        => 0,
          'last-modified' => '1970-01-01 00:00:00',
        )
      );

      if ( $this->logger ) {
        $this->logger->report( "-- Cleaning Up $index_type" );
      }

      // Clean up old files.
      $this->librarian->delete_numbered_sitemap_rows_after(
        $state['number'],
        $index_type
      );

      return;
    }

    // Otherwise, check in the state.
    Jetpack_Sitemap_State::check_in(
      array(
        'sitemap-type'  => $index_type,
        'last-added'    => $result['last_id'],
        'number'        => $state['number'] + 1,
        'last-modified' => $result['last_modified'],
      )
    );

    // If there are still sitemaps left to index, return.
    if ( true === $result['any_left'] ) {
      return;
    }

    // Otherwise, advance to the next type.
    Jetpack_Sitemap_State::check_in(
      array(
        'sitemap-type'  => $next_type,
        'last-added'    => 0,
        'number'        => 0,
        'last-modified' => '1970-01-01 00:00:00',
      )
    );

    if ( $this->logger ) {
      $this->logger->report( "-- Cleaning Up $index_type" );
    }

    // We're done generating indices of this type.
    $this->librarian->delete_numbered_sitemap_rows_after(
      $state['number'] + 1,
      $index_type
    );
  }
 

 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_Builder::build_next_sitemap_index_of_type
Class ref: Jetpack_Sitemap_Builder
Plugin ref: Jetpack
Version: 9.5
Sourcefile: modules/sitemaps/sitemap-builder.php
File ref: modules/sitemaps/sitemap-builder.php
Deprecated?: No
API Letters: B,J,N,S

Footer

Jetpack a2z
Jetpack a2z
Jetpack a2z
WordPress 5.7
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