1、gravatar用户头像

拜很多的免费WordPress主题所赐,现在很多朋友使用的WordPress主题,基本都是使用的gravatar头像,很遗憾的是,目前gravatar基本被墙光了。直接套用一下里面的代码就可以排除这个问题了。我们直接在当前主题的functions。php文件,在文件中加入以下代码:

//gravata的头像转换为多说的图片缓存
function get_avatar_uctheme( $avatar ) {
$avatar = preg_replace( "/http:\/\/(www|\d).gravatar.com/" , "http://gravatar.duoshuo.com" , $avatar );
return $avatar ;
}
add_filter( 'get_avatar' , 'get_avatar_uctheme' );

2、谷歌字体

同样是因为被墙而打不开了,同样很多的主题,默认加载了谷歌字体,我们直接移谷歌字体,就可以排除这个原因了。我们直接在当前主题的functions。php文件。在文件中加入以下代码:

//wordpress后台禁用谷歌的字体api
class Uctheme_Disable_Google_Fonts {
public function __construct() {
add_filter( 'gettext_with_context' , array ( $this , 'disable_open_sans' ), 888, 4 );
}
public function disable_open_sans( $translations , $text , $context , $domain ) {
if ( 'Open Sans font: on or off' == $context && 'on' == $text ) {
$translations = 'off' ;
}
return $translations ;
}
}
$disable_google_fonts = new Uctheme_Disable_Google_Fonts;

为了保险起见,我们再加入一段代码,内容如下:

//谷歌字体移除
function remove_open_sans() {
wp_deregister_style( 'open-sans' );
wp_register_style( 'open-sans' , false );
wp_enqueue_style( 'open-sans' , '' );
}
add_action( 'init' , 'remove_open_sans' );

3、后台插件和主题的更新检测

这个功能需要谨慎使用,对后台打开速度慢的影响可以说也是相当有限的,当然,正常情况下,我们如果觉得主题不必要再修改,而插件也没有安装多少的话,可以使用一下。我们直接在当前主题的functions。php文件,在文件中加入以下代码:

//禁止插件或主题检查更新,
add_filter( "pre_http_request" , disable_plugin_request,10,3);
function disable_plugin_request( $a , $b , $c ){
if (isset( $b [ 'body' ][ 'plugins' ]) || isset( $b [ 'body' ][ 'themes' ]))
return array ( 'response' => array ( 'code' =>404));
return false; }

4、插件数量太多

如果您的worpress上安装了很多的插件,不妨将其中一些不必要去除,有一些插件,如果是官方发布的还好,如果是一些个人发布的,您都不知道它在后台作了一些什么样的工作。

5、functions.php函数中插入了些冗余的函数导致加载缓慢

转载:https://blog.csdn.net/weixin_34085658/article/details/86249768?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_title~default-0.control&spm=1001.2101.3001.4242
解决wordpress后台管理访问速度慢的问题:
https://blog.csdn.net/qq_42837890/article/details/106008321
最后修改:2023 年 03 月 21 日
如果觉得我的文章对你有用,请随意赞赏