Definition:
function search_theme_directories() {}
Search all registered theme directories for complete and valid themes.
Return values
returns:Valid themes found
Source code
function search_theme_directories() { global $wp_theme_directories, $wp_broken_themes; if ( empty( $wp_theme_directories ) ) return false; $theme_files = array(); $wp_broken_themes = array(); /* Loop the registered theme directories and extract all themes */ foreach ( (array) $wp_theme_directories as $theme_root ) { $theme_loc = $theme_root; /* We don't want to replace all forward slashes, see Trac #4541 */ if ( '/' != WP_CONTENT_DIR ) $theme_loc = str_replace(WP_CONTENT_DIR, '', $theme_root); /* Files in the root of the current theme directory and one subdir down */ $themes_dir = @ opendir($theme_root); if ( !$themes_dir ) return false; while ( ($theme_dir = readdir($themes_dir)) !== false ) { if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) { if ( $theme_dir[0] == '.' || $theme_dir == 'CVS' ) continue; $stylish_dir = @opendir($theme_root . '/' . $theme_dir); $found_stylesheet = false; while ( ($theme_file = readdir($stylish_dir)) !== false ) { if ( $theme_file == 'style.css' ) { $theme_files[$theme_dir] = array( 'theme_file' => $theme_dir . '/' . $theme_file, 'theme_root' => $theme_root ); $found_stylesheet = true; break; } } @closedir($stylish_dir); if ( !$found_stylesheet ) { // look for themes in that dir $subdir = "$theme_root/$theme_dir"; $subdir_name = $theme_dir; $theme_subdirs = @opendir( $subdir ); $found_subdir_themes = false; while ( ($theme_subdir = readdir($theme_subdirs)) !== false ) { if ( is_dir( $subdir . '/' . $theme_subdir) && is_readable($subdir . '/' . $theme_subdir) ) { if ( $theme_subdir[0] == '.' || $theme_subdir == 'CVS' ) continue; $stylish_dir = @opendir($subdir . '/' . $theme_subdir); $found_stylesheet = false; while ( ($theme_file = readdir($stylish_dir)) !== false ) { if ( $theme_file == 'style.css' ) { $theme_files["$theme_dir/$theme_subdir"] = array( 'theme_file' => $subdir_name . '/' . $theme_subdir . '/' . $theme_file, 'theme_root' => $theme_root ); $found_stylesheet = true; $found_subdir_themes = true; break; } } @closedir($stylish_dir); } } @closedir($theme_subdirs); if ( !$found_subdir_themes ) $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.')); } } } @closedir( $themes_dir ); } return $theme_files; }
2817
No comments yet... Be the first to leave a reply!