• 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::video_post_to_sitemap_item() – Construct the video sitemap url entry for a WP_Post of video type.

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

 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: 21 August 2020

Primary Sidebar

Information

Function name: Jetpack_Sitemap_Builder::video_post_to_sitemap_item
Class ref: Jetpack_Sitemap_Builder
Plugin ref: Jetpack
Version: 9.2
Sourcefile: modules/sitemaps/sitemap-builder.php
File ref: modules/sitemaps/sitemap-builder.php
Deprecated?: No
API Letters: B,J,P,S,V

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