这东西可以通过修改 theme 的 comment.php (路径: Appearance->Editor->Comments(或者其他类似的))来达到目标。
基本原理是这篇文字的内容。
问题是,现在 WP 的评论框非常之省事:
[php] <?php comment_form();?> [/php]
这就是评论了。
怎么修改?
自己去魔改 args 即可。
参考 How to Quickly and Easily Customize the WordPress Comments Form,可以知道,可以通过修改参数完成自定义。用法是送一个数组进 comment_form 方法。
修改后Comment如下:
[php]
<?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);
?>
[/php]
Update:
现在我们在 macOS 下面, 希望 command + enter 也能实现统一的功能
已知 metaKey 就是我们想要的 command, 最粗暴的方法是 ctrlKey/metaKey 取 or, 然后加上 enter 即可:
[php] ... onkeydown="if((event.ctrlKey || event.metaKey)&&event.keyCode==13){document.getElementById('submit').click();return false};"> ... [/php]
PS: 原作者木木木木木有新博文: WordPress 后台评论 Ctrl+Enter 快捷回复说是jquery实现。 可惜没时间测试了。待有空吧。
Comments · 4