source: trunk/www.guidonia.net/wp/wp-admin/includes/theme.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 3.6 KB
Line 
1<?php
2/**
3 * WordPress Theme Administration API
4 *
5 * @package WordPress
6 * @subpackage Administration
7 */
8
9/**
10 * {@internal Missing Short Description}}
11 *
12 * @since unknown
13 *
14 * @return unknown
15 */
16function 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'];
31 return $ct;
32}
33
34/**
35 * Remove a theme
36 *
37 * @since 2.8.0
38 *
39 * @param string $template Template directory of the theme to delete
40 * @return mixed
41 */
42function delete_theme($template) {
43 global $wp_filesystem;
44
45 if ( empty($template) )
46 return false;
47
48 ob_start();
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();
52 ob_end_clean();
53 if ( ! empty($data) ){
54 include_once( ABSPATH . 'wp-admin/admin-header.php');
55 echo $data;
56 include( ABSPATH . 'wp-admin/admin-footer.php');
57 exit;
58 }
59 return;
60 }
61
62 if ( ! WP_Filesystem($credentials) ) {
63 request_filesystem_credentials($url, '', true); // Failed to connect, Error and request again
64 $data = ob_get_contents();
65 ob_end_clean();
66 if( ! empty($data) ){
67 include_once( ABSPATH . 'wp-admin/admin-header.php');
68 echo $data;
69 include( ABSPATH . 'wp-admin/admin-footer.php');
70 exit;
71 }
72 return;
73 }
74
75
76 if ( ! is_object($wp_filesystem) )
77 return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
78
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);
81
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.'));
86
87 $themes_dir = trailingslashit( $themes_dir );
88
89 $errors = array();
90
91 $theme_dir = trailingslashit($themes_dir . $template);
92 $deleted = $wp_filesystem->delete($theme_dir, true);
93
94 if ( ! $deleted )
95 return new WP_Error('could_not_remove_theme', sprintf(__('Could not fully remove the theme %s'), $template) );
96
97 // Force refresh of theme update information
98 delete_transient('update_themes');
99
100 return true;
101}
102
103/**
104 * {@internal Missing Short Description}}
105 *
106 * @since unknown
107 *
108 * @return unknown
109 */
110function get_broken_themes() {
111 global $wp_broken_themes;
112
113 get_themes();
114 return $wp_broken_themes;
115}
116
117/**
118 * {@internal Missing Short Description}}
119 *
120 * @since unknown
121 *
122 * @return unknown
123 */
124function get_page_templates() {
125 $themes = get_themes();
126 $theme = get_current_theme();
127 $templates = $themes[$theme]['Template Files'];
128 $page_templates = array ();
129
130 if ( is_array( $templates ) ) {
131 foreach ( $templates as $template ) {
132 $template_data = implode( '', file( WP_CONTENT_DIR.$template ));
133
134 $name = '';
135 if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) )
136 $name = _cleanup_header_comment($name[1]);
137
138 if ( !empty( $name ) ) {
139 $page_templates[trim( $name )] = basename( $template );
140 }
141 }
142 }
143
144 return $page_templates;
145}
146
147?>
Note: See TracBrowser for help on using the repository browser.