Making WordPress.org


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.

File:
1 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 */
Note: See TracChangeset for help on using the changeset viewer.