- Timestamp:
- 11/30/2017 11:09:33 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyseventeen/inc/template-tags.php
r41756 r42343 11 11 12 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 }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 28 endif; 29 29 30 30 31 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( $time_string, 42 get_the_date( DATE_W3C ), 43 get_the_date(), 44 get_the_modified_date( DATE_W3C ), 45 get_the_modified_date() 46 ); 47 48 // Wrap the time string in a link, and preface it with 'Posted on'. 49 return sprintf( 50 /* translators: %s: post date */ 51 __( '<span class="screen-reader-text">Posted on</span> %s', 'twentyseventeen' ), 52 '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' 53 ); 54 } 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 } 55 56 endif; 56 57 57 58 58 59 if ( ! function_exists( 'twentyseventeen_entry_footer' ) ) : 59 /**60 * Prints HTML with meta information for the categories, tags and comments.61 */62 function twentyseventeen_entry_footer() {63 64 /* translators: used between list items, there is a space after the comma */65 $separate_meta = __( ', ', 'twentyseventeen' );66 67 // Get Categories for posts.68 $categories_list = get_the_category_list( $separate_meta );69 70 // Get Tags for posts.71 $tags_list = get_the_tag_list( '', $separate_meta );72 73 // We don't want to output .entry-footer if it will be empty, so make sure its not.74 if ( ( ( twentyseventeen_categorized_blog() && $categories_list ) || $tags_list ) || get_edit_post_link() ) {75 76 echo '<footer class="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">'; 77 78 78 79 if ( 'post' === get_post_type() ) { … … 81 82 82 83 // Make sure there's more than one category before displaying. 83 if ( $categories_list && twentyseventeen_categorized_blog() ) {84 echo '<span class="cat-links">' . twentyseventeen_get_svg( array( 'icon' => 'folder-open' ) ) . '<span class="screen-reader-text">' . __( 'Categories', 'twentyseventeen' ) . '</span>' . $categories_list . '</span>';85 }86 87 if ( $tags_list && ! is_wp_error( $tags_list ) ) {88 echo '<span class="tags-links">' . twentyseventeen_get_svg( array( 'icon' => 'hashtag' ) ) . '<span class="screen-reader-text">' . __( 'Tags', 'twentyseventeen' ) . '</span>' . $tags_list . '</span>';89 }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 } 90 91 91 92 echo '</span>'; … … 95 96 twentyseventeen_edit_link(); 96 97 97 echo '</footer> <!-- .entry-footer -->';98 }99 }98 echo '</footer> <!-- .entry-footer -->'; 99 } 100 } 100 101 endif; 101 102 102 103 103 104 if ( ! function_exists( 'twentyseventeen_edit_link' ) ) : 104 /**105 * Returns an accessibility-friendly link to edit a post or page.106 *107 * This also gives us a little context about what exactly we're editing108 * (post or page?) so that users understand a bit more where they are in terms109 * of the template hierarchy and their content. Helpful when/if the single-page110 * layout with multiple posts/pages shown gets confusing.111 */112 function twentyseventeen_edit_link() {113 edit_post_link(114 sprintf(115 /* translators: %s: Name of current post */116 __( 'Edit<span class="screen-reader-text"> "%s"</span>', 'twentyseventeen' ),117 get_the_title()118 ),119 '<span class="edit-link">',120 '</span>'121 );122 }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 } 123 124 endif; 124 125 … … 133 134 // Find out the id and set it up during a selective refresh. 134 135 global $twentyseventeencounter; 135 $id = str_replace( 'panel_', '', $partial->id );136 $id = str_replace( 'panel_', '', $partial->id ); 136 137 $twentyseventeencounter = $id; 137 138 } … … 162 163 if ( false === $category_count ) { 163 164 // Create an array of all the categories that are attached to posts. 164 $categories = get_categories( array( 165 'fields' => 'ids', 166 'hide_empty' => 1, 167 // We only need to know if there is more than one category. 168 'number' => 2, 169 ) ); 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 ); 170 173 171 174 // Count the number of categories that are attached to the posts. … … 195 198 } 196 199 add_action( 'edit_category', 'twentyseventeen_category_transient_flusher' ); 197 add_action( 'save_post', 'twentyseventeen_category_transient_flusher' );200 add_action( 'save_post', 'twentyseventeen_category_transient_flusher' );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)