3 * WordPress Theme Administration API
6 * @subpackage Administration
10 * {@internal Missing Short Description}}
16 function current_theme_info() {
17 $themes = get_themes();
18 $current_theme = get_current_theme();
19 $ct->name = $current_theme;
20 $ct->title = $themes[$current_theme]['Title'];
21 $ct->version = $themes[$current_theme]['Version'];
22 $ct->parent_theme = $themes[$current_theme]['Parent Theme'];
23 $ct->template_dir = $themes[$current_theme]['Template Dir'];
24 $ct->stylesheet_dir = $themes[$current_theme]['Stylesheet Dir'];
25 $ct->template = $themes[$current_theme]['Template'];
26 $ct->stylesheet = $themes[$current_theme]['Stylesheet'];
27 $ct->screenshot = $themes[$current_theme]['Screenshot'];
28 $ct->description = $themes[$current_theme]['Description'];
29 $ct->author = $themes[$current_theme]['Author'];
30 $ct->tags = $themes[$current_theme]['Tags'];
39 * @param string $template Template directory of the theme to delete
42 function delete_theme($template) {
43 global $wp_filesystem;
45 if ( empty($template) )
49 $url = wp_nonce_url('themes.php?action=delete&template=' . $template, 'delete-theme_' . $template);
50 if ( false === ($credentials = request_filesystem_credentials($url)) ) {
51 $data = ob_get_contents();
53 if ( ! empty($data) ){
54 include_once( ABSPATH . 'wp-admin/admin-header.php');
56 include( ABSPATH . 'wp-admin/admin-footer.php');
62 if ( ! WP_Filesystem($credentials) ) {
63 request_filesystem_credentials($url, '', true); // Failed to connect, Error and request again
64 $data = ob_get_contents();
67 include_once( ABSPATH . 'wp-admin/admin-header.php');
69 include( ABSPATH . 'wp-admin/admin-footer.php');
76 if ( ! is_object($wp_filesystem) )
77 return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
79 if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
80 return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors);
82 //Get the base plugin folder
83 $themes_dir = $wp_filesystem->wp_themes_dir();
84 if ( empty($themes_dir) )
85 return new WP_Error('fs_no_themes_dir', __('Unable to locate WordPress theme directory.'));
87 $themes_dir = trailingslashit( $themes_dir );
91 $theme_dir = trailingslashit($themes_dir . $template);
92 $deleted = $wp_filesystem->delete($theme_dir, true);
95 return new WP_Error('could_not_remove_theme', sprintf(__('Could not fully remove the theme %s'), $template) );
97 // Force refresh of theme update information
98 delete_transient('update_themes');
104 * {@internal Missing Short Description}}
110 function get_broken_themes() {
111 global $wp_broken_themes;
114 return $wp_broken_themes;
118 * {@internal Missing Short Description}}
124 function get_page_templates() {
125 $themes = get_themes();
126 $theme = get_current_theme();
127 $templates = $themes[$theme]['Template Files'];
128 $page_templates = array ();
130 if ( is_array( $templates ) ) {
131 foreach ( $templates as $template ) {
132 $template_data = implode( '', file( WP_CONTENT_DIR.$template ));
135 if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) )
136 $name = _cleanup_header_comment($name[1]);
138 if ( !empty( $name ) ) {
139 $page_templates[trim( $name )] = basename( $template );
144 return $page_templates;