把这个放进一个盒子里。wp content/mu插件中的php文件:
add_filter(\'template\', \'check_for_theme_preview\');
add_filter(\'stylesheet\', \'check_for_theme_preview\');
// if you want to display the theme selector
// (this is wrong, you need a custom action in each of your themes, after <body>)
add_action(\'wp_head\', \'display_template_selector\');
// checks for the "theme-preview" argument, and changes the template
function check_for_theme_preview($template){
session_start();
if(isset($_SESSION[\'template\']))
$template = $_SESSION[\'template\'];
// sanitize this!
if(isset($_GET[\'theme-preview\']))
$template = $_GET[\'theme-preview\'];
$_SESSION[\'template\'] = $template;
return $template;
}
// theme selector
function display_template_selector(){
$themes = get_themes(); ?>
<select onchange="document.location.href = this.options[this.selectedIndex].value;">
<?php foreach($themes as $theme_name => $theme_data): ?>
<option value="<?php echo add_query_arg(\'theme-preview\', $theme_data[\'Template\']) ?>"><?php echo $theme_name; ?></option>
<?php endforeach; ?>
</select>
<?php
}
因此,将浏览器指向
http://yoursite.com/?theme-preview=twentyten 将使站点在整个会话中加载该模板。
但是有plugins 在那里做得更好。。。