本博客现在启用Simple-I-copy主题,来源于林木木的主题Simple-I。其中运用了林木木博客和万戈博客中提到的相关代码技术,今汇总到此文,以备查阅。

1、实现 Ctrl+Enter 快捷发表留言功能
在comments.php的后面添加以下代码:

<script type=”text/javascript”>// <![CDATA[
document.getElementById("comment").onkeydown = function (moz_ev) { var ev = null; if (window.event){ ev = window.event; }else{ ev = moz_ev; } if (ev != null && ev.ctrlKey && ev.keyCode == 13) { document.getElementById("submit").click(); } }
// ]]></script>

如果上述效果无效可尝试以下方法,找到comments.php文件中代码:

<textarea id=”comment” style=”width: 205px; height: 64px;” name=”comment”></textarea>

改成:

<textarea id=”comment” onkeydown=”if(event.ctrlKey&amp;&amp;event.keyCode==13){document.getElementById(‘submit’).click();return false};” name=”comment”></textarea>

2、利用jQuery提高访客评论的用户体验
访客留言之后资料输入框会被隐藏起来, 如同登录了一般. 访客可以选择修改相关资料再进行评论. 给予访客很好的用户体验。

<!– 有资料的访客 –>
<!–?php if ( $comment_author != “” ) : ?–>
<script type=”text/javascript”>// <![CDATA[
function setStyleDisplay(id, status){document.getElementById(id).style.display = status;}
// ]]></script>
<div><!–?php printf(__(‘Welcome back <strong–>%s.’), $comment_author) ?&gt;
<span id=”show_author_info”><a href=”javascript:setStyleDisplay(‘author_info’,”);setStyleDisplay(‘show_author_info’,'none’);setStyleDisplay(‘hide_author_info’,”);”><!–?php _e(‘Change &raquo;’); ?–></a></span>
<span id=”hide_author_info”><a href=”javascript:setStyleDisplay(‘author_info’,'none’);setStyleDisplay(‘show_author_info’,”);setStyleDisplay(‘hide_author_info’,'none’);”><!–?php _e(‘Close &raquo;’); ?–></a></span></div>
<!–?php endif; ?–>

<!– 资料输入框 –>
<div id=”author_info”><input id=”author” name=”author” type=”text” value=”&lt;?php echo $comment_author; ?&gt;” tabindex=”1″ />
<label for=”author”><!–?php _e(‘Name’); ?–> <!–?php if ($req) _e(‘(required)’); ?–></label>&nbsp;

<input id=”email” name=”email” type=”text” value=”&lt;?php echo $comment_author_email; ?&gt;” tabindex=”2″ />
<label for=”email”><!–?php _e(‘E-Mail (will not be published)’);?–> <!–?php if ($req) _e(‘(required)’); ?–></label>

<input id=”url” name=”url” type=”text” value=”&lt;?php echo $comment_author_url; ?&gt;” tabindex=”3″ />
<label for=”url”><!–?php _e(‘Website’); ?–></label>

</div>
<!– 有资料的访客 –>
<!–?php if ( $comment_author != “” ) : ?–>
<script type=”text/javascript”>// <![CDATA[
setStyleDisplay('hide_author_info','none');setStyleDisplay('author_info','none');
// ]]></script>
<!–?php endif; ?–>

需要的朋友把这段代码放到comments.php相关位置即可!

3、实现wp日志分页功能

<!–?php the_content(‘继续阅读 &raquo;’).’); ?–>
<!–?php wp_link_pages(); ?–>