首页 > wordpress > 给wp-recentcomments做手术

给wp-recentcomments做手术

之前刚换这个皮肤的时候,就安装了wp-recentcomments这个插件,用起来还是很不错的,功能蛮多哦。

不过,我感觉在最新评论那里获取用户的头像有点太占资源了,也许是心理作用吧。

反正,有心人也可以发现,原来我的那个“活跃土著”的版块不见鸟。

原因一样,我感觉头像获取及展示占资源。

啥?你说我为啥不把评论的头像也取消了?呃,这个嘛,总得留一个地方让其存在吧?

呵,不说了,之前Zeric同学就提醒过我,

去掉头像后,默认的样式太丑了原贴地址真是一位热心的好同学啊。 :shock:

于是,参照其网站,自己动手,来给wp-recentcomments做手术。

原代码为:

//core.php line:119 获取信息处
if ($comment->comment_type == 'pingback') {
    $result .= '<li id="rc_item_' . ++$count . '" class="rc_item rc_pingback">' . sprintf('<div class="rc_info"><span class="rc_label">' . __('Pingback:') . '</span> %1$s</div>', get_comment_author_link()) . '</li>';
} else if ($comment->comment_type == 'trackback') {
    $result .= '<li id="rc_item_' . ++$count . '" class="rc_item rc_trackback">' . sprintf('<div class="rc_info"><span class="rc_label">' . __('Trackback:') . '</span> %1$s</div>', get_comment_author_link()) . '</li>';
} else if ($args['post'] == 'true') {
    $result .= '<li id="rc_item_' . ++$count . '" class="rc_item">' . $element_avatar . sprintf('<div class="rc_info"><span class="author_name">%1$s</span> ' . __('on', 'wp-recentcomments') . ' <span class="post_title">%2$s</span></div>', get_comment_author_link(), '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '<div class="rc_excerpt">' . $comment_excerpt . '</div></li>';      
} else {
    $result .= '<li id="rc_item_' . ++$count . '" class="rc_item">' . $element_avatar . sprintf('<div class="rc_info"><span class="author_name">%1$s</span>' . rc_get_author_info() . '</div>', '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . $comment->comment_author . '</a>') . '<div class="rc_excerpt">' . $comment_excerpt . '</div></li>';
}

改后代码为:

        if ($comment->comment_type == 'pingback') {
    $result .= '<li id="rc_item_' . ++$count . '" class="rc_item rc_pingback">' . sprintf(__('Pingback:') . '%1$s', get_comment_author_link()) . '</li>';
} else if ($comment->comment_type == 'trackback') {
    $result .= '<li id="rc_item_' . ++$count . '" class="rc_item rc_trackback">' . sprintf( __('Trackback:') . '%1$s', get_comment_author_link()) . '</li>';
} else if ($args['post'] == 'true') {
    $result .= '<li id="rc_item_' . ++$count . '" class="rc_item">' . $element_avatar . sprintf('%1$s' . __('on', 'wp-recentcomments') . '%2$s', get_comment_author_link().':', '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . get_the_title($comment->comment_post_ID) . '</a>') .$comment_excerpt . '</li>';
} else {
    $result .= '<li id="rc_item_' . ++$count . '" class="rc_item">' . $element_avatar . sprintf('%1$s' . rc_get_author_info().':', '<a href="'. get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . $comment->comment_author . '</a>')  . $comment_excerpt .'</li>';
}

改完后的效果大家已经见到了(见右侧最新评论处),那么改之前的效果。嗯。我去截个图吧。

wp-recentcomments没头像原效果

wp-recentcomments没头像原效果

  1. 粥小卜 五 6th, 2009 @ 23:38 | #1

    哦~~ 呵呵 整到一行里去了

  2. Zeric 五 6th, 2009 @ 23:49 | #2

    哈哈,来咯来咯,确实改过来了嘞,应该改的比我好.
    以后 php 上都得向你学习呢,下次要改东西找你. :lol:

  3. bolo 五 7th, 2009 @ 08:49 | #3

    头像是到外网拉来的,应该不占资源,但有时载入得慢是一个问题。

  4. 陶陶 五 7th, 2009 @ 11:26 | #4

    你的这个‘广告展示’怎么弄的,我怎么没看到BloggerAds里有这样的代码呢?

  5. simaopig 五 7th, 2009 @ 13:10 | #5

    @粥小卜
    嗯呐,仅此而已。呵呵。

    @Zeric
    参照你的改的哈。怎么会比你改的好呢,我就是乱改的。呵。

    @bolo
    是啊,载入的时候我用HTTPFOX看一下,很慢的。

    @陶陶
    是我自己写的啦。在我上一篇文章里有些。呵。
    那个BloggerAds里,是有这贴纸的哈。

  6. Sean[祭奠青春] 五 7th, 2009 @ 16:35 | #6

    小sean前来做高端互访!

  7. simaopig 五 7th, 2009 @ 17:11 | #7

    @Sean[祭奠青春]
    哈好啊,没事就来玩。这里无城管,不咬人。。

  8. 荒野无灯 五 8th, 2009 @ 12:29 | #8

    我倒不觉得在两行丑,我觉得在两行有点占地方@_@

  9. simaopig 五 8th, 2009 @ 12:42 | #9

    @荒野无灯
    是啊。占好多地方。嗯。。

  10. Jutoy 五 8th, 2009 @ 16:51 | #10

    嗯,就是这个载入时间有一点影响。不过我还是喜欢牺牲一点时间来看着大家漂亮的头像哈~~

  11. simaopig 五 8th, 2009 @ 17:02 | #11

    @Jutoy
    呵,我感觉引导用户看留言,比引导用户看头像要有意义。嗯。

  12. micogle 七 1st, 2009 @ 17:17 | #12

    可以请教个问题么?关于评论中,当你把鼠标放在回复的对象名@Jutoy上的时候会显示原贴内容,这是怎么实现的啊??

  13. simaopig 七 1st, 2009 @ 17:28 | #13

    @micogle
    呵,这么客气干什么,这是这款皮肤原作者弄的效果,具体请看iNove 中鼠标悬浮显示 @ 评论 :) :)

  14. micogle 七 1st, 2009 @ 17:56 | #14

    @simaopig 嘿嘿,谢谢啦,我弄了半天也没弄出来~~~ 8)

评论提交中, 请稍候...

留言

可以使用的标签: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackbacks & Pingbacks ( 0 )
  1. 还没有 trackbacks