Making WordPress.org

Changeset 9908


Ignore:
Timestamp:
05/24/2020 07:27:02 PM (6 years ago)
Author:
ocean90
Message:

Breathe Theme: Append date of last update to handbook pages.

Fixes #5222.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/functions.php

    r9865 r9908  
    1414        remove_action( 'customize_preview_init', 'breathe_customize_preview_js' );
    1515        remove_filter( 'wp_head', 'breathe_color_styles' );
    16 
    1716        add_action( 'customize_register', __NAMESPACE__ . '\customize_register' );
     17
     18        add_filter( 'o2_filtered_content', __NAMESPACE__ . '\append_last_updated', 10, 2 );
    1819}
    1920add_action( 'after_setup_theme', __NAMESPACE__ . '\after_setup_theme', 11 );
    … …  
    236237
    237238/**
     239 * Appends a 'Last updated' to handbook pages.
     240 *
     241 * @param string $content Content of the current post.
     242 * @return Content of the current post.
     243 */
     244function append_last_updated( $content, $post ) {
     245        if ( ! function_exists( 'wporg_is_handbook' ) || ! wporg_is_handbook( $post->post_type ) ) {
     246                return $content;
     247        }
     248
     249        $content .= sprintf(
     250                /* translators: %s: Date of last update. */
     251                '<p class="handbook-last-updated">' . __( 'Last updated: %s', 'wporg' ) . '</p>',
     252                sprintf(
     253                        '<time datetime="%s">%s</time>',
     254                        esc_attr( get_the_modified_date( DATE_W3C ) ),
     255                        esc_html( get_the_modified_date() )
     256                )
     257        );
     258
     259        return $content;
     260}
     261
     262/**
    238263 * Register translations for plugins without their own GlotPress project.
    239264 */
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/single-handbook.php

    r7917 r9908  
    3232                        </header><!-- .handbook-header -->
    3333
    34                         <?php the_content(); ?>
     34                        <?php
     35                        the_content();
    3536
    36                         <?php \WPorg_Handbook_Navigation::show_nav_links(); ?>
     37                        printf(
     38                                /* translators: %s: Date of last update. */
     39                                '<p class="handbook-last-updated">' . __( 'Last updated: %s', 'wporg' ) . '</p>',
     40                                sprintf(
     41                                        '<time datetime="%s">%s</time>',
     42                                        esc_attr( get_the_modified_date( DATE_W3C ) ),
     43                                        esc_html( get_the_modified_date() )
     44                                )
     45                        );
     46
     47                        \WPorg_Handbook_Navigation::show_nav_links();
     48                        ?>
    3749
    3850                <?php endwhile; // end of the loop. ?>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/style.css

    r9882 r9908  
    10381038}
    10391039
     1040.handbook-last-updated {
     1041        font-size: 1.25rem;
     1042        color: #555;
     1043        margin: 2.4em 0 0;
     1044        font-weight: 300;
     1045}
     1046
    10401047/*
    10411048 * Callout boxes
Note: See TracChangeset for help on using the changeset viewer.