[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-content/themes/twentynineteen/inc/ -> template-tags.php (source)

   1  <?php
   2  /**
   3   * Custom template tags for this theme
   4   *
   5   * @package WordPress
   6   * @subpackage Twenty_Nineteen
   7   * @since Twenty Nineteen 1.0
   8   */
   9  
  10  if ( ! function_exists( 'twentynineteen_posted_on' ) ) :
  11      /**
  12       * Prints HTML with meta information for the current post-date/time.
  13       */
  14  	function twentynineteen_posted_on() {
  15          $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
  16          if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
  17              $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
  18          }
  19  
  20          $time_string = sprintf(
  21              $time_string,
  22              esc_attr( get_the_date( DATE_W3C ) ),
  23              esc_html( get_the_date() ),
  24              esc_attr( get_the_modified_date( DATE_W3C ) ),
  25              esc_html( get_the_modified_date() )
  26          );
  27  
  28          printf(
  29              '<span class="posted-on">%1$s<a href="%2$s" rel="bookmark">%3$s</a></span>',
  30              twentynineteen_get_icon_svg( 'watch', 16 ),
  31              esc_url( get_permalink() ),
  32              $time_string
  33          );
  34      }
  35  endif;
  36  
  37  if ( ! function_exists( 'twentynineteen_posted_by' ) ) :
  38      /**
  39       * Prints HTML with meta information about theme author.
  40       */
  41  	function twentynineteen_posted_by() {
  42          printf(
  43              /* translators: 1: SVG icon. 2: Post author, only visible to screen readers. 3: Author link. */
  44              '<span class="byline">%1$s<span class="screen-reader-text">%2$s</span><span class="author vcard"><a class="url fn n" href="%3$s">%4$s</a></span></span>',
  45              twentynineteen_get_icon_svg( 'person', 16 ),
  46              __( 'Posted by', 'twentynineteen' ),
  47              esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
  48              esc_html( get_the_author() )
  49          );
  50      }
  51  endif;
  52  
  53  if ( ! function_exists( 'twentynineteen_comment_count' ) ) :
  54      /**
  55       * Prints HTML with the comment count for the current post.
  56       */
  57  	function twentynineteen_comment_count() {
  58          if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
  59              echo '<span class="comments-link">';
  60              echo twentynineteen_get_icon_svg( 'comment', 16 );
  61  
  62              /* translators: %s: Post title. Only visible to screen readers. */
  63              comments_popup_link( sprintf( __( 'Leave a comment<span class="screen-reader-text"> on %s</span>', 'twentynineteen' ), get_the_title() ) );
  64  
  65              echo '</span>';
  66          }
  67      }
  68  endif;
  69  
  70  if ( ! function_exists( 'twentynineteen_entry_footer' ) ) :
  71      /**
  72       * Prints HTML with meta information for the categories, tags and comments.
  73       */
  74  	function twentynineteen_entry_footer() {
  75  
  76          // Hide author, post date, category and tag text for pages.
  77          if ( 'post' === get_post_type() ) {
  78  
  79              // Posted by.
  80              twentynineteen_posted_by();
  81  
  82              // Posted on.
  83              twentynineteen_posted_on();
  84  
  85              $categories_list = get_the_category_list( wp_get_list_item_separator() );
  86              if ( $categories_list ) {
  87                  printf(
  88                      /* translators: 1: SVG icon. 2: Posted in label, only visible to screen readers. 3: List of categories. */
  89                      '<span class="cat-links">%1$s<span class="screen-reader-text">%2$s</span>%3$s</span>',
  90                      twentynineteen_get_icon_svg( 'archive', 16 ),
  91                      __( 'Posted in', 'twentynineteen' ),
  92                      $categories_list
  93                  ); // WPCS: XSS OK.
  94              }
  95  
  96              $tags_list = get_the_tag_list( '', wp_get_list_item_separator() );
  97              if ( $tags_list && ! is_wp_error( $tags_list ) ) {
  98                  printf(
  99                      /* translators: 1: SVG icon. 2: Posted in label, only visible to screen readers. 3: List of tags. */
 100                      '<span class="tags-links">%1$s<span class="screen-reader-text">%2$s </span>%3$s</span>',
 101                      twentynineteen_get_icon_svg( 'tag', 16 ),
 102                      __( 'Tags:', 'twentynineteen' ),
 103                      $tags_list
 104                  ); // WPCS: XSS OK.
 105              }
 106          }
 107  
 108          // Comment count.
 109          if ( ! is_singular() ) {
 110              twentynineteen_comment_count();
 111          }
 112  
 113          // Edit post link.
 114          edit_post_link(
 115              sprintf(
 116                  wp_kses(
 117                      /* translators: %s: Post title. Only visible to screen readers. */
 118                      __( 'Edit <span class="screen-reader-text">%s</span>', 'twentynineteen' ),
 119                      array(
 120                          'span' => array(
 121                              'class' => array(),
 122                          ),
 123                      )
 124                  ),
 125                  get_the_title()
 126              ),
 127              '<span class="edit-link">' . twentynineteen_get_icon_svg( 'edit', 16 ),
 128              '</span>'
 129          );
 130      }
 131  endif;
 132  
 133  if ( ! function_exists( 'twentynineteen_post_thumbnail' ) ) :
 134      /**
 135       * Displays an optional post thumbnail.
 136       *
 137       * Wraps the post thumbnail in an anchor element on index views, or a div
 138       * element when on single views.
 139       */
 140  	function twentynineteen_post_thumbnail() {
 141          if ( ! twentynineteen_can_show_post_thumbnail() ) {
 142              return;
 143          }
 144  
 145          if ( is_singular() ) :
 146              ?>
 147  
 148              <figure class="post-thumbnail">
 149                  <?php the_post_thumbnail(); ?>
 150              </figure><!-- .post-thumbnail -->
 151  
 152              <?php
 153          else :
 154              ?>
 155  
 156          <figure class="post-thumbnail">
 157              <a class="post-thumbnail-inner" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
 158                  <?php the_post_thumbnail( 'post-thumbnail' ); ?>
 159              </a>
 160          </figure>
 161  
 162              <?php
 163          endif; // End is_singular().
 164      }
 165  endif;
 166  
 167  if ( ! function_exists( 'twentynineteen_get_user_avatar_markup' ) ) :
 168      /**
 169       * Returns the HTML markup to generate a user avatar.
 170       */
 171  	function twentynineteen_get_user_avatar_markup( $id_or_email = null ) {
 172  
 173          if ( ! isset( $id_or_email ) ) {
 174              $id_or_email = get_current_user_id();
 175          }
 176  
 177          return sprintf( '<div class="comment-user-avatar comment-author vcard">%s</div>', get_avatar( $id_or_email, twentynineteen_get_avatar_size() ) );
 178      }
 179  endif;
 180  
 181  if ( ! function_exists( 'twentynineteen_discussion_avatars_list' ) ) :
 182      /**
 183       * Displays a list of avatars involved in a discussion for a given post.
 184       */
 185  	function twentynineteen_discussion_avatars_list( $comment_authors ) {
 186          if ( empty( $comment_authors ) ) {
 187              return;
 188          }
 189          echo '<ol class="discussion-avatar-list">', "\n";
 190          foreach ( $comment_authors as $id_or_email ) {
 191              printf(
 192                  "<li>%s</li>\n",
 193                  twentynineteen_get_user_avatar_markup( $id_or_email )
 194              );
 195          }
 196          echo '</ol><!-- .discussion-avatar-list -->', "\n";
 197      }
 198  endif;
 199  
 200  if ( ! function_exists( 'twentynineteen_comment_form' ) ) :
 201      /**
 202       * Documentation for function.
 203       */
 204  	function twentynineteen_comment_form( $order ) {
 205          if ( true === $order || strtolower( $order ) === strtolower( get_option( 'comment_order', 'asc' ) ) ) {
 206  
 207              comment_form(
 208                  array(
 209                      'title_reply' => null,
 210                  )
 211              );
 212          }
 213      }
 214  endif;
 215  
 216  if ( ! function_exists( 'twentynineteen_the_posts_navigation' ) ) :
 217      /**
 218       * Documentation for function.
 219       */
 220  	function twentynineteen_the_posts_navigation() {
 221          the_posts_pagination(
 222              array(
 223                  'mid_size'  => 2,
 224                  'prev_text' => sprintf(
 225                      '%s <span class="nav-prev-text">%s</span>',
 226                      twentynineteen_get_icon_svg( 'chevron_left', 22 ),
 227                      __( 'Newer posts', 'twentynineteen' )
 228                  ),
 229                  'next_text' => sprintf(
 230                      '<span class="nav-next-text">%s</span> %s',
 231                      __( 'Older posts', 'twentynineteen' ),
 232                      twentynineteen_get_icon_svg( 'chevron_right', 22 )
 233                  ),
 234              )
 235          );
 236      }
 237  endif;
 238  
 239  if ( ! function_exists( 'wp_body_open' ) ) :
 240      /**
 241       * Fire the wp_body_open action.
 242       *
 243       * Added for backward compatibility to support pre-5.2.0 WordPress versions.
 244       *
 245       * @since Twenty Nineteen 1.4
 246       */
 247  	function wp_body_open() {
 248          /**
 249           * Triggered after the opening <body> tag.
 250           *
 251           * @since Twenty Nineteen 1.4
 252           */
 253          do_action( 'wp_body_open' );
 254      }
 255  endif;


Generated: Tue Mar 19 01:00:02 2024 Cross-referenced by PHPXref 0.7.1