### Eclipse Workspace Patch 1.0
#P wordpress-trunk
|
|
|
263 | 263 | |
264 | 264 | asort( $theme_files ); |
265 | 265 | |
266 | | $wp_themes = array(); |
| 266 | $theme_roots = array(); |
| 267 | $wp_themes = array(); |
267 | 268 | |
268 | 269 | foreach ( (array) $theme_files as $theme_file ) { |
269 | 270 | $theme_root = $theme_file['theme_root']; |
… |
… |
|
427 | 428 | |
428 | 429 | /** |
429 | 430 | * Retrieve theme roots. |
| 431 | * |
| 432 | * Theme roots are pathes to theme directories. |
430 | 433 | * |
431 | 434 | * @since 2.9.0 |
432 | 435 | * |
433 | | * @return array Theme roots |
| 436 | * @return array directories of all theme-roots keyed with their stylesheet value |
434 | 437 | */ |
435 | 438 | function get_theme_roots() { |
436 | 439 | $theme_roots = get_site_transient( 'theme_roots' ); |
437 | 440 | if ( false === $theme_roots ) { |
438 | 441 | get_themes(); |
439 | | $theme_roots = get_site_transient( 'theme_roots' ); // this is set in get_theme() |
| 442 | $theme_roots = get_site_transient( 'theme_roots' ); // set in get_themes() |
440 | 443 | } |
441 | | return $theme_roots; |
| 444 | return (array) $theme_roots; |
442 | 445 | } |
443 | 446 | |
444 | 447 | /** |
… |
… |
|
470 | 473 | * @return string |
471 | 474 | */ |
472 | 475 | function get_current_theme() { |
| 476 | // magic number |
| 477 | $default_theme = 'WordPress Default'; |
| 478 | |
473 | 479 | if ( $theme = get_option('current_theme') ) |
474 | 480 | return $theme; |
475 | 481 | |
476 | 482 | $themes = get_themes(); |
477 | | $theme_names = array_keys($themes); |
478 | | $current_template = get_option('template'); |
479 | | $current_stylesheet = get_option('stylesheet'); |
480 | | $current_theme = 'WordPress Default'; |
| 483 | if ( ! is_array($themes) ) |
| 484 | return $default_theme; |
481 | 485 | |
482 | | if ( $themes ) { |
483 | | foreach ( (array) $theme_names as $theme_name ) { |
484 | | if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet && |
485 | | $themes[$theme_name]['Template'] == $current_template ) { |
486 | | $current_theme = $themes[$theme_name]['Name']; |
487 | | break; |
488 | | } |
| 486 | $theme = $default_theme; |
| 487 | $template = get_option('template'); |
| 488 | $stylesheet = get_option('stylesheet'); |
| 489 | |
| 490 | foreach ( $themes as $value ) { |
| 491 | if ( $value['Stylesheet'] == $stylesheet |
| 492 | && $value['Template'] == $template ) { |
| 493 | $theme = $value['Name']; |
| 494 | break; |
489 | 495 | } |
490 | 496 | } |
491 | 497 | |
492 | | update_option('current_theme', $current_theme); |
493 | | |
494 | | return $current_theme; |
| 498 | update_option('current_theme', $theme); |
| 499 | return $theme; |
495 | 500 | } |
496 | 501 | |
497 | 502 | /** |