Make WordPress Core


Ignore:
Timestamp:
02/25/2018 01:17:12 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Themes: Pre-translate theme names on Themes screen before sorting the array, to improve performance and avoid a warning in PHP 5.x.

Props bobbingwide, sebastian.pisula.
Fixes #34565.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme.php

    r42343 r42734  
    15601560            uasort( $themes, array( 'WP_Theme', '_name_sort' ) );
    15611561        } else {
     1562            foreach ( $themes as $key => $theme ) {
     1563                $theme->translate_header( 'Name', $theme->headers['Name'] );
     1564            }
    15621565            uasort( $themes, array( 'WP_Theme', '_name_sort_i18n' ) );
    15631566        }
     
    15841587
    15851588    /**
    1586      * Name sort (with translation).
     1589     * Callback function for usort() to naturally sort themes by translated name.
    15871590     *
    15881591     * @since 3.4.0
     
    15961599     */
    15971600    private static function _name_sort_i18n( $a, $b ) {
    1598         // Don't mark up; Do translate.
    1599         return strnatcasecmp( $a->display( 'Name', false, true ), $b->display( 'Name', false, true ) );
     1601        return strnatcasecmp( $a->name_translated, $b->name_translated );
    16001602    }
    16011603}
Note: See TracChangeset for help on using the changeset viewer.