Modification

Plugins 插件

1 Plugins 插件

NameAuthor
Akismet Anti-SpamAutomattic
Easy WP CleanerNikunj Soni
EnlighterAndi Dittrich
Sync QCloud COS沈唁
Wenprise Better EmailsWordPress 智库
WP Mail SMTPWPForms
WP-China-YesWP中国本土化社区
WPS Hide LoginWPServeur, NicolasKulka, tabrisrp
失效链接检查器WPMU DEV
Updated on Sept. 7 2020

Theme 主题

2 Theme 主题

2.1 Style.css

2.1.1 自定义 – 额外 CSS

/* 修改字体 */
body {
font-family: -apple-system, BlinkMacSystemFont, PingFang SC, Hiragino Sans GB, Microsoft YaHei, helvetica neue, helvetica, ubuntu, roboto, noto, segoe ui, Arial, sans-serif;
}
/* 修改选择文字时的背景颜色 */
::selection {
background: #3c63a4;
}
/* 修改文章中的链接颜色 */
.entry-content a {
color: #3c63a4;
border-bottom: 1px solid #3c63a4;
}

.entry-content a:hover {
color: #0a0813;
border-bottom-color: #0a0813;
}
/* 修改相关文章中的链接颜色 */
.related-post .title span {
color: #3c63a4;
}

.related-post:hover .title span {
color: #0a0813;
border-bottom-color: #0a0813;
}
/* 修改按钮的颜色 */
button,
.button,
input[type="button"],
input[type="submit"] {
background: #3c63a4;
}

button:hover,
.button:hover,
input[type="button"]:hover,
input[type="submit"]:hover {
background: #0a0813;
}
/* 修改评论 checkbox 样式 */
.comment-respond label {
display: block;
font-size: 14px;
}
/* 修改图片描述文字样式 */
.gallery-caption,
.wp-caption-text,
.entry-content figcaption {
font-size: 0.8em;
font-style: italic;
font-weight: bold;
text-align: center;
}
/* 修改图片边框1px */
.wp-block-image img {
border: 1px solid #0a0813;
}

2.1.2 主题编辑器 子主题 style.css

/* 修改父主题第1365行 关键词搜checkbox */
.comment-respond input[type="checkbox"] + label {
	display: inline;
	font-size: 14px;
/*	margin: 0 0 0 5px; */
}

2.2 functions.php

<?php

//替换Gravatar源
//function my_get_avatar( $avatar ) {
//    $avatar = preg_replace("/https:\/\/(secure|\d).gravatar.com\/avatar\//","https://cdn.v2ex.com/gravatar/",$avatar);
//    return $avatar;
//}
//add_filter('get_avatar', 'my_get_avatar');

//禁止缩略图生成
add_filter( 'max_srcset_image_width', create_function( '', 'return 1;' ) );

//保持文章id连续性
function Bing_post_id_continuous_query(){
set_time_limit( 0 );
remove_action( 'publish_post', 'Bing_post_id_continuous' );
query_posts( 'posts_per_page=-1' );
$arr = array();
while( have_posts() ){
the_post();
$post_id = $GLOBALS['post']->ID;
$arr[] = $post_id;
}
wp_reset_query();
$arr = array_reverse( $arr );
$i = 1;
foreach( $arr as $post_id ){
wp_update_post( array(
'ID' => $post_id,
'post_name' => $i++
) );
}
}
if( $_GET['post_id_continuous_query'] == 'yes' && current_user_can( 'level_10' ) ) add_action( 'init', 'Bing_post_id_continuous_query' );

//禁用自动保存
    add_action('wp_print_scripts', 'qgg_not_autosave');
    function qgg_not_autosave() {
        wp_deregister_script('autosave');
    }

//禁用文章修订
    add_filter( 'wp_revisions_to_keep', 'qgg_wp_revisions_to_keep', 10, 2 );
    function qgg_wp_revisions_to_keep( $num, $post ) {
        return 0;
    }

//禁用 WP Editor Google 字体
function remove_gutenberg_styles($translation, $text, $context, $domain)
{
    if($context != 'Google Font Name and Variants' || $text != 'Noto Serif:400,400i,700,700i') {
        return $translation;
    }
    return 'off';
}
add_filter( 'gettext_with_context', 'remove_gutenberg_styles',10, 4);

//古腾堡编辑器默认字体样式
//function custom_admin_css() {
//    echo '<style type="text/css">
//	.editor-rich-text.block-editor-rich-text {
//	    font-family: sans-serif;
//	}
//    </style>';
//}
//add_action('admin_head', 'custom_admin_css');

//替换 WordPress 默认 Emoji 资源地址
function theme_wp_emoji_baseurl( $url ){
    return set_url_scheme('//cos.hxghak.net/emoji/72x72/');
}
add_filter('emoji_url', 'theme_wp_emoji_baseurl');

//WordPress 4.6 新增 SVG 格式资源
function theme_wp_emoji_svgurl($url) {
    return set_url_scheme('//cos.hxghak.net/emoji/svg/');
}
add_filter('emoji_svg_url', 'theme_wp_emoji_svgurl');

//评论框下方 cookie 纪录提示
function comment_form_change_cookies_consent( $fields ) {
	$commenter = wp_get_current_commenter();
	$consent   = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"';
	$fields['cookies'] = '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' .
					 '<label for="wp-comment-cookies-consent">Save my name, email, and website in this browser.</label></p>';
	return $fields;
}
add_filter( 'comment_form_default_fields', 'comment_form_change_cookies_consent' );

//替换 googleapis 源为 dogedoge cdn,直接替换源地址 fonts.googleapis.com 为 fonts.dogedoge.com