wppaste
WordPress

wp_get_theme( string $stylesheet = '', string $theme_root = '' ): WP_Theme

Since
3.4.0
Source
wp-includes/theme.php:117
Gets a WP_Theme object for a theme.

Parameters

$stylesheetstringoptional
Directory name for the theme. Defaults to active theme.Default: ''
$theme_rootstringoptional
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 active theme).Default: ''

Return

WP_Theme
Theme object. Be sure to check the object's exists() method if you need to confirm the theme's existence.

Uses · 3

Used by · 50

Show all 50

Source

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 );}

History

Introduced in 3.4.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/theme.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.