Making WordPress.org

Changeset 14153


Ignore:
Timestamp:
10/29/2024 03:18:40 AM (7 months ago)
Author:
dd32
Message:

Plugin Directory: Resolve some closed plugins showing 'Last updated: 55 years ago'.

See #7057.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php

    r14152 r14153  
    165165        krsort( $result['ratings'] );
    166166
     167        // Determine the last_updated date.
     168        $last_updated = $post->last_updated ?: $post->post_modified_gmt; // Prefer the post_meta unless not set.
     169        if ( '0000-00-00 00:00:00' === $last_updated ) {
     170            $last_updated = $post->post_date_gmt;
     171        }
     172
    167173        $result['num_ratings']              = array_sum( $result['ratings'] );
    168174        $result['support_url']              = 'https://wordpress.org/support/plugin/' . urlencode( $plugin_slug ) . '/';
     
    171177        $result['active_installs']          = intval( get_post_meta( $post_id, 'active_installs', true ) );
    172178        $result['downloaded']               = intval( get_post_meta( $post_id, 'downloads', true ) );
    173         $result['last_updated']             = gmdate( 'Y-m-d g:ia \G\M\T', strtotime( $post->post_modified_gmt ) );
     179        $result['last_updated']             = gmdate( 'Y-m-d g:ia \G\M\T', strtotime( $last_updated ) );
    174180        $result['added']                    = gmdate( 'Y-m-d', strtotime( $post->post_date_gmt ) );
    175181        $result['homepage']                 = get_post_meta( $post_id, 'header_plugin_uri', true );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-meta.php

    r13751 r14153  
    6161            <li>
    6262                <?php
    63                 $modified_time = get_post_modified_time();
     63                $last_updated = get_post_meta( $post->ID, 'last_updated', true );
     64                // Fallback to modified timestamp if meta unavailable.
     65                $last_updated = $last_updated ? strtotime( $last_updated ) : get_post_modified_time( 'U', true );
    6466
    6567                // Fallback for approved plugins that are not published yet.
    66                 if ( $modified_time < 0 ) {
    67                     $modified_time = get_post_time();
     68                if ( ! $last_updated || $last_updated < 0 ) {
     69                    $last_updated = get_post_time( 'U', true );
    6870                }
    6971
     
    7274                    __( 'Last updated %s', 'wporg-plugins' ),
    7375                    /* translators: %s: time since the last update */
    74                     '<strong>' . wp_kses( sprintf( __( '%s ago', 'wporg-plugins' ), '<span>' . human_time_diff( $modified_time ) . '</span>' ), array( 'span' => true ) ) . '</strong>'
     76                    '<strong>' . wp_kses( sprintf( __( '%s ago', 'wporg-plugins' ), '<span>' . human_time_diff( $last_updated ) . '</span>' ), array( 'span' => true ) ) . '</strong>'
    7577                );
    7678                ?>
Note: See TracChangeset for help on using the changeset viewer.