今天我们来制作评论主题的评论模块。在主题目录Aurelius下新建comments.php,在single.php剪切以下代码,粘贴到comments.php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
<!– Comment’s List –> <h3>Comments</h3> <div class="hr dotted clearfix"> </div> <ol class="commentlist"> <li class="comment"> <div class="gravatar"> <img alt="" src=’images/gravatar.png’ height=’48′ width=’48′ /> <a class="comment-reply-link" href=">Reply</a> </div> <div class="comment_content"> <div class="clearfix"> <cite class="author_name"><a href="">Joe Bloggs</a></cite> <div class="comment-meta commentmetadata">January 6, 2010 at 6:26 am</div> </div> <div class="comment_text"> <p>Donec leo. Aliquam risus elit, luctus vel, interdum vitae, malesuada eget, elit. Nulla vitae ipsum. Donec ligula ante, bibendum sit amet, elementum quis, viverra eu, ante. Fusce tincidunt. Mauris pellentesque, arcu eget feugiat accumsan, ipsum mi molestie orci, ut pulvinar sapien lorem nec dui.</p> </div> </div> </li> </ol> <div class="hr clearfix"> </div> <!– Comment Form –> <form id="comment_form" action="" method="post"> <h3>Add a comment</h3> <div class="hr dotted clearfix"> </div> <ul> <li class="clearfix"> <label for="name">Your Name</label> <input id="name" name="name" type="text" /> </li> <li class="clearfix"> <label for="email">Your Email</label> <input id="email" name="email" type="text" /> </li> <li class="clearfix"> <label for="email">Your Website</label> <input id="website" name="website" type="text" /> </li> <li class="clearfix"> <label for="message">Comment</label> <textarea id="message" name="message" rows="3" cols="40"></textarea> </li> <li class="clearfix"> <!– Add Comment Button –> <a type="submit" class="button medium black right">Add comment</a> </li> </ul> </form> |
在single.php原位置添加代码:
1 |
<?php comments_template(); ?> |
以上语句的作用就是将comments.php里的所有内容导入到single.php中,与直接在single.php写comments.php中的代码效果是一样的。
为了安全起见,不让恶意用户直接打开评论文件,请在comments.php头部添加以下代码:
1 2 3 4 |
<?php if (isset($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Please do not load this page directly. Thanks!'); ?> |
因为WordPress的输出评论函数wp_list_comments()输出的评论代码与我们主题的评论代码不一样的,我们得自定义我们的评论列表,将comments.php中的以下代码删除(以下代码用于列出文章的所有评论):
1 2 3 4 5 6 7 8 9 10 11 |
<li class="comment"> <div class="gravatar"> <img alt="" src=’images/gravatar.png’ height=’48′ width=’48′ /> <a class="comment-reply-link" href=">Reply</a> </div> <div class="comment_content"> <div class="clearfix"> <cite class="author_name"><a href="">Joe Bloggs</a></cite> <div class="comment-meta commentmetadata">January 6, 2010 at 6:26 am</div> </div> <div class="comment_text"> <p>Donec leo. Aliquam risus elit, luctus vel, interdum vitae, malesuada eget, elit. Nulla vitae ipsum. Donec ligul a ante, bibendum sit amet, elementum quis, viverra eu, ante. Fusce tincidunt. Mauris pellentesque, arcu eget feugiat accumsan, ipsum mi molestie orci, ut pulvinar sapien lorem nec dui.</p> </div> </div> </li> |
改成:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?php if (!empty($post->post_password) && $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // if there's a password // and it doesn't match the cookie ?> <li class="decmt-box"> <p><a href="#addcomment">请输入密码再查看评论内容.</a></p> </li> <?php } else if ( !comments_open() ) { ?> <li class="decmt-box"> <p><a href="#addcomment">评论功能已经关闭!</a></p> </li> <?php } else if ( !have_comments() ) { ?> <li class="decmt-box"> <p><a href="#addcomment">还没有任何评论,你来说两句吧</a></p> </li> <?php } else { wp_list_comments('type=comment&callback=aurelius_comment'); } ?> |
以上代码的意思大致也可以看得出来了,就是一大堆 如果…就….,如果以上条件都不满足就列出所有评论。现在将主题文件夹Aurelius中的functions.php中的 ?> ,改成以下代码,如果你之前从本博客下载到的functions.php已经有以下代码则不用再添加:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
function aurelius_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?> <li class="comment" id="li-comment-<?php comment_ID(); ?>"> <div class="gravatar"> <?php if (function_exists('get_avatar') && get_option('show_avatars')) { echo get_avatar($comment, 48); } ?> <?php comment_reply_link(array_merge( $args, array('reply_text' => '回复','depth' => $depth, 'max_depth' => $args['max_depth']))) ?> </div> <div class="comment_content" id="comment-<?php comment_ID(); ?>"> <div class="clearfix"> <?php printf(__('<cite class="author_name">%s</cite>'), get_comment_author_link()); ?> <div class="comment-meta commentmetadata">发表于:<?php echo get_comment_time('Y-m-d H:i'); ?></div> <?php edit_comment_link('修改'); ?> </div> <div class="comment_text"> <?php if ($comment->comment_approved == '0') : ?> <em>你的评论正在审核,稍后会显示出来!</em><br /> <?php endif; ?> <?php comment_text(); ?> </div> </div> <?php } ?> |
以上代码所用到的WordPress函数及相应的说明:
函数名称 | 函数功能 |
get_avatar($comment, 48) | 获取评论者的gravatar头像,尺寸为48 * 48 |
comment_reply_link() | 回复留言的链接 |
get_comment_author_link | 用于获取评论者博客地址 |
get_comment_time | 获取评论发布时间 |
edit_comment_link | 管理员修改评论的链接 |
comment_text() | 输出评论内容 |
好,现在在你的文章页面底部就可以正常地显示评论了!现在我们继续来制作提交评论的表单,将以下代码删除(也就是评论表单的代码):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<!– Comment Form –> <form id="comment_form" action="" method="post"> <h3>Add a comment</h3> <div class="hr dotted clearfix"> </div> <ul> <li class="clearfix"> <label for="name">Your Name</label> <input id="name" name="name" type="text" /> </li> <li class="clearfix"> <label for="email">Your Email</label> <input id="email" name="email" type="text" /> </li> <li class="clearfix"> <label for="email">Your Website</label> <input id="website" name="website" type="text" /> </li> <li class="clearfix"> <label for="message">Comment</label> <textarea id="message" name="message" rows="3" cols="40"></textarea> </li> <li class="clearfix"> <!– Add Comment Button –> <a type="submit" class="button medium black right">Add comment</a> </li> </ul> </form> |
改成:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
<?php if ( !comments_open() ) : // If registration required and not logged in. elseif ( get_option('comment_registration') && !is_user_logged_in() ) : ?> <p>你必须 <a href="<?php echo wp_login_url( get_permalink() ); ?>">登录</a> 才能发表评论.</p> <?php else : ?> <!-- Comment Form --> <form id="commentform" name="commentform" action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post"> <h3>发表评论</h3> <div class="hr dotted clearfix"> </div> <ul> <?php if ( !is_user_logged_in() ) : ?> <li class="clearfix"> <label for="name">昵称</label> <input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="23" tabindex="1" /> </li> <li class="clearfix"> <label for="email">电子邮件</label> <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="23" tabindex="2" /> </li> <li class="clearfix"> <label for="email">网址(选填)</label> <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="23" tabindex="3" /> </li> <?php else : ?> <li class="clearfix">您已登录:<a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="退出登录">退出 »</a></li> <?php endif; ?> <li class="clearfix"> <label for="message">评论内容</label> <textarea id="message comment" name="comment" tabindex="4" rows="3" cols="40"></textarea> </li> <li class="clearfix"> <!-- Add Comment Button --> <a href="javascript:void(0);" onClick="Javascript:document.forms['commentform'].submit()" class="button medium black right">发表评论</a> </li> </ul> <?php comment_id_fields(); ?> <?php do_action('comment_form', $post->ID); ?> </form> <?php endif; ?> |
函数名称 | 函数功能 |
is_user_logged_in | 判断用户是否登录 |
wp_login_url | 博客登录地址 |
get_comment_author_link | 用于获取评论者博客地址 |
$comment_author | 读取cookie,如果该用户之前已经发表过评论则自动帮助用户填写用户名 |
$comment_author_email | 读取cookie,如果该用户之前已经发表过评论则自动帮助用户填写Email |
$comment_author_url | 读取cookie,如果该用户之前已经发表过评论则自动帮助用户填写博客地址 |
do_action(‘comment_form’, $post->ID); | 该函数为某些插件预留 |
wp_logout_url | 退出登录的链接 |
好了,评论模板comments.php制作完毕!最后本次修改后的主题文件下载:
文章目录[隐藏] 本系列教程适合以下人群阅读本系列教程不适合以下人群阅读阅读完本系列教程,你将收获开始制作主题之前,你必须配备以下工具 本教程算是涵盖了WordPress主题模版制作的全过程吧 本系列...
时间:2019/9/7 分类:建站教程 人气:967 评论:1
文章目录[隐藏] 怎么看下面的文件层次结构?主页页面分类标签作者日期页面搜索结果404 (未找到)页面附件页面 在开始制作WordPress主题之前,首先需要了解WordPress主题包含哪些文件。您...
时间:2019/9/7 分类:建站教程 人气:1701 评论:0
要制作WordPress,您需要了解PHP,但无论如何,您的博客页面是一个网页。网页可以在浏览器中显示的原因是因为最终传输到浏览器的终端代码是HTML,CSS和JS。此代码控制浏览器的显示。制作Wor...
时间:2020/2/24 分类:建站教程 人气:2197 评论:2
一个WordPress主题至少包含以下两个文件: style.css index.php 好,现在就开始我们的WordPress主题制作。在你的WordPress目录 wp-content\theme...
时间:2019/9/7 分类:建站教程 人气:525 评论:0
文章目录[隐藏] 1、更改<title>2、更改样式表style.css路径3、添加pingback4、更改博客名称和描述5、添加订阅feed链接6、添加wp_head7、添加Descri...
时间:2019/9/7 分类:建站教程 人气:2033 评论:0
上节内容我们已经弄好了博客的页头header.php,今天我们就一起来制作页脚footer.php。footer.php与header.php差不多,写这个文件的目的也是为了精简代码,提高代码的重用性...
时间:2019/9/10 分类:建站教程 人气:401 评论:0
制作好了header.php 和 footer.php ,今天我们来制作侧边栏sidebar.php。由于侧边栏的可定制性实在是太强了,所以本节内容比较难,我讲解起来也比较困难,有些内容会被略掉! 作...
时间:2021/2/6 分类:建站教程 人气:807 评论:2
文章目录[隐藏] 1、添加文章标题2、添加文章标签3、添加日期4、显示评论数5、添加编辑按钮6、添加文章内容7、阅读全文8、添加文章循环9、添加文章分页10、文章缩略图 前面我们已经制作完成博客所有公...
时间:2021/6/15 分类:建站教程 人气:400 评论:0
文章目录[隐藏] 1、添加文章标题:2、添加文章标签3、添加日期4、显示评论数5、添加编辑按钮6、添加文章内容7、添加返回博客首页和发表评论按钮 今天我们来制作单文章页single.php,有了之前制...
时间:2019/9/7 分类:建站教程 人气:414 评论:0
今天我们来制作评论主题的评论模块。在主题目录Aurelius下新建comments.php,在single.php剪切以下代码,粘贴到comments.php: <!– Comment’s Li...
时间:2019/9/7 分类:建站教程 人气:1417 评论:0
page.php也就是页面,可能大家不太理解页面是什么意思,博客上的所有网页不都是页面吗?我们这里指的页面一个单独的页面,如”关于”、”联系方式”等,可...
时间:2021/6/15 分类:建站教程 人气:1199 评论:4
你有没有群组或者什么的,这里讨论太麻烦了
这个 只能 ipad 用吗,在 iphone 上都配置好了,安装软件的时候出现:此团队中没有带有请求标识符的配置配置文件。
请问,这个SideServer是不是只能用苹果电脑装啊,手上没有苹果电脑怎么办呀!
棒诶
大佬研究一下猩红,我装也也会掉
不是很理解,自己手机导出的ipa?意思是必须用手机下载的才行吗?
从github下载的windows下载,解压找到你说的@后面的内容,修改名字上传,再安装
已经改成zip解压后查看,按照你的提示,把下载下来的ipa改成Alock@net.darkce.app-locker.ipa这样后上传再安装,还是提示无法安装此app,因为无法验证其完整性。