这东西可以通过修改 theme 的 comment.php (路径: Appearance->Editor->Comments(或者其他类似的))来达到目标。

基本原理是这篇文字的内容。

问题是,现在 WP 的评论框非常之省事:

<?php comment_form();?>

这就是评论了。

怎么修改?

自己去魔改 args 即可。

参考 How to Quickly and Easily Customize the WordPress Comments Form,可以知道,可以通过修改参数完成自定义。用法是送一个数组进 comment_form 方法。

修改后Comment如下:

<?php
$comments_args = array(
    'title_reply'=>'Tell us about you!',
    'comment_notes_before'=>'',
    'comment_notes_after'=>'',
    'comment_field'=>'<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea name="comment" id="comment" cols="105" rows="10" tabindex="4"
onkeydown="if(event.ctrlKey&&event.keyCode==13){document.getElementById(\'submit\').click();return false};">
</textarea></p>',
);
comment_form($comments_args);
?>

Update:

现在我们在 macOS 下面, 希望 command + enter 也能实现统一的功能

这其实也很简单. 可以参考这个讨论这个实现

已知 metaKey 就是我们想要的 command, 最粗暴的方法是 ctrlKey/metaKey 取 or, 然后加上 enter 即可:

...
onkeydown="if((event.ctrlKey || event.metaKey)&&event.keyCode==13){document.getElementById(\'submit\').click();return false};">
...

PS: 原作者木木木木木有新博文: WordPress 后台评论 Ctrl+Enter 快捷回复说是jquery实现。 可惜没时间测试了。待有空吧。

Categories: Code

Yu

Ideals are like the stars: we never reach them, but like the mariners of the sea, we chart our course by them.

4 Comments

Era · July 11, 2014 at 08:10

Maxthon 4.0 Maxthon 4.0 Windows XP Windows XP

嗯 。 有的时候就是直接C+E 直接发送。

简搜博客 · April 8, 2013 at 14:08

Google Chrome 25.0.1364.97 Google Chrome 25.0.1364.97 Windows 7 Windows 7

现在好啦 不过我这网页不慢呀

    yu · April 8, 2013 at 14:12

    Google Chrome 26.0.1410.43 Google Chrome 26.0.1410.43 GNU/Linux x64 GNU/Linux x64

    恐怕是小服务器的问题吧 —

简搜博客 · April 8, 2013 at 13:59

Google Chrome 25.0.1364.97 Google Chrome 25.0.1364.97 Windows 7 Windows 7

亲 这博客是咋啦 我咋进来都是白底加黑字呀 布局还是乱的

Leave a Reply to yu Cancel reply

Your email address will not be published. Required fields are marked *