Themes: Reduce usage of wp_get_theme function.

Calling the `wp_get_theme` function creates a instance of the `WP_Theme` class. This can be a performance issue, if all you need is one property of the class instance. This change replaces the usage of `wp_get_theme()->get_stylesheet()` with `get_stylesheet()` to improve performance.

Props spacedmonkey, flixos90, peterwilsoncc, desrosj.
Fixes #57057.
Built from https://develop.svn.wordpress.org/trunk@54817


git-svn-id: http://core.svn.wordpress.org/trunk@54369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
spacedmonkey
2022-11-11 16:26:12 +00:00
parent 4e492ffe61
commit 8ea348f6db
9 changed files with 20 additions and 19 deletions

View File

@@ -27,7 +27,7 @@ function wp_set_unique_slug_on_create_template_part( $post_id ) {
$terms = get_the_terms( $post_id, 'wp_theme' );
if ( ! is_array( $terms ) || ! count( $terms ) ) {
wp_set_post_terms( $post_id, wp_get_theme()->get_stylesheet(), 'wp_theme' );
wp_set_post_terms( $post_id, get_stylesheet(), 'wp_theme' );
}
}
@@ -60,7 +60,7 @@ function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_ID
* in the case of new entities since is too early in the process to have been saved
* to the entity. So for now we use the currently activated theme for creation.
*/
$theme = wp_get_theme()->get_stylesheet();
$theme = get_stylesheet();
$terms = get_the_terms( $post_ID, 'wp_theme' );
if ( $terms && ! is_wp_error( $terms ) ) {
$theme = $terms[0]->name;