首页     ITJOY 博客社区     登录

Posts Tagged ‘theme’

theme-preview插件功能改进

09月 14th, 2008 by brian | 7 Comments | Filed in WordPress, WordPress mu

 

theme-preview是一个允许未登录用户预览主题首页的插件,

现改进了一下,使其也能显示除首页之外的其他页面。

另外加入一个函数,可以调用以显示指定数量个主题资料。

插件效果请看我的 ITjoy 博客社区 的首页,具体调用方法可看插件中介绍。

下载:

theme-preview

Tags: , , , ,

主题选择页面增加搜索功能

09月 10th, 2008 by brian | No Comments | Filed in WordPress, WordPress mu

主题多的时候,挑选主题很麻烦,特别是想要的主题不在第一页的时候,得一页一页的去翻。

搞定wpmu-themes.php 的主题批量激活JS后轮到给 themes.php 动手术了。

1. /wp-admin/themes.php 19行,两个reset( $themes ) 之间的内容改为以下,目的是搜索符合的主题:

reset( $themes );
$theme_all=count($themes); //add by libanglai 20080910
foreach( $themes as $key => $theme ) {

if( isset( $allowed_themes[ wp_specialchars( $theme[ 'Stylesheet' ] ) ] ) == false ) {

unset( $themes[ $key ] );

}

//add by libanglai 20080910  start

else if( isset($_GET['search']) ) {

$str=$themes[ $key ][Name].’,’.$themes[ $key ][Title].’,’.$themes[ $key ][Description].’,’.$themes[ $key ][Author];

$str.=implode(’,',$themes[ $key ]['Tags']);

$str=strtolower($str);

//echo $str.”|”; //for debug

//echo strpos($str,strtolower($_GET['search'])).”<br>”; //for debug

if(strpos($str,strtolower($_GET['search']))===false ){

unset( $themes[ $key ] );

}

 }

//end add by libanglai 20080910 

}
reset( $themes );
$theme_show=count($themes); //add by libanglai 20080910

 

2. 62行 <?php if ( ! validate_current_theme() ) : ?> 之前加入以下内容,目的是加上搜索框

 

<!–for search  themes, add by libanglai //–>

<form action=’themes.php’ method=’get’ name=’form1′>

<div id=”message0″ class=”updated fade”><p><?php _e(’SEARCH THEMES: You can enter a word to search for the themes that name,description or tags include this word.’); ?>

<input type=input name=’search’ value=’<?php echo $_GET['search'];?>’><input type=submit value=”<?php _e(”Search”); ?>”>

</p></div>

</form>

<!– end //—>

 

3. 128行要改一下,否则搜索结果只有1个时不会显示

<?php if ( 1 < $theme_total ) { ?>

改为:

<?php if ( 1 <= $theme_total ) {//edit by libanglai 20080910 ?>

4. 117行改一下,让它显示搜索结果数和主题总数:

<h2><?php _e(’Available Themes’); ?></h2>

改为:

<h2><?php _e(’Available Themes’); echo “&nbsp  ”.$theme_show.’ of ‘.$theme_all;//add for show num of search result ?></h2>

修改四个地方,都没动到wordpress原有的代码,手术还不算大,和效果很不错啊,看下面的图:

 

后台增加搜索主题功能

后台增加搜索主题功能

Tags: , , ,

给主题管理页面增加全部激活/禁用主题功能

09月 10th, 2008 by brian | 5 Comments | Filed in WordPress, WordPress mu

主题多的时候,像我现在有近100个,要一个个启用,手都点断了(radio又那么小);

用下面的js函数可以帮你把所有的主题全部开启或禁用。

需要在 wp-admin/wpmu-themes.php 21行后加入以下两个javascript函数:

<script type=’text/javascript’>

function active_theme_all(){

obj=document.all(”form1″);

for (i=0;i<obj.length;i++){

if(obj[i].type==’radio’ && obj[i].value==’enabled’) obj[i].checked=true;

}

function disnable_theme_all(){

obj=document.all(”form1″);

for (i=0;i<obj.length;i++){

if(obj[i].type==’radio’ && obj[i].value==’disabled’) obj[i].checked=true;

}

}

</script> 

然后在你喜欢的地方添加控制的radio 

<input type=”radio” name=”theme_all” onclick=”active_theme_all();” value=”enabled”><?php _e(’Active’) ?><input type=”radio” name=”theme_all” onclick=”disnable_theme_all();” value=”disabled”>

成功了,效果如下:

 

批量看起主题

批量看起主题

Tags: , ,