Make WordPress Core


Ignore:
Timestamp:
11/11/2022 04:24:47 PM (17 months ago)
Author:
spacedmonkey
Message:

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.

File:
1 edited

Legend:

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

    r53331 r54817  
    2828    $terms = get_the_terms( $post_id, 'wp_theme' );
    2929    if ( ! is_array( $terms ) || ! count( $terms ) ) {
    30         wp_set_post_terms( $post_id, wp_get_theme()->get_stylesheet(), 'wp_theme' );
     30        wp_set_post_terms( $post_id, get_stylesheet(), 'wp_theme' );
    3131    }
    3232}
     
    6161     * to the entity. So for now we use the currently activated theme for creation.
    6262     */
    63     $theme = wp_get_theme()->get_stylesheet();
     63    $theme = get_stylesheet();
    6464    $terms = get_the_terms( $post_ID, 'wp_theme' );
    6565    if ( $terms && ! is_wp_error( $terms ) ) {
Note: See TracChangeset for help on using the changeset viewer.