IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> PHP知识库 -> 优化访问wordpress后台打开速度慢 - 【全面整理】 -> 正文阅读

[PHP知识库]优化访问wordpress后台打开速度慢 - 【全面整理】

Wordpress打开速度太慢,这个问题一直困扰wordpress初学者。?wordpress的网站打开速度慢要怎么解决? 下面首次整理了关于wordpress后台速度提升的方法。按下面操作反应得到最大化提升。提升WordPress后台打开速度全面解决方案:

一、谷歌相关速度优化:

将下方相关代码添加至主题目录下functions.php中:

1、屏蔽谷歌字体

// 屏蔽谷歌字体
add_filter( 'gettext_with_context', 'wpjam_disable_google_fonts', 888, 4);
function wpjam_disable_google_fonts($translations, $text, $context, $domain ) {
    $google_fonts_contexts = array('Open Sans font: on or off','Lato font: on or off','Source Sans Pro font: on or off','Bitter font: on or off');
    if( $text == 'on' && in_array($context, $google_fonts_contexts ) ){
        $translations = 'off';
    }

    return $translations;
}

2、屏蔽wordpress的API

// 彻底关闭自动更新
add_filter('automatic_updater_disabled', '__return_true');
// 关闭更新检查定时作业
remove_action('init', 'wp_schedule_update_checks');
// 移除已有的版本检查定时作业
wp_clear_scheduled_hook('wp_version_check');
// 移除已有的插件更新定时作业
wp_clear_scheduled_hook('wp_update_plugins');
// 移除已有的主题更新定时作业 
wp_clear_scheduled_hook('wp_update_themes');
// 移除已有的自动更新定时作业 
wp_clear_scheduled_hook('wp_maybe_auto_update');
// 移除后台内核更新检查 
remove_action( 'admin_init', '_maybe_update_core' );
// 移除后台插件更新检查 
remove_action( 'load-plugins.php', 'wp_update_plugins' );
remove_action( 'load-update.php', 'wp_update_plugins' );
remove_action( 'load-update-core.php', 'wp_update_plugins' );
remove_action( 'admin_init', '_maybe_update_plugins' );
 // 移除后台主题更新检查 
remove_action( 'load-themes.php', 'wp_update_themes' );
remove_action( 'load-update.php', 'wp_update_themes' );
remove_action( 'load-update-core.php', 'wp_update_themes' );
remove_action( 'admin_init', '_maybe_update_themes' );

3、禁止古腾堡加载 Google 字体

// 禁止古腾堡加载 Google 字体
add_action('admin_print_styles', function(){
    wp_deregister_style('wp-editor-font');
    wp_register_style('wp-editor-font', '');
});

4、替换 Gravatar 头像的服务器地址

名称	地址
V2EX	https://cdn.v2ex.com/gravatar/
极客族	https://sdn.geekzu.org/avatar/
loli	https://gravatar.loli.net/avatar/
inwao	https://gravatar.inwao.com/avatar/

// 替换 Gravatar 头像的服务器地址
function mytheme_get_avatar( $avatar ) {
    $avatar = preg_replace( "/http://(www|d).gravatar.com/","替换地址",$avatar );
    return $avatar; 
} add_filter( 'get_avatar', 'mytheme_get_avatar' );

二、其他相关速度提升优化:

1、移除后台界面右上角的选项

// 移除后台界面右上角的选项
add_action('in_admin_header', function(){
    add_filter('screen_options_show_screen', '__return_false');
    add_filter('hidden_columns', '__return_empty_array');
});

2、移除后台界面右上角的帮助

// 移除后台界面右上角的帮助
add_action('in_admin_header', function(){
    global $current_screen;
    $current_screen->remove_help_tabs();
});

3、屏蔽站点管理员邮箱验证功能

// 屏蔽站点管理员邮箱验证功能
add_filter('admin_email_check_interval', '__return_false');

4、屏蔽站点Feed

// 屏蔽站点Feed
function wpjam_feed_disabled() {
    wp_die('Feed已经关闭, 请访问网站<a href="'.get_bloginfo('url').'">首页</a>!');
}

add_action('do_feed',        'wpjam_feed_disabled', 1);
add_action('do_feed_rdf',    'wpjam_feed_disabled', 1);
add_action('do_feed_rss',    'wpjam_feed_disabled', 1);
add_action('do_feed_rss2',    'wpjam_feed_disabled', 1);
add_action('do_feed_atom',    'wpjam_feed_disabled', 1);

5、前台不加载语言包

// 屏蔽前台语言包,提升加载速度
add_filter('locale', function($locale) {
    $locale = ( is_admin() ) ? $locale : 'en_US';
    return $locale;
});

6、删除 wp_head 中不重要的代码

// 删除 wp_head 中不重要的代码
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'start_post_rel_link');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'adjacent_posts_rel_link');

7、禁用 Emoji 功能

// 禁用 Emoji 功能
remove_action('admin_print_scripts',    'print_emoji_detection_script');
remove_action('admin_print_styles',    'print_emoji_styles');
remove_action('wp_head',        'print_emoji_detection_script',    7);
remove_action('wp_print_styles',    'print_emoji_styles');
remove_action('embed_head',        'print_emoji_detection_script');
remove_filter('the_content_feed',    'wp_staticize_emoji');
remove_filter('comment_text_rss',    'wp_staticize_emoji');
remove_filter('wp_mail',        'wp_staticize_emoji_for_email');
add_filter( 'emoji_svg_url',        '__return_false' );

以上参考自:企业号? ?整理!

  PHP知识库 最新文章
Laravel 下实现 Google 2fa 验证
UUCTF WP
DASCTF10月 web
XAMPP任意命令执行提升权限漏洞(CVE-2020-
[GYCTF2020]Easyphp
iwebsec靶场 代码执行关卡通关笔记
多个线程同步执行,多个线程依次执行,多个
php 没事记录下常用方法 (TP5.1)
php之jwt
2021-09-18
上一篇文章      下一篇文章      查看所有文章
加:2021-08-26 11:53:54  更:2021-08-26 11:53:56 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/21 3:29:14-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码