register_theme_directory
Register a directory that contains themes.
Description
register_theme_directory( (string) $directory );
Parameters (1)
- 0. $directory (string)
- Either the full filesystem path to a theme folder or a folder within WP_CONTENT_DIR
Usage
if ( !function_exists( 'register_theme_directory' ) ) { require_once ABSPATH . WPINC . '/theme.php'; } // Either the full filesystem path to a theme folder or a folder within WP_CONTENT_DIR $directory = ''; // NOTICE! Understand what this does before running. $result = register_theme_directory($directory);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/theme.php
- function register_theme_directory( $directory ) {
- global $wp_theme_directories;
- if ( ! file_exists( $directory ) ) {
- // Try prepending as the theme directory could be relative to the content directory
- $directory = WP_CONTENT_DIR . '/' . $directory;
- // If this directory does not exist, return and do not register
- if ( ! file_exists( $directory ) ) {
- return false;
- }
- }
- if ( ! is_array( $wp_theme_directories ) ) {
- $wp_theme_directories = array();
- }
- $untrailed = untrailingslashit( $directory );
- if ( ! empty( $untrailed ) && ! in_array( $untrailed, $wp_theme_directories ) ) {
- $wp_theme_directories[] = $untrailed;
- }
- return true;
- }