Make WordPress Core

Ticket #23620: 23620.3.diff

File 23620.3.diff, 3.6 KB (added by lancewillett, 12 years ago)
  • wp-content/themes/twentythirteen/style.css

     
    18541854        font-weight: 400;
    18551855}
    18561856
     1857.format-video .entry-header {
     1858        max-width: 724px;
     1859}
     1860
    18571861.format-video .entry-meta {
    18581862        color: #220e10;
    18591863}
  • wp-content/themes/twentythirteen/functions.php

     
    436436        return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
    437437}
    438438
     439/**
     440 * Echoes the first found video from current post.
     441 *
     442 * @uses twentythirteen_get_split_content
     443 *
     444 * @print HTML
     445 */
     446function twentythirteen_post_video() {
     447        $first_video = twentythirteen_get_split_content( 'url' );
     448
     449        if ( is_array( $first_video ) )
     450                $first_video = $first_video[0];
     451
     452        echo wp_oembed_get( $first_video );
     453}
     454
     455/**
     456 * Echoes the post content without the chosen piece of media (video, image, etc).
     457 *
     458 * @uses twentythirteen_get_split_content
     459 *
     460 * @print HTML
     461 */
     462function twentythirteen_split_content() {
     463        echo twentythirteen_get_split_content( 'rest' );
     464}
     465
     466/**
     467 * Finds first media piece in a given post.
     468 *
     469 * 1. Find a URL or media embed in post format meta.
     470 * 2. Find a source element in post content.
     471 * 3. Find an embed in post content.
     472 * 4. Find an attachment.
     473 *
     474 * @param string $return Whether to return the URL or the filtered content.
     475 * @return string Either URL of the first media piece found, or the rest of the content without the piece.
     476 */
     477function twentythirteen_get_split_content( $return = 'url' ) {
     478        $format       = get_post_format();
     479        $post_meta    = get_post_format_meta( get_the_ID() );
     480        $post_content = get_the_content();
     481
     482        $media_url = $post_meta['url'];
     483
     484        if ( empty( $media_url ) ) {
     485                $media_url = $post_meta['media'];
     486
     487                if ( empty( $media_url ) ) {
     488                        $media_url = get_content_video( $post_content, true );
     489
     490                        if ( empty( $media_url ) ) {
     491                                $media_url = get_embedded_video( $post_content, true );
     492
     493                                if ( empty( $media_url ) )
     494                                        $media_url = get_attached_video( get_the_ID() );
     495                        }
     496                }
     497        }
     498
     499        if ( 'rest' === $return )
     500                return $post_content;
     501
     502        return $media_url;
     503}
     504
    439505if ( ! function_exists( 'twentythirteen_featured_gallery' ) ) :
    440506/**
    441507 * Displays first gallery from post content. Changes image size from thumbnail
  • 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 twentythirteen_post_video(); ?>
     14
    1315                <?php if ( is_single() ) : ?>
    1416                <h1 class="entry-title"><?php the_title(); ?></h1>
    1517                <?php else : ?>
     
    2022        </header><!-- .entry-header -->
    2123
    2224        <div class="entry-content">
    23                 <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentythirteen' ) ); ?>
     25                <?php twentythirteen_split_content(); ?>
    2426                <?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>' ) ); ?>
    2527        </div><!-- .entry-content -->
    2628