[教程] wordpress后台打开缓慢的解决方法(临时)

[复制链接]
发表于 2023-10-30 00:00:00 | 显示全部楼层 |阅读模式

最近打开博客后台,发现后台打开速度很慢。

通过开发者调试工具对网络加载进行检测,发现是由于后台使用了谷歌字体的API。由于谷歌api被墙的缘故,导致我们的浏览器会反复的请求谷歌服务器而无法正常加载页面。

因此简单的解决方案就是禁用谷歌的字体api。

解决方法是添加下面的主题在目前的代码在functions.php:

  1. /禁用Open Sans     
  2. class Disable_Google_Fonts {     
  3. public function __construct() {     
  4. add_filter( 'gettext_with_context', array( $this, 'disable_open_sans' ), 888, 4 );     
  5. }     
  6. public function disable_open_sans( $translations, $text, $context, $domain ) {     
  7. if ( 'Open Sans font: on or off' == $context && 'on' == $text ) {     
  8. $translations = 'off';     
  9. }     
  10. return $translations;     
  11. }     
  12. }     
  13. $disable_google_fonts = new Disable_Google_Fonts;   
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

圆梦公社,专注于为全球华人提供纯粹技术交流的地方,请勿发布任何政治及违法的言论。如有相关侵权、举报、投诉及建议等,请发 E-mail:dzh188@hotmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部