wp_get_theme() WP 1.0
Gets a WP_Theme object for a theme.
Works based on: WP_Theme()
1 time = 0.00056s = slow | 50000 times = 2.02s = fast | PHP 7.0.5, WP 4.5.2
No Hooks.
Return
WP_Theme. Theme object. Be sure to check the object's exists() method if you need to confirm the theme's existence.
Usage
wp_get_theme( $stylesheet, $theme_root );
- $stylesheet(string)
- Directory name for the theme.
Default: current theme - $theme_root(string)
- Absolute path of the theme root to look in. If not specified, get_raw_theme_root() is used to calculate the theme root for the $stylesheet provided (or current theme).
Default: ''
Notes
- Global. Array. $wp_theme_directories
Changelog
Since 3.4.0 | Introduced. |
Code of wp_get_theme() wp get theme WP 5.6
function wp_get_theme( $stylesheet = '', $theme_root = '' ) {
global $wp_theme_directories;
if ( empty( $stylesheet ) ) {
$stylesheet = get_stylesheet();
}
if ( empty( $theme_root ) ) {
$theme_root = get_raw_theme_root( $stylesheet );
if ( false === $theme_root ) {
$theme_root = WP_CONTENT_DIR . '/themes';
} elseif ( ! in_array( $theme_root, (array) $wp_theme_directories, true ) ) {
$theme_root = WP_CONTENT_DIR . $theme_root;
}
}
return new WP_Theme( $stylesheet, $theme_root );
}Related Functions
From category: Other Theme Functions
- add_theme_support()
- bloginfo()
- body_class()
- current_theme_supports()
- get_custom_header_markup()
- get_custom_logo()
- get_header_image()
- get_header_image_tag()
- get_header_textcolor()
- get_header_video_url()
- get_page_templates()
- get_post_class()
- get_query_template()
- get_stylesheet()
- get_template()
- get_theme_mod()
- get_theme_mods()
- get_theme_root()
- has_custom_logo()
- has_header_image()
- has_header_video()
- is_child_theme()
- is_header_video_active()
- is_multi_author()
- post_class()
- register_nav_menu()
- register_nav_menus()
- register_theme_directory()
- remove_theme_mod()
- remove_theme_mods()
- remove_theme_support()
- search_theme_directories()
- set_theme_mod()
- single_month_title()