[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

WP_Theme Class

File Size: 1657 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.

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.

since: 3.4.0
return: string Theme name, ready for display (translated)

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

param: string $offset Property to check if set.
since: 3.4.0
return: bool Whether the given property is set.

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

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

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()

param: mixed $offset
since: 3.4.0
return: bool

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.

param: mixed $offset
since: 3.4.0
return: mixed

errors()   X-Ref
Returns errors property.

since: 3.4.0
return: WP_Error|false WP_Error if there are errors, or false.

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.

since: 3.4.0
return: bool Whether the theme exists.

parent()   X-Ref
Returns reference to the parent theme.

since: 3.4.0
return: WP_Theme|false Parent theme, or false if the current theme is not a child theme.

cache_add( $key, $data )   X-Ref
Adds theme data to cache.

Cache entries keyed by the theme and the type of data.

param: string $key Type of data to store (theme, screenshot, headers, post_templates)
param: array|string $data Data to store
since: 3.4.0
return: bool Return value from wp_cache_add()

cache_get( $key )   X-Ref
Gets theme data from cache.

Cache entries are keyed by the theme and the type of data.

param: string $key Type of data to retrieve (theme, screenshot, headers, post_templates)
since: 3.4.0
return: mixed Retrieved data

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.

param: string $header Theme header. Name, Description, Author, Version, ThemeURI, AuthorURI, Status, Tags.
since: 3.4.0
return: string|false String on success, false on failure.

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

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

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

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

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

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.
since: 3.4.0
return: string Value, marked up.

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

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

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().

since: 3.4.0
return: string Stylesheet

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().

since: 3.4.0
return: string Template

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.

since: 3.4.0
return: string Absolute path of the stylesheet directory.

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.

since: 3.4.0
return: string Absolute path of the template directory.

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.

since: 3.4.0
return: string URL to the stylesheet directory.

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.

since: 3.4.0
return: string URL to the template directory.

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.

since: 3.4.0
return: string Theme root.

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.

since: 3.4.0
return: string Theme root URI.

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.)

param: string $uri Type of URL to return, either 'relative' or an absolute URI. Defaults to absolute URI.
since: 3.4.0
return: string|false Screenshot file. False if the theme does not have a screenshot.

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

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.
since: 3.4.0
return: string[] Array of files, keyed by the path to the file relative to the theme's directory, with the values

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

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

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

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.
return: string[] Array of template header names keyed by the template file name.

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

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

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.

since: 3.4.0
return: bool True if the textdomain was successfully loaded or has already been loaded.

is_allowed( $check = 'both', $blog_id = null )   X-Ref
Whether the theme is allowed (multisite only).

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

get_core_default_theme()   X-Ref
Determines the latest WordPress default theme that is installed.

This hits the filesystem.

since: 4.4.0
return: WP_Theme|false Object, or false if no theme is installed, which would be bad.

get_allowed( $blog_id = null )   X-Ref
Returns array of stylesheet names of themes allowed on the site or network.

param: int $blog_id Optional. ID of the site. Defaults to the current site.
since: 3.4.0
return: string[] Array of stylesheet names.

get_allowed_on_network()   X-Ref
Returns array of stylesheet names of themes allowed on the network.

since: 3.4.0
return: string[] Array of stylesheet names.

get_allowed_on_site( $blog_id = null )   X-Ref
Returns array of stylesheet names of themes allowed on the site.

param: int $blog_id Optional. ID of the site. Defaults to the current site.
since: 3.4.0
return: string[] Array of stylesheet names.

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().

param: string $a First name.
param: string $b Second name.
since: 3.4.0
return: int Negative if `$a` falls lower in the natural order than `$b`. Zero if they fall equally.

_name_sort_i18n( $a, $b )   X-Ref
Callback function for usort() to naturally sort themes by translated name.

param: string $a First name.
param: string $b Second name.
since: 3.4.0
return: int Negative if `$a` falls lower in the natural order than `$b`. Zero if they fall equally.



Generated: Fri Nov 15 01:00:03 2019 Cross-referenced by PHPXref 0.7.1