WordPress 4.7
[autoinstalls/wordpress.git] / wp-content / themes / twentyseventeen / template-parts / post / content-video.php
1 <?php
2 /**
3  * Template part for displaying video posts
4  *
5  * @link https://codex.wordpress.org/Template_Hierarchy
6  *
7  * @package WordPress
8  * @subpackage Twenty_Seventeen
9  * @since 1.0
10  * @version 1.0
11  */
12 ?>
13
14 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
15         <?php
16                 if ( is_sticky() && is_home() ) :
17                         echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
18                 endif;
19         ?>
20         <header class="entry-header">
21                 <?php
22                         if ( 'post' === get_post_type() ) :
23                                 echo '<div class="entry-meta">';
24                                         if ( is_single() ) :
25                                                 twentyseventeen_posted_on();
26                                         else :
27                                                 echo twentyseventeen_time_link();
28                                                 twentyseventeen_edit_link();
29                                         endif;
30                                 echo '</div><!-- .entry-meta -->';
31                         endif;
32
33                         if ( is_single() ) {
34                                 the_title( '<h1 class="entry-title">', '</h1>' );
35                         } else {
36                                 the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
37                         }
38                 ?>
39         </header><!-- .entry-header -->
40
41         <?php
42                 $content = apply_filters( 'the_content', get_the_content() );
43                 $video = false;
44
45                 // Only get video from the content if a playlist isn't present.
46                 if ( false === strpos( $content, 'wp-playlist-script' ) ) {
47                         $video = get_media_embedded_in_content( $content, array( 'video', 'object', 'embed', 'iframe' ) );
48                 }
49         ?>
50
51         <?php if ( '' !== get_the_post_thumbnail() && ! is_single() && empty( $video ) ) : ?>
52                 <div class="post-thumbnail">
53                         <a href="<?php the_permalink(); ?>">
54                                 <?php the_post_thumbnail( 'twentyseventeen-featured-image' ); ?>
55                         </a>
56                 </div><!-- .post-thumbnail -->
57         <?php endif; ?>
58
59         <div class="entry-content">
60
61                 <?php if ( ! is_single() ) :
62
63                         // If not a single post, highlight the video file.
64                         if ( ! empty( $video ) ) :
65                                 foreach ( $video as $video_html ) {
66                                         echo '<div class="entry-video">';
67                                                 echo $video_html;
68                                         echo '</div>';
69                                 }
70                         endif;
71
72                 endif;
73
74                 if ( is_single() || empty( $video ) ) :
75
76                         /* translators: %s: Name of current post */
77                         the_content( sprintf(
78                                 __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
79                                 get_the_title()
80                         ) );
81
82                         wp_link_pages( array(
83                                 'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
84                                 'after'       => '</div>',
85                                 'link_before' => '<span class="page-number">',
86                                 'link_after'  => '</span>',
87                         ) );
88
89                 endif; ?>
90
91         </div><!-- .entry-content -->
92
93         <?php if ( is_single() ) : ?>
94                 <?php twentyseventeen_entry_footer(); ?>
95         <?php endif; ?>
96
97 </article><!-- #post-## -->