前言
无尽的期盼和无尽的等待中,官方宣布2008年11月10日,也就是光棍节的前一天发布,好囧的时间。。。。
但是在今天实在顶不住诱惑,一咬牙,一跺脚,还是升级到了WordPress 2.7-beta2,囧
紧接着麻烦来了,新特性有很多,我们要修改主题,有的插件也可以下班了(警告,谁再说我是插件狂人我会轰杀他的),反正总之一个字:改!
第一步:更新主题
要体验的东西有很多,后台和核心什么的我不懂,所以从主题开始更新
评论样式
打开head.php文件,在wp_head() 函数之前添加如下函数:
打开single.php和page.php以及其他的需要评论的页面样式(比如:guestbook.php)文件,将其中的
<?php comments_template(); ?>
替换为
<?php comments_template('', true); ?>
这样将生成一个全局名为$comments_by_type的全局变量数组,用于评论和引用的分离
打开comments.php文件对其进行修改,几乎相当于重写了,囧。
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('请不要下载这个页面,谢谢合作');
if (!empty($post->post_password)) { // 如果是需要密码才能访问的日志
if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // 密码不匹配 ?>
<p class="nocomments">这是一篇加密文章,请输入密码以显示评论
<?php
return;
}
}
?>
<!-- 评论列表开始 -->
<?php if ( have_comments() ) : ?>
<div class="commentlistdiv">
<h1 id="comments"><?php comments_number('沙发还在?!', '还有板凳哦!~', '已有%个人在这里唧唧歪歪' );?> on <?php the_title(); ?></h1>
<?php if (!empty($comments_by_type['comment']) ) : ?>
<ul class="commentlist">
<?php wp_list_comments('type=comment&callback=list_comments'); ?>
</ul>
<?php endif; ?>
</div>
<!-- 评论列表结束 -->
<!-- Trackbacks开始 -->
<?php if (!empty($comments_by_type['pings']) ) : ?>
<div class="post_ping">
<h1>Trackbacks/Pingbacks</h1>
<ol>
<?php wp_list_comments('type=pings&callback=list_pings'); ?>
</ol>
</div>
<?php endif; ?>
<!-- End Trackbacks display -->
<!-- 页脚翻页开始 -->
<div class="nav">
<div class="nav_left"><?php next_comments_link() ?></div>
<div class="nav_right"><?php previous_comments_link() ?></div>
</div>
<!-- 页脚翻页结束 -->
<!--留言框-->
<?php else : ?>
<!-- this is displayed if there are no comments so far -->
<?php if ('open' == $post->comment_status) : ?>
<!-- If comments are open, but there are no comments. -->
<?php else : // comments are closed ?>
<!-- If comments are closed. -->
<?php endif; ?>
<?php endif; ?>
<?php if ('open' == $post->comment_status) : ?>
<div id="respond" class="reply">
<h1><?php comment_form_title( '发表评论', '给%s回复' ); ?></h1>
<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
你必须要<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">登陆</a>后才能发表评论。
<?php else : ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<fieldset>
<?php if ( $user_ID ) : ?>
<p style="line-height: 1.5em">已经以<a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>的身份登陆。<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">注销 </a>
<?php else : ?>
<input type="text" name="author" id="author" value="<?php echo $comment_author; ?/>" tabindex="1" class="replytext" <?php if ($req) echo "aria-required='true'"; ?> /><label for="author">Name <?php if ($req) echo "(required)"; ?></label>
<input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?/>" tabindex="2" class="replytext" <?php if ($req) echo "aria-required='true'"; ?> /><label for="email">Mail <?php if ($req) echo "(required)"; ?></label>
<input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?/>" tabindex="3" class="replytext" /><label for="url">Website</label>
<?php endif; ?>
<textarea name="comment" id="comment" tabindex="4" class="replyarea"></textarea>
<label class="replybar">
<strong>XHTML:</strong><small><?php echo allowed_tags(); ?></small>
<strong>表情:</strong><?php if (function_exists(cs_print_smilies)) {cs_print_smilies();} ?>
</label>
<input name="submit" type="submit" id="submit" tabindex="5" value="写好了!~" class="replybutton" />
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?/>" />
<div id="cancel-comment-reply"><small><?php cancel_comment_reply_link() ?></small></div>
<?php comment_id_fields(); ?>
</p></fieldset>
</form>
</div>
<!-- End Leave a Reply Box -->
<?php endif; // If registration required and not logged in ?>
<?php endif; // if you delete this the sky will fall on your head ?></p>
打开functions.php加入以下代码
<?php
function list_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
global $commentcount;
if(!$commentcount) $commentcount = 0;
$commentcount ++;
global $commentalt;
($commentalt == "alt")?$commentalt="":$commentalt="alt"; ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>" class="header <?php echo $commentalt?>">
<div class="pane_l">
<div class="c_author"><?php comment_author_link() ?></div>
<div class="c_avatar"><?php echo get_avatar( $comment, 32 ); ?></div>
<div class="c_date"><?php comment_date('j F, Y, G:i'); ?></div>
<div class="c_approved"><strong><?php echo $commentcount ?>楼</strong>|<?php if ($comment->comment_approved == '0') : ?>您的评论正在审核ing<?php endif; ?><a href="#comment-<?php comment_ID( ); ?>">#</a><?php edit_comment_link('edit','|',''); ?></div>
</div>
<div class="pane_r">
<?php comment_text() ?>
<?php comment_reply_link(array('depth' => $depth, 'max_depth'=> $args['max_depth'], 'reply_text' => "回复该留言"));?>
</div>
<div class="clear"></div>
</li>
<?php }
//定义Trackbacks样式
function list_pings($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
?>
<li id="comment-<?php comment_ID( ); ?>" class="trackback"><?php comment_author_link(); ?> </li>
<?php } ?>
WordPress 2.7 来了!我们需要做些什么? | ::冰封::...
无尽的期盼和无尽的等待中,官方宣布2008年11月10日,也就是光棍节的前一天发布,好囧的时间。。。。
但是在今天实在顶不住诱惑,一咬牙,一跺脚,还是升级到了WordPress 2.7-beta2,囧
紧接...
WordPress 2.7 来了!我们需要做些什么?...
无尽的期盼和无尽的等待中,官方宣布2008年11月10日,也就是光棍节的前一天发布,好囧的时间。。。。 但是在今天实在顶不住诱惑,一咬牙,一跺脚,还是升级到了WordPress 2.7-beta2,囧 紧接...