• 武汉加油,中国加油,免费投稿邮箱 creust@creust.com,vps,服务器,vps 推荐

wordpress后台加载速度慢的解决方法

VPS推荐 创启云客 5个月前 (06-16) 1849次浏览 已收录 0个评论 扫描二维码

wordpress后台加载速度慢的解决方法

WordPress 功能强大、扩展性强,这主要得益于其插件众多,易于扩充功能,基本上一个完整网站该有的功能,通过其第三方插件都能实现所有功能;

wordpress 有强大的社区支持,有上千万的开发者贡献和审查 wordpress,所以 wordpress 是安全并且活跃的。

由于静态化较差,确切地说是真正静态化做得不好,所以在访问后台的时候 wordpress 会加载很多接口信息。

当你登陆 wordpress 后台的时候,它会连接 wordpress 官方接口,获取程序更新,主题更新,插件更新,语言包更新等,由于 wordpress 官方服务器在国外,所以说国内用户访问加载极其缓慢,有时候直接假死。

我们需要做的就是屏蔽掉无用的后台查询功能,把以下代码添加到你当前主题目录下的函数文件functions.php中:

<code><span class="com">//去除后台没必要的功能</span></code> <code><span class="kwd">function</span><span class="pln"> disable_dashboard_widgets</span><span class="pun">()</span> <span class="pun">{</span> </code> <code><span class="pln">remove_meta_box</span><span class="pun">(</span><span class="str">'dashboard_recent_comments'</span><span class="pun">,</span> <span class="str">'dashboard'</span><span class="pun">,</span> <span class="str">'normal'</span><span class="pun">);</span><span class="com">//近期评论 </span></code> <code><span class="pln">remove_meta_box</span><span class="pun">(</span><span class="str">'dashboard_recent_drafts'</span><span class="pun">,</span> <span class="str">'dashboard'</span><span class="pun">,</span> <span class="str">'normal'</span><span class="pun">);</span><span class="com">//近期草稿</span></code> <code><span class="pln">remove_meta_box</span><span class="pun">(</span><span class="str">'dashboard_primary'</span><span class="pun">,</span> <span class="str">'dashboard'</span><span class="pun">,</span> <span class="str">'core'</span><span class="pun">);</span><span class="com">//wordpress</span><strong><a title="博客" href="http://www.mlwei.com/" target="_blank" rel="noopener noreferrer"><span class="com">博客</span></a></strong> </code> <code><span class="pln">remove_meta_box</span><span class="pun">(</span><span class="str">'dashboard_secondary'</span><span class="pun">,</span> <span class="str">'dashboard'</span><span class="pun">,</span> <span class="str">'core'</span><span class="pun">);</span><span class="com">//wordpress 其它新闻 </span></code> <code><span class="pln">remove_meta_box</span><span class="pun">(</span><span class="str">'dashboard_right_now'</span><span class="pun">,</span> <span class="str">'dashboard'</span><span class="pun">,</span> <span class="str">'core'</span><span class="pun">);</span><span class="com">//wordpress 概况 </span></code> <code><span class="pln">remove_meta_box</span><span class="pun">(</span><span class="str">'dashboard_incoming_links'</span><span class="pun">,</span> <span class="str">'dashboard'</span><span class="pun">,</span> <span class="str">'core'</span><span class="pun">);</span><span class="com">//wordresss 链入链接 </span></code> <code><span class="pln">remove_meta_box</span><span class="pun">(</span><span class="str">'dashboard_plugins'</span><span class="pun">,</span> <span class="str">'dashboard'</span><span class="pun">,</span> <span class="str">'core'</span><span class="pun">);</span><span class="com">//wordpress 链入插件 </span></code> <code><span class="pln">remove_meta_box</span><span class="pun">(</span><span class="str">'dashboard_quick_press'</span><span class="pun">,</span> <span class="str">'dashboard'</span><span class="pun">,</span> <span class="str">'core'</span><span class="pun">);</span><span class="com">//wordpress 快速发布 </span></code> <code><span class="pun">}</span> </code> <code><span class="pln">add_action</span><span class="pun">(</span><span class="str">'admin_menu'</span><span class="pun">,</span> <span class="str">'disable_dashboard_widgets'</span><span class="pun">);</span></code> <code><span class="com">//移除 <a href="https://blog.creust.com/tag/11" title="查看更多关于 WordPress 的文章" target="_blank">WordPress</a> 加载的 JS 和 CSS 链接中的版本号</span></code> <code><span class="kwd">function</span><span class="pln"> wpdaxue_remove_cssjs_ver</span><span class="pun">(</span><span class="pln"> $src </span><span class="pun">)</span> <span class="pun">{</span></code> <code><span class="kwd">if</span><span class="pun">(</span><span class="pln"> strpos</span><span class="pun">(</span><span class="pln"> $src</span><span class="pun">,</span> <span class="str">'ver='</span> <span class="pun">)</span> <span class="pun">)</span></code> <code><span class="pln">$src </span><span class="pun">=</span><span class="pln"> remove_query_arg</span><span class="pun">(</span> <span class="str">'ver'</span><span class="pun">,</span><span class="pln"> $src </span><span class="pun">);</span></code> <code><span class="kwd">return</span><span class="pln"> $src</span><span class="pun">;</span></code> <code><span class="pun">}</span></code> <code><span class="pln">add_filter</span><span class="pun">(</span> <span class="str">'style_loader_src'</span><span class="pun">,</span> <span class="str">'wpdaxue_remove_cssjs_ver'</span><span class="pun">,</span> <span class="lit">999</span> <span class="pun">);</span></code> <code><span class="pln">add_filter</span><span class="pun">(</span> <span class="str">'script_loader_src'</span><span class="pun">,</span> <span class="str">'wpdaxue_remove_cssjs_ver'</span><span class="pun">,</span> <span class="lit">999</span> <span class="pun">);</span></code> <code><span class="com">//移除自动保存</span></code> <code><span class="pln">wp_deregister_script</span><span class="pun">(</span><span class="str">'autosave'</span><span class="pun">);</span></code> <code><span class="com">//移除修订版本</span></code> <code><span class="pln">remove_action</span><span class="pun">(</span><span class="str">'post_updated'</span><span class="pun">,</span><span class="str">'wp_save_post_revision'</span> <span class="pun">);</span></code> <code><span class="com">//后台禁用 Google Open Sans 字体,加速网站</span></code> <code><span class="pln">add_filter</span><span class="pun">(</span> <span class="str">'gettext_with_context'</span><span class="pun">,</span> <span class="str">'wpdx_disable_open_sans'</span><span class="pun">,</span> <span class="lit">888</span><span class="pun">,</span> <span class="lit">4</span> <span class="pun">);</span></code> <code><span class="kwd">function</span><span class="pln"> wpdx_disable_open_sans</span><span class="pun">(</span><span class="pln"> $translations</span><span class="pun">,</span><span class="pln"> $text</span><span class="pun">,</span><span class="pln"> $context</span><span class="pun">,</span><span class="pln"> $domain </span><span class="pun">)</span> <span class="pun">{</span></code> <code><span class="kwd">if</span> <span class="pun">(</span> <span class="str">'Open Sans font: on or off'</span> <span class="pun">==</span><span class="pln"> $context </span><span class="pun">&&</span> <span class="str">'on'</span> <span class="pun">==</span><span class="pln"> $text </span><span class="pun">)</span> <span class="pun">{</span></code> <code><span class="pln">$translations </span><span class="pun">=</span> <span class="str">'off'</span><span class="pun">;</span></code> <code><span class="pun">}</span><span class="kwd">return</span><span class="pln"> $translations</span><span class="pun">;</span></code> <code><span class="pun">}</span></code>

创启云客 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:wordpress后台加载速度慢的解决方法
喜欢 (0)
[13738388032@qq.com]
分享 (0)
创启云客
关于作者:
vps,服务器,云服务器,第三方支付,免费CDN,免费pos,Hexo,pos机,支付圈,免费vps,Discuz,emlog,主题,日本vps,国外服务器,美国vps,香港vps,便宜vps,便宜服务器,vps服务器
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址