WordPress.org

Making WordPress.org


Ignore:
Timestamp:
09/20/2017 08:53:07 PM (3 years ago)
Author:
obenland
Message:

Main: Bring entry meta closer to existing styles.

Also adds the sidebar to single posts.

See #2861.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg/inc/template-tags.php

    r5939 r5942  
    1818function entry_meta() {
    1919    if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) {
    20         entry_date();
     20        $time_string = sprintf( '<a href="%1$s" rel="bookmark">%2$s</a>',
     21            esc_url( get_permalink() ),
     22            get_entry_date()
     23        );
     24
     25        $author_string = sprintf(
     26            '<span class="entry-author vcard"><a class="url fn n" href="%1$s">%2$s</a></span>',
     27            esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
     28            get_the_author()
     29        );
     30
     31        printf(
     32            /* translators: 1: post date 2: post author */
     33            '<span class="posted-on">' . __( 'Posted on %1$s by %2$s.', 'wporg' ) . '</span>',
     34            $time_string,
     35            $author_string
     36        );
    2137    }
    2238
     
    4258endif;
    4359
     60if ( ! function_exists( __NAMESPACE__ . '\get_entry_date' ) ) :
     61    /**
     62     * Prints HTML with published and updated information for current post.
     63     *
     64     * Create your own  WordPressdotorg\Theme\get_entry_date() function to override in a child theme.
     65     */
     66    function get_entry_date() {
     67        $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
     68
     69        if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
     70            $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
     71        }
     72
     73        return sprintf( $time_string,
     74            esc_attr( get_the_date( 'c' ) ),
     75            get_the_date(),
     76            esc_attr( get_the_modified_date( 'c' ) ),
     77            get_the_modified_date()
     78        );
     79    }
     80endif;
     81
    4482if ( ! function_exists( __NAMESPACE__ . '\entry_date' ) ) :
    45 /**
    46  * Prints HTML with date information for current post.
    47  *
    48  * Create your own  WordPressdotorg\Theme\entry_date() function to override in a child theme.
    49  */
    50 function entry_date() {
    51     $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
    52 
    53     if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
    54         $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
     83    /**
     84     * Prints HTML with date information for current post.
     85     *
     86     * Create your own  WordPressdotorg\Theme\entry_date() function to override in a child theme.
     87     */
     88    function entry_date() {
     89        printf( '<span class="posted-on">%1$s <a href="%2$s" rel="bookmark">%3$s</a></span>',
     90            _x( 'Posted on', 'Used before publish date.', 'wporg' ),
     91            esc_url( get_permalink() ),
     92            get_entry_date()
     93        );
    5594    }
    56 
    57     $time_string = sprintf( $time_string,
    58         esc_attr( get_the_date( 'c' ) ),
    59         get_the_date(),
    60         esc_attr( get_the_modified_date( 'c' ) ),
    61         get_the_modified_date()
    62     );
    63 
    64     printf( '<span class="posted-on">%1$s <a href="%2$s" rel="bookmark">%3$s</a></span>',
    65         _x( 'Posted on', 'Used before publish date.', 'wporg' ),
    66         esc_url( get_permalink() ),
    67         $time_string
    68     );
    69 }
    7095endif;
    7196
Note: See TracChangeset for help on using the changeset viewer.