Making WordPress.org


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.

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