[ Index ] |
PHP Cross Reference of WordPress |
[Source view] [Print] [Project Stats]
WP_Theme Class
File Size: | 1772 lines (54 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
__construct( $theme_dir, $theme_root, $_child = null ) X-Ref |
Constructor for WP_Theme. param: string $theme_dir Directory of the theme within the theme_root. param: string $theme_root Theme root. param: WP_Theme|null $_child If this theme is a parent theme, the child may be passed for validation purposes. since: 3.4.0 |
__toString() X-Ref |
When converting the object to a string, the theme name is returned. return: string Theme name, ready for display (translated) since: 3.4.0 |
__isset( $offset ) X-Ref |
__isset() magic method for properties formerly returned by current_theme_info() return: bool Whether the given property is set. param: string $offset Property to check if set. since: 3.4.0 |
__get( $offset ) X-Ref |
__get() magic method for properties formerly returned by current_theme_info() return: mixed Property value. param: string $offset Property to get. since: 3.4.0 |
offsetSet( $offset, $value ) X-Ref |
Method to implement ArrayAccess for keys formerly returned by get_themes() param: mixed $offset param: mixed $value since: 3.4.0 |
offsetUnset( $offset ) X-Ref |
Method to implement ArrayAccess for keys formerly returned by get_themes() param: mixed $offset since: 3.4.0 |
offsetExists( $offset ) X-Ref |
Method to implement ArrayAccess for keys formerly returned by get_themes() return: bool param: mixed $offset since: 3.4.0 |
offsetGet( $offset ) X-Ref |
Method to implement ArrayAccess for keys formerly returned by get_themes(). Author, Author Name, Author URI, and Description did not previously return translated data. We are doing so now as it is safe to do. However, as Name and Title could have been used as the key for get_themes(), both remain untranslated for back compatibility. This means that ['Name'] is not ideal, and care should be taken to use `$theme::display( 'Name' )` to get a properly translated header. return: mixed param: mixed $offset since: 3.4.0 |
errors() X-Ref |
Returns errors property. return: WP_Error|false WP_Error if there are errors, or false. since: 3.4.0 |
exists() X-Ref |
Determines whether the theme exists. A theme with errors exists. A theme with the error of 'theme_not_found', meaning that the theme's directory was not found, does not exist. return: bool Whether the theme exists. since: 3.4.0 |
parent() X-Ref |
Returns reference to the parent theme. return: WP_Theme|false Parent theme, or false if the active theme is not a child theme. since: 3.4.0 |
cache_add( $key, $data ) X-Ref |
Adds theme data to cache. Cache entries keyed by the theme and the type of data. return: bool Return value from wp_cache_add() param: string $key Type of data to store (theme, screenshot, headers, post_templates) param: array|string $data Data to store since: 3.4.0 |
cache_get( $key ) X-Ref |
Gets theme data from cache. Cache entries are keyed by the theme and the type of data. return: mixed Retrieved data param: string $key Type of data to retrieve (theme, screenshot, headers, post_templates) since: 3.4.0 |
cache_delete() X-Ref |
Clears the cache for the theme. since: 3.4.0 |
get( $header ) X-Ref |
Gets a raw, unformatted theme header. The header is sanitized, but is not translated, and is not marked up for display. To get a theme header for display, use the display() method. Use the get_template() method, not the 'Template' header, for finding the template. The 'Template' header is only good for what was written in the style.css, while get_template() takes into account where WordPress actually located the theme and whether it is actually valid. return: string|array|false String or array (for Tags header) on success, false on failure. param: string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. since: 3.4.0 |
display( $header, $markup = true, $translate = true ) X-Ref |
Gets a theme header, formatted and translated for display. return: string|array|false Processed header. An array for Tags if `$markup` is false, string otherwise. param: string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. param: bool $markup Optional. Whether to mark up the header. Defaults to true. param: bool $translate Optional. Whether to translate the header. Defaults to true. since: 3.4.0 |
sanitize_header( $header, $value ) X-Ref |
Sanitizes a theme header. return: string|array An array for Tags header, string otherwise. param: string $header Theme header. Accepts 'Name', 'Description', 'Author', 'Version', param: string $value Value to sanitize. since: 3.4.0 since: 5.4.0 Added support for `Requires at least` and `Requires PHP` headers. |
markup_header( $header, $value, $translate ) X-Ref |
Marks up a theme header. return: string Value, marked up. param: string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. param: string|array $value Value to mark up. An array for Tags header, string otherwise. param: string $translate Whether the header has been translated. since: 3.4.0 |
translate_header( $header, $value ) X-Ref |
Translates a theme header. return: string|array Translated value. An array for Tags header, string otherwise. param: string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags. param: string|array $value Value to translate. An array for Tags header, string otherwise. since: 3.4.0 |
get_stylesheet() X-Ref |
Returns the directory name of the theme's "stylesheet" files, inside the theme root. In the case of a child theme, this is directory name of the child theme. Otherwise, get_stylesheet() is the same as get_template(). return: string Stylesheet since: 3.4.0 |
get_template() X-Ref |
Returns the directory name of the theme's "template" files, inside the theme root. In the case of a child theme, this is the directory name of the parent theme. Otherwise, the get_template() is the same as get_stylesheet(). return: string Template since: 3.4.0 |
get_stylesheet_directory() X-Ref |
Returns the absolute path to the directory of a theme's "stylesheet" files. In the case of a child theme, this is the absolute path to the directory of the child theme's files. return: string Absolute path of the stylesheet directory. since: 3.4.0 |
get_template_directory() X-Ref |
Returns the absolute path to the directory of a theme's "template" files. In the case of a child theme, this is the absolute path to the directory of the parent theme's files. return: string Absolute path of the template directory. since: 3.4.0 |
get_stylesheet_directory_uri() X-Ref |
Returns the URL to the directory of a theme's "stylesheet" files. In the case of a child theme, this is the URL to the directory of the child theme's files. return: string URL to the stylesheet directory. since: 3.4.0 |
get_template_directory_uri() X-Ref |
Returns the URL to the directory of a theme's "template" files. In the case of a child theme, this is the URL to the directory of the parent theme's files. return: string URL to the template directory. since: 3.4.0 |
get_theme_root() X-Ref |
Returns the absolute path to the directory of the theme root. This is typically the absolute path to wp-content/themes. return: string Theme root. since: 3.4.0 |
get_theme_root_uri() X-Ref |
Returns the URL to the directory of the theme root. This is typically the absolute URL to wp-content/themes. This forms the basis for all other URLs returned by WP_Theme, so we pass it to the public function get_theme_root_uri() and allow it to run the {@see 'theme_root_uri'} filter. return: string Theme root URI. since: 3.4.0 |
get_screenshot( $uri = 'uri' ) X-Ref |
Returns the main screenshot file for the theme. The main screenshot is called screenshot.png. gif and jpg extensions are also allowed. Screenshots for a theme must be in the stylesheet directory. (In the case of child themes, parent theme screenshots are not inherited.) return: string|false Screenshot file. False if the theme does not have a screenshot. param: string $uri Type of URL to return, either 'relative' or an absolute URI. Defaults to absolute URI. since: 3.4.0 |
get_files( $type = null, $depth = 0, $search_parent = false ) X-Ref |
Returns files in the theme's directory. return: string[] Array of files, keyed by the path to the file relative to the theme's directory, with the values param: string[]|string $type Optional. Array of extensions to find, string of a single extension, param: int $depth Optional. How deep to search for files. Defaults to a flat scan (0 depth). param: bool $search_parent Optional. Whether to return parent files. Default false. since: 3.4.0 |
get_post_templates() X-Ref |
Returns the theme's post templates. return: array[] Array of page template arrays, keyed by post type and filename, since: 4.7.0 since: 5.8.0 Include block templates. |
get_page_templates( $post = null, $post_type = 'page' ) X-Ref |
Returns the theme's post templates for a given post type. return: string[] Array of template header names keyed by the template file name. param: WP_Post|null $post Optional. The post being edited, provided for context. param: string $post_type Optional. Post type to get the templates for. Default 'page'. since: 3.4.0 since: 4.7.0 Added the `$post_type` parameter. |
scandir( $path, $extensions = null, $depth = 0, $relative_path = '' ) X-Ref |
Scans a directory for files of a certain extension. return: string[]|false Array of files, keyed by the path to the file relative to the `$path` directory prepended param: string $path Absolute path to search. param: array|string|null $extensions Optional. Array of extensions to find, string of a single extension, param: int $depth Optional. How many levels deep to search for files. Accepts 0, 1+, or param: string $relative_path Optional. The basename of the absolute path. Used to control the since: 3.4.0 |
load_textdomain() X-Ref |
Loads the theme's textdomain. Translation files are not inherited from the parent theme. TODO: If this fails for the child theme, it should probably try to load the parent theme's translations. return: bool True if the textdomain was successfully loaded or has already been loaded. since: 3.4.0 |
is_allowed( $check = 'both', $blog_id = null ) X-Ref |
Determines whether the theme is allowed (multisite only). return: bool Whether the theme is allowed for the network. Returns true in single-site. param: string $check Optional. Whether to check only the 'network'-wide settings, the 'site' param: int $blog_id Optional. Ignored if only network-wide settings are checked. Defaults to current site. since: 3.4.0 |
is_block_theme() X-Ref |
Returns whether this theme is a block-based theme or not. return: bool since: 5.9.0 |
get_file_path( $file = '' ) X-Ref |
Retrieves the path of a file in the theme. Searches in the stylesheet directory before the template directory so themes which inherit from a parent theme can just override one file. return: string The path of the file. param: string $file Optional. File to search for in the stylesheet directory. since: 5.9.0 |
get_core_default_theme() X-Ref |
Determines the latest WordPress default theme that is installed. This hits the filesystem. return: WP_Theme|false Object, or false if no theme is installed, which would be bad. since: 4.4.0 |
get_allowed( $blog_id = null ) X-Ref |
Returns array of stylesheet names of themes allowed on the site or network. return: string[] Array of stylesheet names. param: int $blog_id Optional. ID of the site. Defaults to the current site. since: 3.4.0 |
get_allowed_on_network() X-Ref |
Returns array of stylesheet names of themes allowed on the network. return: string[] Array of stylesheet names. since: 3.4.0 |
get_allowed_on_site( $blog_id = null ) X-Ref |
Returns array of stylesheet names of themes allowed on the site. return: string[] Array of stylesheet names. param: int $blog_id Optional. ID of the site. Defaults to the current site. since: 3.4.0 |
network_enable_theme( $stylesheets ) X-Ref |
Enables a theme for all sites on the current network. param: string|string[] $stylesheets Stylesheet name or array of stylesheet names. since: 4.6.0 |
network_disable_theme( $stylesheets ) X-Ref |
Disables a theme for all sites on the current network. param: string|string[] $stylesheets Stylesheet name or array of stylesheet names. since: 4.6.0 |
sort_by_name( &$themes ) X-Ref |
Sorts themes by name. param: WP_Theme[] $themes Array of theme objects to sort (passed by reference). since: 3.4.0 |
_name_sort( $a, $b ) X-Ref |
Callback function for usort() to naturally sort themes by name. Accesses the Name header directly from the class for maximum speed. Would choke on HTML but we don't care enough to slow it down with strip_tags(). return: int Negative if `$a` falls lower in the natural order than `$b`. Zero if they fall equally. param: WP_Theme $a First theme. param: WP_Theme $b Second theme. since: 3.4.0 |
_name_sort_i18n( $a, $b ) X-Ref |
Callback function for usort() to naturally sort themes by translated name. return: int Negative if `$a` falls lower in the natural order than `$b`. Zero if they fall equally. param: WP_Theme $a First theme. param: WP_Theme $b Second theme. since: 3.4.0 |
Generated: Thu Nov 21 01:00:03 2024 | Cross-referenced by PHPXref 0.7.1 |