WordPress.org

Make WordPress Core

Changeset 10590


Ignore:
Timestamp:
02/18/2009 09:55:00 PM (9 years ago)
Author:
ryan
Message:

Fix preview for theme installer. see #8652

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/theme-install.php

    r10567 r10590  
    66 * @subpackage Administration
    77 */
     8
     9$themes_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
     10                                'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
     11                                'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
     12                                'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
     13                                'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
     14                                'img' => array('src' => array(), 'class' => array(), 'alt' => array()));
    815
    916/**
     
    258265 */
    259266function display_themes($themes, $page = 1, $totalpages = 1) {
     267    global $themes_allowedtags;
     268
    260269    $type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : '';
    261270    $term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';
     
    299308            $name = wp_kses($theme->name, $themes_allowedtags);
    300309            $desc = wp_kses($theme->description, $themes_allowedtags);
    301             if ( strlen($desc) > 30 )
    302                 $desc =  substr($desc, 0, 30) . '<span class="dots">...</span><span>' . substr($desc, 30) . '</span>';
    303 
     310            //if ( strlen($desc) > 30 )
     311            //  $desc =  substr($desc, 0, 30) . '<span class="dots">...</span><span>' . substr($desc, 30) . '</span>';
     312
     313            $preview_link = $theme->preview_url . '?TB_iframe=true&amp;width=600&amp;height=400';
    304314            $action_links = array();
    305315            $action_links[] = '<a href="' . admin_url('theme-install.php?tab=theme-information&amp;theme=' . $theme->slug .
    306                                 '&amp;TB_iframe=true&amp;width=600&amp;height=800') . '" class="thickbox onclick" title="' .
    307                                 attribute_escape($name) . '">' . __('Install') . '</a>';
    308             $action_links[] = '<a href="' . $theme->preview_url . '&TB_iframe" class="thickbox onclick" title="' .
    309                                 attribute_escape( sprintf(__('Preview %s'), $name) ) . '">' . __('Preview') . '</a>';
     316                                '&amp;TB_iframe=true&amp;width=600&amp;height=800') . '" class="button thickbox onclick">' . __('Install') . '</a>';
     317            $action_links[] = '<a href="' . $preview_link . '" class="button thickbox onclick previewlink">' . __('Preview') . '</a>';
    310318
    311319            $action_links = apply_filters('theme_install_action_links', $action_links, $theme);
    312             $actions = implode ( ' | ', $action_links );
     320            $actions = implode ( ' ', $action_links );
    313321            echo "
    314         <div class='theme-item'>
    315             <h3>{$theme->name}</h3>
    316             <img src='{$theme->screenshot_url}' width='150' /><br />
     322        <div class='theme-item available-theme'>
     323            <a class='thickbox screenshot' href='$preview_link'>
     324            <img src='{$theme->screenshot_url}' width='150' />
     325            </a>
     326            <h3>{$name}</h3>
     327            <span class='action-links'>$actions</span>
    317328            <div class='theme-item-info'>
    318329                {$desc}
    319                 <br class='line' />
    320                 <span class='action-links'>$actions</span>
    321330            </div>
    322331        </div>";
     
    358367function install_theme_information() {
    359368    //TODO: This function needs a LOT of UI work :)
    360     global $tab;
     369    global $tab, $themes_allowedtags;;
    361370
    362371    $api = themes_api('theme_information', array('slug' => stripslashes( $_REQUEST['theme'] ) ));
     
    365374        wp_die($api);
    366375
    367     $themes_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
    368                                 'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
    369                                 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
    370                                 'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
    371                                 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
    372                                 'img' => array('src' => array(), 'class' => array(), 'alt' => array()));
    373376    //Sanitize HTML
    374377    foreach ( (array)$api->sections as $section_name => $content )
  • trunk/wp-admin/js/theme-preview.dev.js

    r10365 r10590  
    1515
    1616        return $('a.thickbox').each( function() {
    17             var href = $(this).parents('.available-theme').find('.previewlink').attr('href');
     17            var href = $(this).attr('href');
    1818            if ( ! href ) return;
    1919            href = href.replace(/&width=[0-9]+/g, '');
     
    2727        var alink = $(this).parents('.available-theme').find('.activatelink'), url = alink.attr('href'), text = alink.html();
    2828
     29        if ( null == text ) text = '';
    2930        $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
    3031        $('#TB_closeAjaxWindow').css({'float':'left'});
  • trunk/wp-admin/js/theme-preview.js

    r10365 r10590  
    1 var thickDims;jQuery(document).ready(function(a){thickDims=function(){var d=a("#TB_window"),c=a(window).height(),b=a(window).width();if(d.size()){d.width(b-90).height(c-60);a("#TB_iframeContent").width(b-90).height(c-90);d.css({"margin-left":"-"+parseInt(((b-90)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){d.css({top:"30px","margin-top":"0"})}}return a("a.thickbox").each(function(){var e=a(this).parents(".available-theme").find(".previewlink").attr("href");if(!e){return}e=e.replace(/&width=[0-9]+/g,"");e=e.replace(/&height=[0-9]+/g,"");a(this).attr("href",e+"&width="+(b-110)+"&height="+(c-100))})};thickDims().click(function(){var c=a(this).parents(".available-theme").find(".activatelink"),b=c.attr("href"),d=c.html();a("#TB_title").css({"background-color":"#222",color:"#cfcfcf"});a("#TB_closeAjaxWindow").css({"float":"left"});a("#TB_ajaxWindowTitle").css({"float":"right"}).append('&nbsp;<a href="'+b+'" target="_top" class="tb-theme-preview-link">'+d+"</a>");a("#TB_iframeContent").width("100%");return false});a(window).resize(function(){thickDims()})});function tb_position(){thickDims()};
     1var thickDims;jQuery(document).ready(function(a){thickDims=function(){var d=a("#TB_window"),c=a(window).height(),b=a(window).width();if(d.size()){d.width(b-90).height(c-60);a("#TB_iframeContent").width(b-90).height(c-90);d.css({"margin-left":"-"+parseInt(((b-90)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){d.css({top:"30px","margin-top":"0"})}}return a("a.thickbox").each(function(){var e=a(this).attr("href");if(!e){return}e=e.replace(/&width=[0-9]+/g,"");e=e.replace(/&height=[0-9]+/g,"");a(this).attr("href",e+"&width="+(b-110)+"&height="+(c-100))})};thickDims().click(function(){var c=a(this).parents(".available-theme").find(".activatelink"),b=c.attr("href"),d=c.html();if(null==d){d=""}a("#TB_title").css({"background-color":"#222",color:"#cfcfcf"});a("#TB_closeAjaxWindow").css({"float":"left"});a("#TB_ajaxWindowTitle").css({"float":"right"}).append('&nbsp;<a href="'+b+'" target="_top" class="tb-theme-preview-link">'+d+"</a>");a("#TB_iframeContent").width("100%");return false});a(window).resize(function(){thickDims()})});function tb_position(){thickDims()};
  • trunk/wp-admin/theme-install.php

    r10567 r10590  
    2323
    2424add_thickbox();
     25wp_enqueue_script( 'theme-preview' );
    2526
    2627//These are the tabs which are shown on the page,
  • trunk/wp-admin/themes.php

    r10150 r10590  
    179179    $activate_text = attribute_escape( sprintf( __('Activate "%s"'), $title ) );
    180180?>
    181         <a href="<?php echo $activate_link; ?>" class="<?php echo $thickbox_class; ?> screenshot">
     181        <a href="<?php echo $preview_link; ?>" class="<?php echo $thickbox_class; ?> screenshot">
    182182<?php if ( $screenshot ) : ?>
    183183            <img src="<?php echo WP_CONTENT_URL . $stylesheet_dir . '/' . $screenshot; ?>" alt="" />
  • trunk/wp-includes/script-loader.php

    r10581 r10590  
    342342        ));
    343343
    344         $scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20090114' );
     344        $scripts->add( 'theme-preview', "/wp-admin/js/theme-preview$suffix.js", array( 'thickbox', 'jquery' ), '20090218' );
    345345        $scripts->add_data( 'theme-preview', 'group', 1 );
    346346
Note: See TracChangeset for help on using the changeset viewer.