Making WordPress.org

Changeset 640


Ignore:
Timestamp:
05/23/2014 06:04:40 AM (11 years ago)
Author:
coffee2code
Message:

Code Reference: In get_current_version(), use the global wp_version instead of a hardcoded version number, unless wp_version isn't a release version. Fixes #484. props keesiemeijer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/template-tags.php

    r639 r640  
    254254     * Prefers the 'wp_parser_imported_wp_version' option value set by more
    255255     * recent versions of the parser. Failing that, it checks the
    256      * WP_CORE_LATEST_RELEASE constant (set on wp.org) though this is not
    257      * guaranteed to be the latest parsed version. Failing that, it uses a
    258      * hardcoded value, which isn't guaranteed either.
     256     * WP_CORE_LATEST_RELEASE constant (set on WP.org) though this is not
     257     * guaranteed to be the latest parsed version. Failing that, it uses
     258     * the WP version of the site, unless it isn't a release version, in
     259     * which case a hardcoded value is assumed.
    259260     *
    260261     * @return string
    261262     */
    262263    function get_current_version() {
     264        global $wp_version;
     265
     266        // Preference for the value saved as an option.
    263267        $current_version = get_option( 'wp_parser_imported_wp_version' );
    264268
     269        // Otherwise, assume the value stored in a constant (which is set on WP.org), if defined.
     270        if ( empty( $current_version ) && defined( 'WP_CORE_LATEST_RELEASE' ) && WP_CORE_LATEST_RELEASE ) {
     271            $current_version = WP_CORE_LATEST_RELEASE;
     272        }
     273
     274        // Otherwise, use the version of the running WP instance.
    265275        if ( empty( $current_version ) ) {
    266             $current_version = defined( 'WP_CORE_LATEST_RELEASE' ) ? WP_CORE_LATEST_RELEASE : '3.9.1';
     276            $current_version = $wp_version;
     277
     278            // However, if the running WP instance appears to not be a release
     279            // version, assume a hardcoded version that is at least valid.
     280            if ( false !== strpos( $current_version, '-' ) ) {
     281                $current_version = '3.9.1';
     282            }
    267283        }
    268284
Note: See TracChangeset for help on using the changeset viewer.