mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 15:31:42 +01:00
Refactor some theme code.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1643 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
37e39a2917
commit
ff7a84c8d6
@ -565,7 +565,7 @@ function get_themes() {
|
||||
}
|
||||
|
||||
// The default theme always exists.
|
||||
$themes['Default'] = array('Name' => 'Default', 'Title' => 'Default', 'Description' => 'The default theme', 'Author' => '', 'Version' => '1.3', 'Template' => 'default', 'Stylesheet' => 'default', 'Template Files' => $default_template_files, 'Stylesheet Files' => $default_stylesheet_files);
|
||||
$themes['Default'] = array('Name' => 'Default', 'Title' => 'Default', 'Description' => 'The default theme', 'Author' => '', 'Version' => '1.3', 'Template' => 'default', 'Stylesheet' => 'default', 'Template Files' => $default_template_files, 'Stylesheet Files' => $default_stylesheet_files, 'Template Dir' => '/', 'Stylesheet Dir' => '/', 'Parent Theme' => '');
|
||||
|
||||
if (!$themes_dir || !$theme_files) {
|
||||
return $themes;
|
||||
@ -629,10 +629,50 @@ function get_themes() {
|
||||
$template_files = $default_template_files;
|
||||
}
|
||||
|
||||
$themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Stylesheet' => $stylesheet, 'Template Files' => $template_files, 'Stylesheet Files' => $stylesheet_files);
|
||||
$template_dir = dirname($template_files[0]);
|
||||
$stylesheet_dir = dirname($stylesheet_files[0]);
|
||||
|
||||
if (empty($template_dir)) $template_dir = '/';
|
||||
if (empty($stylesheet_dir)) $stylesheet_dir = '/';
|
||||
|
||||
$themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Stylesheet' => $stylesheet, 'Template Files' => $template_files, 'Stylesheet Files' => $stylesheet_files, 'Template Dir' => $template_dir, 'Stylesheet Dir' => $stylesheet_dir);
|
||||
}
|
||||
|
||||
// Resolve theme dependencies.
|
||||
$theme_names = array_keys($themes);
|
||||
|
||||
foreach ($theme_names as $theme_name) {
|
||||
$themes[$theme_name]['Parent Theme'] = '';
|
||||
if ($themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template']) {
|
||||
foreach ($theme_names as $parent_theme_name) {
|
||||
if (($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template'])) {
|
||||
$themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $themes;
|
||||
}
|
||||
|
||||
function get_current_theme() {
|
||||
$themes = get_themes();
|
||||
$theme_names = array_keys($themes);
|
||||
$current_template = get_settings('template');
|
||||
$current_stylesheet = get_settings('stylesheet');
|
||||
$current_theme = 'Default';
|
||||
|
||||
if ($themes) {
|
||||
foreach ($theme_names as $theme_name) {
|
||||
if ($themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
|
||||
$themes[$theme_name]['Template'] == $current_template) {
|
||||
$current_theme = $themes[$theme_name]['Name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $current_theme;
|
||||
}
|
||||
|
||||
?>
|
@ -30,33 +30,12 @@ if ($user_level < 9) // Must be at least level 9
|
||||
|
||||
<?php
|
||||
$themes = get_themes();
|
||||
$theme_names = array_keys($themes);
|
||||
natcasesort($theme_names);
|
||||
$current_template = get_settings('template');
|
||||
$current_stylesheet = get_settings('stylesheet');
|
||||
$current_theme = 'Default';
|
||||
$current_parent_theme = '';
|
||||
$current_template_dir = '/';
|
||||
$current_stylesheet_dir = '/';
|
||||
|
||||
if ($themes) {
|
||||
foreach ($theme_names as $theme_name) {
|
||||
if ($themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
|
||||
$themes[$theme_name]['Template'] == $current_template) {
|
||||
$current_theme = $themes[$theme_name]['Name'];
|
||||
if ($current_template != 'default')
|
||||
$current_template_dir = dirname($themes[$theme_name]['Template Files'][0]);
|
||||
if ($current_stylesheet != 'default')
|
||||
$current_stylesheet_dir = dirname($themes[$theme_name]['Stylesheet Files'][0]);
|
||||
}
|
||||
|
||||
if (($current_template != $current_stylesheet) &&
|
||||
($themes[$theme_name]['Stylesheet'] == $themes[$theme_name]['Template']) &&
|
||||
($themes[$theme_name]['Template'] == $current_template)) {
|
||||
$current_parent_theme = $themes[$theme_name]['Name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$current_theme = get_current_theme();
|
||||
$current_parent_theme = $themes[$current_theme]['Parent Theme'];
|
||||
$current_template_dir = $themes[$current_theme]['Template Dir'];
|
||||
$current_stylesheet_dir = $themes[$current_theme]['Stylesheet Dir'];
|
||||
$current_template = $themes[$current_theme]['Template'];
|
||||
$current_stylesheet = $themes[$current_theme]['Stylesheet'];
|
||||
?>
|
||||
|
||||
<?php if ($current_parent_theme) { ?>
|
||||
|
Loading…
Reference in New Issue
Block a user