Make WordPress Core


Ignore:
Timestamp:
05/20/2008 05:19:33 PM (17 years ago)
Author:
ryan
Message:

Theme preview and thickbox CSS cleanup. Props azaozz. see #5486

File:
1 edited

Legend:

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

    r7522 r7961  
    1414$title = __('Manage Themes');
    1515$parent_file = 'themes.php';
     16
     17add_thickbox();
     18wp_enqueue_script( 'theme-preview' );
     19
    1620require_once('admin-header.php');
    1721?>
     
    3034<div class="wrap">
    3135<h2><?php _e('Current Theme'); ?></h2>
    32 <div id="currenttheme">
     36<div id="current-theme">
    3337<?php if ( $ct->screenshot ) : ?>
    3438<img src="<?php echo get_option('siteurl') . '/' . $ct->stylesheet_dir . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" />
    3539<?php endif; ?>
    3640<h3><?php printf(_c('%1$s %2$s by %3$s|1: theme title, 2: theme version, 3: theme author'), $ct->title, $ct->version, $ct->author) ; ?></h3>
    37 <p><?php echo $ct->description; ?></p>
     41<p class="description"><?php echo $ct->description; ?></p>
    3842<?php if ($ct->parent_theme) { ?>
    3943    <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>
     
    4852<h2><?php _e('Available Themes'); ?></h2>
    4953<?php if ( 1 < count($themes) ) { ?>
    50 
     54<table id="availablethemes" cellspacing="0" cellpadding="0">
    5155<?php
    5256$style = '';
     
    5559natcasesort($theme_names);
    5660
    57 foreach ($theme_names as $theme_name) {
    58     if ( $theme_name == $ct->name )
    59         continue;
     61$rows = ceil(count($theme_names) / 3);
     62for ( $row = 1; $row <= $rows; $row++ )
     63    for ( $col = 1; $col <= 3; $col++ )
     64        $table[$row][$col] = array_shift($theme_names);
     65
     66foreach ( $table as $row => $cols ) {
     67?>
     68<tr>
     69<?php
     70foreach ( $cols as $col => $theme_name ) {
     71    $class = array('available-theme');
     72    if ( $row == 1 ) $class[] = 'top';
     73    if ( $col == 1 ) $class[] = 'left';
     74    if ( $row == $rows ) $class[] = 'bottom';
     75    if ( $col == 3 ) $class[] = 'right';
     76?>
     77    <td class="<?php echo join(' ', $class); ?>">
     78<?php if ( !empty($theme_name) ) :
    6079    $template = $themes[$theme_name]['Template'];
    6180    $stylesheet = $themes[$theme_name]['Stylesheet'];
     
    6685    $screenshot = $themes[$theme_name]['Screenshot'];
    6786    $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
     87    $preview_link = clean_url( get_option('home') . '/');
     88    $preview_link = add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true', 'width' => 600, 'height' => 400 ), $preview_link );
     89    $preview_text = attribute_escape( sprintf( __('Preview of "%s"'), $title ) );
    6890    $tags = $themes[$theme_name]['Tags'];
     91    $thickbox_class = 'thickbox';
    6992    $activate_link = wp_nonce_url("themes.php?action=activate&amp;template=".urlencode($template)."&amp;stylesheet=".urlencode($stylesheet), 'switch-theme_' . $template);
     93    $activate_text = attribute_escape( sprintf( __('Activate "%s"'), $title ) );
    7094?>
    71 <div class="available-theme">
    72 <h3><a href="<?php echo $activate_link; ?>"><?php echo $title; ?></a></h3>
    73 
    74 <a href="<?php echo $activate_link; ?>" class="screenshot">
     95        <a href="<?php echo $activate_link; ?>" class="<?php echo $thickbox_class; ?> screenshot">
    7596<?php if ( $screenshot ) : ?>
    76 <img src="<?php echo get_option('siteurl') . '/' . $stylesheet_dir . '/' . $screenshot; ?>" alt="" />
     97            <img src="<?php echo ( $tpage == 'stage' ) ? $screenshot : get_option('siteurl') . '/' . $stylesheet_dir . '/' . $screenshot; ?>" alt="" />
    7798<?php endif; ?>
    78 </a>
    79 
    80 <p><?php echo $description; ?></p>
     99        </a>
     100        <h3><a class="<?php echo $thickbox_class; ?>" href="<?php echo $activate_link; ?>"><?php echo $title; ?></a></h3>
     101        <p><?php echo $description; ?></p>
    81102<?php if ( $tags ) : ?>
    82 <p><?php _e('Tags:'); ?> <?php echo join(', ', $tags); ?></p>
     103        <p><?php _e('Tags:'); ?> <?php echo join(', ', $tags); ?></p>
     104        <noscript><p class="themeactions"><a href="<?php echo $preview_link; ?>" title="<?php echo $preview_text; ?>"><?php _e('Preview'); ?></a> <a href="<?php echo $activate_link; ?>" title="<?php echo $activate_text; ?>"><?php _e('Activate'); ?></a></p></noscript>
    83105<?php endif; ?>
    84 </div>
    85 <?php } // end foreach theme_names ?>
    86 
     106        <div style="display:none;"><a class="previewlink" href="<?php echo $preview_link; ?>"><?php echo $preview_text; ?></a> <a class="activatelink" href="<?php echo $activate_link; ?>"><?php echo $activate_text; ?></a></div>
     107<?php endif; // end if not empty theme_name ?>
     108    </td>
     109<?php } // end foreach $cols ?>
     110</tr>
     111<?php } // end foreach $table ?>
     112</table>
    87113<?php } ?>
    88114
Note: See TracChangeset for help on using the changeset viewer.