WP_Theme
- Since
- 3.4.0
- Source
wp-includes/class-wp-theme.php:9
WP_Theme Class
Compatibility
- WordPress
- since 3.4.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 10
Every hook that fires from inside WP_Theme, in the order it appears in the class, grouped by the method that fires it.
WP_Theme::get_page_templates()
- apply_filters( theme_templates )filter line 1412
- apply_filters( theme_{$post_type}_templates )filter line 1434
WP_Theme::scandir()
- apply_filters( theme_scandir_exclusions )filter line 1480
WP_Theme::get_file_path()
- apply_filters( theme_file_path )filter line 1626
WP_Theme::get_allowed()
- apply_filters( network_allowed_themes )filter line 1668
WP_Theme::get_allowed_on_site()
- apply_filters( site_allowed_themes )filter line 1721
- apply_filters( site_allowed_themes )filter line 1774
Properties · 20
$updateboolpublic- Whether the theme has been marked as updateable.
$file_headersstring[]private static- Headers for style.css files.
$default_themesstring[]private static- Default themes.
$tag_mapstring[]private static- Renamed theme tags.
$theme_rootstringprivate- Absolute path to the theme root, usually wp-content/themes
$headersarrayprivate- Header data from the theme's style.css file.
$headers_sanitizedarrayprivate- Header data from the theme's style.css file after being sanitized.
$block_themeboolprivate- Is this theme a block theme.
$name_translatedstringprivate- Header name from the theme's style.css after being translated.
$errorsWP_Errorprivate- Errors encountered when initializing the theme.
$stylesheetstringprivate- The directory name of the theme's files, inside the theme root.
$templatestringprivate- The directory name of the theme's files, inside the theme root.
$parentWP_Themeprivate- A reference to the parent theme, in the case of a child theme.
$theme_root_uristringprivate- URL to the theme root, usually an absolute URL to wp-content/themes
$textdomain_loadedboolprivate- Flag for whether the theme's textdomain is loaded.
$cache_hashstringprivate- Stores an md5 hash of the theme root, to function as the cache key.
$block_template_foldersstring[]private- Block template folders.
$default_template_foldersstring[]private- Default values for template folders.
$persistently_cacheboolprivate static- Flag for whether the themes cache bucket should be persistently cached.
$cache_expirationboolprivate static- Expiration time for the themes cache bucket.
Methods · 52
- __construct()Constructor for WP_Theme.
- __toString()When converting the object to a string, the theme name is returned.
- __isset()__isset() magic method for properties formerly returned by current_theme_info()
- __get()__get() magic method for properties formerly returned by current_theme_info()
- offsetSet()Method to implement ArrayAccess for keys formerly returned by get_themes()
- offsetUnset()Method to implement ArrayAccess for keys formerly returned by get_themes()
- offsetExists()Method to implement ArrayAccess for keys formerly returned by get_themes()
- offsetGet()Method to implement ArrayAccess for keys formerly returned by get_themes().
- errors()Returns errors property.
- exists()Determines whether the theme exists.
- parent()Returns reference to the parent theme.
- __wakeup()Perform reinitialization tasks.
- cache_add()Adds theme data to cache.
- cache_get()Gets theme data from cache.
- cache_delete()Clears the cache for the theme.
- get()Gets a raw, unformatted theme header.
- display()Gets a theme header, formatted and translated for display.
- sanitize_header()Sanitizes a theme header.
- markup_header()Marks up a theme header.
- translate_header()Translates a theme header.
- get_stylesheet()Returns the directory name of the theme's "stylesheet" files, inside the theme root.
- get_template()Returns the directory name of the theme's "template" files, inside the theme root.
- get_stylesheet_directory()Returns the absolute path to the directory of a theme's "stylesheet" files.
- get_template_directory()Returns the absolute path to the directory of a theme's "template" files.
- get_stylesheet_directory_uri()Returns the URL to the directory of a theme's "stylesheet" files.
- get_template_directory_uri()Returns the URL to the directory of a theme's "template" files.
- get_theme_root()Returns the absolute path to the directory of the theme root.
- get_theme_root_uri()Returns the URL to the directory of the theme root.
- get_screenshot()Returns the main screenshot file for the theme.
- get_files()Returns files in the theme's directory.
- get_post_templates()Returns the theme's post templates.
- get_page_templates()Returns the theme's post templates for a given post type.
- scandir()Scans a directory for files of a certain extension.
- load_textdomain()Loads the theme's textdomain.
- is_allowed()Determines whether the theme is allowed (multisite only).
- is_block_theme()Returns whether this theme is a block-based theme or not.
- get_file_path()Retrieves the path of a file in the theme.
- get_core_default_theme()Determines the latest WordPress default theme that is installed.
- get_allowed()Returns array of stylesheet names of themes allowed on the site or network.
- get_allowed_on_network()Returns array of stylesheet names of themes allowed on the network.
- get_allowed_on_site()Returns array of stylesheet names of themes allowed on the site.
- get_block_template_folders()Returns the folder names of the block template directories.
- get_block_patterns()Gets block pattern data for a specified theme.
- get_pattern_cache()Gets block pattern cache.
- set_pattern_cache()Sets block pattern cache.
- delete_pattern_cache()Clears block pattern cache.
- network_enable_theme()Enables a theme for all sites on the current network.
- network_disable_theme()Disables a theme for all sites on the current network.
- sort_by_name()Sorts themes by name.
- _name_sort()Callback function for usort() to naturally sort themes by name.
- _name_sort_i18n()Callback function for usort() to naturally sort themes by translated name.
- _check_headers_property_has_correct_type()
Source code
#[AllowDynamicProperties]final class WP_Theme implements ArrayAccess { /** * Whether the theme has been marked as updateable. * * @since 4.4.0 * @var bool * * @see WP_MS_Themes_List_Table */ public $update = false; /** * Headers for style.css files. * * @since 3.4.0 * @since 5.4.0 Added `Requires at least` and `Requires PHP` headers. * @since 6.1.0 Added `Update URI` header. * @var string[] */ private static $file_headers = array( 'Name' => 'Theme Name', 'ThemeURI' => 'Theme URI', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'Version' => 'Version', 'Template' => 'Template', 'Status' => 'Status', 'Tags' => 'Tags', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path', 'RequiresWP' => 'Requires at least', 'RequiresPHP' => 'Requires PHP', 'UpdateURI' => 'Update URI', ); /** * Default themes. * * @since 3.4.0 * @since 3.5.0 Added the Twenty Twelve theme. * @since 3.6.0 Added the Twenty Thirteen theme. * @since 3.8.0 Added the Twenty Fourteen theme. * @since 4.1.0 Added the Twenty Fifteen theme. * @since 4.4.0 Added the Twenty Sixteen theme. * @since 4.7.0 Added the Twenty Seventeen theme. * @since 5.0.0 Added the Twenty Nineteen theme. * @since 5.3.0 Added the Twenty Twenty theme. * @since 5.6.0 Added the Twenty Twenty-One theme. * @since 5.9.0 Added the Twenty Twenty-Two theme. * @since 6.1.0 Added the Twenty Twenty-Three theme. * @since 6.4.0 Added the Twenty Twenty-Four theme. * @since 6.7.0 Added the Twenty Twenty-Five theme. * @var string[] */ private static $default_themes = array( 'classic' => 'WordPress Classic', 'default' => 'WordPress Default', 'twentyten' => 'Twenty Ten', 'twentyeleven' => 'Twenty Eleven', 'twentytwelve' => 'Twenty Twelve', 'twentythirteen' => 'Twenty Thirteen', 'twentyfourteen' => 'Twenty Fourteen', 'twentyfifteen' => 'Twenty Fifteen', 'twentysixteen' => 'Twenty Sixteen', 'twentyseventeen' => 'Twenty Seventeen', 'twentynineteen' => 'Twenty Nineteen', 'twentytwenty' => 'Twenty Twenty', 'twentytwentyone' => 'Twenty Twenty-One', 'twentytwentytwo' => 'Twenty Twenty-Two', 'twentytwentythree' => 'Twenty Twenty-Three', 'twentytwentyfour' => 'Twenty Twenty-Four', 'twentytwentyfive' => 'Twenty Twenty-Five', ); /** * Renamed theme tags. *Changelog
Introduced in 3.4.0. One change between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
7.0.4
Method
_check_headers_property_has_correct_type() removed.verified against source3.4.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/class-wp-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.