diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index 1ca03911c..8e5b731fa 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -49,12 +49,16 @@ if ( isset($page_hook) ) do_action('admin_print_scripts-' . $page_hook); else if ( isset($plugin_page) ) do_action('admin_print_scripts-' . $plugin_page); +else if ( isset($pagenow) ) + do_action('admin_print_scripts-' . $pagenow); do_action('admin_print_scripts'); if ( isset($page_hook) ) do_action('admin_head-' . $page_hook); else if ( isset($plugin_page) ) do_action('admin_head-' . $plugin_page); +else if ( isset($pagenow) ) + do_action('admin_head-' . $pagenow); do_action('admin_head'); ?> diff --git a/wp-admin/comment.php b/wp-admin/comment.php index 72d014703..4e254bb94 100644 --- a/wp-admin/comment.php +++ b/wp-admin/comment.php @@ -21,7 +21,7 @@ case 'editcomment' : $title = __('Edit Comment'); wp_enqueue_script('comment'); - //wp_enqueue_script('thickbox'); + require_once('admin-header.php'); $comment_id = absint( $_GET['c'] ); diff --git a/wp-admin/css/press-this.css b/wp-admin/css/press-this.css index 43357ba3d..44248ee66 100644 --- a/wp-admin/css/press-this.css +++ b/wp-admin/css/press-this.css @@ -1,155 +1,5 @@ - -/* ---------->>> global settings needed for thickbox <<<-----------------------------------------------------------*/ -*{padding: 0; margin: 0;} - -/* ---------->>> thickbox specific link and font settings <<<------------------------------------------------------*/ -#TB_window { -} - -#TB_secondLine { -} - -#TB_overlay { - position: fixed; - z-index:100; - top: 0px; - left: 0px; - background-color:#000; - filter:alpha(opacity=75); - -moz-opacity: 0.75; - opacity: 0.75; - height:100%; - width:100%; -} - -* html #TB_overlay { /* ie6 hack */ - position: absolute; - height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'); -} - -#TB_window { - position: fixed; - background: #ffffff; - z-index: 102; - color:#000000; - display:none; - border: 4px solid #525252; - text-align:left; - top:50%; - left:50%; -} - -* html #TB_window { /* ie6 hack */ -position: absolute; -margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px'); -} - -#TB_window img#TB_Image { - display:block; - margin: 15px 0 0 15px; - border-right: 1px solid #ccc; - border-bottom: 1px solid #ccc; - border-top: 1px solid #666; - border-left: 1px solid #666; -} - -#TB_caption{ - height:25px; - padding:7px 30px 10px 25px; - float:left; -} - -#TB_closeWindow{ - height:25px; - padding:11px 25px 10px 0; - float:right; -} - -#TB_closeAjaxWindow{ - padding:7px 10px 5px 0; - margin-bottom:1px; - text-align:right; - float:right; -} - -#TB_ajaxWindowTitle{ - float:left; - padding:7px 0 5px 10px; - margin-bottom:1px; -} - -#TB_title{ - background-color:#e8e8e8; - height:27px; -} - -#TB_ajaxContent{ - clear:both; - padding:2px 15px 15px 15px; - overflow:auto; - text-align:left; - line-height:1.4em; -} - -#TB_ajaxContent.TB_modal{ - padding:15px; -} - -#TB_ajaxContent p{ - padding:5px 0px 5px 0px; -} - -#TB_load{ - position: fixed; - display:none; - height:13px; - width:208px; - z-index:103; - top: 50%; - left: 50%; - margin: -6px 0 0 -104px; /* -height/2 0 0 -width/2 */ -} - -* html #TB_load { /* ie6 hack */ -position: absolute; -margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px'); -} - -#TB_HideSelect{ - z-index:99; - position:fixed; - top: 0; - left: 0; - background-color:#fff; - border:none; - filter:alpha(opacity=0); - -moz-opacity: 0; - opacity: 0; - height:100%; - width:100%; -} - -* html #TB_HideSelect { /* ie6 hack */ - position: absolute; - height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'); -} - -#TB_iframeContent{ - clear:both; - border:none; - margin-bottom:-1px; - margin-top:1px; - _margin-bottom:1px; -} -/* end jquery thickbox css */ - -/* quickpost css */ - - - - body { -font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; + font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; } /* jquery tabs css */ @@ -169,12 +19,12 @@ font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; /* Skin */ div.ui-tabs-panel { -border: none; -width: 100%; -height: auto; -margin: 0; -padding: 0; -position: relative; + border: none; + width: 100%; + height: auto; + margin: 0; + padding: 0; + position: relative; } .ui-tabs-nav { list-style: none; @@ -256,7 +106,7 @@ margin-top: -2px; } #wphead { -border-top: none; + border-top: none; } .submit input { } diff --git a/wp-admin/gears-manifest.php b/wp-admin/gears-manifest.php index eb510f993..7d96a268d 100644 --- a/wp-admin/gears-manifest.php +++ b/wp-admin/gears-manifest.php @@ -33,13 +33,13 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' ); // applicatio ?> { "betaManifestVersion" : 1, -"version" : "_20080511", +"version" : "_20080520", "entries" : [ { "url" : "wp-admin.css?version=2.6-bleeding" }, { "url" : "rtl.css?version=2.6-bleeding" }, -{ "url" : "../wp-includes/js/thickbox/thickbox.css?ver=20080430" }, +{ "url" : "../wp-includes/js/thickbox/thickbox.css?version=2.6-bleeding" }, { "url" : "css/colors-classic-rtl.css?version=2.6-bleeding" }, { "url" : "css/colors-classic.css?version=2.6-bleeding" }, { "url" : "css/colors-fresh-rtl.css?version=2.6-bleeding" }, @@ -56,6 +56,7 @@ header( 'Content-Type: application/x-javascript; charset=UTF-8' ); // applicatio { "url" : "css/login.css?version=2.6-bleeding" }, { "url" : "css/media-rtl.css?version=2.6-bleeding" }, { "url" : "css/media.css?version=2.6-bleeding" }, +{ "url" : "css/press-this.css?version=2.6-bleeding" }, { "url" : "css/theme-editor-rtl.css?version=2.6-bleeding" }, { "url" : "css/theme-editor.css?version=2.6-bleeding" }, { "url" : "css/upload-rtl.css?version=2.6-bleeding" }, diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 0227a86fc..1a5da5e06 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -167,34 +167,20 @@ function media_buttons() { $audio_title = __('Add Audio'); $out = <<$image_title - $video_title - $audio_title - $media_title + $image_title + $video_title + $audio_title + $media_title EOF; printf($context, $out); } add_action( 'media_buttons', 'media_buttons' ); -function media_buttons_head() { -$siteurl = get_option('siteurl'); -echo "\n"; -} - -add_action( 'admin_print_scripts', 'media_buttons_head' ); +add_action( 'admin_print_scripts-post-new.php', 'add_thickbox' ); +add_action( 'admin_print_scripts-post.php', 'add_thickbox' ); +add_action( 'admin_print_scripts-page-new.php', 'add_thickbox' ); +add_action( 'admin_print_scripts-page.php', 'add_thickbox' ); function media_admin_css() { wp_admin_css('css/media'); diff --git a/wp-admin/js/media-upload.js b/wp-admin/js/media-upload.js index 506faf85e..13630a7c5 100644 --- a/wp-admin/js/media-upload.js +++ b/wp-admin/js/media-upload.js @@ -21,7 +21,10 @@ jQuery(function($) { if ( tbWindow.size() ) { tbWindow.width( W - 50 ).height( H - 45 ); $('#TB_iframeContent').width( W - 50 ).height( H - 75 ); - tbWindow.css({marginLeft: '-' + parseInt((( W - 50 ) / 2),10) + 'px'}); + tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px','top':'20px','margin-top':'0'}); + $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'}); + if ( $.browser.msie && $.browser.version.substr(0,1) < 7 ) + tbWindow.css({'margin-top':document.documentElement.scrollTop+'px'}); }; return $('a.thickbox').each( function() { diff --git a/wp-admin/js/theme-preview.js b/wp-admin/js/theme-preview.js new file mode 100644 index 000000000..2f20043b3 --- /dev/null +++ b/wp-admin/js/theme-preview.js @@ -0,0 +1,44 @@ + +jQuery(function($) { + if ( 'undefined' == typeof $.fn.pngFix ) + $.fn.pngFix = function() { return this; } + + var thickDims = function() { + var tbWindow = $('#TB_window'); + var H = $(window).height(); + var W = $(window).width(); + + if ( tbWindow.size() ) { + tbWindow.width( W - 100 ).height( H - 60 ); + $('#TB_iframeContent').width( W - 100 ).height( H - 90 ); + tbWindow.css({'margin-left': '-' + parseInt((( W - 100 ) / 2),10) + 'px','top':'30px','margin-top':'0'}); + if ( $.browser.msie && $.browser.version.substr(0,1) < 7 ) + tbWindow.css({'margin-top':document.documentElement.scrollTop+'px'}); + }; + + return $('a.thickbox').each( function() { + var href = $(this).parents('.available-theme').find('.previewlink').attr('href'); + if ( ! href ) return; + href = href.replace(/&width=[0-9]+/g, ''); + href = href.replace(/&height=[0-9]+/g, ''); + $(this).attr( 'href', href + '&width=' + ( W - 100 ) + '&height=' + ( H - 100 ) ); + }); + }; + + thickDims() + .click( function() { + var alink = $(this).parents('.available-theme').find('.activatelink'); + var url = alink.attr('href'); + var text = alink.html(); + + $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'}); + $('#TB_closeAjaxWindow').css({'float':'left'}); + $('#TB_ajaxWindowTitle').css({'float':'right'}) + .append(' ' + text + ''); + + $('#TB_iframeContent').width('100%'); + return false; + } ); + + $(window).resize( function() { thickDims() } ); +}); diff --git a/wp-admin/link-add.php b/wp-admin/link-add.php index be3f04037..4b6493b54 100644 --- a/wp-admin/link-add.php +++ b/wp-admin/link-add.php @@ -13,7 +13,6 @@ wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', wp_enqueue_script('link'); wp_enqueue_script('xfn'); -wp_enqueue_script('thickbox'); require('admin-header.php'); ?> diff --git a/wp-admin/link.php b/wp-admin/link.php index bc593f56a..c387a8764 100644 --- a/wp-admin/link.php +++ b/wp-admin/link.php @@ -85,7 +85,6 @@ switch ($action) { case 'edit' : wp_enqueue_script('link'); wp_enqueue_script('xfn'); - wp_enqueue_script('thickbox'); $parent_file = 'edit.php'; $submenu_file = 'link-manager.php'; diff --git a/wp-admin/page-new.php b/wp-admin/page-new.php index 95d49073e..c193aeb4d 100644 --- a/wp-admin/page-new.php +++ b/wp-admin/page-new.php @@ -7,7 +7,6 @@ wp_enqueue_script('autosave'); wp_enqueue_script('page'); if ( user_can_richedit() ) wp_enqueue_script('editor'); -wp_enqueue_script('thickbox'); wp_enqueue_script('media-upload'); wp_enqueue_script('word-count'); diff --git a/wp-admin/page.php b/wp-admin/page.php index b6eef5f47..523ddd7fa 100644 --- a/wp-admin/page.php +++ b/wp-admin/page.php @@ -81,7 +81,6 @@ case 'edit': wp_enqueue_script('page'); if ( user_can_richedit() ) wp_enqueue_script('editor'); - wp_enqueue_script('thickbox'); wp_enqueue_script('media-upload'); wp_enqueue_script('word-count'); diff --git a/wp-admin/post-new.php b/wp-admin/post-new.php index 7d32c8aa7..e342cdf3b 100644 --- a/wp-admin/post-new.php +++ b/wp-admin/post-new.php @@ -7,7 +7,6 @@ wp_enqueue_script('autosave'); wp_enqueue_script('post'); if ( user_can_richedit() ) wp_enqueue_script('editor'); -wp_enqueue_script('thickbox'); wp_enqueue_script('media-upload'); wp_enqueue_script('word-count'); diff --git a/wp-admin/post.php b/wp-admin/post.php index bbc214bbf..c07e1b7ac 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -88,7 +88,6 @@ case 'edit': wp_enqueue_script('post'); if ( user_can_richedit() ) wp_enqueue_script('editor'); - wp_enqueue_script('thickbox'); wp_enqueue_script('media-upload'); wp_enqueue_script('word-count'); diff --git a/wp-admin/press-this.php b/wp-admin/press-this.php index e3ded7f1e..d42952c36 100644 --- a/wp-admin/press-this.php +++ b/wp-admin/press-this.php @@ -194,7 +194,7 @@ if ( empty($_GET['tab']) ) { @@ -29,12 +33,12 @@ $ct = current_theme_info();

-
+
screenshot ) : ?> <?php _e('Current theme preview'); ?>

title, $ct->version, $ct->author) ; ?>

-

description; ?>

+

description; ?>

parent_theme) { ?>

%2$s. The stylesheet files are located in %3$s. %4$s uses templates from %5$s. Changes made to the templates will affect both themes.'), $ct->title, $ct->template_dir, $ct->stylesheet_dir, $ct->title, $ct->parent_theme); ?>

@@ -47,16 +51,31 @@ $ct = current_theme_info();

- +name ) - continue; +$rows = ceil(count($theme_names) / 3); +for ( $row = 1; $row <= $rows; $row++ ) + for ( $col = 1; $col <= 3; $col++ ) + $table[$row][$col] = array_shift($theme_names); + +foreach ( $table as $row => $cols ) { +?> + + $theme_name ) { + $class = array('available-theme'); + if ( $row == 1 ) $class[] = 'top'; + if ( $col == 1 ) $class[] = 'left'; + if ( $row == $rows ) $class[] = 'bottom'; + if ( $col == 3 ) $class[] = 'right'; +?> + + + + +
+ 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true', 'width' => 600, 'height' => 400 ), $preview_link ); + $preview_text = attribute_escape( sprintf( __('Preview of "%s"'), $title ) ); $tags = $themes[$theme_name]['Tags']; + $thickbox_class = 'thickbox'; $activate_link = wp_nonce_url("themes.php?action=activate&template=".urlencode($template)."&stylesheet=".urlencode($stylesheet), 'switch-theme_' . $template); + $activate_text = attribute_escape( sprintf( __('Activate "%s"'), $title ) ); ?> -
-

- - + - + - - -

+ +

+

-

+

+ -
- - +
+ +
url; $_file = ('css/colors-rtl' == $file) ? str_replace('.css','-rtl.css',$_file) : $_file; + } elseif ( 'css/thickbox' == $file ) { + $_file = get_option( 'siteurl' ) . "/wp-includes/js/thickbox/thickbox.css"; } else { $_file = get_option( 'siteurl' ) . "/wp-admin/$file.css"; } @@ -1157,6 +1159,15 @@ function wp_admin_css( $file = 'wp-admin' ) { } } +function add_thickbox() { + wp_enqueue_script( 'thickbox' ); + add_action( 'admin_print_scripts', 'add_thickbox_css' ); +} + +function add_thickbox_css() { + wp_admin_css( 'css/thickbox' ); +} + /** * Outputs the XHTML generator that is generated on the wp_head hook. */ diff --git a/wp-includes/js/thickbox/thickbox.css b/wp-includes/js/thickbox/thickbox.css index dc502a7b4..cadee178d 100644 --- a/wp-includes/js/thickbox/thickbox.css +++ b/wp-includes/js/thickbox/thickbox.css @@ -45,17 +45,19 @@ #TB_window { position: fixed; + background: #ffffff; z-index: 102; color:#000000; display:none; + border: 4px solid #525252; text-align:left; - top:20px; + top:50%; left:50%; } * html #TB_window { /* ie6 hack */ position: absolute; -margin-top: expression(20) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px'); +margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px'); } #TB_window img#TB_Image { @@ -80,24 +82,19 @@ margin-top: expression(20) + (TBWindowMargin = document.documentElement && docum } #TB_closeAjaxWindow{ - padding:7px 10px 5px 0; - margin-bottom:1px; + padding:6px 10px 0; text-align:right; float:right; } #TB_ajaxWindowTitle{ float:left; - padding:7px 0 5px 10px; - margin-bottom:1px; + padding:6px 10px 0; } #TB_title{ background-color:#e8e8e8; height:27px; - border-width: 4px; - border-color: #525252; - border-style: solid solid none; } #TB_ajaxContent{ @@ -155,6 +152,5 @@ margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = d clear:both; border:none; margin-bottom:-1px; - margin-top:1px; _margin-bottom:1px; } diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 5ade668bb..49d3338c2 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -205,6 +205,8 @@ class WP_Scripts { 'updateCompleted' => __('Update completed.'), 'error' => __('Error:') )); + + $this->add( 'theme-preview', '/wp-admin/js/theme-preview.js', array( 'thickbox', 'dimensions' ), '20080515' ); } } diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 2bff937e4..a2eb7aa00 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -479,6 +479,48 @@ function locale_stylesheet() { echo ''; } +function preview_theme() { + if ( ! (isset($_GET['template']) && isset($_GET['preview'])) ) + return; + + if ( !current_user_can( 'switch_themes' ) ) + return; + + $_GET[template] = preg_replace('|[^a-z0-9]|i', '', $_GET[template]); + + add_filter('template', create_function('', "return '$_GET[template]';") ); + + if ( isset($_GET['stylesheet']) ) { + $_GET[stylesheet] = preg_replace('|[^a-z0-9]|i', '', $_GET[stylesheet]); + add_filter('stylesheet', create_function('', "return '$_GET[stylesheet]';") ); + } + + ob_start( 'preview_theme_ob_filter' ); +} +add_action('setup_theme', 'preview_theme'); + +function preview_theme_ob_filter( $content ) { + return preg_replace_callback( "|()|", 'preview_theme_ob_filter_callback', $content ); +} + +function preview_theme_ob_filter_callback( $matches ) { + if ( + ( false !== strpos($matches[3], '/wp-admin/') ) + || + ( false !== strpos($matches[3], '://') && 0 !== strpos($matches[3], get_option('home')) ) + || + ( false !== strpos($matches[3], '/feed/') ) + || + ( false !== strpos($matches[3], '/trackback/') ) + ) + return $matches[1] . "#$matches[2] onclick=$matches[2]return false;" . $matches[4]; + + $link = add_query_arg( array('preview' => 1, 'template' => $_GET['template'], 'stylesheet' => @$_GET['stylesheet'] ), $matches[3] ); + if ( 0 === strpos($link, 'preview=1') ) + $link = "?$link"; + return $matches[1] . attribute_escape( $link ) . $matches[4]; +} + function switch_theme($template, $stylesheet) { update_option('template', $template); update_option('stylesheet', $stylesheet); diff --git a/wp-settings.php b/wp-settings.php index 0f5ce0883..791aada2e 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -425,6 +425,7 @@ $wp_rewrite =& new WP_Rewrite(); */ $wp =& new WP(); +do_action('setup_theme'); /** * Web Path to the current active template directory