[ XREF Home ] [ Index ]

PHP Cross Reference of WordPress Trunk

Provided by Yoast

title

Body

[close]

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

Theme, template, and stylesheet functions.

File Size: 1971 lines (57 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 2 files
 wp-admin/custom-background.php
 wp-admin/custom-header.php

Defines 78 functions

  is_child_theme()
  get_stylesheet()
  get_stylesheet_directory()
  get_stylesheet_directory_uri()
  get_stylesheet_uri()
  get_locale_stylesheet_uri()
  get_template()
  get_template_directory()
  get_template_directory_uri()
  get_theme_data()
  get_themes()
  get_theme_roots()
  get_theme()
  get_current_theme()
  register_theme_directory()
  search_theme_directories()
  get_theme_root()
  get_theme_root_uri()
  get_raw_theme_root()
  get_query_template()
  get_index_template()
  get_404_template()
  get_archive_template()
  get_author_template()
  get_category_template()
  get_tag_template()
  get_taxonomy_template()
  get_date_template()
  get_home_template()
  get_front_page_template()
  get_page_template()
  get_paged_template()
  get_search_template()
  get_single_template()
  get_attachment_template()
  get_comments_popup_template()
  locate_template()
  load_template()
  locale_stylesheet()
  preview_theme()
  _preview_theme_template_filter()
  _preview_theme_stylesheet_filter()
  preview_theme_ob_filter()
  preview_theme_ob_filter_callback()
  switch_theme()
  validate_current_theme()
  get_theme_mods()
  get_theme_mod()
  set_theme_mod()
  remove_theme_mod()
  remove_theme_mods()
  get_header_textcolor()
  header_textcolor()
  get_header_image()
  get_random_header_image()
  is_random_header_image()
  header_image()
  get_uploaded_header_images()
  add_custom_image_header()
  remove_custom_image_header()
  register_default_headers()
  unregister_default_headers()
  get_background_image()
  background_image()
  get_background_color()
  background_color()
  add_custom_background()
  remove_custom_background()
  _custom_background_cb()
  add_editor_style()
  remove_editor_styles()
  add_theme_support()
  get_theme_support()
  remove_theme_support()
  _remove_theme_support()
  current_theme_supports()
  require_if_theme_supports()
  _delete_attachment_theme_mod()

Functions
Functions that are not part of a class:

is_child_theme()   X-Ref
Whether a child theme is in use.

return: bool true if a child theme is in use, false otherwise.

get_stylesheet()   X-Ref
Retrieve name of the current stylesheet.

The theme name that the administrator has currently set the front end theme
as.

For all extensive purposes, the template name and the stylesheet name are
going to be the same for most cases.

return: string Stylesheet name.

get_stylesheet_directory()   X-Ref
Retrieve stylesheet directory path for current theme.

return: string Path to current theme directory.

get_stylesheet_directory_uri()   X-Ref
Retrieve stylesheet directory URI.

return: string

get_stylesheet_uri()   X-Ref
Retrieve URI of current theme stylesheet.

The stylesheet file name is 'style.css' which is appended to {@link
get_stylesheet_directory_uri() stylesheet directory URI} path.

return: string

get_locale_stylesheet_uri()   X-Ref
Retrieve localized stylesheet URI.

The stylesheet directory for the localized stylesheet files are located, by
default, in the base theme directory. The name of the locale file will be the
locale followed by '.css'. If that does not exist, then the text direction
stylesheet will be checked for existence, for example 'ltr.css'.

The theme may change the location of the stylesheet directory by either using
the 'stylesheet_directory_uri' filter or the 'locale_stylesheet_uri' filter.
If you want to change the location of the stylesheet files for the entire
WordPress workflow, then change the former. If you just have the locale in a
separate folder, then change the latter.

return: string

get_template()   X-Ref
Retrieve name of the current theme.

return: string Template name.

get_template_directory()   X-Ref
Retrieve current theme directory.

return: string Template directory path.

get_template_directory_uri()   X-Ref
Retrieve theme directory URI.

return: string Template directory URI.

get_theme_data( $theme_file )   X-Ref
Retrieve theme data from parsed theme file.

The description will have the tags filtered with the following HTML elements
whitelisted. The <b>'a'</b> element with the <em>href</em> and <em>title</em>
attributes. The <b>abbr</b> element with the <em>title</em> attribute. The
<b>acronym</b> element with the <em>title</em> attribute allowed. The
<b>code</b>, <b>em</b>, and <b>strong</b> elements also allowed.

The style.css file must contain theme name, theme URI, and description. The
data can also contain author URI, author, template (parent template),
version, status, and finally tags. Some of these are not used by WordPress
administration panels, but are used by theme directory web sites which list
the theme.

param: string $theme_file Theme file path.
return: array Theme data.

get_themes()   X-Ref
Retrieve list of themes with theme data in theme directory.

The theme is broken, if it doesn't have a parent theme and is missing either
style.css and, or index.php. If the theme has a parent theme then it is
broken, if it is missing style.css; index.php is optional. The broken theme
list is saved in the {@link $wp_broken_themes} global, which is displayed on
the theme list in the administration panels.

return: array Theme list with theme data.

get_theme_roots()   X-Ref
Retrieve theme roots.

return: array|string An arry of theme roots keyed by template/stylesheet or a single theme root if all themes have the same root.

get_theme($theme)   X-Ref
Retrieve theme data.

param: string $theme Theme name.
return: array|null Null, if theme name does not exist. Theme data, if exists.

get_current_theme()   X-Ref
Retrieve current theme display name.

If the 'current_theme' option has already been set, then it will be returned
instead. If it is not set, then each theme will be iterated over until both
the current stylesheet and current template name.

return: string

register_theme_directory( $directory)   X-Ref
Register a directory that contains themes.

param: string $directory Either the full filesystem path to a theme folder or a folder within WP_CONTENT_DIR
return: bool

search_theme_directories()   X-Ref
Search all registered theme directories for complete and valid themes.

return: array Valid themes found

get_theme_root( $stylesheet_or_template = false )   X-Ref
Retrieve path to themes directory.

Does not have trailing slash.

param: string $stylesheet_or_template The stylesheet or template name of the theme
return: string Theme path.

get_theme_root_uri( $stylesheet_or_template = false )   X-Ref
Retrieve URI for themes directory.

Does not have trailing slash.

param: string $stylesheet_or_template The stylesheet or template name of the theme
return: string Themes URI.

get_raw_theme_root( $stylesheet_or_template, $no_cache = false )   X-Ref
Get the raw theme root relative to the content directory with no filters applied.

param: string $stylesheet_or_template The stylesheet or template name of the theme
return: string Theme root

get_query_template( $type, $templates = array()   X-Ref
Retrieve path to a template

Used to quickly retrieve the path of a template without including the file
extension. It will also check the parent theme, if the file exists, with
the use of {@link locate_template()}. Allows for more generic template location
without the use of the other get_*_template() functions.

param: string $type Filename without extension.
param: array $templates An optional list of template candidates
return: string Full path to file.

get_index_template()   X-Ref
Retrieve path of index template in current or parent template.

return: string

get_404_template()   X-Ref
Retrieve path of 404 template in current or parent template.

return: string

get_archive_template()   X-Ref
Retrieve path of archive template in current or parent template.

return: string

get_author_template()   X-Ref
Retrieve path of author template in current or parent template.

return: string

get_category_template()   X-Ref
Retrieve path of category template in current or parent template.

Works by first retrieving the current slug for example 'category-default.php' and then
trying category ID, for example 'category-1.php' and will finally fallback to category.php
template, if those files don't exist.

return: string

get_tag_template()   X-Ref
Retrieve path of tag template in current or parent template.

Works by first retrieving the current tag name, for example 'tag-wordpress.php' and then
trying tag ID, for example 'tag-1.php' and will finally fallback to tag.php
template, if those files don't exist.

return: string

get_taxonomy_template()   X-Ref
Retrieve path of taxonomy template in current or parent template.

Retrieves the taxonomy and term, if term is available. The template is
prepended with 'taxonomy-' and followed by both the taxonomy string and
the taxonomy string followed by a dash and then followed by the term.

The taxonomy and term template is checked and used first, if it exists.
Second, just the taxonomy template is checked, and then finally, taxonomy.php
template is used. If none of the files exist, then it will fall back on to
index.php.

return: string

get_date_template()   X-Ref
Retrieve path of date template in current or parent template.

return: string

get_home_template()   X-Ref
Retrieve path of home template in current or parent template.

This is the template used for the page containing the blog posts

Attempts to locate 'home.php' first before falling back to 'index.php'.

return: string

get_front_page_template()   X-Ref
Retrieve path of front-page template in current or parent template.

Looks for 'front-page.php'.

return: string

get_page_template()   X-Ref
Retrieve path of page template in current or parent template.

Will first look for the specifically assigned page template
The will search for 'page-{slug}.php' followed by 'page-id.php'
and finally 'page.php'

return: string

get_paged_template()   X-Ref
Retrieve path of paged template in current or parent template.

return: string

get_search_template()   X-Ref
Retrieve path of search template in current or parent template.

return: string

get_single_template()   X-Ref
Retrieve path of single template in current or parent template.

return: string

get_attachment_template()   X-Ref
Retrieve path of attachment template in current or parent template.

The attachment path first checks if the first part of the mime type exists.
The second check is for the second part of the mime type. The last check is
for both types separated by an underscore. If neither are found then the file
'attachment.php' is checked and returned.

Some examples for the 'text/plain' mime type are 'text.php', 'plain.php', and
finally 'text_plain.php'.

return: string

get_comments_popup_template()   X-Ref
Retrieve path of comment popup template in current or parent template.

Checks for comment popup template in current template, if it exists or in the
parent template.

return: string

locate_template($template_names, $load = false, $require_once = true )   X-Ref
Retrieve the name of the highest priority template file that exists.

Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which
inherit from a parent theme can just overload one file.

param: string|array $template_names Template file(s) to search for, in order.
param: bool $load If true the template file will be loaded if it is found.
param: bool $require_once Whether to require_once or require. Default true. Has no effect if $load is false.
return: string The template filename if one is located.

load_template( $_template_file, $require_once = true )   X-Ref
Require the template file with WordPress environment.

The globals are set up for the template file to ensure that the WordPress
environment is available from within the function. The query variables are
also available.

param: string $_template_file Path to template file.
param: bool $require_once Whether to require_once or require. Default true.

locale_stylesheet()   X-Ref
Display localized stylesheet link element.


preview_theme()   X-Ref
Start preview theme output buffer.

Will only preform task if the user has permissions and template and preview
query variables exist.


_preview_theme_template_filter()   X-Ref
Private function to modify the current template when previewing a theme

return: string

_preview_theme_stylesheet_filter()   X-Ref
Private function to modify the current stylesheet when previewing a theme

return: string

preview_theme_ob_filter( $content )   X-Ref
Callback function for ob_start() to capture all links in the theme.

param: string $content
return: string

preview_theme_ob_filter_callback( $matches )   X-Ref
Manipulates preview theme links in order to control and maintain location.

Callback function for preg_replace_callback() to accept and filter matches.

param: array $matches
return: string

switch_theme($template, $stylesheet)   X-Ref
Switches current theme to new template and stylesheet names.

param: string $template Template name
param: string $stylesheet Stylesheet name.

validate_current_theme()   X-Ref
Checks that current theme files 'index.php' and 'style.css' exists.

Does not check the default theme, which is the fallback and should always exist.
Will switch theme to the fallback theme if current theme does not validate.
You can use the 'validate_current_theme' filter to return FALSE to
disable this functionality.

return: bool

get_theme_mods()   X-Ref
Retrieve all theme modifications.

return: array Theme modifications.

get_theme_mod( $name, $default = false )   X-Ref
Retrieve theme modification value for the current theme.

If the modification name does not exist, then the $default will be passed
through {@link http://php.net/sprintf sprintf()} PHP function with the first
string the template directory URI and the second string the stylesheet
directory URI.

param: string $name Theme modification name.
param: bool|string $default
return: string

set_theme_mod( $name, $value )   X-Ref
Update theme modification value for the current theme.

param: string $name Theme modification name.
param: string $value theme modification value.

remove_theme_mod( $name )   X-Ref
Remove theme modification name from current theme list.

If removing the name also removes all elements, then the entire option will
be removed.

param: string $name Theme modification name.
return: null

remove_theme_mods()   X-Ref
Remove theme modifications option for current theme.


get_header_textcolor()   X-Ref
Retrieve text color for custom header.

return: string

header_textcolor()   X-Ref
Display text color for custom header.


get_header_image()   X-Ref
Retrieve header image for custom header.

return: string

get_random_header_image()   X-Ref
Get random header image from registered images in theme.

return: string Path to header image

is_random_header_image( $type = 'any' )   X-Ref
Check if random header image is in use.

Always true if user expressly chooses the option in Appearance > Header.
Also true if theme has multiple header images registered and no specific header image is chosen.

param: string $type The random pool to use. any|default|uploaded
return: boolean

header_image()   X-Ref
Display header image path.


get_uploaded_header_images()   X-Ref
Get the header images uploaded for the current theme.

return: array

add_custom_image_header( $header_callback, $admin_header_callback, $admin_image_div_callback = '' )   X-Ref
Add callbacks for image header display.

The parameter $header_callback callback will be required to display the
content for the 'wp_head' action. The parameter $admin_header_callback
callback will be added to Custom_Image_Header class and that will be added
to the 'admin_menu' action.

param: callback $header_callback Call on 'wp_head' action.
param: callback $admin_header_callback Call on custom header administration screen.
param: callback $admin_image_div_callback Output a custom header image div on the custom header administration screen. Optional.

remove_custom_image_header()   X-Ref
Remove image header support.

return: bool Whether support was removed.

register_default_headers( $headers )   X-Ref
Register a selection of default headers to be displayed by the custom header admin UI.

param: array $headers Array of headers keyed by a string id. The ids point to arrays containing 'url', 'thumbnail_url', and 'description' keys.

unregister_default_headers( $header )   X-Ref
Unregister default headers.

This function must be called after register_default_headers() has already added the
header you want to remove.

param: string|array $header The header string id (key of array) to remove, or an array thereof.
return: True on success, false on failure.

get_background_image()   X-Ref
Retrieve background image for custom background.

return: string

background_image()   X-Ref
Display background image path.


get_background_color()   X-Ref
Retrieve value for custom background color.

return: string

background_color()   X-Ref
Display background color value.


add_custom_background( $header_callback = '', $admin_header_callback = '', $admin_image_div_callback = '' )   X-Ref
Add callbacks for background image display.

The parameter $header_callback callback will be required to display the
content for the 'wp_head' action. The parameter $admin_header_callback
callback will be added to Custom_Background class and that will be added
to the 'admin_menu' action.

param: callback $header_callback Call on 'wp_head' action.
param: callback $admin_header_callback Call on custom background administration screen.
param: callback $admin_image_div_callback Output a custom background image div on the custom background administration screen. Optional.

remove_custom_background()   X-Ref
Remove custom background support.

return: bool Whether support was removed.

_custom_background_cb()   X-Ref
Default custom background callback.


add_editor_style( $stylesheet = 'editor-style.css' )   X-Ref
Add callback for custom TinyMCE editor stylesheets.

The parameter $stylesheet is the name of the stylesheet, relative to
the theme root. It also accepts an array of stylesheets.
It is optional and defaults to 'editor-style.css'.

Supports RTL stylesheets automatically by searching for the -rtl prefix, e.g.
editor-style-rtl.css. If an array of stylesheets is passed to add_editor_style(),
RTL is only added for the first stylesheet.

param: mixed $stylesheet Optional. Stylesheet name or array thereof, relative to theme root.

remove_editor_styles()   X-Ref
Removes all visual editor stylesheets.

return: bool True on success, false if there were no stylesheets to remove.

add_theme_support( $feature )   X-Ref
Allows a theme to register its support of a certain feature

Must be called in the theme's functions.php file to work.
If attached to a hook, it must be after_setup_theme.
The init hook may be too late for some features.

param: string $feature the feature being added

get_theme_support( $feature )   X-Ref
Gets the theme support arguments passed when registering that support

param: string $feature the feature to check
return: array The array of extra arguments

remove_theme_support( $feature )   X-Ref
Allows a theme to de-register its support of a certain feature

Should be called in the theme's functions.php file. Generally would
be used for child themes to override support from the parent theme.

param: string $feature the feature being added
return: bool Whether feature was removed.

_remove_theme_support( $feature )   X-Ref
Do not use. Removes theme support internally, ignorant of the blacklist.


current_theme_supports( $feature )   X-Ref
Checks a theme's support for a given feature

param: string $feature the feature being checked
return: boolean

require_if_theme_supports( $feature, $include)   X-Ref
Checks a theme's support for a given feature before loading the functions which implement it.

param: string $feature the feature being checked
param: string $include the file containing the functions that implement the feature

_delete_attachment_theme_mod( $id )   X-Ref
Checks an attachment being deleted to see if it's a header or background image.

If true it removes the theme modification which would be pointing at the deleted
attachment

param: int $id the attachment id



Generated: Wed Jun 1 08:30:02 2011 Cross-referenced by PHPXref 0.7
Provided by Yoast and awesome WordPress Hosting