Making WordPress.org

Changeset 6474


Ignore:
Timestamp:
01/30/2018 08:08:35 PM (7 years ago)
Author:
obenland
Message:

Plugins: Show updated banner based on WP versions

Props SergeyBiryukov.
Fixes #3010.

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

Legend:

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

    r6471 r6474  
    312312
    313313/**
     314 * Get current major WP version to check against "Tested up to" value.
     315 *
     316 * @global string $wp_version WordPress version.
     317 *
     318 * @return float Current major WP version.
     319 */
     320function get_current_major_wp_version() {
     321    $current_version = '';
     322
     323    // Assume the value stored in a constant (which is set on WP.org), if defined.
     324    if ( defined( 'WP_CORE_LATEST_RELEASE' ) && WP_CORE_LATEST_RELEASE ) {
     325        $current_version = substr( WP_CORE_LATEST_RELEASE, 0, 3 );
     326    }
     327
     328    // Otherwise, use the version of the running WP instance.
     329    if ( empty( $current_version ) ) {
     330        global $wp_version;
     331
     332        $current_version = substr( $wp_version, 0, 3 );
     333
     334        // However, if the running WP instance appears to not be a release version, assume the latest stable version.
     335        if ( false !== strpos( $wp_version, '-' ) ) {
     336            $current_version = (float) $current_version - 0.1;
     337        }
     338    }
     339
     340    return (float) $current_version;
     341}
     342
     343/**
    314344 * Custom template tags for this theme.
    315345 */
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/inc/template-tags.php

    r6343 r6474  
    178178    switch ( $post_status ) {
    179179        case 'publish':
    180             if ( time() - get_post_modified_time() > 2 * YEAR_IN_SECONDS ) {
     180            $tested_up_to             = (string) get_post_meta( get_post( $post )->ID, 'tested', true );
     181            $version_to_check_against = (string) ( get_current_major_wp_version() - 0.2 );
     182            if ( version_compare( $version_to_check_against, $tested_up_to, '>' ) ) {
    181183                $message = sprintf(
    182184                    $warning_notice,
    183                     __( 'This plugin <strong>hasn&#146;t been updated in over 2 years</strong>. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.', 'wporg-plugins' )
     185                    __( 'This plugin <strong>hasn&#146;t been tested with the latest 3 major releases of WordPress</strong>. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.', 'wporg-plugins' )
    184186                );
    185187            }
Note: See TracChangeset for help on using the changeset viewer.