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