Make WordPress Core


Ignore:
Timestamp:
09/05/2005 11:33:10 PM (20 years ago)
Author:
matt
Message:

Fix menu annoyance. Clean up themes.php code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/themes.php

    r2763 r2839  
    44if ( isset($_GET['action']) ) {
    55    check_admin_referer();
    6 
     6   
    77    if ('activate' == $_GET['action']) {
    8       if (isset($_GET['template'])) {
    9         update_option('template', $_GET['template']);
    10       }
    11 
    12       if (isset($_GET['stylesheet'])) {
    13         update_option('stylesheet', $_GET['stylesheet']);
    14       }
    15 
     8        if ( isset($_GET['template']) )
     9            update_option('template', $_GET['template']);
     10       
     11        if ( isset($_GET['stylesheet']) )
     12            update_option('stylesheet', $_GET['stylesheet']);
     13       
    1614        do_action('switch_theme', get_current_theme());
    17 
    18       header('Location: themes.php?activated=true');
     15       
     16        header('Location: themes.php?activated=true');
     17        exit;
    1918    }
    20  }
     19}
    2120
    2221$title = __('Manage Themes');
     
    2423require_once('admin-header.php');
    2524?>
     25
    2626<?php if ( ! validate_current_theme() ) : ?>
    2727<div id="message1" class="updated fade"><p><?php _e('The active theme is broken.  Reverting to the default theme.'); ?></p></div>
    28 <?php elseif ( isset($activated) ) : ?>
     28<?php elseif ( isset($_GET['activated']) ) : ?>
    2929<div id="message2" class="updated fade"><p><?php printf(__('New theme activated. <a href="%s">View site &raquo;</a>'), get_bloginfo('home')); ?></p></div>
    3030<?php endif; ?>
     
    3232<?php
    3333$themes = get_themes();
    34 $current_theme = get_current_theme();
    35 $current_title = $themes[$current_theme]['Title'];
    36 $current_version = $themes[$current_theme]['Version'];
    37 $current_parent_theme = $themes[$current_theme]['Parent Theme'];
    38 $current_template_dir = $themes[$current_theme]['Template Dir'];
    39 $current_stylesheet_dir = $themes[$current_theme]['Stylesheet Dir'];
    40 $current_template = $themes[$current_theme]['Template'];
    41 $current_stylesheet = $themes[$current_theme]['Stylesheet'];
    42 $current_screenshot = $themes[$current_theme]['Screenshot'];
     34$ct = current_theme_info();
    4335?>
    4436
     
    4638<h2><?php _e('Current Theme'); ?></h2>
    4739<div id="currenttheme">
    48 <?php if ( $current_screenshot ) : ?>
    49 <img src="<?php echo get_option('siteurl') . '/' . $current_stylesheet_dir . '/' . $current_screenshot; ?>" alt="Current theme preview" />
     40<?php if ( $ct->screenshot ) : ?>
     41<img src="<?php echo get_option('siteurl') . '/' . $ct->stylesheet_dir . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" />
    5042<?php endif; ?>
    51 <h3><?php printf(__('%1$s %2$s by %3$s'), $current_title, $current_version, $themes[$current_theme]['Author']) ; ?></h3>
    52 <p><?php echo $themes[$current_theme]['Description']; ?></p>
    53 <?php if ($current_parent_theme) { ?>
    54     <p><?php printf(__('The template files are located in <code>%2$s</code>.  The stylesheet files are located in <code>%3$s</code>.  <strong>%4$s</strong> uses templates from <strong>%5$s</strong>.  Changes made to the templates will affect both themes.'), $current_theme, $current_template_dir, $current_stylesheet_dir, $current_theme, $current_parent_theme); ?></p>
     43<h3><?php printf(__('%1$s %2$s by %3$s'), $ct->title, $ct->version, $ct->author) ; ?></h3>
     44<p><?php echo $ct->description; ?></p>
     45<?php if ($ct->parent_theme) { ?>
     46    <p><?php printf(__('The template files are located in <code>%2$s</code>.  The stylesheet files are located in <code>%3$s</code>.  <strong>%4$s</strong> uses templates from <strong>%5$s</strong>.  Changes made to the templates will affect both themes.'), $ct->title, $ct->template_dir, $ct->stylesheet_dir, $ct->title, $ct->parent_theme); ?></p>
    5547<?php } else { ?>
    56     <p><?php printf(__('All of this theme&#8217;s files are located in <code>%2$s</code>.'), $current_theme, $current_template_dir, $current_stylesheet_dir); ?></p>
     48    <p><?php printf(__('All of this theme&#8217;s files are located in <code>%2$s</code>.'), $ct->title, $ct->template_dir, $ct->stylesheet_dir); ?></p>
    5749<?php } ?>
    5850</div>
     
    7870    $screenshot = $themes[$theme_name]['Screenshot'];
    7971    $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
     72    $activate_link = "themes.php?action=activate&amp;template=$template&amp;stylesheet=$stylesheet";
    8073?>
    8174<div class="available-theme">
    82 <h3><a href="<?php echo "themes.php?action=activate&amp;template=$template&amp;stylesheet=$stylesheet"; ?>"><?php echo "$title $version"; ?>
    83 <span>
     75<h3><a href="<?php echo $activate_link; ?>"><?php echo "$title $version"; ?></a></h3>
     76
     77<a href="<?php echo $activate_link; ?>" class="screenshot">
    8478<?php if ( $screenshot ) : ?>
    8579<img src="<?php echo get_option('siteurl') . '/' . $stylesheet_dir . '/' . $screenshot; ?>" alt="" />
    8680<?php endif; ?>
    87 </span>
    88 </a></h3>
     81</a>
     82
    8983<p><?php echo $description; ?></p>
    9084</div>
    91 <?php
    92 /*
    93         if ($template == $current_template && $stylesheet == $current_stylesheet) {
    94             $action = '<strong>' . __('Active Theme') . '</strong>';
    95             $current = true;
    96         } else {
    97             $action = "<a href='' title='" . __('Select this theme') . "' class='edit'>" . __('Select') . '</a>';
    98             $current = false;
    99         }
     85<?php } // end foreach theme_names ?>
    10086
    101         $style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
    102         if ($current) $style .= $style == 'alternate' ? ' active' : 'active';
    103         if ($style != '') $style = 'class="' . $style . '"';
    104 
    105         echo "
    106       <tr $style>";
    107 if ( $current )
    108     echo "<td><strong>$title $version</strong></td>";
    109 else
    110     echo "<td></td>";
    111 echo "
    112          <td class=\"auth\">$author</td>
    113          <td class=\"desc\">$description</td>
    114          <td class=\"togl\">$action</td>
    115       </tr>";
    116 */
    117     }
    118 
    119 ?>
    120 
    121 <?php
    122 }
    123 ?>
     87<?php } ?>
    12488
    12589<?php
    12690// List broken themes, if any.
    12791$broken_themes = get_broken_themes();
    128 if (count($broken_themes)) {
     92if ( count($broken_themes) ) {
    12993?>
    13094
     
    161125
    162126<h2><?php _e('Get More Themes'); ?></h2>
    163 <p><?php _e('You can find additional themes for your site in the <a href="http://wordpress.org/extend/themes/">WordPress theme directory</a>. To install a theme you generally just need to upload the theme folder into your <code>wp-content/themes</code> directory. Once a theme is uploaded, you may activate it on this page.'); ?></p>
     127<p><?php _e('You can find additional themes for your site in the <a href="http://wordpress.org/extend/themes/">WordPress theme directory</a>. To install a theme you generally just need to upload the theme folder into your <code>wp-content/themes</code> directory. Once a theme is uploaded, you should see it on this page.'); ?></p>
    164128
    165129</div>
    166130
    167 <?php
    168 include('admin-footer.php');
    169 ?>
     131<?php require('admin-footer.php'); ?>
Note: See TracChangeset for help on using the changeset viewer.