焦Tang小站主题修改备忘
嗯,这是第一篇正式的文章,主要意图是记录一下应用了PIX主题之后,做了哪些主题源码层面上的修改,以防下次更新之后,覆盖后,还得重新摸索一遍。
针对片刻模块,原主题对每一个片刻自动获取的头像和昵称都是来自于主题的后台设置,即一个设置,并没有根据不同的用户自动提取对应的作者相关信息。为了改变这个情况,需要修改主题文件tpl/content-moment.php(列表页面)中的:
<div class="list_user_meta">
<div class="avatar"><?php echo get_avatar( get_the_author_meta( 'ID' ) ); ?></div>
<div class="name">
<?php the_author(); ?>
<time itemprop="datePublished" datetime="<?php echo get_the_date('c');?>"><?php echo ''.timeago( get_gmt_from_date(get_the_time('Y-m-d G:i:s')) ); ?></time>
</div>
</div>
以及tpl/single-moment.php(单独页面)中的:
<div class="list_user_meta">
<div class="avatar"><?php echo get_avatar( get_the_author_meta( 'ID' ) ); ?></div>
<div class="name">
<?php the_author(); ?>
<time itemprop="datePublished" datetime="<?php echo get_the_date('c');?>"><?php echo ''.timeago( get_gmt_from_date(get_the_time('Y-m-d G:i:s')) ); ?></time>
</div>
</div>
为了让邮件通知模板更加贴近主题,修改了几个关键颜色,主要修改inc/pix-mail.php中的:
function ea_mail_template($content,$parent_id,$comment_id){
$blogname = get_bloginfo('name');//站点名称
$bloghome = get_bloginfo('url');//站点链接
$logo = get_op('mail_logo');
if($logo){//站点LOGO
$head_title = '<img src="'.$logo.'" style="max-width: 260px;">';
} else {
$head_title = '<h1 style="display: inline-block;font-size: 16px;font-family: microsoft yahei; padding: 12px 30px;background: #485dff;color: #fff; border-radius: 3px;">'.$blogname.'</h1>';
}
$comment = get_comment($comment_id);
$author_name = $comment->comment_author;//评论者昵称
$post_id = $comment->comment_post_ID;
$post = get_post($post_id);
$post_title = $post->post_title;//文章标题
$parent_comment = get_comment($parent_id);
$parent_name = $parent_comment->comment_author;//接收者昵称
$parent_content = $parent_comment->comment_content;
$comment_link = htmlspecialchars(get_permalink($post_id));
$html = '<div class="email_warp" style="max-width:540px;width:100%;background: #fdfdff;margin: 0 auto;padding:30px;border: 1px solid #65c4b7;border-radius: 4px;">
<div class="mail_head" style="text-align: center;margin-bottom: 30px;"><a href="'.$bloghome.'" target="_blank">'.$head_title.'</a></div>
<p style="margin:0">Hi, '.$parent_name.' , 您曾在['.$blogname.']的片刻中发表的评论:</p>
<div class="mail_content" style="background: #ebf3f2;padding: 20px 20px;margin-bottom: 40px;margin-top: 10px;"><p style="margin:0">'.$parent_content.'</p></div>
<p style="margin:0">'.$author_name.' 给您的回复如下:</p>
<div class="mail_content" style="background: #ebf3f2;padding: 20px 20px;margin-bottom: 40px;margin-top: 10px;"><p style="margin:0">'.$content.'</p></div>
<p>您可以点击<a style="color: #65c4b7;text-decoration: none;" href="'.$comment_link.'">查看完整回复内容</a></p>
<div class="mail_footer" style="text-align: center;margin-top: 60px;"><p>Copyright © <a href="'.$bloghome.'" target="_blank" style="color: #65c4b7;text-decoration: none;">'.$blogname.'</a></div>
</div>';
return $html;
}
具体修改位置如下:
修改后如图:
为了方便快速返回主页,在user_info标签的div块上增加了点击返回首页的onclick事件,即修改header.php文件的user_info类(位置在最后),具体修改如下:
<div class="user_info" onclick="window.open('https://jt.xiaoten.com','_self')">
空空如也!