| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Custom template tags for this theme 4 * 5 * @package WordPress 6 * @subpackage Twenty_Twenty_One 7 * @since Twenty Twenty-One 1.0 8 */ 9 10 if ( ! function_exists( 'twenty_twenty_one_posted_on' ) ) { 11 /** 12 * Prints HTML with meta information for the current post-date/time. 13 * 14 * @since Twenty Twenty-One 1.0 15 * 16 * @return void 17 */ 18 function twenty_twenty_one_posted_on() { 19 $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>'; 20 21 $time_string = sprintf( 22 $time_string, 23 esc_attr( get_the_date( DATE_W3C ) ), 24 esc_html( get_the_date() ) 25 ); 26 echo '<span class="posted-on">'; 27 printf( 28 /* translators: %s: Publish date. */ 29 esc_html__( 'Published %s', 'twentytwentyone' ), 30 $time_string 31 ); 32 echo '</span>'; 33 } 34 } 35 36 if ( ! function_exists( 'twenty_twenty_one_posted_by' ) ) { 37 /** 38 * Prints HTML with meta information about theme author. 39 * 40 * @since Twenty Twenty-One 1.0 41 * 42 * @return void 43 */ 44 function twenty_twenty_one_posted_by() { 45 if ( ! get_the_author_meta( 'description' ) && post_type_supports( get_post_type(), 'author' ) ) { 46 echo '<span class="byline">'; 47 printf( 48 /* translators: %s: Author name. */ 49 esc_html__( 'By %s', 'twentytwentyone' ), 50 '<a href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" rel="author">' . esc_html( get_the_author() ) . '</a>' 51 ); 52 echo '</span>'; 53 } 54 } 55 } 56 57 if ( ! function_exists( 'twenty_twenty_one_entry_meta_footer' ) ) { 58 /** 59 * Prints HTML with meta information for the categories, tags and comments. 60 * Footer entry meta is displayed differently in archives and single posts. 61 * 62 * @since Twenty Twenty-One 1.0 63 * 64 * @return void 65 */ 66 function twenty_twenty_one_entry_meta_footer() { 67 68 // Early exit if not a post. 69 if ( 'post' !== get_post_type() ) { 70 return; 71 } 72 73 // Hide meta information on pages. 74 if ( ! is_single() ) { 75 76 if ( is_sticky() ) { 77 echo '<p>' . esc_html_x( 'Featured post', 'Label for sticky posts', 'twentytwentyone' ) . '</p>'; 78 } 79 80 $post_format = get_post_format(); 81 if ( 'aside' === $post_format || 'status' === $post_format ) { 82 echo '<p><a href="' . esc_url( get_permalink() ) . '">' . twenty_twenty_one_continue_reading_text() . '</a></p>'; 83 } 84 85 // Posted on. 86 twenty_twenty_one_posted_on(); 87 88 // Edit post link. 89 edit_post_link( 90 sprintf( 91 /* translators: %s: Post title. Only visible to screen readers. */ 92 esc_html__( 'Edit %s', 'twentytwentyone' ), 93 '<span class="screen-reader-text">' . get_the_title() . '</span>' 94 ), 95 '<span class="edit-link">', 96 '</span><br>' 97 ); 98 99 if ( has_category() || has_tag() ) { 100 101 echo '<div class="post-taxonomies">'; 102 103 $categories_list = get_the_category_list( wp_get_list_item_separator() ); 104 if ( $categories_list ) { 105 printf( 106 /* translators: %s: List of categories. */ 107 '<span class="cat-links">' . esc_html__( 'Categorized as %s', 'twentytwentyone' ) . ' </span>', 108 $categories_list 109 ); 110 } 111 112 $tags_list = get_the_tag_list( '', wp_get_list_item_separator() ); 113 if ( $tags_list && ! is_wp_error( $tags_list ) ) { 114 printf( 115 /* translators: %s: List of tags. */ 116 '<span class="tags-links">' . esc_html__( 'Tagged %s', 'twentytwentyone' ) . '</span>', 117 $tags_list 118 ); 119 } 120 echo '</div>'; 121 } 122 } else { 123 124 echo '<div class="posted-by">'; 125 // Posted on. 126 twenty_twenty_one_posted_on(); 127 // Posted by. 128 twenty_twenty_one_posted_by(); 129 // Edit post link. 130 edit_post_link( 131 sprintf( 132 /* translators: %s: Post title. Only visible to screen readers. */ 133 esc_html__( 'Edit %s', 'twentytwentyone' ), 134 '<span class="screen-reader-text">' . get_the_title() . '</span>' 135 ), 136 '<span class="edit-link">', 137 '</span>' 138 ); 139 echo '</div>'; 140 141 if ( has_category() || has_tag() ) { 142 143 echo '<div class="post-taxonomies">'; 144 145 $categories_list = get_the_category_list( wp_get_list_item_separator() ); 146 if ( $categories_list ) { 147 printf( 148 /* translators: %s: List of categories. */ 149 '<span class="cat-links">' . esc_html__( 'Categorized as %s', 'twentytwentyone' ) . ' </span>', 150 $categories_list 151 ); 152 } 153 154 $tags_list = get_the_tag_list( '', wp_get_list_item_separator() ); 155 if ( $tags_list && ! is_wp_error( $tags_list ) ) { 156 printf( 157 /* translators: %s: List of tags. */ 158 '<span class="tags-links">' . esc_html__( 'Tagged %s', 'twentytwentyone' ) . '</span>', 159 $tags_list 160 ); 161 } 162 echo '</div>'; 163 } 164 } 165 } 166 } 167 168 if ( ! function_exists( 'twenty_twenty_one_post_thumbnail' ) ) { 169 /** 170 * Displays an optional post thumbnail. 171 * 172 * Wraps the post thumbnail in an anchor element on index views, or a div 173 * element when on single views. 174 * 175 * @since Twenty Twenty-One 1.0 176 * 177 * @return void 178 */ 179 function twenty_twenty_one_post_thumbnail() { 180 if ( ! twenty_twenty_one_can_show_post_thumbnail() ) { 181 return; 182 } 183 ?> 184 185 <?php if ( is_singular() ) : ?> 186 187 <figure class="post-thumbnail"> 188 <?php 189 // Lazy-loading attributes should be skipped for thumbnails since they are immediately in the viewport. 190 the_post_thumbnail( 'post-thumbnail', array( 'loading' => false ) ); 191 ?> 192 <?php if ( wp_get_attachment_caption( get_post_thumbnail_id() ) ) : ?> 193 <figcaption class="wp-caption-text"><?php echo wp_kses_post( wp_get_attachment_caption( get_post_thumbnail_id() ) ); ?></figcaption> 194 <?php endif; ?> 195 </figure><!-- .post-thumbnail --> 196 197 <?php else : ?> 198 199 <figure class="post-thumbnail"> 200 <a class="post-thumbnail-inner alignwide" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1"> 201 <?php the_post_thumbnail( 'post-thumbnail' ); ?> 202 </a> 203 <?php if ( wp_get_attachment_caption( get_post_thumbnail_id() ) ) : ?> 204 <figcaption class="wp-caption-text"><?php echo wp_kses_post( wp_get_attachment_caption( get_post_thumbnail_id() ) ); ?></figcaption> 205 <?php endif; ?> 206 </figure><!-- .post-thumbnail --> 207 208 <?php endif; ?> 209 <?php 210 } 211 } 212 213 if ( ! function_exists( 'twenty_twenty_one_the_posts_navigation' ) ) { 214 /** 215 * Prints the next and previous posts navigation. 216 * 217 * @since Twenty Twenty-One 1.0 218 * 219 * @return void 220 */ 221 function twenty_twenty_one_the_posts_navigation() { 222 $order = get_query_var( 'order', 'DESC' ); 223 $new_posts_text = __( 'Newer <span class="nav-short">posts</span>', 'twentytwentyone' ); 224 $old_posts_text = __( 'Older <span class="nav-short">posts</span>', 'twentytwentyone' ); 225 226 the_posts_pagination( 227 array( 228 'before_page_number' => esc_html__( 'Page', 'twentytwentyone' ) . ' ', 229 'mid_size' => 0, 230 'prev_text' => sprintf( 231 '%s <span class="nav-prev-text">%s</span>', 232 is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' ), 233 wp_kses( 234 ( 'DESC' === $order ) ? $new_posts_text : $old_posts_text, 235 array( 236 'span' => array( 237 'class' => array(), 238 ), 239 ) 240 ) 241 ), 242 'next_text' => sprintf( 243 '<span class="nav-next-text">%s</span> %s', 244 wp_kses( 245 ( 'DESC' === $order ) ? $old_posts_text : $new_posts_text, 246 array( 247 'span' => array( 248 'class' => array(), 249 ), 250 ) 251 ), 252 is_rtl() ? twenty_twenty_one_get_icon_svg( 'ui', 'arrow_left' ) : twenty_twenty_one_get_icon_svg( 'ui', 'arrow_right' ) 253 ), 254 ) 255 ); 256 } 257 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Fri Oct 16 08:20:34 2026 | Cross-referenced by PHPXref |