Make WordPress Core

Ticket #33628: wp_theme_mods_cache.patch

File wp_theme_mods_cache.patch, 1.5 KB (added by spacedmonkey, 11 years ago)
  • wp-includes/theme.php

    diff --git a/wp-includes/theme.php b/wp-includes/theme.php
    index 07b0f6a..01f9def 100644
    a b function validate_current_theme() {  
    796796 * Retrieve all theme modifications.
    797797 *
    798798 * @since 3.1.0
     799 * @staticvar array $_wp_theme_mods
    799800 *
    800801 * @return array|void Theme modifications.
    801802 */
    802803function get_theme_mods() {
    803         $theme_slug = get_option( 'stylesheet' );
    804         $mods = get_option( "theme_mods_$theme_slug" );
    805         if ( false === $mods ) {
    806                 $theme_name = get_option( 'current_theme' );
    807                 if ( false === $theme_name )
    808                         $theme_name = wp_get_theme()->get('Name');
    809                 $mods = get_option( "mods_$theme_name" ); // Deprecated location.
    810                 if ( is_admin() && false !== $mods ) {
    811                         update_option( "theme_mods_$theme_slug", $mods );
    812                         delete_option( "mods_$theme_name" );
     804        static $_wp_theme_mods = false;
     805
     806        if ( empty( $_wp_theme_mods ) ) {
     807                $theme_slug     = get_option( 'stylesheet' );
     808                $_wp_theme_mods = get_option( "theme_mods_$theme_slug" );
     809                if ( false === $_wp_theme_mods ) {
     810                        $theme_name = get_option( 'current_theme' );
     811                        if ( false === $theme_name ) {
     812                                $theme_name = wp_get_theme()->get( 'Name' );
     813                        }
     814                        $_wp_theme_mods = get_option( "mods_$theme_name" ); // Deprecated location.
     815                        if ( is_admin() && false !== $_wp_theme_mods ) {
     816                                update_option( "theme_mods_$theme_slug", $_wp_theme_mods );
     817                                delete_option( "mods_$theme_name" );
     818                        }
    813819                }
    814820        }
    815         return $mods;
     821        return $_wp_theme_mods;
    816822}
    817823
    818824/**