You appear to be a bot. Output may be restricted
Description
Build and store a single image sitemap. Returns false if no sitemap is built.
Side effect: Create/update an image sitemap row.
Usage
$bool|array = Jetpack_Sitemap_Builder::build_one_image_sitemap( $number, $from_id );
Parameters
- $number
- ( int ) required – The number of the current sitemap.
- $from_id
- ( int ) required – The greatest lower bound of the IDs of the posts to be included.
- $last_id
- ( int ) required – The ID of the last item to be successfully added to the buffer.
- $any_left
- ( bool ) required – 'true' if there are items which haven't been saved to a sitemap, 'false' otherwise.
- $last_modified
- ( string ) required – The most recent timestamp to appear on the sitemap. }
Returns
bool|array @args {
Source
File name: jetpack/modules/sitemaps/sitemap-builder.php
Lines:
1 to 61 of 61
public function build_one_image_sitemap( $number, $from_id ) { $last_post_id = $from_id; $any_posts_left = true; if ( $this->logger ) { $debug_name = jp_sitemap_filename( JP_IMAGE_SITEMAP_TYPE, $number ); $this->logger->report( "-- Building $debug_name" ); } $buffer = new Jetpack_Sitemap_Buffer_Image( JP_SITEMAP_MAX_ITEMS, JP_SITEMAP_MAX_BYTES ); // Add as many items to the buffer as possible. while ( false === $buffer->is_full() ) { $posts = $this->librarian->query_images_after_id( $last_post_id, JP_SITEMAP_BATCH_SIZE ); if ( null == $posts ) { // WPCS: loose comparison ok. $any_posts_left = false; break; } foreach ( $posts as $post ) { $current_item = $this->image_post_to_sitemap_item( $post ); if ( true === $buffer->append( $current_item['xml'] ) ) { $last_post_id = $post->ID; $buffer->view_time( $current_item['last_modified'] ); } else { break; } } } // If no items were added, return false. if ( true === $buffer->is_empty() ) { return false; } // Store the buffer as the content of a jp_sitemap post. $this->librarian->store_sitemap_data( $number, JP_IMAGE_SITEMAP_TYPE, $buffer->contents(), $buffer->last_modified() ); /* * Now report back with the ID of the last post to be * successfully added and whether there are any posts left. */ return array( 'last_id' => $last_post_id, 'any_left' => $any_posts_left, 'last_modified' => $buffer->last_modified(), ); }