WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/05/2012 01:05:49 AM (8 years ago)
Author:
nacin
Message:

Always return a WP_Theme object from wp_get_theme(). Check \$theme->exists() or \$theme->errors() to confirm the requested theme actually exists. see #20361.

File:
1 edited

Legend:

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

    r20330 r20363  
    8888 * @param string $theme_root Absolute path of the theme root to look in. Optional. If not specified, get_raw_theme_root()
    8989 *  is used to calculate the theme root for the $stylesheet provided (or current theme).
    90  * @return WP_Theme|bool WP_Theme object. False if the theme is not found.
     90 * @return WP_Theme Theme object. Be sure to check the object's exists() method if you need to confirm the theme's existence.
    9191 */
    9292function wp_get_theme( $stylesheet = null, $theme_root = null ) {
     
    105105    }
    106106
    107     $theme = new WP_Theme( $stylesheet, $theme_root );
    108     if ( $theme->exists() )
    109         return $theme;
    110 
    111     return false;
     107    return new WP_Theme( $stylesheet, $theme_root );
    112108}
    113109
     
    15571553        $old_theme = wp_get_theme( $stylesheet );
    15581554
    1559         // If we can't find the old theme then fallback to passing the raw data to the action like we did pre-3.4
    1560         if ( $old_theme )
     1555        if ( $old_theme->exists() )
    15611556            do_action( 'after_switch_theme', $old_theme->get('Name'), $old_theme );
    15621557        else
Note: See TracChangeset for help on using the changeset viewer.