Tag Archives: 插件

为Ajax Comments-Reply添加Gravatar

Wordpress 2.5 内置了Gravatar功能,就是用email绑定的通用头像服务。自己用的theme是blog.txt,相当朴素,有新闻报纸的style,默认的comments.php支持Gravatar,但插件Ajax Comments-Reply现在还不支持它,据作者说会加,谁知道猴年马月的事情。反正只是对插件的php文件++–相关语句,一定是这样,没什么难的,自己搞得定!

首先,在function.php文件里查找“avatar”,如下

// Produces an avatar image with the hCard-compliant photo class
{……
$email = get_comment_author_email();
$avatar_size = get_option('blogtxt_avatarsize');
if ( empty($avatar_size) ) $avatar_size = '16';
$avatar = str_replace( "class='avatar", "class='photo avatar", get_avatar( "$email", "$avatar_size" ) );
echo $avatar . ' <span class="fn n">' . $commenter . '</span>';
}

avatar_size就是控制头像大小尺寸,默认的太小,改成64,保存之。

第二步,打开blog.txt原始的comments.php,查找关键字“gravatar”,“avatar”,竟然没有= =。分析blog上的留言后注意到,每个评论都有“wrote”,以它为关键字查找,找到

<?php _e('wrote:', 'blogtxt') ?>

前面有comments相关的语句

<span class="comment-author vcard"><?php blogtxt_commenter_link() ?>

原来在blog.txt里使用的是”comment-author vcard”控制式样,用”blogtxt_commenter_link()”调用评论功能。

第三步,把

<php blogtxt_commenter_link() ?>

copy到Ajax-Comments的comments.php中适当位置。

最后,在css里加上相应的style,不断调整,大功告成!

Update:Ajax Comments-Reply2.62已经更新加入Gravatar功能,默认样式还行!

关闭
E-mail It