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. Built from https://develop.svn.wordpress.org/trunk@42734 git-svn-id: http://core.svn.wordpress.org/trunk@42564 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b12620e798
commit
b6229650e0
|
@ -1559,6 +1559,9 @@ final class WP_Theme implements ArrayAccess {
|
||||||
if ( 0 === strpos( get_user_locale(), 'en_' ) ) {
|
if ( 0 === strpos( get_user_locale(), 'en_' ) ) {
|
||||||
uasort( $themes, array( 'WP_Theme', '_name_sort' ) );
|
uasort( $themes, array( 'WP_Theme', '_name_sort' ) );
|
||||||
} else {
|
} else {
|
||||||
|
foreach ( $themes as $key => $theme ) {
|
||||||
|
$theme->translate_header( 'Name', $theme->headers['Name'] );
|
||||||
|
}
|
||||||
uasort( $themes, array( 'WP_Theme', '_name_sort_i18n' ) );
|
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
|
* @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().
|
* Greater than 0 if `$a` falls higher in the natural order than `$b`. Used with usort().
|
||||||
*/
|
*/
|
||||||
private static function _name_sort_i18n( $a, $b ) {
|
private static function _name_sort_i18n( $a, $b ) {
|
||||||
// Don't mark up; Do translate.
|
return strnatcasecmp( $a->name_translated, $b->name_translated );
|
||||||
return strnatcasecmp( $a->display( 'Name', false, true ), $b->display( 'Name', false, true ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.0-alpha-42733';
|
$wp_version = '5.0-alpha-42734';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue