[ 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 1.0.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              /* translators: Used between list items, there is a space after the comma. */
  86              $categories_list = get_the_category_list( __( ', ', 'twentynineteen' ) );
  87              if ( $categories_list ) {
  88                  printf(
  89                      /* translators: 1: SVG icon. 2: Posted in label, only visible to screen readers. 3: List of categories. */
  90                      '<span class="cat-links">%1$s<span class="screen-reader-text">%2$s</span>%3$s</span>',
  91                      twentynineteen_get_icon_svg( 'archive', 16 ),
  92                      __( 'Posted in', 'twentynineteen' ),
  93                      $categories_list
  94                  ); // WPCS: XSS OK.
  95              }
  96  
  97              /* translators: Used between list items, there is a space after the comma. */
  98              $tags_list = get_the_tag_list( '', __( ', ', 'twentynineteen' ) );
  99              if ( $tags_list ) {
 100                  printf(
 101                      /* translators: 1: SVG icon. 2: Posted in label, only visible to screen readers. 3: List of tags. */
 102                      '<span class="tags-links">%1$s<span class="screen-reader-text">%2$s </span>%3$s</span>',
 103                      twentynineteen_get_icon_svg( 'tag', 16 ),
 104                      __( 'Tags:', 'twentynineteen' ),
 105                      $tags_list
 106                  ); // WPCS: XSS OK.
 107              }
 108          }
 109  
 110          // Comment count.
 111          if ( ! is_singular() ) {
 112              twentynineteen_comment_count();
 113          }
 114  
 115          // Edit post link.
 116          edit_post_link(
 117              sprintf(
 118                  wp_kses(
 119                      /* translators: %s: Post title. Only visible to screen readers. */
 120                      __( 'Edit <span class="screen-reader-text">%s</span>', 'twentynineteen' ),
 121                      array(
 122                          'span' => array(
 123                              'class' => array(),
 124                          ),
 125                      )
 126                  ),
 127                  get_the_title()
 128              ),
 129              '<span class="edit-link">' . twentynineteen_get_icon_svg( 'edit', 16 ),
 130              '</span>'
 131          );
 132      }
 133  endif;
 134  
 135  if ( ! function_exists( 'twentynineteen_post_thumbnail' ) ) :
 136      /**
 137       * Displays an optional post thumbnail.
 138       *
 139       * Wraps the post thumbnail in an anchor element on index views, or a div
 140       * element when on single views.
 141       */
 142  	function twentynineteen_post_thumbnail() {
 143          if ( ! twentynineteen_can_show_post_thumbnail() ) {
 144              return;
 145          }
 146  
 147          if ( is_singular() ) :
 148              ?>
 149  
 150              <figure class="post-thumbnail">
 151                  <?php the_post_thumbnail(); ?>
 152              </figure><!-- .post-thumbnail -->
 153  
 154              <?php
 155          else :
 156              ?>
 157  
 158          <figure class="post-thumbnail">
 159              <a class="post-thumbnail-inner" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
 160                  <?php the_post_thumbnail( 'post-thumbnail' ); ?>
 161              </a>
 162          </figure>
 163  
 164              <?php
 165          endif; // End is_singular().
 166      }
 167  endif;
 168  
 169  if ( ! function_exists( 'twentynineteen_get_user_avatar_markup' ) ) :
 170      /**
 171       * Returns the HTML markup to generate a user avatar.
 172       */
 173  	function twentynineteen_get_user_avatar_markup( $id_or_email = null ) {
 174  
 175          if ( ! isset( $id_or_email ) ) {
 176              $id_or_email = get_current_user_id();
 177          }
 178  
 179          return sprintf( '<div class="comment-user-avatar comment-author vcard">%s</div>', get_avatar( $id_or_email, twentynineteen_get_avatar_size() ) );
 180      }
 181  endif;
 182  
 183  if ( ! function_exists( 'twentynineteen_discussion_avatars_list' ) ) :
 184      /**
 185       * Displays a list of avatars involved in a discussion for a given post.
 186       */
 187  	function twentynineteen_discussion_avatars_list( $comment_authors ) {
 188          if ( empty( $comment_authors ) ) {
 189              return;
 190          }
 191          echo '<ol class="discussion-avatar-list">', "\n";
 192          foreach ( $comment_authors as $id_or_email ) {
 193              printf(
 194                  "<li>%s</li>\n",
 195                  twentynineteen_get_user_avatar_markup( $id_or_email )
 196              );
 197          }
 198          echo '</ol><!-- .discussion-avatar-list -->', "\n";
 199      }
 200  endif;
 201  
 202  if ( ! function_exists( 'twentynineteen_comment_form' ) ) :
 203      /**
 204       * Documentation for function.
 205       */
 206  	function twentynineteen_comment_form( $order ) {
 207          if ( true === $order || strtolower( $order ) === strtolower( get_option( 'comment_order', 'asc' ) ) ) {
 208  
 209              comment_form(
 210                  array(
 211                      'logged_in_as' => null,
 212                      'title_reply'  => null,
 213                  )
 214              );
 215          }
 216      }
 217  endif;
 218  
 219  if ( ! function_exists( 'twentynineteen_the_posts_navigation' ) ) :
 220      /**
 221       * Documentation for function.
 222       */
 223  	function twentynineteen_the_posts_navigation() {
 224          the_posts_pagination(
 225              array(
 226                  'mid_size'  => 2,
 227                  'prev_text' => sprintf(
 228                      '%s <span class="nav-prev-text">%s</span>',
 229                      twentynineteen_get_icon_svg( 'chevron_left', 22 ),
 230                      __( 'Newer posts', 'twentynineteen' )
 231                  ),
 232                  'next_text' => sprintf(
 233                      '<span class="nav-next-text">%s</span> %s',
 234                      __( 'Older posts', 'twentynineteen' ),
 235                      twentynineteen_get_icon_svg( 'chevron_right', 22 )
 236                  ),
 237              )
 238          );
 239      }
 240  endif;
 241  
 242  if ( ! function_exists( 'wp_body_open' ) ) :
 243      /**
 244       * Fire the wp_body_open action.
 245       *
 246       * Added for backwards compatibility to support pre 5.2.0 WordPress versions.
 247       *
 248       * @since Twenty Nineteen 1.4
 249       */
 250  	function wp_body_open() {
 251          /**
 252           * Triggered after the opening <body> tag.
 253           *
 254           * @since Twenty Nineteen 1.4
 255           */
 256          do_action( 'wp_body_open' );
 257      }
 258  endif;


Generated: Sun Nov 17 01:00:03 2019 Cross-referenced by PHPXref 0.7.1