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. git-svn-id: https://develop.svn.wordpress.org/trunk@42734 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6586a5c467
commit
e0b18a023c
@ -1559,6 +1559,9 @@ final class WP_Theme implements ArrayAccess {
|
||||
if ( 0 === strpos( get_user_locale(), 'en_' ) ) {
|
||||
uasort( $themes, array( 'WP_Theme', '_name_sort' ) );
|
||||
} else {
|
||||
foreach ( $themes as $key => $theme ) {
|
||||
$theme->translate_header( 'Name', $theme->headers['Name'] );
|
||||
}
|
||||
uasort( $themes, array( 'WP_Theme', '_name_sort_i18n' ) );
|
||||
}
|
||||
}
|
||||
@ -1583,7 +1586,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
}
|
||||
|
||||
/**
|
||||
* Name sort (with translation).
|
||||
* Callback function for usort() to naturally sort themes by translated name.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*
|
||||
@ -1595,7 +1598,6 @@ final class WP_Theme implements ArrayAccess {
|
||||
* Greater than 0 if `$a` falls higher in the natural order than `$b`. Used with usort().
|
||||
*/
|
||||
private static function _name_sort_i18n( $a, $b ) {
|
||||
// Don't mark up; Do translate.
|
||||
return strnatcasecmp( $a->display( 'Name', false, true ), $b->display( 'Name', false, true ) );
|
||||
return strnatcasecmp( $a->name_translated, $b->name_translated );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user