Sierra主题修改记录

1.
/* 改变选中颜色 */::selection {background:#f3a500; color:#fff;}
::-moz-selection {background:#f3a500; color:#fff;}
::-webkit-selection {background:#f3a500; color:#fff;}
/* 滑动条 */
::-webkit-scrollbar-track-piece {
width: 13px;
border-right: 1px solid #eee;
border-left: 1px solid #e4e4e4;
background-color: #f0f0f0;
background-image: -webkit-linear-gradient(left,#f0f0f0,#fff)
}::-webkit-scrollbar {
width: 13px;
height: 13px
}

::-webkit-scrollbar-thumb {
position: relative;
min-height: 25px;
border-radius: 9999px;
background-color: #c2c2c2;
background-clip: padding-box
}

::-webkit-scrollbar-thumb:vertical {
border-top: 0 solid transparent;
border-right: 2px solid transparent;
border-bottom: 0 solid transparent;
border-left: 3px solid transparent
}

::-webkit-scrollbar-thumb:horizontal {
border-top: 3px solid transparent;
border-right: 0 solid transparent;
border-bottom: 2px solid transparent;
border-left: 0 solid transparent
}

::-webkit-scrollbar-thumb:active {
background-color: #7d7d7d
}

 
2.未完成-评论头像旋转

3.app.js添加—ajax使用cdn
<a class=”block-image” href=”‘+a.permalink+'” style=”background-image:url(‘+a.image+’!/both/140×120)”></a><div class=”block-content”>

4.base—-图片使用cdn
function aladdin_get_background_image($post_id,$width = null,$height = null){
if( has_post_thumbnail($post_id) ){
$timthumb_src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id),’full’);
$output = $timthumb_src[0];
//yun
if( pure_get_setting(‘upyun’)){
$pattern =’/http:\/\/(www\.|)dsecret\.com\/wp-([^”\’]*?)\.(jpg|png|gif|jpeg|bmp)/i’;
$replacement = ‘http://sta.dsecret.com/wp-$2.$3’;
$output = preg_replace($pattern, $replacement,$output);
}
//end
} else {
$content = get_post_field(‘post_content’, $post_id);
$defaltthubmnail = get_template_directory_uri().’/images/default.jpg’;
preg_match_all(‘/<img.*?(?: |\\t|\\r|\\n)?src=[\'”]?(.+?)[\'”]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim’, $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
$output = $strResult[1][0];
} else {
$output = $defaltthubmnail;
}
}
if ( $height && $width ) {

$user_qiniu = pure_get_setting(‘qiniu’);

if( $user_qiniu ){
$result = $output . “?imageView2/1/w/{$width}/h/{$height}/q/100”;
} elseif ( pure_get_setting(‘upyun’) ) {
$result = $output . “!/both/{$width}x{$height}”;
}else {
$result = PURE_THEME_URL . “/timthumb.php&#63;src={$output}&#38;w={$width}&#38;h={$height}&#38;zc=1&#38;q=100”;
}

} else {
$result = $output;
}
return $result;
}

5.base—添加代码

//cdn替换
function QiNiuCDN(){
function Rewrite_URI($html){
$pattern =’/http:\/\/(www\.|)dsecret\.com\/wp-([^”\’]*?)\.(js|css|bmp|gif|jpeg|jpg|png)/i’;
$replacement = ‘http://sta.dsecret.com/wp-$2.$3’;
$html = preg_replace($pattern, $replacement,$html);
return $html;
}
if(!is_admin()){
ob_start(“Rewrite_URI”);
}
}
add_action(‘init’, ‘QiNiuCDN’);
//content-max800
add_filter(‘the_content’, ‘QiNiuThumbnail’);
function QiNiuThumbnail($content) {
global $post;
$pattern =”/<img(.*?)src=(‘|\”)(.*?).(bmp|gif|jpeg|jpg|png)(‘|\”)(.*?)>/i”;
$replacement = ‘<img$1src=$2$3.$4!max800$5$6>’;
$content = preg_replace($pattern, $replacement, $content);
return $content;
}

//替换jq库
add_action( ‘init’, ‘jquery_register’ );
function jquery_register() {
if ( !is_admin() ) {
wp_deregister_script( ‘jquery’ );
wp_register_script( ‘jquery’, ( ‘http://cdn.bootcss.com/jquery/2.1.1/jquery.min.js’ ), false, null, true );
wp_enqueue_script( ‘jquery’ );
}
}
//no emoji
remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );
remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );
remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );
//no embed
remove_action( ‘wp_head’, ‘wp_oembed_add_host_js’ );

//彻底禁止WordPress缩略图
add_filter( ‘add_image_size’, create_function( ”, ‘return 1;’ ) );

// 禁用修订版本
remove_action(‘post_updated’, ‘wp_save_post_revision’,10,1);
//头像缓存到本地
function fa_cache_avatar($avatar, $id_or_email, $size, $default, $alt)
{
$avatar = str_replace(array(“www.gravatar.com”, “0.gravatar.com”, “1.gravatar.com”, “2.gravatar.com”), “secure.gravatar.com”, $avatar);
$tmp = strpos($avatar, ‘http’);
$url = get_avatar_url( $id_or_email, $size ) ;
$url = str_replace(array(“www.gravatar.com”, “0.gravatar.com”, “1.gravatar.com”, “2.gravatar.com”), “secure.gravatar.com”, $url);
$avatar2x = get_avatar_url( $id_or_email, ( $size * 2 ) ) ;
$avatar2x = str_replace(array(“www.gravatar.com”, “0.gravatar.com”, “1.gravatar.com”, “2.gravatar.com”), “secure.gravatar.com”, $avatar2x);
$g = substr($avatar, $tmp, strpos($avatar, “‘”, $tmp) – $tmp);
$tmp = strpos($g, ‘avatar/’) + 7;
$f = substr($g, $tmp, strpos($g, “?”, $tmp) – $tmp);
$w = home_url();
$e = ABSPATH .’avatar/’. $size . ‘*’. $f .’.jpg’;
$e2x = ABSPATH .’avatar/’. ( $size * 2 ) . ‘*’. $f .’.jpg’;
$t = 1209600;
if ( (!is_file($e) || (time() – filemtime($e)) > $t) && (!is_file($e2x) || (time() – filemtime($e2x)) > $t ) ) {
copy(htmlspecialchars_decode($g), $e);
copy(htmlspecialchars_decode($avatar2x), $e2x);
} else { $avatar = $w.’/avatar/’. $size . ‘*’.$f.’.jpg’;
$avatar2x = $w.’/avatar/’. ( $size * 2) . ‘*’.$f.’.jpg’;
if (filesize($e) < 1000) copy($w.’/avatar/default.png’, $e);
if (filesize($e2x) < 1000) copy($w.’/avatar/default.png’, $e2x);
//getavatartoyun
$pattern =’/http:\/\/(www\.|)dsecret\.com\/avatar\/([^”\’]*?)\.(jpg)/i’;
$replacement = ‘http://sta.dsecret.com/avatar/$2.$3′;
$avatar = preg_replace($pattern, $replacement,$avatar);
$avatar2x = preg_replace($pattern, $replacement,$avatar2x);
//end
$avatar = “<img alt='{$alt}’ src='{$avatar}’ srcset='{$avatar2x}’ class=’avatar avatar-{$size} photo’ height='{$size}’ width='{$size}’ />”;
}
return $avatar;
}
add_filter(‘get_avatar’, ‘fa_cache_avatar’,1,5);

6.邮件通知

function mail_smtp( $phpmailer ) {
$phpmailer->FromName = ‘Doctor\’s Secret’; //发件人
$phpmailer->Host = ‘smtp.qq.com’; //修改为你使用的SMTP服务器
$phpmailer->Port = 465; //SMTP端口
$phpmailer->Username = ‘god@dsecret.com’; //邮箱账户
$phpmailer->Password = ‘Haoyeniubi123’; //邮箱密码
$phpmailer->From = ‘god@dsecret.com’; //你的邮箱
$phpmailer->SMTPAuth = true;
$phpmailer->SMTPSecure = ‘ssl’; //tls or ssl (port=25留空,465为ssl)
$phpmailer->IsSMTP();
}
add_action(‘phpmailer_init’, ‘mail_smtp’);
function comment_mail_notify($comment_id) {
$comment = get_comment($comment_id);
$parent_id = $comment->comment_parent ? $comment->comment_parent : ”;
$spam_confirmed = $comment->comment_approved;
if (($parent_id != ”) && ($spam_confirmed != ‘spam’)) {
$wp_email = ‘no-reply@’ . preg_replace(‘#^www\.#’, ”, strtolower($_SERVER[‘SERVER_NAME’]));
$to = trim(get_comment($parent_id)->comment_author_email);
$subject = ‘你在 [‘ . get_option(“blogname”) . ‘] 的留言有了新回复’;
$message = ‘<table class=”email” style=” width: 600px; margin-top: 10px; margin-right: auto; margin-bottom: 0; margin-left: auto; font-size: 16px; line-height: 1.4; font-weight: 300 ; ; ; ; ; ; ; ; ; “>
<tbody>
<tr>
<td style=”padding-top:40px;padding-right:5%;padding-bottom:46px;padding-left:5%;color:#333332″>
<div class=”email-header” style=”margin-bottom: 20px;”>
<div class=”email-logo-wrapper” style=”width: 50px; margin-top: 0; margin-right: auto; margin-bottom: 0; margin-left: auto;”>
<img class=”email-logo” style=”display: block; width: 50px;” src=”‘.get_template_directory_uri().’/images/logo.png”>
</div>
</div>
<div>
<p style=”margin-top:0;margin-right:0;margin-bottom:20px;margin-left:0;font-size:18px;line-height:1.4;text-align:center;color:#333332″>’ . trim(get_comment($parent_id)->comment_author) . ‘,你好。</p>
<p><span style=”color:#333332;”>’ . trim($comment->comment_author) . ‘</span> 在文章 <strong style=”font-weight:bold”>’ . get_the_title($comment->comment_post_ID) . ‘</strong> 回复了您。</p>
<hr style=”width:50px;border:0;border-bottom:1px solid #e5e5e5;margin-bottom:35px;margin-top:20px”>
<p style=”margin-top:20px;margin-right:0;margin-bottom:20px;margin-left:0″>If you like what you read, keep the conversation going!</p>
<div style=”margin-top:30px;padding-top:26px;border-top:1px solid #e5e5e5;font-size:16px;color:#333332;overflow:hidden”>
<div><a target=”_blank” style=”color:#333332;text-decoration:none;min-height:50px;max-height:50px;display:block;width:50px;border-radius:25px;float:left;margin-left:0;background:#b3b3b1;line-height:0;margin-right:10px” href=”‘ . htmlspecialchars(get_comment_link($parent_id)) . ‘”>’. get_avatar($comment->comment_author_email,50). ‘</a><span style=”font-weight:bold”>’ . trim($comment->comment_content) . ‘</span></div>
<p style=”margin-top:0;margin-right:0;margin-bottom:20px;margin-left:60px;font-size:14px;color:#333332;display:block”></p>
<div style=”padding-top:0;padding-right:0;padding-bottom:0;padding-left:0;margin-top:20px;margin-right:0;margin-bottom:0;margin-left:60px;overflow:hidden”><a target=”_blank” style=”color:#ffffff;text-decoration:none;display:inline-block;min-height:32px;line-height:33px;padding-top:0;padding-right:16px;padding-bottom:0;padding-left:16px;outline:0;background:#3eae5f;font-size:14px;text-align:center;font-style:normal;font-weight:400;border:0;vertical-align:bottom;white-space:nowrap;border-radius:999em” href=”‘ . htmlspecialchars(get_comment_link($parent_id)) . ‘”>View</a></div>
</div>
<div style=”color:#b3b3b1;font-size:14px;text-align:center;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0;margin-top:50px;margin-right:0;margin-left:0″>If you think this response violates,<a target=”_blank” style=”text-decoration:none;color:#3eae5f” href=”‘ . home_url() . ‘”>heres how to report it</a>.</div>
</div>
</td>
</tr>
<tr>
<td style=”padding-top:0;padding-right:0;padding-bottom:0;padding-left:0;font-size:12px;text-align:center;color:#b3b3b1″>
<div style=”padding-top:13px;border-top:1px solid #e5e5e5″>Sent by <a target=”_blank” style=”color:#b3b3b1″ href=”‘ . home_url() . ‘”>’ . get_option(“blogname”) . ‘</a> · Since 2011 </div>
</td>
</tr>
</tbody>
</table>’;
$from = “From: \”” . get_option(‘blogname’) . “\” <$wp_email>”;
$headers = “$from\nContent-Type: text/html; charset=” . get_option(‘blog_charset’) . “\n”;
wp_mail( $to, $subject, $message, $headers );
}
}
add_action(‘comment_post’, ‘comment_mail_notify’);
7.归档页面
<div class=”u-backgroundGrayLightest u-marginBottom50″>
<header class=”hero–page hero–standalone layoutSingleColumn layoutSingleColumn–wide”>
<h1 class=”hero-title”>归档</h1>
<p class=”hero-description”>本站所有文章归档</p>
</header>
</div>
<div class=”layoutMultiColumn-container”>
<div class=”layoutMultiColumn layoutMultiColumn–primary”>
<h3 class=”heading-title”>日期</h3>
<div class=”list-archive-wrapper”>
<?php
$args = array(
‘posts_per_page’ => -1,
‘post_type’ => array(‘post’),
‘ignore_sticky_posts’ => 1,
);
$the_query = new WP_Query( $args );
$year=0;
$mon=0;
$all = array();
$output = ”;
$i= 0;
while ( $the_query->have_posts() ) : $the_query->the_post();
$i++;
$year_tmp = get_the_time(‘Y’);
$mon_tmp = get_the_time(‘n’);
$y = $year;
$m = $mon;
if ($mon != $mon_tmp && $mon > 0) $output .= ‘</ul></div>’;
if ($year != $year_tmp) { // 输出年份
$year = $year_tmp;
$all[$year] = array();
}
if ($mon != $mon_tmp) { // 输出月份
$i = 0;
$mon = $mon_tmp;
$output .= “<div class=’list list–archive’><h3 class=’month-title’>” . $year . ‘ – ‘ . $mon . ‘<a class=”u-floatRight” href=”/’ . $year . ‘/’ . $mon . ‘”>查看当月全部文章</a></h3>’ . “<ul class=’blockGroup is-ordered’>” ;
}
if($i < 5) :
$output .= ‘<li class=”archive-item”><a class=”archive-item-title” href=”‘.get_permalink() .'”>’ . get_the_title() . ‘</a><span class=”v-floatRight archive-item-meta”> – ‘ . custom_the_views($post->ID) . ‘ reads / ‘ . get_comments_number() .’ responses</span></li>’;
endif;
endwhile;
wp_reset_postdata();
$output .= ‘</ul></div>’;
echo $output; ?>
</div>
</div>
<div class=”layoutMultiColumn layoutMultiColumn–secondary”>
<h3 class=”heading-title”>分类</h3>
<ul>
<?php $cateogries = get_categories(array(‘hide_empty’=>0));
foreach ($cateogries as $key => $category) { ?>
<li class=”card card-collection card–small”>
<?php if( is_category_has_thumb($category->term_id) ) :?>
<div class=”card-imageWrapper”>
<img class=”avatar-image avatar–roundedRectangle” src=”<?php echo pure_get_category_thumb($category->term_id,64,64)?>”>
</div>
<?php endif; ?>
<div class=”card-content”>
<h3 class=”card-name”>
<a class=”link link–primary” href=”<?php echo get_category_link( $category->term_id );?>”><?php echo $category->name;?></a>
</h3>
<p class=”card-description”><?php echo $category->description;?></p>
</div>
</li>
<?php } ?>
</ul>
</div>
</div>
<?php get_footer(); ?>

8.logo

9.single页面

注释

<!–
<?php if(has_post_thumbnail()):?>
<p class=”u-textAlignCenter”><?php the_post_thumbnail( ‘full’ ); ?></p>
<?php endif;?>
–>

10.header-layoutLarge

<div class=”collectionHeader-overlayBackground u-textAlignCenter” style=”background-image:url(<?php echo pure_get_category_thumb($term->term_id,2000,380); ?>)”>

11.tpl/template-archives

<img class=”avatar-image avatar–roundedRectangle” src=”<?php echo pure_get_category_thumb($category->term_id,64,64)?>”>

12.404页面

 

0

Related Posts