欢迎您光临自学哈网,只为分享网络知识教程,供大家学习参考!

「自学哈网」IE浏览器下,让免插件读者墙显示留言者名字

作者 : 自学哈 本文共2540个字,预计阅读时间需要7分钟 2022-11-6 共108人阅读
也想出现在这里? 联系我们

这段免插件读者墙代码原型,确实无此功能,之前改过,后来忘记加了,因为很少用IE看自己的博客,有人提议加上,就改了一下,愿意折腾的可以按下面方法修改。

IE下浏览器下,让免插件读者墙显示留言者名字

这段免插件读者墙代码原型,确实无此功能,之前改过,后来忘记加了,因为很少用IE看自己的WordPress博客,有人提议加上,就改了一下,愿意折腾的可以按下面方法修改:主题中添加的免插件读者墙代码在原型基础上稍作修改添加了external nofollow属性,原出处未知:

<?php$query="SELECT COUNT(comment_ID) AS cnt, comment_author, comment_author_url, comment_author_email FROM (SELECT * FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->posts.ID=$wpdb->comments.comment_post_ID) WHERE comment_date > date_sub( NOW(), INTERVAL 1 MONTH ) AND user_id='0' AND comment_author_email != '' AND post_password='' AND comment_approved='1' AND comment_type='') AS tempcmt GROUP BY comment_author_email ORDER BY cnt DESC LIMIT 10";$wall = $wpdb->get_results($query);foreach ($wallas$comment){if( $comment->comment_author_url )$url = $comment->comment_author_url;else$url="#";$r="rel='external nofollow'";$tmp = "<a href='".$url."' '".$r."' title='".$comment->comment_author." (留下".$comment->cnt."个脚印)'>".get_avatar($comment->comment_author_email, 32)."</a>";$output .= $tmp;}echo$output ;?>

上面代码,未针对IE添加atl属性,参考了一下别人的修改方法,改为:

<?php$query="SELECT COUNT(comment_ID) AS cnt, comment_author, comment_author_url, comment_author_email FROM (SELECT * FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->posts.ID=$wpdb->comments.comment_post_ID) WHERE comment_date > date_sub( NOW(), INTERVAL 1 MONTH ) AND user_id='0' AND comment_author_email != '' AND post_password='' AND comment_approved='1' AND comment_type='') AS tempcmt GROUP BY comment_author_email ORDER BY cnt DESC LIMIT 10";$wall = $wpdb->get_results($query);foreach ($wallas$comment){if( $comment->comment_author_url )$url = $comment->comment_author_url;else$url="#";$r="rel='external nofollow'";$imgsize="32";$tmp = "<a target='_blank' href='".$url."' title='".$comment->comment_author." (留下".$comment->cnt."个脚印)'><img width='".$imgsize ."' height='".$imgsize ."' src='https://www.gravatar.com/avatar.php?gravatar_id=".md5( strtolower($comment->comment_author_email) )."&size=".$imgsize ."&d=identicon&r=G' alt='".$comment->comment_author."(留下".$comment->cnt."个脚印)' /></a>";$output .= $tmp;}echo$output ;?>

具体针对热点新闻2.4版主题修改方法:

打开:top_comment.php及Message.php

找到:

$tmp = "<a href='".$url."' '".$r."' title='".$comment->comment_author." (留下".$comment->cnt."个脚印)'>".get_avatar($comment->comment_author_email, 32)."</a>";

替换为:

$imgsize="32";$tmp = "<a target='_blank' href='".$url."' title='".$comment->comment_author." (留下".$comment->cnt."个脚印)'><img width='".$imgsize ."' height='".$imgsize ."' src='https://www.gravatar.com/avatar.php?gravatar_id=".md5( strtolower($comment->comment_author_email) )."&size=".$imgsize ."&d=identicon&r=G' alt='".$comment->comment_author."(留下".$comment->cnt."个脚印)' /></a>";

改后可以看看效果

本站声明:
本站所有资源来源于网络,分享目的仅供大家学习和交流!如若本站内容侵犯了原著者的合法权益,可联系邮箱976157886@qq.com进行删除。
自学哈专注于免费提供最新的分享知识、网络教程、网络技术的资源分享平台,好资源不私藏,大家一起分享!

自学哈网 » 「自学哈网」IE浏览器下,让免插件读者墙显示留言者名字
也想出现在这里? 联系我们
© 2022 Theme by - 自学哈网 & WordPress Theme. All rights reserved 浙ICP备2022016594号