Changeset 20029 for trunk/wp-admin/includes/theme.php
- Timestamp:
- 02/28/2012 09:24:44 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/theme.php
r20025 r20029 6 6 * @subpackage Administration 7 7 */ 8 9 /**10 * {@internal Missing Short Description}}11 *12 * @since 2.0.013 *14 * @return unknown15 */16 function current_theme_info() {17 $themes = get_themes();18 $current_theme = get_current_theme();19 20 if ( ! $themes ) {21 $ct = new stdClass;22 $ct->name = $current_theme;23 return $ct;24 }25 26 if ( ! isset( $themes[$current_theme] ) ) {27 delete_option( 'current_theme' );28 $current_theme = get_current_theme();29 }30 31 $ct = new stdClass;32 $ct->name = $current_theme;33 $ct->title = $themes[$current_theme]['Title'];34 $ct->version = $themes[$current_theme]['Version'];35 $ct->parent_theme = $themes[$current_theme]['Parent Theme'];36 $ct->template_dir = $themes[$current_theme]['Template Dir'];37 $ct->stylesheet_dir = $themes[$current_theme]['Stylesheet Dir'];38 $ct->template = $themes[$current_theme]['Template'];39 $ct->stylesheet = $themes[$current_theme]['Stylesheet'];40 $ct->screenshot = $themes[$current_theme]['Screenshot'];41 $ct->description = $themes[$current_theme]['Description'];42 $ct->author = $themes[$current_theme]['Author'];43 $ct->tags = $themes[$current_theme]['Tags'];44 $ct->theme_root = $themes[$current_theme]['Theme Root'];45 $ct->theme_root_uri = $themes[$current_theme]['Theme Root URI'];46 return $ct;47 }48 8 49 9 /** … … 115 75 116 76 /** 117 * {@internal Missing Short Description}}77 * Get the Page Templates available in this theme 118 78 * 119 79 * @since 1.5.0 120 80 * 121 * @return unknown122 */123 function get_broken_themes() {124 global $wp_broken_themes;125 126 get_themes();127 return $wp_broken_themes;128 }129 130 /**131 * Get the allowed themes for the current blog.132 *133 * @since 3.0.0134 *135 * @uses get_themes()136 * @uses current_theme_info()137 * @uses get_site_allowed_themes()138 * @uses wpmu_get_blog_allowedthemes139 *140 * @return array $themes Array of allowed themes.141 */142 function get_allowed_themes() {143 if ( !is_multisite() )144 return get_themes();145 146 $themes = get_themes();147 $ct = current_theme_info();148 $allowed_themes = apply_filters("allowed_themes", get_site_allowed_themes() );149 if ( $allowed_themes == false )150 $allowed_themes = array();151 152 $blog_allowed_themes = wpmu_get_blog_allowedthemes();153 if ( is_array( $blog_allowed_themes ) )154 $allowed_themes = array_merge( $allowed_themes, $blog_allowed_themes );155 156 if ( isset( $allowed_themes[ esc_html( $ct->stylesheet ) ] ) == false )157 $allowed_themes[ esc_html( $ct->stylesheet ) ] = true;158 159 reset( $themes );160 foreach ( $themes as $key => $theme ) {161 if ( isset( $allowed_themes[ esc_html( $theme[ 'Stylesheet' ] ) ] ) == false )162 unset( $themes[ $key ] );163 }164 reset( $themes );165 166 return $themes;167 }168 169 /**170 * Get the Page Templates available in this theme171 *172 * @since 1.5.0173 *174 81 * @return array Key is the template name, value is the filename of the template 175 82 */ 176 83 function get_page_templates() { 177 $themes = get_themes(); 178 $theme = get_current_theme(); 179 $templates = $themes[$theme]['Template Files']; 180 $page_templates = array(); 181 182 if ( is_array( $templates ) ) { 183 $base = array( trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()) ); 184 185 foreach ( $templates as $template ) { 186 $basename = str_replace($base, '', $template); 187 188 // don't allow template files in subdirectories 189 if ( false !== strpos($basename, '/') ) 190 continue; 191 192 if ( 'functions.php' == $basename ) 193 continue; 194 195 $template_data = implode( '', file( $template )); 196 197 $name = ''; 198 if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) 199 $name = _cleanup_header_comment($name[1]); 200 201 if ( !empty( $name ) ) { 202 $page_templates[trim( $name )] = $basename; 203 } 204 } 205 } 206 207 return $page_templates; 84 return wp_get_theme()->get_page_templates(); 208 85 } 209 86 … … 241 118 $themes_update = get_site_transient('update_themes'); 242 119 243 if ( is_object($theme) && isset($theme->stylesheet) ) 244 $stylesheet = $theme->stylesheet; 245 elseif ( is_array($theme) && isset($theme['Stylesheet']) ) 246 $stylesheet = $theme['Stylesheet']; 247 else 248 return false; //No valid info passed. 120 if ( ! is_a( $theme, 'WP_Theme' ) ) 121 return; 122 123 $stylesheet = $theme->get_stylesheet(); 249 124 250 125 if ( isset($themes_update->response[ $stylesheet ]) ) { 251 126 $update = $themes_update->response[ $stylesheet ]; 252 $theme_name = is_object($theme) ? $theme->name : (is_array($theme) ? $theme['Name'] : '');127 $theme_name = $theme->get('Name'); 253 128 $details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list. 254 129 $update_url = wp_nonce_url('update.php?action=upgrade-theme&theme=' . urlencode($stylesheet), 'upgrade-theme_' . $stylesheet);
Note: See TracChangeset
for help on using the changeset viewer.