You appear to be a bot. Output may be restricted
Description
Construct the image sitemap url entry for a WP_Post of image type.
Usage
$array = Jetpack_Sitemap_Builder::image_post_to_sitemap_item( $post );
Parameters
- $post
- ( WP_Post ) required – The image post to be processed.
- $xml
- ( array ) required – An XML fragment representing the post URL.
- $last_modified
- ( string ) required – Date post was last modified.
Returns
array
Source
File name: jetpack/modules/sitemaps/sitemap-builder.php
Lines:
1 to 70 of 70
private function image_post_to_sitemap_item( $post ) { /** * Filter condition to allow skipping specific image posts in the sitemap. * * @module sitemaps * * @since 4.8.0 * * @param bool $skip Current boolean. False by default, so no post is skipped. * @param WP_POST $post Current post object. */ if ( apply_filters( 'jetpack_sitemap_image_skip_post', false, $post ) ) { return array( 'xml' => null, 'last_modified' => null, ); } $url = wp_get_attachment_url( $post->ID ); // Do not include the image if the attached parent is not published. // Unattached will be published. Otherwise, will inherit parent status. if ( 'publish' !== get_post_status( $post ) ) { return array( 'xml' => null, 'last_modified' => null, ); } $parent_url = get_permalink( get_post( $post->post_parent ) ); if ( '' == $parent_url ) { // WPCS: loose comparison ok. $parent_url = get_permalink( $post ); } $item_array = array( 'url' => array( 'loc' => $parent_url, 'lastmod' => jp_sitemap_datetime( $post->post_modified_gmt ), 'image:image' => array( 'image:loc' => $url, ), ), ); $item_array['url']['image:image']['image:title'] = $post->post_title; $item_array['url']['image:image']['image:caption'] = $post->post_excerpt; /** * Filter associative array with data to build <url> node * and its descendants for current post in image sitemap. * * @module sitemaps * * @since 4.8.0 * * @param array $item_array Data to build parent and children nodes for current post. * @param int $post_id Current image post ID. */ $item_array = apply_filters( 'jetpack_sitemap_image_sitemap_item', $item_array, $post->ID ); return array( 'xml' => $item_array, 'last_modified' => $post->post_modified_gmt, ); }