[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> class-wp-theme.php (summary)

WP_Theme Class

File Size: 1658 lines (50 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 43 functions

  __construct()
  __toString()
  __isset()
  __get()
  offsetSet()
  offsetUnset()
  offsetExists()
  offsetGet()
  errors()
  exists()
  parent()
  cache_add()
  cache_get()
  cache_delete()
  get()
  display()
  sanitize_header()
  markup_header()
  translate_header()
  get_stylesheet()
  get_template()
  get_stylesheet_directory()
  get_template_directory()
  get_stylesheet_directory_uri()
  get_template_directory_uri()
  get_theme_root()
  get_theme_root_uri()
  get_screenshot()
  get_files()
  get_post_templates()
  get_page_templates()
  scandir()
  load_textdomain()
  is_allowed()
  get_core_default_theme()
  get_allowed()
  get_allowed_on_network()
  get_allowed_on_site()
  network_enable_theme()
  network_disable_theme()
  sort_by_name()
  _name_sort()
  _name_sort_i18n()

Functions
Functions that are not part of a class:

__construct( $theme_dir, $theme_root, $_child = null )   X-Ref
Constructor for WP_Theme.

since: 3.4.0
param: string $theme_dir Directory of the theme within the theme_root.
param: string $theme_root Theme root.
param: WP_Error|void $_child If this theme is a parent theme, the child may be passed for validation purposes.

__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.
since: 3.4.0
param: string $offset Property to check if set.

__get( $offset )   X-Ref
__get() magic method for properties formerly returned by current_theme_info()

return: mixed Property value.
since: 3.4.0
param: string $offset Property to get.

offsetSet( $offset, $value )   X-Ref
Method to implement ArrayAccess for keys formerly returned by get_themes()

since: 3.4.0
param: mixed $offset
param: mixed $value

offsetUnset( $offset )   X-Ref
Method to implement ArrayAccess for keys formerly returned by get_themes()

since: 3.4.0
param: mixed $offset

offsetExists( $offset )   X-Ref
Method to implement ArrayAccess for keys formerly returned by get_themes()

return: bool
since: 3.4.0
param: mixed $offset

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
since: 3.4.0
param: mixed $offset

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
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 current 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()
since: 3.4.0
param: string $key Type of data to store (theme, screenshot, headers, post_templates)
param: string $data Data to store

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
since: 3.4.0
param: string $key Type of data to retrieve (theme, screenshot, headers, post_templates)

cache_delete()   X-Ref
Clears the cache for the theme.

since: 3.4.0

get( $header )   X-Ref
Get 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|false String on success, false on failure.
since: 3.4.0
param: string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.

display( $header, $markup = true, $translate = true )   X-Ref
Gets a theme header, formatted and translated for display.

return: string|false Processed header, false on failure.
since: 3.4.0
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.

sanitize_header( $header, $value )   X-Ref
Sanitize a theme header.

return: mixed
since: 3.4.0
param: string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
param: string $value Value to sanitize.

markup_header( $header, $value, $translate )   X-Ref
Mark up a theme header.

return: string Value, marked up.
since: 3.4.0
param: string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
param: string $value Value to mark up.
param: string $translate Whether the header has been translated.

translate_header( $header, $value )   X-Ref
Translate a theme header.

return: string Translated value.
since: 3.4.0
param: string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
param: string $value Value to translate.

get_stylesheet()   X-Ref
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
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
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.
since: 3.4.0
param: string $uri Type of URL to return, either 'relative' or an absolute URI. Defaults to absolute URI.

get_files( $type = null, $depth = 0, $search_parent = false )   X-Ref
Return files in the theme's directory.

return: array Array of files, keyed by the path to the file relative to the theme's directory, with the values
since: 3.4.0
param: mixed $type Optional. Array of extensions to return. Defaults to all files (null).
param: int $depth Optional. How deep to search for files. Defaults to a flat scan (0 depth). -1 depth is infinite.
param: bool $search_parent Optional. Whether to return parent files. Defaults to false.

get_post_templates()   X-Ref
Returns the theme's post templates.

return: array Array of page templates, keyed by filename and post type,
since: 4.7.0

get_page_templates( $post = null, $post_type = 'page' )   X-Ref
Returns the theme's post templates for a given post type.

return: array Array of page templates, keyed by filename, with the value of the translated header name.
since: 3.4.0
since: 4.7.0 Added the `$post_type` parameter.
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'.

scandir( $path, $extensions = null, $depth = 0, $relative_path = '' )   X-Ref
Scans a directory for files of a certain extension.

return: array|false Array of files, keyed by the path to the file relative to the `$path` directory prepended
since: 3.4.0
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

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
Whether the theme is allowed (multisite only).

return: bool Whether the theme is allowed for the network. Returns true in single-site.
since: 3.4.0
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.

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.
since: 3.4.0
param: int $blog_id Optional. ID of the site. Defaults to the current site.

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.
since: 3.4.0
param: int $blog_id Optional. ID of the site. Defaults to the current site.

network_enable_theme( $stylesheets )   X-Ref
Enables a theme for all sites on the current network.

since: 4.6.0
param: string|string[] $stylesheets Stylesheet name or array of stylesheet names.

network_disable_theme( $stylesheets )   X-Ref
Disables a theme for all sites on the current network.

since: 4.6.0
param: string|string[] $stylesheets Stylesheet name or array of stylesheet names.

sort_by_name( &$themes )   X-Ref
Sorts themes by name.

since: 3.4.0
param: WP_Theme[] $themes Array of theme objects to sort (passed by reference).

_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.
since: 3.4.0
param: string $a First name.
param: string $b Second name.

_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.
since: 3.4.0
param: string $a First name.
param: string $b Second name.



Generated: Sun Sep 15 01:00:03 2019 Cross-referenced by PHPXref 0.7.1