Touching Comments 插件修改

   

威言威语发布了一款小巧隽永的插件Touching Comments,安装后还是比较美观实用的。

插件介绍

每一条评论,都是一个故事!

大家在不同的时间,不同的故事中,发出一条评论。或许就是这么一些不经意的话语给当下你一丝温暖和感触,我们用这个插件将这些评论选出来,整理成独立页面,方便以后访问时可以让我们重拾当时的心境与温暖。

William. (2023-08-25). WordPress插件:走心评论Touching Comments. https://www.weisay.com/blog/wordpress-plugin-touching-comments.html

使用后根据个人喜好修改touching.php如下:

1、注释掉jQuery引用:

/*function weisay_touching_comments_head_jq() {
print('<script type="text/javascript" src="'.plugin_dir_url( __FILE__ ).'jquery.min.js?ver=3.7.0"></script>
');
}
add_action('wp_head', 'weisay_touching_comments_head_jq', '1');*/

2、注释掉图片:

<!--div class="touching-comments-picture"><img src="<?php echo plugin_dir_url( __FILE__ ) ; ?>images/touching<?php echo rand(1,4)?>.jpg" alt="每一条评论,都是一个故事"></div-->

3、集成进自己网站的评说页面(https://synyan.cn/t/comments):

<!-- mindful comments start -->
<h3 style="text-align: ;" class="grap--h3">走心评论</h3>
	<?php 
		if(function_exists(touchingcomments))
			touchingcomments();
	?>				
<!-- mindful comments stop -->

4、原插件默认20条评论进行分页,分页功能的使用依赖Wordpress启用评论分页功能,如果插件分页点击不生效,检查 后台-设置-讨论-其他评论设置-分页显示评论前面的勾有没有勾上。如果想调整每页评论显示数量,修改touching.php文件,将里面有两处的20改为你想修改的数字。

想去掉分页,只显示前10条。待改。

5、修改touching.css。

ol.touching-comments-list li {
	margin-left: 0;
	padding-bottom: 10px;
	border-bottom: 0;
}
ol.touching-comments-list li:before {
	content: none;
}
ol.touching-comments-list {
	padding-inline-start: 0;
}
ol.touching-comments-list p {
	margin-bottom: 0;
}
ol.touching-comments-list .comment--location {
	display: none;
}
ol.touching-comments-list div.comment-body p {
	display: inline !important;
}
.touching-comments-chosen {
	background: var(--day-gray-06);
}
.touching-comments-chosen span {
	color: var(--day-gray-6);
}

6、评论于&nbsp;&nbsp;•&nbsp;&nbsp;

去掉&nbsp;&nbsp;•&nbsp;&nbsp;

7、改//走心评论

function weisay_touching_comments_list($comment) {
	$cpage1 = get_page_of_comment( $comment->comment_ID, $args );
?>
	<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
		<div id="comment-<?php comment_ID(); ?>" class="comment-body">
			<span class="status-footer"><span><?php comment_author_link() ?></span></span> <?php strip_tags(comment_text()); ?> 《<a href="<?php echo(get_comment_link($comment->comment_ID, [ $cpage ] = $cpage1)); ?>" target="_blank"><?php echo get_the_title($comment->comment_post_ID); ?></a>》 <span class="status-footer"><span>[<?php comment_date('Y-m-d H:j:s') ?>]</span></span>
	</div>
<?php
}
function weisay_touching_comments_end_list() {
		echo '</li>';
}

效果:

入选页面
列表页面

吐个小槽:“走心评论”的英文不应该是Mindful Comments吗……

共有 10 条评论

  1. 拾风

    广东

    有那么一刻有一句话闯进了你的心里,感动了你。求走心展示,哈哈

    九个月前 Safari 16 · Mac OS X 10.15

    回复

    • S

      江苏

      @拾风 已加~

      九个月前 Safari 16 · Mac OS X 10.15

      回复

  2. 子痕

    江苏

    这个插件点赞,良言一句三冬暖。

    九个月前 Microsoft Edge 115 · Windows 10

    回复

    • S

      江苏

      @子痕 装起来都

      九个月前 Safari 16 · Mac OS X 10.15

      回复

  3. 不亦乐乎

    福建

    能文能武,能码能摄。

    八个月前 Google Chrome 116 · Windows 10

    回复

  4. 威言威语

    上海

    哈哈,改的挺好。不错不错。

    八个月前 Microsoft Edge 115 · Windows 10

    回复

  5. 牧羊人

    重庆

    你这好多代码都可以抄一抄哈哈哈哈

    八个月前 Google Chrome 115 · Windows 10

    回复

       

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注