You appear to be a bot. Output may be restricted
Description
Construct the video sitemap url entry for a WP_Post of video type.
Usage
$array = Jetpack_Sitemap_Builder::video_post_to_sitemap_item( $post );
Parameters
- $post
- ( WP_Post ) required – The video 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 94 of 94
private function video_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_video_skip_post', false, $post ) ) { return array( 'xml' => null, 'last_modified' => null, ); } // Do not include the video 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 = esc_url( get_permalink( get_post( $post->post_parent ) ) ); if ( '' == $parent_url ) { // WPCS: loose comparison ok. $parent_url = esc_url( get_permalink( $post ) ); } // Prepare the content like get_the_content_feed(). $content = $post->post_content; /** This filter is already documented in core/wp-includes/post-template.php */ $content = apply_filters( 'the_content', $content ); /** This filter is already documented in core/wp-includes/feed.php */ $content = apply_filters( 'the_content_feed', $content, 'rss2' ); // Include thumbnails for VideoPress videos, use blank image for others if ( 'complete' === get_post_meta( $post->ID, 'videopress_status', true ) && has_post_thumbnail( $post ) ) { $video_thumbnail_url = get_the_post_thumbnail_url( $post ); } else { /** * Filter the thumbnail image used in the video sitemap for non-VideoPress videos. * * @since 7.2.0 * * @param string $str Image URL. */ $video_thumbnail_url = apply_filters( 'jetpack_video_sitemap_default_thumbnail', 'https://s0.wp.com/i/blank.jpg' ); } $item_array = array( 'url' => array( 'loc' => $parent_url, 'lastmod' => jp_sitemap_datetime( $post->post_modified_gmt ), 'video:video' => array( /** This filter is already documented in core/wp-includes/feed.php */ 'video:title' => apply_filters( 'the_title_rss', $post->post_title ), 'video:thumbnail_loc' => esc_url( $video_thumbnail_url ), 'video:description' => $content, 'video:content_loc' => esc_url( wp_get_attachment_url( $post->ID ) ), ), ), ); // TODO: Integrate with VideoPress here. // cf. video:player_loc tag in video sitemap spec. /** * Filter associative array with data to build <url> node * and its descendants for current post in video 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 video post ID. */ $item_array = apply_filters( 'jetpack_sitemap_video_sitemap_item', $item_array, $post->ID ); return array( 'xml' => $item_array, 'last_modified' => $post->post_modified_gmt, ); }