Changeset 4392 for trunk/wp-includes/theme.php
- Timestamp:
- 10/13/2006 10:33:44 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/theme.php
r4194 r4392 1 1 <?php 2 2 /* 3 * Theme/template/stylesheet functions. 3 * Theme/template/stylesheet functions. 4 4 */ 5 5 … … 33 33 if ( file_exists("$dir/$locale.css") ) 34 34 $stylesheet_uri = "$stylesheet_dir_uri/$locale.css"; 35 else 35 elseif ( !empty($wp_locale->text_direction) && file_exists("$dir/{$wp_locale->text_direction}.css") ) 36 36 $stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css"; 37 37 else … … 89 89 90 90 function get_themes() { 91 global $wp_themes; 92 global $wp_broken_themes; 91 global $wp_themes, $wp_broken_themes; 93 92 94 93 if ( isset($wp_themes) ) … … 103 102 $themes_dir = @ dir($theme_root); 104 103 if ( $themes_dir ) { 105 while (($theme_dir = $themes_dir->read()) !== false) {104 while ( ($theme_dir = $themes_dir->read()) !== false ) { 106 105 if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) { 107 if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) {106 if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) 108 107 continue; 109 }110 108 $stylish_dir = @ dir($theme_root . '/' . $theme_dir); 111 109 $found_stylesheet = false; 112 while ( ($theme_file = $stylish_dir->read()) !== false) {110 while ( ($theme_file = $stylish_dir->read()) !== false ) { 113 111 if ( $theme_file == 'style.css' ) { 114 112 $theme_files[] = $theme_dir . '/' . $theme_file; … … 117 115 } 118 116 } 119 if ( !$found_stylesheet ) {117 if ( !$found_stylesheet ) 120 118 $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.')); 121 } 122 } 123 } 124 } 125 126 if ( !$themes_dir || !$theme_files ) { 119 } 120 } 121 } 122 123 if ( !$themes_dir || !$theme_files ) 127 124 return $themes; 128 }129 125 130 126 sort($theme_files); 131 127 132 foreach ($theme_files as $theme_file) {133 if ( ! 128 foreach ( (array) $theme_files as $theme_file ) { 129 if ( !is_readable("$theme_root/$theme_file") ) { 134 130 $wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.')); 135 131 continue; … … 138 134 $theme_data = get_theme_data("$theme_root/$theme_file"); 139 135 140 $name = $theme_data['Name'];141 $title = $theme_data['Title'];136 $name = $theme_data['Name']; 137 $title = $theme_data['Title']; 142 138 $description = wptexturize($theme_data['Description']); 143 $version = $theme_data['Version'];144 $author = $theme_data['Author'];145 $template = $theme_data['Template'];146 $stylesheet = dirname($theme_file);147 148 foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext) {139 $version = $theme_data['Version']; 140 $author = $theme_data['Author']; 141 $template = $theme_data['Template']; 142 $stylesheet = dirname($theme_file); 143 144 foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext ) { 149 145 if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) { 150 146 $screenshot = "screenshot.$ext"; … … 159 155 160 156 if ( empty($template) ) { 161 if ( file_exists(dirname("$theme_root/$theme_file/index.php")) ) {157 if ( file_exists(dirname("$theme_root/$theme_file/index.php")) ) 162 158 $template = dirname($theme_file); 163 } else {159 else 164 160 continue; 165 }166 161 } 167 162 … … 176 171 $stylesheet_dir = @ dir("$theme_root/$stylesheet"); 177 172 if ( $stylesheet_dir ) { 178 while (($file = $stylesheet_dir->read()) !== false) {173 while ( ($file = $stylesheet_dir->read()) !== false ) { 179 174 if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) ) 180 175 $stylesheet_files[] = "$theme_loc/$stylesheet/$file"; … … 223 218 $theme_names = array_keys($themes); 224 219 225 foreach ( $theme_names as $theme_name) {220 foreach ( (array) $theme_names as $theme_name ) { 226 221 $themes[$theme_name]['Parent Theme'] = ''; 227 222 if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) { 228 foreach ( $theme_names as $parent_theme_name) {223 foreach ( (array) $theme_names as $parent_theme_name ) { 229 224 if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) { 230 225 $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name']; … … 257 252 258 253 if ( $themes ) { 259 foreach ( $theme_names as $theme_name) {254 foreach ( (array) $theme_names as $theme_name ) { 260 255 if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet && 261 256 $themes[$theme_name]['Template'] == $current_template ) { … … 301 296 if ( file_exists(TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php') ) 302 297 $template = TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php'; 303 else 298 elseif ( file_exists(TEMPLATEPATH . "/category.php") ) 304 299 $template = TEMPLATEPATH . "/category.php"; 305 300 … … 316 311 if ( file_exists(TEMPLATEPATH . "/home.php") ) 317 312 $template = TEMPLATEPATH . "/home.php"; 318 else 313 elseif ( file_exists(TEMPLATEPATH . "/index.php") ) 319 314 $template = TEMPLATEPATH . "/index.php"; 320 315 … … 331 326 $template = ''; 332 327 333 if ( ! 328 if ( !empty($template) && file_exists(TEMPLATEPATH . "/$template") ) 334 329 $template = TEMPLATEPATH . "/$template"; 335 else 330 elseif ( file_exists(TEMPLATEPATH . "/page.php") ) 336 331 $template = TEMPLATEPATH . "/page.php"; 337 332 else … … 396 391 return true; 397 392 398 if ( (get_template() != 'default') && (!file_exists(get_template_directory() . '/index.php'))) {393 if ( get_template() != 'default' && !file_exists(get_template_directory() . '/index.php') ) { 399 394 update_option('template', 'default'); 400 395 update_option('stylesheet', 'default'); … … 403 398 } 404 399 405 if ( (get_stylesheet() != 'default') && (!file_exists(get_template_directory() . '/style.css'))) {400 if ( get_stylesheet() != 'default' && !file_exists(get_template_directory() . '/style.css') ) { 406 401 update_option('template', 'default'); 407 402 update_option('stylesheet', 'default');
Note: See TracChangeset
for help on using the changeset viewer.