Make WordPress Core

Ticket #23620: 23620.2.diff

File 23620.2.diff, 2.5 KB (added by lancewillett, 11 years ago)
  • wp-content/themes/twentythirteen/functions.php

     
    436436        return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
    437437}
    438438
     439/**
     440 * Finds first video from a given post.
     441 *
     442 * 1. Tries for a video source element in post content.
     443 * 2. Tries for a video embed in post content.
     444 * 3. Tries for an attached video.
     445 *
     446 * @param object $post
     447 * @return array First node in just video URL, second node is the rest of the content.
     448 */
     449function twentythirteen_get_video_content() {
     450        $post_content = get_the_content();
     451
     452        $content_video = get_content_video( $post_content, true );
     453       
     454        if ( empty( $content_video ) ) {
     455                $content_video = get_embedded_video( $post_content, true );
     456
     457                if ( empty( $content_video ) )
     458                        $content_video = get_attached_video( get_the_ID() );
     459        }
     460
     461        return array(
     462                $content_video[0],
     463                $post_content
     464        );
     465}
     466
    439467if ( ! function_exists( 'twentythirteen_featured_gallery' ) ) :
    440468/**
    441469 * Displays first gallery from post content. Changes image size from thumbnail
     
    574602/**
    575603 * Adds support for a custom header image.
    576604 */
    577 require( get_template_directory() . '/inc/custom-header.php' );
     605require( get_template_directory() . '/inc/custom-header.php' );
     606 No newline at end of file
  • wp-content/themes/twentythirteen/content-video.php

     
    1010
    1111<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    1212        <header class="entry-header">
     13                <?php
     14                        $content_pieces = twentythirteen_get_video_content();
     15                        echo $content_pieces[0];
     16                ?>
     17
    1318                <?php if ( is_single() ) : ?>
    1419                <h1 class="entry-title"><?php the_title(); ?></h1>
    1520                <?php else : ?>
     
    2025        </header><!-- .entry-header -->
    2126
    2227        <div class="entry-content">
    23                 <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentythirteen' ) ); ?>
     28                <?php echo $content_pieces[1]; ?>
    2429                <?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
    2530        </div><!-- .entry-content -->
    2631