Make WordPress Core

Changeset 7961


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

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

Location:
trunk
Files:
1 added
20 edited

Legend:

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

    r7951 r7961  
    5050else if ( isset($plugin_page) )
    5151        do_action('admin_print_scripts-' . $plugin_page);
     52else if ( isset($pagenow) )
     53        do_action('admin_print_scripts-' . $pagenow);
    5254do_action('admin_print_scripts');
    5355
    … …  
    5658else if ( isset($plugin_page) )
    5759        do_action('admin_head-' . $plugin_page);
     60else if ( isset($pagenow) )
     61        do_action('admin_head-' . $pagenow);
    5862do_action('admin_head');
    5963?>
  • trunk/wp-admin/comment.php

    r7755 r7961  
    2222
    2323        wp_enqueue_script('comment');
    24         //wp_enqueue_script('thickbox');
     24
    2525        require_once('admin-header.php');
    2626
  • trunk/wp-admin/css/press-this.css

    r7957 r7961  
    1 
    2 /* ---------->>> global settings needed for thickbox <<<-----------------------------------------------------------*/
    3 *{padding: 0; margin: 0;}
    4 
    5 /* ---------->>> thickbox specific link and font settings <<<------------------------------------------------------*/
    6 #TB_window {
    7 }
    8 
    9 #TB_secondLine {
    10 }
    11 
    12 #TB_overlay {
    13         position: fixed;
    14         z-index:100;
    15         top: 0px;
    16         left: 0px;
    17         background-color:#000;
    18         filter:alpha(opacity=75);
    19         -moz-opacity: 0.75;
    20         opacity: 0.75;
    21         height:100%;
    22         width:100%;
    23 }
    24 
    25 * html #TB_overlay { /* ie6 hack */
    26      position: absolute;
    27      height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');
    28 }
    29 
    30 #TB_window {
    31         position: fixed;
    32         background: #ffffff;
    33         z-index: 102;
    34         color:#000000;
    35         display:none;
    36         border: 4px solid #525252;
    37         text-align:left;
    38         top:50%;
    39         left:50%;
    40 }
    41 
    42 * html #TB_window { /* ie6 hack */
    43 position: absolute;
    44 margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px');
    45 }
    46 
    47 #TB_window img#TB_Image {
    48         display:block;
    49         margin: 15px 0 0 15px;
    50         border-right: 1px solid #ccc;
    51         border-bottom: 1px solid #ccc;
    52         border-top: 1px solid #666;
    53         border-left: 1px solid #666;
    54 }
    55 
    56 #TB_caption{
    57         height:25px;
    58         padding:7px 30px 10px 25px;
    59         float:left;
    60 }
    61 
    62 #TB_closeWindow{
    63         height:25px;
    64         padding:11px 25px 10px 0;
    65         float:right;
    66 }
    67 
    68 #TB_closeAjaxWindow{
    69         padding:7px 10px 5px 0;
    70         margin-bottom:1px;
    71         text-align:right;
    72         float:right;
    73 }
    74 
    75 #TB_ajaxWindowTitle{
    76         float:left;
    77         padding:7px 0 5px 10px;
    78         margin-bottom:1px;
    79 }
    80 
    81 #TB_title{
    82         background-color:#e8e8e8;
    83         height:27px;
    84 }
    85 
    86 #TB_ajaxContent{
    87         clear:both;
    88         padding:2px 15px 15px 15px;
    89         overflow:auto;
    90         text-align:left;
    91         line-height:1.4em;
    92 }
    93 
    94 #TB_ajaxContent.TB_modal{
    95         padding:15px;
    96 }
    97 
    98 #TB_ajaxContent p{
    99         padding:5px 0px 5px 0px;
    100 }
    101 
    102 #TB_load{
    103         position: fixed;
    104         display:none;
    105         height:13px;
    106         width:208px;
    107         z-index:103;
    108         top: 50%;
    109         left: 50%;
    110         margin: -6px 0 0 -104px; /* -height/2 0 0 -width/2 */
    111 }
    112 
    113 * html #TB_load { /* ie6 hack */
    114 position: absolute;
    115 margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px');
    116 }
    117 
    118 #TB_HideSelect{
    119         z-index:99;
    120         position:fixed;
    121         top: 0;
    122         left: 0;
    123         background-color:#fff;
    124         border:none;
    125         filter:alpha(opacity=0);
    126         -moz-opacity: 0;
    127         opacity: 0;
    128         height:100%;
    129         width:100%;
    130 }
    131 
    132 * html #TB_HideSelect { /* ie6 hack */
    133      position: absolute;
    134      height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');
    135 }
    136 
    137 #TB_iframeContent{
    138         clear:both;
    139         border:none;
    140         margin-bottom:-1px;
    141         margin-top:1px;
    142         _margin-bottom:1px;
    143 }
    144 /* end jquery thickbox css */
    145 
    146 /* quickpost css */
    147 
    148 
    149 
    150 
    1511body {
    152 font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
     2        font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
    1533}
    1544/* jquery tabs css */
    … …  
    17020/* Skin */
    17121div.ui-tabs-panel {
    172 border: none;
    173 width: 100%;
    174 height: auto;
    175 margin: 0;
    176 padding: 0;
    177 position: relative;
     22        border: none;
     23        width: 100%;
     24        height: auto;
     25        margin: 0;
     26        padding: 0;
     27        position: relative;
    17828}
    17929.ui-tabs-nav {
    … …  
    257107
    258108#wphead {
    259 border-top: none;
     109        border-top: none;
    260110}
    261111.submit input {
  • trunk/wp-admin/gears-manifest.php

    r7943 r7961  
    3434{
    3535"betaManifestVersion" : 1,
    36 "version" : "<?php echo $version; ?>_20080511",
     36"version" : "<?php echo $version; ?>_20080520",
    3737"entries" : [
    3838<?php echo $default_js; ?>
    … …  
    4040{ "url" : "wp-admin.css?version=2.6-bleeding" },
    4141{ "url" : "rtl.css?version=2.6-bleeding" },
    42 { "url" : "../wp-includes/js/thickbox/thickbox.css?ver=20080430" },
     42{ "url" : "../wp-includes/js/thickbox/thickbox.css?version=2.6-bleeding" },
    4343{ "url" : "css/colors-classic-rtl.css?version=2.6-bleeding" },
    4444{ "url" : "css/colors-classic.css?version=2.6-bleeding" },
    … …  
    5757{ "url" : "css/media-rtl.css?version=2.6-bleeding" },
    5858{ "url" : "css/media.css?version=2.6-bleeding" },
     59{ "url" : "css/press-this.css?version=2.6-bleeding" },
    5960{ "url" : "css/theme-editor-rtl.css?version=2.6-bleeding" },
    6061{ "url" : "css/theme-editor.css?version=2.6-bleeding" },
  • trunk/wp-admin/includes/media.php

    r7922 r7961  
    168168        $out = <<<EOF
    169169
    170         <a href="{$image_upload_iframe_src}&amp;TB_iframe=true&amp;height=500&amp;width=640" class="thickbox" title='$image_title'><img src='images/media-button-image.gif' alt='$image_title' /></a>
    171         <a href="{$video_upload_iframe_src}&amp;TB_iframe=true&amp;height=500&amp;width=640" class="thickbox" title='$video_title'><img src='images/media-button-video.gif' alt='$video_title' /></a>
    172         <a href="{$audio_upload_iframe_src}&amp;TB_iframe=true&amp;height=500&amp;width=640" class="thickbox" title='$audio_title'><img src='images/media-button-music.gif' alt='$audio_title' /></a>
    173         <a href="{$media_upload_iframe_src}&amp;TB_iframe=true&amp;height=500&amp;width=640" class="thickbox" title='$media_title'><img src='images/media-button-other.gif' alt='$media_title' /></a>
     170        <a href="{$image_upload_iframe_src}&amp;TB_iframe=true" class="thickbox" title='$image_title'><img src='images/media-button-image.gif' alt='$image_title' /></a>
     171        <a href="{$video_upload_iframe_src}&amp;TB_iframe=true" class="thickbox" title='$video_title'><img src='images/media-button-video.gif' alt='$video_title' /></a>
     172        <a href="{$audio_upload_iframe_src}&amp;TB_iframe=true" class="thickbox" title='$audio_title'><img src='images/media-button-music.gif' alt='$audio_title' /></a>
     173        <a href="{$media_upload_iframe_src}&amp;TB_iframe=true" class="thickbox" title='$media_title'><img src='images/media-button-other.gif' alt='$media_title' /></a>
    174174
    175175EOF;
    … …  
    178178add_action( 'media_buttons', 'media_buttons' );
    179179
    180 function media_buttons_head() {
    181 $siteurl = get_option('siteurl');
    182 echo "<style type='text/css' media='all'>
    183         @import '{$siteurl}/wp-includes/js/thickbox/thickbox.css?ver=20080430';
    184         div#TB_title {
    185                 background-color: #222222;
    186                 color: #cfcfcf;
    187         }
    188         div#TB_title a, div#TB_title a:visited {
    189                 color: #cfcfcf;
    190         }
    191         #TB_window {
    192                 top: 20px;
    193         }
    194 </style>\n";
    195 }
    196 
    197 add_action( 'admin_print_scripts', 'media_buttons_head' );
     180add_action( 'admin_print_scripts-post-new.php', 'add_thickbox' );
     181add_action( 'admin_print_scripts-post.php', 'add_thickbox' );
     182add_action( 'admin_print_scripts-page-new.php', 'add_thickbox' );
     183add_action( 'admin_print_scripts-page.php', 'add_thickbox' );
    198184
    199185function media_admin_css() {
  • trunk/wp-admin/js/media-upload.js

    r7862 r7961  
    2222                        tbWindow.width( W - 50 ).height( H - 45 );
    2323                        $('#TB_iframeContent').width( W - 50 ).height( H - 75 );
    24                         tbWindow.css({marginLeft: '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
     24                        tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px','top':'20px','margin-top':'0'});
     25                        $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
     26                        if ( $.browser.msie && $.browser.version.substr(0,1) < 7 )
     27                                tbWindow.css({'margin-top':document.documentElement.scrollTop+'px'});
    2528                };
    2629
  • trunk/wp-admin/link-add.php

    r7196 r7961  
    1414wp_enqueue_script('link');
    1515wp_enqueue_script('xfn');
    16 wp_enqueue_script('thickbox');
    1716
    1817require('admin-header.php');
  • trunk/wp-admin/link.php

    r7196 r7961  
    8686                wp_enqueue_script('link');
    8787                wp_enqueue_script('xfn');
    88                 wp_enqueue_script('thickbox');
    8988
    9089                $parent_file = 'edit.php';
  • trunk/wp-admin/page-new.php

    r7854 r7961  
    88if ( user_can_richedit() )
    99        wp_enqueue_script('editor');
    10 wp_enqueue_script('thickbox');
    1110wp_enqueue_script('media-upload');
    1211wp_enqueue_script('word-count');
  • trunk/wp-admin/page.php

    r7854 r7961  
    8282        if ( user_can_richedit() )
    8383                wp_enqueue_script('editor');
    84         wp_enqueue_script('thickbox');
    8584        wp_enqueue_script('media-upload');
    8685        wp_enqueue_script('word-count');
  • trunk/wp-admin/post-new.php

    r7854 r7961  
    88if ( user_can_richedit() )
    99        wp_enqueue_script('editor');
    10 wp_enqueue_script('thickbox');
    1110wp_enqueue_script('media-upload');
    1211wp_enqueue_script('word-count');
  • trunk/wp-admin/post.php

    r7854 r7961  
    8989        if ( user_can_richedit() )
    9090                wp_enqueue_script('editor');
    91         wp_enqueue_script('thickbox');
    9291        wp_enqueue_script('media-upload');
    9392        wp_enqueue_script('word-count');
  • trunk/wp-admin/press-this.php

    r7957 r7961  
    195195<?php
    196196        wp_enqueue_script('jquery-ui-tabs');
    197         wp_enqueue_script('thickbox');
     197        add_thickbox();
    198198        wp_enqueue_script('post');
    199199        do_action('admin_print_scripts');
  • 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
  • trunk/wp-admin/wp-admin.css

    r7951 r7961  
    5353}
    5454
    55 .available-theme {
    56         width: 30%;
    57         margin: 0 1em;
    58         float: left;
    59         text-align: center;
    60         height: 28em;
    61         overflow: hidden;
     55table#availablethemes {
     56        border-spacing: 0px;
     57        border: none;
     58        border-top: 1px solid #ccc;
     59        border-bottom: 1px solid #ccc;
     60        margin: 10px auto;
     61}
     62td.available-theme {
     63        vertical-align: top;
     64        width: 240px;
     65        margin: 0;
     66        padding: 20px;
     67        text-align: left;
     68}
     69table#availablethemes td {
     70        border: 1px solid #eee;
     71        border-top: none;
     72}
     73table#availablethemes td.top {
     74        border-top: none;
     75}
     76table#availablethemes td.right {
     77        border-right: none;
     78        border-left: none;
     79}
     80table#availablethemes td.bottom {
     81        border-bottom: none;
     82}
     83table#availablethemes td.left {
     84        border-right: none;
     85        border-left: none;
    6286}
    6387
    6488.available-theme a.screenshot {
    65         width: 250px;
    66         height: 200px;
     89        width: 240px;
     90        height: 180px;
    6791        display: block;
    68         margin: auto;
     92        border: 1px solid #efefef;
    6993        margin-bottom: 10px;
    7094        overflow: hidden;
    71         border-width: 1px;
    72         border-style: solid;
    73 }
    74 
     95}
    7596.available-theme img {
    76         width: 100%;
     97        width: 240px;
     98}
     99.available-theme h3 {
     100        margin: 15px 0 5px;
     101}
     102
     103#current-theme {
     104        margin-top: 1em;
     105}
     106
     107#current-theme a {
     108        border-bottom: none;
     109}
     110
     111#current-theme h3 {
     112        font-size: 17px;
     113        font-weight: normal;
     114        margin: 0;
     115}
     116
     117#current-theme .description {
     118        margin-top: 5px;
     119}
     120
     121#current-theme img {
     122        float: left;
     123        border: 1px solid #666;
     124        margin-right: 1em;
     125        margin-bottom: 1.5em;
     126        width: 150px;
     127}
     128
     129#TB_window #TB_title a.tb-theme-preview-link,
     130#TB_window #TB_title a.tb-theme-preview-link:visited {
     131        font-weight: bold;
     132        color: #999;
     133        text-decoration: none;
     134}
     135
     136#TB_window #TB_title a.tb-theme-preview-link:hover,
     137#TB_window #TB_title a.tb-theme-preview-link:focus {
     138        color: #ccc;
    77139}
    78140
    … …  
    248310        border-width: 1px;
    249311        border-collapse: separate;
    250 }
    251 
    252 #currenttheme img {
    253         float: left;
    254         margin-right: 1em;
    255         margin-bottom: 1.5em;
    256         width: 300px;
    257         border-width: 1px;
    258         border-style: solid;
    259312}
    260313
  • trunk/wp-includes/general-template.php

    r7959 r7961  
    11401140                        $_file = $color->url;
    11411141                        $_file = ('css/colors-rtl' == $file) ? str_replace('.css','-rtl.css',$_file) : $_file;
     1142                } elseif ( 'css/thickbox' == $file ) {
     1143                        $_file = get_option( 'siteurl' ) . "/wp-includes/js/thickbox/thickbox.css";
    11421144                } else {
    11431145                        $_file = get_option( 'siteurl' ) . "/wp-admin/$file.css";
    … …  
    11561158                echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . wp_admin_css_uri( $rtl ) . "' type='text/css' />\n", $rtl );
    11571159        }
     1160}
     1161
     1162function add_thickbox() {
     1163        wp_enqueue_script( 'thickbox' );
     1164        add_action( 'admin_print_scripts', 'add_thickbox_css' );
     1165}
     1166
     1167function add_thickbox_css() {
     1168        wp_admin_css( 'css/thickbox' );
    11581169}
    11591170
  • trunk/wp-includes/js/thickbox/thickbox.css

    r7862 r7961  
    4646#TB_window {
    4747        position: fixed;
     48        background: #ffffff;
    4849        z-index: 102;
    4950        color:#000000;
    5051        display:none;
     52        border: 4px solid #525252;
    5153        text-align:left;
    52         top:20px;
     54        top:50%;
    5355        left:50%;
    5456}
    … …  
    5658* html #TB_window { /* ie6 hack */
    5759position: absolute;
    58 margin-top: expression(20) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px');
     60margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px');
    5961}
    6062
    … …  
    8183
    8284#TB_closeAjaxWindow{
    83         padding:7px 10px 5px 0;
    84         margin-bottom:1px;
     85        padding:6px 10px 0;
    8586        text-align:right;
    8687        float:right;
    … …  
    8990#TB_ajaxWindowTitle{
    9091        float:left;
    91         padding:7px 0 5px 10px;
    92         margin-bottom:1px;
     92        padding:6px 10px 0;
    9393}
    9494
    … …  
    9696        background-color:#e8e8e8;
    9797        height:27px;
    98         border-width: 4px;
    99         border-color: #525252;
    100         border-style: solid solid none;
    10198}
    10299
    … …  
    156153        border:none;
    157154        margin-bottom:-1px;
    158         margin-top:1px;
    159155        _margin-bottom:1px;
    160156}
  • trunk/wp-includes/script-loader.php

    r7956 r7961  
    206206                                'error' => __('Error:')
    207207                        ));
     208                       
     209                        $this->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'dimensions' ), '20080515' );
    208210                }
    209211        }
  • trunk/wp-includes/theme.php

    r7921 r7961  
    480480}
    481481
     482function preview_theme() {
     483        if ( ! (isset($_GET['template']) && isset($_GET['preview'])) )
     484                return;
     485
     486        if ( !current_user_can( 'switch_themes' ) )
     487                return;
     488
     489        $_GET[template] = preg_replace('|[^a-z0-9]|i', '', $_GET[template]);
     490
     491        add_filter('template', create_function('', "return '$_GET[template]';") );
     492
     493        if ( isset($_GET['stylesheet']) ) {
     494                $_GET[stylesheet] = preg_replace('|[^a-z0-9]|i', '', $_GET[stylesheet]);
     495                add_filter('stylesheet', create_function('', "return '$_GET[stylesheet]';") );
     496        }
     497
     498        ob_start( 'preview_theme_ob_filter' );
     499}
     500add_action('setup_theme', 'preview_theme');
     501
     502function preview_theme_ob_filter( $content ) {
     503        return preg_replace_callback( "|(<a.*?href=([\"']))(.*?)([\"'].*?>)|", 'preview_theme_ob_filter_callback', $content );
     504}
     505
     506function preview_theme_ob_filter_callback( $matches ) {
     507        if (
     508                ( false !== strpos($matches[3], '/wp-admin/') )
     509        ||
     510                ( false !== strpos($matches[3], '://') && 0 !== strpos($matches[3], get_option('home')) )
     511        ||
     512                ( false !== strpos($matches[3], '/feed/') )
     513        ||
     514                ( false !== strpos($matches[3], '/trackback/') )
     515        )
     516                return $matches[1] . "#$matches[2] onclick=$matches[2]return false;" . $matches[4];
     517
     518        $link = add_query_arg( array('preview' => 1, 'template' => $_GET['template'], 'stylesheet' => @$_GET['stylesheet'] ), $matches[3] );
     519        if ( 0 === strpos($link, 'preview=1') )
     520                $link = "?$link";
     521        return $matches[1] . attribute_escape( $link ) . $matches[4];
     522}
     523
    482524function switch_theme($template, $stylesheet) {
    483525        update_option('template', $template);
  • trunk/wp-settings.php

    r7947 r7961  
    426426$wp           =& new WP();
    427427
     428do_action('setup_theme');
    428429
    429430/**
Note: See TracChangeset for help on using the changeset viewer.