Make WordPress Core

Ticket #44536: 44536.patch

File 44536.patch, 53.2 KB (added by Shital Patel, 7 years ago)

Added role in article tag

  • src/wp-content/themes/twentyseventeen/inc/template-tags.php

     
    1 <?php
    2 /**
    3  * Custom template tags for this theme
    4  *
    5  * Eventually, some of the functionality here could be replaced by core features.
    6  *
    7  * @package WordPress
    8  * @subpackage Twenty_Seventeen
    9  * @since 1.0
    10  */
    11 
    12 if ( ! function_exists( 'twentyseventeen_posted_on' ) ) :
    13         /**
    14          * Prints HTML with meta information for the current post-date/time and author.
    15          */
    16         function twentyseventeen_posted_on() {
    17 
    18                 // Get the author name; wrap it in a link.
    19                 $byline = sprintf(
    20                         /* translators: %s: post author */
    21                         __( 'by %s', 'twentyseventeen' ),
    22                         '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . get_the_author() . '</a></span>'
    23                 );
    24 
    25                 // Finally, let's write all of this to the page.
    26                 echo '<span class="posted-on">' . twentyseventeen_time_link() . '</span><span class="byline"> ' . $byline . '</span>';
    27         }
    28 endif;
    29 
    30 
    31 if ( ! function_exists( 'twentyseventeen_time_link' ) ) :
    32         /**
    33          * Gets a nicely formatted string for the published date.
    34          */
    35         function twentyseventeen_time_link() {
    36                 $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
    37                 if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
    38                         $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
    39                 }
    40 
    41                 $time_string = sprintf(
    42                         $time_string,
    43                         get_the_date( DATE_W3C ),
    44                         get_the_date(),
    45                         get_the_modified_date( DATE_W3C ),
    46                         get_the_modified_date()
    47                 );
    48 
    49                 // Wrap the time string in a link, and preface it with 'Posted on'.
    50                 return sprintf(
    51                         /* translators: %s: post date */
    52                         __( '<span class="screen-reader-text">Posted on</span> %s', 'twentyseventeen' ),
    53                         '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
    54                 );
    55         }
    56 endif;
    57 
    58 
    59 if ( ! function_exists( 'twentyseventeen_entry_footer' ) ) :
    60         /**
    61          * Prints HTML with meta information for the categories, tags and comments.
    62          */
    63         function twentyseventeen_entry_footer() {
    64 
    65                 /* translators: used between list items, there is a space after the comma */
    66                 $separate_meta = __( ', ', 'twentyseventeen' );
    67 
    68                 // Get Categories for posts.
    69                 $categories_list = get_the_category_list( $separate_meta );
    70 
    71                 // Get Tags for posts.
    72                 $tags_list = get_the_tag_list( '', $separate_meta );
    73 
    74                 // We don't want to output .entry-footer if it will be empty, so make sure its not.
    75                 if ( ( ( twentyseventeen_categorized_blog() && $categories_list ) || $tags_list ) || get_edit_post_link() ) {
    76 
    77                         echo '<footer class="entry-footer">';
    78 
    79                         if ( 'post' === get_post_type() ) {
    80                                 if ( ( $categories_list && twentyseventeen_categorized_blog() ) || $tags_list ) {
    81                                         echo '<span class="cat-tags-links">';
    82 
    83                                                 // Make sure there's more than one category before displaying.
    84                                         if ( $categories_list && twentyseventeen_categorized_blog() ) {
    85                                                 echo '<span class="cat-links">' . twentyseventeen_get_svg( array( 'icon' => 'folder-open' ) ) . '<span class="screen-reader-text">' . __( 'Categories', 'twentyseventeen' ) . '</span>' . $categories_list . '</span>';
    86                                         }
    87 
    88                                         if ( $tags_list && ! is_wp_error( $tags_list ) ) {
    89                                                 echo '<span class="tags-links">' . twentyseventeen_get_svg( array( 'icon' => 'hashtag' ) ) . '<span class="screen-reader-text">' . __( 'Tags', 'twentyseventeen' ) . '</span>' . $tags_list . '</span>';
    90                                         }
    91 
    92                                         echo '</span>';
    93                                 }
    94                         }
    95 
    96                         twentyseventeen_edit_link();
    97 
    98                         echo '</footer> <!-- .entry-footer -->';
    99                 }
    100         }
    101 endif;
    102 
    103 
    104 if ( ! function_exists( 'twentyseventeen_edit_link' ) ) :
    105         /**
    106          * Returns an accessibility-friendly link to edit a post or page.
    107          *
    108          * This also gives us a little context about what exactly we're editing
    109          * (post or page?) so that users understand a bit more where they are in terms
    110          * of the template hierarchy and their content. Helpful when/if the single-page
    111          * layout with multiple posts/pages shown gets confusing.
    112          */
    113         function twentyseventeen_edit_link() {
    114                 edit_post_link(
    115                         sprintf(
    116                                 /* translators: %s: Name of current post */
    117                                 __( 'Edit<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
    118                                 get_the_title()
    119                         ),
    120                         '<span class="edit-link">',
    121                         '</span>'
    122                 );
    123         }
    124 endif;
    125 
    126 /**
    127  * Display a front page section.
    128  *
    129  * @param WP_Customize_Partial $partial Partial associated with a selective refresh request.
    130  * @param integer              $id Front page section to display.
    131  */
    132 function twentyseventeen_front_page_section( $partial = null, $id = 0 ) {
    133         if ( is_a( $partial, 'WP_Customize_Partial' ) ) {
    134                 // Find out the id and set it up during a selective refresh.
    135                 global $twentyseventeencounter;
    136                 $id                     = str_replace( 'panel_', '', $partial->id );
    137                 $twentyseventeencounter = $id;
    138         }
    139 
    140         global $post; // Modify the global post object before setting up post data.
    141         if ( get_theme_mod( 'panel_' . $id ) ) {
    142                 $post = get_post( get_theme_mod( 'panel_' . $id ) );
    143                 setup_postdata( $post );
    144                 set_query_var( 'panel', $id );
    145 
    146                 get_template_part( 'template-parts/page/content', 'front-page-panels' );
    147 
    148                 wp_reset_postdata();
    149         } elseif ( is_customize_preview() ) {
    150                 // The output placeholder anchor.
    151                 echo '<article class="panel-placeholder panel twentyseventeen-panel twentyseventeen-panel' . $id . '" id="panel' . $id . '"><span class="twentyseventeen-panel-title">' . sprintf( __( 'Front Page Section %1$s Placeholder', 'twentyseventeen' ), $id ) . '</span></article>';
    152         }
    153 }
    154 
    155 /**
    156  * Returns true if a blog has more than 1 category.
    157  *
    158  * @return bool
    159  */
    160 function twentyseventeen_categorized_blog() {
    161         $category_count = get_transient( 'twentyseventeen_categories' );
    162 
    163         if ( false === $category_count ) {
    164                 // Create an array of all the categories that are attached to posts.
    165                 $categories = get_categories(
    166                         array(
    167                                 'fields'     => 'ids',
    168                                 'hide_empty' => 1,
    169                                 // We only need to know if there is more than one category.
    170                                 'number'     => 2,
    171                         )
    172                 );
    173 
    174                 // Count the number of categories that are attached to the posts.
    175                 $category_count = count( $categories );
    176 
    177                 set_transient( 'twentyseventeen_categories', $category_count );
    178         }
    179 
    180         // Allow viewing case of 0 or 1 categories in post preview.
    181         if ( is_preview() ) {
    182                 return true;
    183         }
    184 
    185         return $category_count > 1;
    186 }
    187 
    188 
    189 /**
    190  * Flush out the transients used in twentyseventeen_categorized_blog.
    191  */
    192 function twentyseventeen_category_transient_flusher() {
    193         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
    194                 return;
    195         }
    196         // Like, beat it. Dig?
    197         delete_transient( 'twentyseventeen_categories' );
    198 }
    199 add_action( 'edit_category', 'twentyseventeen_category_transient_flusher' );
    200 add_action( 'save_post', 'twentyseventeen_category_transient_flusher' );
     1<?php
     2/**
     3 * Custom template tags for this theme
     4 *
     5 * Eventually, some of the functionality here could be replaced by core features.
     6 *
     7 * @package WordPress
     8 * @subpackage Twenty_Seventeen
     9 * @since 1.0
     10 */
     11
     12if ( ! function_exists( 'twentyseventeen_posted_on' ) ) :
     13        /**
     14         * Prints HTML with meta information for the current post-date/time and author.
     15         */
     16        function twentyseventeen_posted_on() {
     17
     18                // Get the author name; wrap it in a link.
     19                $byline = sprintf(
     20                        /* translators: %s: post author */
     21                        __( 'by %s', 'twentyseventeen' ),
     22                        '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . get_the_author() . '</a></span>'
     23                );
     24
     25                // Finally, let's write all of this to the page.
     26                echo '<span class="posted-on">' . twentyseventeen_time_link() . '</span><span class="byline"> ' . $byline . '</span>';
     27        }
     28endif;
     29
     30
     31if ( ! function_exists( 'twentyseventeen_time_link' ) ) :
     32        /**
     33         * Gets a nicely formatted string for the published date.
     34         */
     35        function twentyseventeen_time_link() {
     36                $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
     37                if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
     38                        $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
     39                }
     40
     41                $time_string = sprintf(
     42                        $time_string,
     43                        get_the_date( DATE_W3C ),
     44                        get_the_date(),
     45                        get_the_modified_date( DATE_W3C ),
     46                        get_the_modified_date()
     47                );
     48
     49                // Wrap the time string in a link, and preface it with 'Posted on'.
     50                return sprintf(
     51                        /* translators: %s: post date */
     52                        __( '<span class="screen-reader-text">Posted on</span> %s', 'twentyseventeen' ),
     53                        '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
     54                );
     55        }
     56endif;
     57
     58
     59if ( ! function_exists( 'twentyseventeen_entry_footer' ) ) :
     60        /**
     61         * Prints HTML with meta information for the categories, tags and comments.
     62         */
     63        function twentyseventeen_entry_footer() {
     64
     65                /* translators: used between list items, there is a space after the comma */
     66                $separate_meta = __( ', ', 'twentyseventeen' );
     67
     68                // Get Categories for posts.
     69                $categories_list = get_the_category_list( $separate_meta );
     70
     71                // Get Tags for posts.
     72                $tags_list = get_the_tag_list( '', $separate_meta );
     73
     74                // We don't want to output .entry-footer if it will be empty, so make sure its not.
     75                if ( ( ( twentyseventeen_categorized_blog() && $categories_list ) || $tags_list ) || get_edit_post_link() ) {
     76
     77                        echo '<footer class="entry-footer">';
     78
     79                        if ( 'post' === get_post_type() ) {
     80                                if ( ( $categories_list && twentyseventeen_categorized_blog() ) || $tags_list ) {
     81                                        echo '<span class="cat-tags-links">';
     82
     83                                                // Make sure there's more than one category before displaying.
     84                                        if ( $categories_list && twentyseventeen_categorized_blog() ) {
     85                                                echo '<span class="cat-links">' . twentyseventeen_get_svg( array( 'icon' => 'folder-open' ) ) . '<span class="screen-reader-text">' . __( 'Categories', 'twentyseventeen' ) . '</span>' . $categories_list . '</span>';
     86                                        }
     87
     88                                        if ( $tags_list && ! is_wp_error( $tags_list ) ) {
     89                                                echo '<span class="tags-links">' . twentyseventeen_get_svg( array( 'icon' => 'hashtag' ) ) . '<span class="screen-reader-text">' . __( 'Tags', 'twentyseventeen' ) . '</span>' . $tags_list . '</span>';
     90                                        }
     91
     92                                        echo '</span>';
     93                                }
     94                        }
     95
     96                        twentyseventeen_edit_link();
     97
     98                        echo '</footer> <!-- .entry-footer -->';
     99                }
     100        }
     101endif;
     102
     103
     104if ( ! function_exists( 'twentyseventeen_edit_link' ) ) :
     105        /**
     106         * Returns an accessibility-friendly link to edit a post or page.
     107         *
     108         * This also gives us a little context about what exactly we're editing
     109         * (post or page?) so that users understand a bit more where they are in terms
     110         * of the template hierarchy and their content. Helpful when/if the single-page
     111         * layout with multiple posts/pages shown gets confusing.
     112         */
     113        function twentyseventeen_edit_link() {
     114                edit_post_link(
     115                        sprintf(
     116                                /* translators: %s: Name of current post */
     117                                __( 'Edit<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
     118                                get_the_title()
     119                        ),
     120                        '<span class="edit-link">',
     121                        '</span>'
     122                );
     123        }
     124endif;
     125
     126/**
     127 * Display a front page section.
     128 *
     129 * @param WP_Customize_Partial $partial Partial associated with a selective refresh request.
     130 * @param integer              $id Front page section to display.
     131 */
     132function twentyseventeen_front_page_section( $partial = null, $id = 0 ) {
     133        if ( is_a( $partial, 'WP_Customize_Partial' ) ) {
     134                // Find out the id and set it up during a selective refresh.
     135                global $twentyseventeencounter;
     136                $id                     = str_replace( 'panel_', '', $partial->id );
     137                $twentyseventeencounter = $id;
     138        }
     139
     140        global $post; // Modify the global post object before setting up post data.
     141        if ( get_theme_mod( 'panel_' . $id ) ) {
     142                $post = get_post( get_theme_mod( 'panel_' . $id ) );
     143                setup_postdata( $post );
     144                set_query_var( 'panel', $id );
     145
     146                get_template_part( 'template-parts/page/content', 'front-page-panels' );
     147
     148                wp_reset_postdata();
     149        } elseif ( is_customize_preview() ) {
     150                // The output placeholder anchor.
     151                echo '<article role="article" class="panel-placeholder panel twentyseventeen-panel twentyseventeen-panel' . $id . '" id="panel' . $id . '"><span class="twentyseventeen-panel-title">' . sprintf( __( 'Front Page Section %1$s Placeholder', 'twentyseventeen' ), $id ) . '</span></article>';
     152        }
     153}
     154
     155/**
     156 * Returns true if a blog has more than 1 category.
     157 *
     158 * @return bool
     159 */
     160function twentyseventeen_categorized_blog() {
     161        $category_count = get_transient( 'twentyseventeen_categories' );
     162
     163        if ( false === $category_count ) {
     164                // Create an array of all the categories that are attached to posts.
     165                $categories = get_categories(
     166                        array(
     167                                'fields'     => 'ids',
     168                                'hide_empty' => 1,
     169                                // We only need to know if there is more than one category.
     170                                'number'     => 2,
     171                        )
     172                );
     173
     174                // Count the number of categories that are attached to the posts.
     175                $category_count = count( $categories );
     176
     177                set_transient( 'twentyseventeen_categories', $category_count );
     178        }
     179
     180        // Allow viewing case of 0 or 1 categories in post preview.
     181        if ( is_preview() ) {
     182                return true;
     183        }
     184
     185        return $category_count > 1;
     186}
     187
     188
     189/**
     190 * Flush out the transients used in twentyseventeen_categorized_blog.
     191 */
     192function twentyseventeen_category_transient_flusher() {
     193        if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
     194                return;
     195        }
     196        // Like, beat it. Dig?
     197        delete_transient( 'twentyseventeen_categories' );
     198}
     199add_action( 'edit_category', 'twentyseventeen_category_transient_flusher' );
     200add_action( 'save_post', 'twentyseventeen_category_transient_flusher' );
  • src/wp-content/themes/twentyseventeen/template-parts/page/content-front-page-panels.php

     
    1 <?php
    2 /**
    3  * Template part for displaying pages on front page
    4  *
    5  * @package WordPress
    6  * @subpackage Twenty_Seventeen
    7  * @since 1.0
    8  * @version 1.0
    9  */
    10 
    11 global $twentyseventeencounter;
    12 
    13 ?>
    14 
    15 <article id="panel<?php echo $twentyseventeencounter; ?>" <?php post_class( 'twentyseventeen-panel ' ); ?> >
    16 
    17         <?php
    18         if ( has_post_thumbnail() ) :
    19                 $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'twentyseventeen-featured-image' );
    20 
    21                 // Calculate aspect ratio: h / w * 100%.
    22                 $ratio = $thumbnail[2] / $thumbnail[1] * 100;
    23                 ?>
    24 
    25                 <div class="panel-image" style="background-image: url(<?php echo esc_url( $thumbnail[0] ); ?>);">
    26                         <div class="panel-image-prop" style="padding-top: <?php echo esc_attr( $ratio ); ?>%"></div>
    27                 </div><!-- .panel-image -->
    28 
    29         <?php endif; ?>
    30 
    31         <div class="panel-content">
    32                 <div class="wrap">
    33                         <header class="entry-header">
    34                                 <?php the_title( '<h2 class="entry-title">', '</h2>' ); ?>
    35 
    36                                 <?php twentyseventeen_edit_link( get_the_ID() ); ?>
    37 
    38                         </header><!-- .entry-header -->
    39 
    40                         <div class="entry-content">
    41                                 <?php
    42                                         /* translators: %s: Name of current post */
    43                                         the_content(
    44                                                 sprintf(
    45                                                         __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
    46                                                         get_the_title()
    47                                                 )
    48                                         );
    49                                 ?>
    50                         </div><!-- .entry-content -->
    51 
    52                         <?php
    53                         // Show recent blog posts if is blog posts page (Note that get_option returns a string, so we're casting the result as an int).
    54                         if ( get_the_ID() === (int) get_option( 'page_for_posts' ) ) :
    55                         ?>
    56 
    57                                 <?php
    58                                 // Show three most recent posts.
    59                                 $recent_posts = new WP_Query(
    60                                         array(
    61                                                 'posts_per_page'      => 3,
    62                                                 'post_status'         => 'publish',
    63                                                 'ignore_sticky_posts' => true,
    64                                                 'no_found_rows'       => true,
    65                                         )
    66                                 );
    67                                 ?>
    68 
    69                                 <?php if ( $recent_posts->have_posts() ) : ?>
    70 
    71                                         <div class="recent-posts">
    72 
    73                                                 <?php
    74                                                 while ( $recent_posts->have_posts() ) :
    75                                                         $recent_posts->the_post();
    76                                                         get_template_part( 'template-parts/post/content', 'excerpt' );
    77                                                 endwhile;
    78                                                 wp_reset_postdata();
    79                                                 ?>
    80                                         </div><!-- .recent-posts -->
    81                                 <?php endif; ?>
    82                         <?php endif; ?>
    83 
    84                 </div><!-- .wrap -->
    85         </div><!-- .panel-content -->
    86 
    87 </article><!-- #post-## -->
     1<?php
     2/**
     3 * Template part for displaying pages on front page
     4 *
     5 * @package WordPress
     6 * @subpackage Twenty_Seventeen
     7 * @since 1.0
     8 * @version 1.0
     9 */
     10
     11global $twentyseventeencounter;
     12
     13?>
     14
     15<article id="panel<?php echo $twentyseventeencounter; ?>" <?php post_class( 'twentyseventeen-panel ' ); ?> role="article" >
     16
     17        <?php
     18        if ( has_post_thumbnail() ) :
     19                $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'twentyseventeen-featured-image' );
     20
     21                // Calculate aspect ratio: h / w * 100%.
     22                $ratio = $thumbnail[2] / $thumbnail[1] * 100;
     23                ?>
     24
     25                <div class="panel-image" style="background-image: url(<?php echo esc_url( $thumbnail[0] ); ?>);">
     26                        <div class="panel-image-prop" style="padding-top: <?php echo esc_attr( $ratio ); ?>%"></div>
     27                </div><!-- .panel-image -->
     28
     29        <?php endif; ?>
     30
     31        <div class="panel-content">
     32                <div class="wrap">
     33                        <header class="entry-header">
     34                                <?php the_title( '<h2 class="entry-title">', '</h2>' ); ?>
     35
     36                                <?php twentyseventeen_edit_link( get_the_ID() ); ?>
     37
     38                        </header><!-- .entry-header -->
     39
     40                        <div class="entry-content">
     41                                <?php
     42                                        /* translators: %s: Name of current post */
     43                                        the_content(
     44                                                sprintf(
     45                                                        __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
     46                                                        get_the_title()
     47                                                )
     48                                        );
     49                                ?>
     50                        </div><!-- .entry-content -->
     51
     52                        <?php
     53                        // Show recent blog posts if is blog posts page (Note that get_option returns a string, so we're casting the result as an int).
     54                        if ( get_the_ID() === (int) get_option( 'page_for_posts' ) ) :
     55                        ?>
     56
     57                                <?php
     58                                // Show three most recent posts.
     59                                $recent_posts = new WP_Query(
     60                                        array(
     61                                                'posts_per_page'      => 3,
     62                                                'post_status'         => 'publish',
     63                                                'ignore_sticky_posts' => true,
     64                                                'no_found_rows'       => true,
     65                                        )
     66                                );
     67                                ?>
     68
     69                                <?php if ( $recent_posts->have_posts() ) : ?>
     70
     71                                        <div class="recent-posts">
     72
     73                                                <?php
     74                                                while ( $recent_posts->have_posts() ) :
     75                                                        $recent_posts->the_post();
     76                                                        get_template_part( 'template-parts/post/content', 'excerpt' );
     77                                                endwhile;
     78                                                wp_reset_postdata();
     79                                                ?>
     80                                        </div><!-- .recent-posts -->
     81                                <?php endif; ?>
     82                        <?php endif; ?>
     83
     84                </div><!-- .wrap -->
     85        </div><!-- .panel-content -->
     86
     87</article><!-- #post-## -->
  • src/wp-content/themes/twentyseventeen/template-parts/page/content-front-page.php

     
    1 <?php
    2 /**
    3  * Displays content for front page
    4  *
    5  * @package WordPress
    6  * @subpackage Twenty_Seventeen
    7  * @since 1.0
    8  * @version 1.0
    9  */
    10 
    11 ?>
    12 <article id="post-<?php the_ID(); ?>" <?php post_class( 'twentyseventeen-panel ' ); ?> >
    13 
    14         <?php
    15         if ( has_post_thumbnail() ) :
    16                 $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'twentyseventeen-featured-image' );
    17 
    18                 // Calculate aspect ratio: h / w * 100%.
    19                 $ratio = $thumbnail[2] / $thumbnail[1] * 100;
    20                 ?>
    21 
    22                 <div class="panel-image" style="background-image: url(<?php echo esc_url( $thumbnail[0] ); ?>);">
    23                         <div class="panel-image-prop" style="padding-top: <?php echo esc_attr( $ratio ); ?>%"></div>
    24                 </div><!-- .panel-image -->
    25 
    26         <?php endif; ?>
    27 
    28         <div class="panel-content">
    29                 <div class="wrap">
    30                         <header class="entry-header">
    31                                 <?php the_title( '<h2 class="entry-title">', '</h2>' ); ?>
    32 
    33                                 <?php twentyseventeen_edit_link( get_the_ID() ); ?>
    34 
    35                         </header><!-- .entry-header -->
    36 
    37                         <div class="entry-content">
    38                                 <?php
    39                                         /* translators: %s: Name of current post */
    40                                         the_content(
    41                                                 sprintf(
    42                                                         __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
    43                                                         get_the_title()
    44                                                 )
    45                                         );
    46                                 ?>
    47                         </div><!-- .entry-content -->
    48 
    49                 </div><!-- .wrap -->
    50         </div><!-- .panel-content -->
    51 
    52 </article><!-- #post-## -->
     1<?php
     2/**
     3 * Displays content for front page
     4 *
     5 * @package WordPress
     6 * @subpackage Twenty_Seventeen
     7 * @since 1.0
     8 * @version 1.0
     9 */
     10
     11?>
     12<article id="post-<?php the_ID(); ?>" <?php post_class( 'twentyseventeen-panel ' ); ?> role="article" >
     13
     14        <?php
     15        if ( has_post_thumbnail() ) :
     16                $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'twentyseventeen-featured-image' );
     17
     18                // Calculate aspect ratio: h / w * 100%.
     19                $ratio = $thumbnail[2] / $thumbnail[1] * 100;
     20                ?>
     21
     22                <div class="panel-image" style="background-image: url(<?php echo esc_url( $thumbnail[0] ); ?>);">
     23                        <div class="panel-image-prop" style="padding-top: <?php echo esc_attr( $ratio ); ?>%"></div>
     24                </div><!-- .panel-image -->
     25
     26        <?php endif; ?>
     27
     28        <div class="panel-content">
     29                <div class="wrap">
     30                        <header class="entry-header">
     31                                <?php the_title( '<h2 class="entry-title">', '</h2>' ); ?>
     32
     33                                <?php twentyseventeen_edit_link( get_the_ID() ); ?>
     34
     35                        </header><!-- .entry-header -->
     36
     37                        <div class="entry-content">
     38                                <?php
     39                                        /* translators: %s: Name of current post */
     40                                        the_content(
     41                                                sprintf(
     42                                                        __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
     43                                                        get_the_title()
     44                                                )
     45                                        );
     46                                ?>
     47                        </div><!-- .entry-content -->
     48
     49                </div><!-- .wrap -->
     50        </div><!-- .panel-content -->
     51
     52</article><!-- #post-## -->
  • src/wp-content/themes/twentyseventeen/template-parts/page/content-page.php

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

     
    1 <?php
    2 /**
    3  * Template part for displaying posts with excerpts
    4  *
    5  * Used in Search Results and for Recent Posts in Front Page panels.
    6  *
    7  * @link https://codex.wordpress.org/Template_Hierarchy
    8  *
    9  * @package WordPress
    10  * @subpackage Twenty_Seventeen
    11  * @since 1.0
    12  * @version 1.2
    13  */
    14 
    15 ?>
    16 
    17 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    18 
    19         <header class="entry-header">
    20                 <?php if ( 'post' === get_post_type() ) : ?>
    21                         <div class="entry-meta">
    22                                 <?php
    23                                 echo twentyseventeen_time_link();
    24                                 twentyseventeen_edit_link();
    25                                 ?>
    26                         </div><!-- .entry-meta -->
    27                 <?php elseif ( 'page' === get_post_type() && get_edit_post_link() ) : ?>
    28                         <div class="entry-meta">
    29                                 <?php twentyseventeen_edit_link(); ?>
    30                         </div><!-- .entry-meta -->
    31                 <?php endif; ?>
    32 
    33                 <?php
    34                 if ( is_front_page() && ! is_home() ) {
    35 
    36                         // The excerpt is being displayed within a front page section, so it's a lower hierarchy than h2.
    37                         the_title( sprintf( '<h3 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h3>' );
    38                 } else {
    39                         the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
    40                 }
    41                 ?>
    42         </header><!-- .entry-header -->
    43 
    44         <div class="entry-summary">
    45                 <?php the_excerpt(); ?>
    46         </div><!-- .entry-summary -->
    47 
    48 </article><!-- #post-## -->
     1<?php
     2/**
     3 * Template part for displaying posts with excerpts
     4 *
     5 * Used in Search Results and for Recent Posts in Front Page panels.
     6 *
     7 * @link https://codex.wordpress.org/Template_Hierarchy
     8 *
     9 * @package WordPress
     10 * @subpackage Twenty_Seventeen
     11 * @since 1.0
     12 * @version 1.2
     13 */
     14
     15?>
     16
     17<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> role="article">
     18
     19        <header class="entry-header">
     20                <?php if ( 'post' === get_post_type() ) : ?>
     21                        <div class="entry-meta">
     22                                <?php
     23                                echo twentyseventeen_time_link();
     24                                twentyseventeen_edit_link();
     25                                ?>
     26                        </div><!-- .entry-meta -->
     27                <?php elseif ( 'page' === get_post_type() && get_edit_post_link() ) : ?>
     28                        <div class="entry-meta">
     29                                <?php twentyseventeen_edit_link(); ?>
     30                        </div><!-- .entry-meta -->
     31                <?php endif; ?>
     32
     33                <?php
     34                if ( is_front_page() && ! is_home() ) {
     35
     36                        // The excerpt is being displayed within a front page section, so it's a lower hierarchy than h2.
     37                        the_title( sprintf( '<h3 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h3>' );
     38                } else {
     39                        the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
     40                }
     41                ?>
     42        </header><!-- .entry-header -->
     43
     44        <div class="entry-summary">
     45                <?php the_excerpt(); ?>
     46        </div><!-- .entry-summary -->
     47
     48</article><!-- #post-## -->
  • src/wp-content/themes/twentyseventeen/template-parts/post/content-gallery.php

     
    1 <?php
    2 /**
    3  * Template part for displaying gallery 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.2
    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         }
    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                         };
    31                         echo '</div><!-- .entry-meta -->';
    32                 };
    33 
    34                 if ( is_single() ) {
    35                         the_title( '<h1 class="entry-title">', '</h1>' );
    36                 } elseif ( is_front_page() && is_home() ) {
    37                         the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
    38                 } else {
    39                         the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    40                 }
    41                 ?>
    42         </header><!-- .entry-header -->
    43 
    44         <?php if ( '' !== get_the_post_thumbnail() && ! is_single() && ! get_post_gallery() ) : ?>
    45                 <div class="post-thumbnail">
    46                         <a href="<?php the_permalink(); ?>">
    47                                 <?php the_post_thumbnail( 'twentyseventeen-featured-image' ); ?>
    48                         </a>
    49                 </div><!-- .post-thumbnail -->
    50         <?php endif; ?>
    51 
    52         <div class="entry-content">
    53 
    54                 <?php
    55                 if ( ! is_single() ) {
    56 
    57                         // If not a single post, highlight the gallery.
    58                         if ( get_post_gallery() ) {
    59                                 echo '<div class="entry-gallery">';
    60                                         echo get_post_gallery();
    61                                 echo '</div>';
    62                         };
    63 
    64                 };
    65 
    66                 if ( is_single() || ! get_post_gallery() ) {
    67 
    68                         /* translators: %s: Name of current post */
    69                         the_content(
    70                                 sprintf(
    71                                         __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
    72                                         get_the_title()
    73                                 )
    74                         );
    75 
    76                         wp_link_pages(
    77                                 array(
    78                                         'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
    79                                         'after'       => '</div>',
    80                                         'link_before' => '<span class="page-number">',
    81                                         'link_after'  => '</span>',
    82                                 )
    83                         );
    84 
    85                 };
    86                 ?>
    87 
    88         </div><!-- .entry-content -->
    89 
    90         <?php
    91         if ( is_single() ) {
    92                 twentyseventeen_entry_footer();
    93         }
    94         ?>
    95 
    96 </article><!-- #post-## -->
     1<?php
     2/**
     3 * Template part for displaying gallery 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.2
     11 */
     12
     13?>
     14
     15<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> role="article">
     16        <?php
     17        if ( is_sticky() && is_home() ) {
     18                echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
     19        }
     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                        };
     31                        echo '</div><!-- .entry-meta -->';
     32                };
     33
     34                if ( is_single() ) {
     35                        the_title( '<h1 class="entry-title">', '</h1>' );
     36                } elseif ( is_front_page() && is_home() ) {
     37                        the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
     38                } else {
     39                        the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
     40                }
     41                ?>
     42        </header><!-- .entry-header -->
     43
     44        <?php if ( '' !== get_the_post_thumbnail() && ! is_single() && ! get_post_gallery() ) : ?>
     45                <div class="post-thumbnail">
     46                        <a href="<?php the_permalink(); ?>">
     47                                <?php the_post_thumbnail( 'twentyseventeen-featured-image' ); ?>
     48                        </a>
     49                </div><!-- .post-thumbnail -->
     50        <?php endif; ?>
     51
     52        <div class="entry-content">
     53
     54                <?php
     55                if ( ! is_single() ) {
     56
     57                        // If not a single post, highlight the gallery.
     58                        if ( get_post_gallery() ) {
     59                                echo '<div class="entry-gallery">';
     60                                        echo get_post_gallery();
     61                                echo '</div>';
     62                        };
     63
     64                };
     65
     66                if ( is_single() || ! get_post_gallery() ) {
     67
     68                        /* translators: %s: Name of current post */
     69                        the_content(
     70                                sprintf(
     71                                        __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
     72                                        get_the_title()
     73                                )
     74                        );
     75
     76                        wp_link_pages(
     77                                array(
     78                                        'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
     79                                        'after'       => '</div>',
     80                                        'link_before' => '<span class="page-number">',
     81                                        'link_after'  => '</span>',
     82                                )
     83                        );
     84
     85                };
     86                ?>
     87
     88        </div><!-- .entry-content -->
     89
     90        <?php
     91        if ( is_single() ) {
     92                twentyseventeen_entry_footer();
     93        }
     94        ?>
     95
     96</article><!-- #post-## -->
  • src/wp-content/themes/twentyseventeen/template-parts/post/content-image.php

     
    1 <?php
    2 /**
    3  * Template part for displaying image 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.2
    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         }
    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                         };
    31                                 echo '</div><!-- .entry-meta -->';
    32                 };
    33 
    34                 if ( is_single() ) {
    35                         the_title( '<h1 class="entry-title">', '</h1>' );
    36                 } elseif ( is_front_page() && is_home() ) {
    37                         the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
    38                 } else {
    39                         the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    40                 }
    41                 ?>
    42         </header><!-- .entry-header -->
    43 
    44         <?php if ( '' !== get_the_post_thumbnail() && ! is_single() ) : ?>
    45                 <div class="post-thumbnail">
    46                         <a href="<?php the_permalink(); ?>">
    47                                 <?php the_post_thumbnail( 'twentyseventeen-featured-image' ); ?>
    48                         </a>
    49                 </div><!-- .post-thumbnail -->
    50         <?php endif; ?>
    51 
    52         <div class="entry-content">
    53 
    54                 <?php
    55                 if ( is_single() || '' === get_the_post_thumbnail() ) {
    56 
    57                         // Only show content if is a single post, or if there's no featured image.
    58                         /* translators: %s: Name of current post */
    59                         the_content(
    60                                 sprintf(
    61                                         __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
    62                                         get_the_title()
    63                                 )
    64                         );
    65 
    66                         wp_link_pages(
    67                                 array(
    68                                         'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
    69                                         'after'       => '</div>',
    70                                         'link_before' => '<span class="page-number">',
    71                                         'link_after'  => '</span>',
    72                                 )
    73                         );
    74 
    75                 };
    76                 ?>
    77 
    78         </div><!-- .entry-content -->
    79 
    80         <?php
    81         if ( is_single() ) {
    82                 twentyseventeen_entry_footer();
    83         }
    84         ?>
    85 
    86 </article><!-- #post-## -->
     1<?php
     2/**
     3 * Template part for displaying image 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.2
     11 */
     12
     13?>
     14
     15<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> role="article">
     16        <?php
     17        if ( is_sticky() && is_home() ) {
     18                echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
     19        }
     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                        };
     31                                echo '</div><!-- .entry-meta -->';
     32                };
     33
     34                if ( is_single() ) {
     35                        the_title( '<h1 class="entry-title">', '</h1>' );
     36                } elseif ( is_front_page() && is_home() ) {
     37                        the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
     38                } else {
     39                        the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
     40                }
     41                ?>
     42        </header><!-- .entry-header -->
     43
     44        <?php if ( '' !== get_the_post_thumbnail() && ! is_single() ) : ?>
     45                <div class="post-thumbnail">
     46                        <a href="<?php the_permalink(); ?>">
     47                                <?php the_post_thumbnail( 'twentyseventeen-featured-image' ); ?>
     48                        </a>
     49                </div><!-- .post-thumbnail -->
     50        <?php endif; ?>
     51
     52        <div class="entry-content">
     53
     54                <?php
     55                if ( is_single() || '' === get_the_post_thumbnail() ) {
     56
     57                        // Only show content if is a single post, or if there's no featured image.
     58                        /* translators: %s: Name of current post */
     59                        the_content(
     60                                sprintf(
     61                                        __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
     62                                        get_the_title()
     63                                )
     64                        );
     65
     66                        wp_link_pages(
     67                                array(
     68                                        'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
     69                                        'after'       => '</div>',
     70                                        'link_before' => '<span class="page-number">',
     71                                        'link_after'  => '</span>',
     72                                )
     73                        );
     74
     75                };
     76                ?>
     77
     78        </div><!-- .entry-content -->
     79
     80        <?php
     81        if ( is_single() ) {
     82                twentyseventeen_entry_footer();
     83        }
     84        ?>
     85
     86</article><!-- #post-## -->
  • src/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.2
    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         }
    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                         }
    31                                 echo '</div><!-- .entry-meta -->';
    32                 };
    33 
    34                 if ( is_single() ) {
    35                         the_title( '<h1 class="entry-title">', '</h1>' );
    36                 } elseif ( is_front_page() && is_home() ) {
    37                         the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
    38                 } else {
    39                         the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    40                 }
    41                 ?>
    42         </header><!-- .entry-header -->
    43 
    44         <?php
    45                 $content = apply_filters( 'the_content', get_the_content() );
    46                 $video   = false;
    47 
    48                 // Only get video from the content if a playlist isn't present.
    49         if ( false === strpos( $content, 'wp-playlist-script' ) ) {
    50                 $video = get_media_embedded_in_content( $content, array( 'video', 'object', 'embed', 'iframe' ) );
    51         }
    52         ?>
    53 
    54         <?php if ( '' !== get_the_post_thumbnail() && ! is_single() && empty( $video ) ) : ?>
    55                 <div class="post-thumbnail">
    56                         <a href="<?php the_permalink(); ?>">
    57                                 <?php the_post_thumbnail( 'twentyseventeen-featured-image' ); ?>
    58                         </a>
    59                 </div><!-- .post-thumbnail -->
    60         <?php endif; ?>
    61 
    62         <div class="entry-content">
    63 
    64                 <?php
    65                 if ( ! is_single() ) {
    66 
    67                         // If not a single post, highlight the video file.
    68                         if ( ! empty( $video ) ) {
    69                                 foreach ( $video as $video_html ) {
    70                                         echo '<div class="entry-video">';
    71                                                 echo $video_html;
    72                                         echo '</div>';
    73                                 }
    74                         };
    75 
    76                 };
    77 
    78                 if ( is_single() || empty( $video ) ) {
    79 
    80                         /* translators: %s: Name of current post */
    81                         the_content(
    82                                 sprintf(
    83                                         __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
    84                                         get_the_title()
    85                                 )
    86                         );
    87 
    88                         wp_link_pages(
    89                                 array(
    90                                         'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
    91                                         'after'       => '</div>',
    92                                         'link_before' => '<span class="page-number">',
    93                                         'link_after'  => '</span>',
    94                                 )
    95                         );
    96                 };
    97                 ?>
    98 
    99         </div><!-- .entry-content -->
    100 
    101         <?php
    102         if ( is_single() ) {
    103                 twentyseventeen_entry_footer();
    104         }
    105         ?>
    106 
    107 </article><!-- #post-## -->
     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.2
     11 */
     12
     13?>
     14
     15<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> role="article">
     16        <?php
     17        if ( is_sticky() && is_home() ) {
     18                echo twentyseventeen_get_svg( array( 'icon' => 'thumb-tack' ) );
     19        }
     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                        }
     31                                echo '</div><!-- .entry-meta -->';
     32                };
     33
     34                if ( is_single() ) {
     35                        the_title( '<h1 class="entry-title">', '</h1>' );
     36                } elseif ( is_front_page() && is_home() ) {
     37                        the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
     38                } else {
     39                        the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
     40                }
     41                ?>
     42        </header><!-- .entry-header -->
     43
     44        <?php
     45                $content = apply_filters( 'the_content', get_the_content() );
     46                $video   = false;
     47
     48                // Only get video from the content if a playlist isn't present.
     49        if ( false === strpos( $content, 'wp-playlist-script' ) ) {
     50                $video = get_media_embedded_in_content( $content, array( 'video', 'object', 'embed', 'iframe' ) );
     51        }
     52        ?>
     53
     54        <?php if ( '' !== get_the_post_thumbnail() && ! is_single() && empty( $video ) ) : ?>
     55                <div class="post-thumbnail">
     56                        <a href="<?php the_permalink(); ?>">
     57                                <?php the_post_thumbnail( 'twentyseventeen-featured-image' ); ?>
     58                        </a>
     59                </div><!-- .post-thumbnail -->
     60        <?php endif; ?>
     61
     62        <div class="entry-content">
     63
     64                <?php
     65                if ( ! is_single() ) {
     66
     67                        // If not a single post, highlight the video file.
     68                        if ( ! empty( $video ) ) {
     69                                foreach ( $video as $video_html ) {
     70                                        echo '<div class="entry-video">';
     71                                                echo $video_html;
     72                                        echo '</div>';
     73                                }
     74                        };
     75
     76                };
     77
     78                if ( is_single() || empty( $video ) ) {
     79
     80                        /* translators: %s: Name of current post */
     81                        the_content(
     82                                sprintf(
     83                                        __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
     84                                        get_the_title()
     85                                )
     86                        );
     87
     88                        wp_link_pages(
     89                                array(
     90                                        'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
     91                                        'after'       => '</div>',
     92                                        'link_before' => '<span class="page-number">',
     93                                        'link_after'  => '</span>',
     94                                )
     95                        );
     96                };
     97                ?>
     98
     99        </div><!-- .entry-content -->
     100
     101        <?php
     102        if ( is_single() ) {
     103                twentyseventeen_entry_footer();
     104        }
     105        ?>
     106
     107</article><!-- #post-## -->
  • src/wp-content/themes/twentyseventeen/template-parts/post/content.php

     
    1 <?php
    2 /**
    3  * Template part for displaying 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.2
    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                         };
    31                         echo '</div><!-- .entry-meta -->';
    32                 };
    33 
    34                 if ( is_single() ) {
    35                         the_title( '<h1 class="entry-title">', '</h1>' );
    36                 } elseif ( is_front_page() && is_home() ) {
    37                         the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
    38                 } else {
    39                         the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    40                 }
    41                 ?>
    42         </header><!-- .entry-header -->
    43 
    44         <?php if ( '' !== get_the_post_thumbnail() && ! is_single() ) : ?>
    45                 <div class="post-thumbnail">
    46                         <a href="<?php the_permalink(); ?>">
    47                                 <?php the_post_thumbnail( 'twentyseventeen-featured-image' ); ?>
    48                         </a>
    49                 </div><!-- .post-thumbnail -->
    50         <?php endif; ?>
    51 
    52         <div class="entry-content">
    53                 <?php
    54                 /* translators: %s: Name of current post */
    55                 the_content(
    56                         sprintf(
    57                                 __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
    58                                 get_the_title()
    59                         )
    60                 );
    61 
    62                 wp_link_pages(
    63                         array(
    64                                 'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
    65                                 'after'       => '</div>',
    66                                 'link_before' => '<span class="page-number">',
    67                                 'link_after'  => '</span>',
    68                         )
    69                 );
    70                 ?>
    71         </div><!-- .entry-content -->
    72 
    73         <?php
    74         if ( is_single() ) {
    75                 twentyseventeen_entry_footer();
    76         }
    77         ?>
    78 
    79 </article><!-- #post-## -->
     1<?php
     2/**
     3 * Template part for displaying 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.2
     11 */
     12
     13?>
     14
     15<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> role="article">
     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                        };
     31                        echo '</div><!-- .entry-meta -->';
     32                };
     33
     34                if ( is_single() ) {
     35                        the_title( '<h1 class="entry-title">', '</h1>' );
     36                } elseif ( is_front_page() && is_home() ) {
     37                        the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
     38                } else {
     39                        the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
     40                }
     41                ?>
     42        </header><!-- .entry-header -->
     43
     44        <?php if ( '' !== get_the_post_thumbnail() && ! is_single() ) : ?>
     45                <div class="post-thumbnail">
     46                        <a href="<?php the_permalink(); ?>">
     47                                <?php the_post_thumbnail( 'twentyseventeen-featured-image' ); ?>
     48                        </a>
     49                </div><!-- .post-thumbnail -->
     50        <?php endif; ?>
     51
     52        <div class="entry-content">
     53                <?php
     54                /* translators: %s: Name of current post */
     55                the_content(
     56                        sprintf(
     57                                __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),
     58                                get_the_title()
     59                        )
     60                );
     61
     62                wp_link_pages(
     63                        array(
     64                                'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
     65                                'after'       => '</div>',
     66                                'link_before' => '<span class="page-number">',
     67                                'link_after'  => '</span>',
     68                        )
     69                );
     70                ?>
     71        </div><!-- .entry-content -->
     72
     73        <?php
     74        if ( is_single() ) {
     75                twentyseventeen_entry_footer();
     76        }
     77        ?>
     78
     79</article><!-- #post-## -->