//隐藏wordpress版本号
remove_action('wp_head', 'wp_generator');
//去除后台没必要的功能
function disable_dashboard_widgets() {
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');//近期评论
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'normal');//近期草稿
remove_meta_box('dashboard_primary', 'dashboard', 'core');//wordpress博客
remove_meta_box('dashboard_secondary', 'dashboard', 'core');//wordpress其它新闻
remove_meta_box('dashboard_right_now', 'dashboard', 'core');//wordpress概况
remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');//wordresss链入链接
remove_meta_box('dashboard_plugins', 'dashboard', 'core');//wordpress链入插件
remove_meta_box('dashboard_quick_press', 'dashboard', 'core');//wordpress快速发布
}
add_action('admin_menu', 'disable_dashboard_widgets');
//移除 WordPress 加载的JS和CSS链接中的版本号
function wpdaxue_remove_cssjs_ver( $src ) {
if( strpos( $src, 'ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'wpdaxue_remove_cssjs_ver', 999 );
add_filter( 'script_loader_src', 'wpdaxue_remove_cssjs_ver', 999 );
//移除自动保存
wp_deregister_script('autosave');
//移除修订版本
remove_action('post_updated','wp_save_post_revision' );
//后台禁用Google Open Sans字体,加速网站
add_filter( 'gettext_with_context', 'wpdx_disable_open_sans', 888, 4 );
function wpdx_disable_open_sans( $translations, $text, $context, $domain ) {
if ( 'Open Sans font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}return $translations;
}
//部分内容进行加密
function e_secret($atts, $content=null){
extract(shortcode_atts(array('key'=>null), $atts));
if(isset($_POST['e_secret_key']) && $_POST['e_secret_key']==$key){
return '
'.$content.'
';
}
else{
return '
';
}
}
add_shortcode('secret','e_secret');
//关闭rss feed功能
function disable_all_feeds() {
wp_die(__('本博客不提供Feed,请访问网站首页!
'));
}
add_action('do_feed', 'disable_all_feeds', 1);
add_action('do_feed_rdf', 'disable_all_feeds', 1);
add_action('do_feed_rss', 'disable_all_feeds', 1);
add_action('do_feed_rss2', 'disable_all_feeds', 1);
add_action('do_feed_atom', 'disable_all_feeds', 1);
//清理header
remove_action( 'wp_head', 'feed_links', 2 ); //去除文章feed
remove_action( 'wp_head', 'rsd_link' ); //针对Blog的远程离线编辑器接口
remove_action( 'wp_head', 'wlwmanifest_link' ); //Windows Live Writer接口
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); //移除后面文章的url
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); //移除最开始文章的url
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );//自动生成的短链接
remove_action( 'wp_head', 'wp_generator' ); // 移除版本号
remove_action('wp_head', 'index_rel_link');//当前文章的索引
remove_action('wp_head', 'feed_links_extra', 3);// 额外的feed,例如category, tag页
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); // 上、下篇.
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );//rel=pre
wp_deregister_script('l10n');
remove_filter('the_content', 'wptexturize');//禁用半角符号自动转换为全角
add_filter('run_wptexturize', '__return_false');//禁用转义
remove_action('wp_head', 'wp_resource_hints', 2);//禁用类似rel='dns-prefetch' href='//fonts.g(oogle)apis.com'
//移除wp-json
add_filter('json_enabled', '__return_false' );
add_filter('json_jsonp_enabled', '__return_false' );
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );
#禁用找回密碼和屏蔽找回密碼按鈕 function.php
function disable_reset_lost_password() {
return false;
}
add_filter( 'allow_password_reset', 'disable_reset_lost_password');
add_action('login_head', 'ygj_login_head');
function ygj_login_head() {
?>
5){
remove_filter('authenticate', 'wp_authenticate_username_password', 20, 3);
remove_filter('authenticate', 'wp_authenticate_email_password', 20, 3);
return new WP_Error('too_many_retries', '已尝试多次失败登录,15分钟后重试!');
}
return $user;
}, 1, 3 );
// Remove Open Sans that WP adds from frontend
if (!function_exists('remove_wp_open_sans')):
function remove_wp_open_sans() {
wp_deregister_style( 'open-sans' );
wp_register_style( 'open-sans', false );
}
// 前台删除Google字体CSS
add_action('wp_enqueue_scripts', 'remove_wp_open_sans');
// 后台删除Google字体CSS
add_action('admin_enqueue_scripts', 'remove_wp_open_sans');
endif;