“CONCATENATE_SCRIPTS"如何在 wp-config 上工作? [英] How does 'CONCATENATE_SCRIPTS' work on wp-config?

查看:23
本文介绍了“CONCATENATE_SCRIPTS"如何在 wp-config 上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 wordpress 文本编辑器上的文本是白底白字,因此对大多数人来说是不可见的..

我搜索了一下,找到的解决方案是将以下代码添加到 wp-config.php

define('CONCATENATE_SCRIPTS', false );

它运行良好,但我找不到它的作用或它为什么起作用.

我只发现了一个问同样问题的问题 here 但它没有得到答案.

有人能解释一下上面的代码是做什么的以及它为什么起作用吗?

解决方案

首先,好问题.

据我所知,它仅适用于管理区域(后端).结果是像

这样的网址

<script src="http://somewordpress.site/wp-admin/load-scripts.php?c=1&load=jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,hoverIntent,common,jquery-color,wp-ajax-response,wp-lists,jquery-ui-resizable,quicktags,jquery-query,admin-comments,postbox,dashboard,thickbox,插件安装,媒体上传&ver=e0f647a6df61adcc7200ce17a647db7f" type="text/javascript">

这是正常的默认行为,如果您遇到问题,可能是由于主题或插件中的某些javascript冲突.

另一种可能(虽然不太频繁)是由于 TinyMCE 缓存导致的浏览器问题.清除浏览器缓存.(对 2015 年 9 月 是真实的 - 未验证但仍然值得尝试)

如果您真的想查看它的定义位置或它在做什么,您可以看这里.

无论如何,通过将常量定义为 false,您实际上是在迫使 WordPress 加载管理页面上的每个脚本单独评分而不是集体.所以在这种情况下 - 如果一个脚本无法加载并正常工作,其他脚本仍然可以继续正常运行.

这是调试和本地开发的推荐设置.但是,就您而言,这是问题的症状,而不是问题本身.您应该隔离问题并修复它(可能是之前所说的插件)

The text on my wordpress text editor is white on a white background so its invisible for most people..

I searched it and the solution I found was to add the following code to wp-config.php

define('CONCATENATE_SCRIPTS', false );

It worked fine but I couldn't find what it does or why it works.

I only found a question that asks the same thing here but it didn't get an answer.

Could someone explain what the code above does and why it works?

解决方案

First of all, nice question.

CONCATENATE_SCRIPTS is the constant that tells wordpress to, well.. concatenate all of the dependencies into one URL and load it together ( to save http requests I guess ).

As far as I know, it applies only to the Admin area ( back end ). The result is a url like

<script src="http://somewordpress.site/wp-admin/load-scripts.php?c=1&load=jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,hoverIntent,common,jquery-color,wp-ajax-response,wp-lists,jquery-ui-resizable,quicktags,jquery-query,admin-comments,postbox,dashboard,thickbox,plugin-install,media-upload&ver=e0f647a6df61adcc7200ce17a647db7f" type="text/javascript">

This is the normal default behavior, and if you have problems with it, it is probably because of some javascript conflict in theme or plugin.

Another possible ( albeit less frequent ) is a browser problem due to TinyMCE caching. clear browser cache. ( edit : was true to Sep.2015 - not verified since but still worth trying )

If you really want to see where it is defined or what is it doing you can look here.

Anyhow, by defining the constant as false you are practically forcing WordPress to load each script on the administration page individually rater than collectively. So in that case - If one script fails to load and work correctly, the others can still continue to operate correctly.

This is a recommended setting for debugging and local development. However, in your case, it is a symptom of a problem, and not the problem itself. you should isolate the problem and fix it ( probably a plugin like said before )

这篇关于“CONCATENATE_SCRIPTS"如何在 wp-config 上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆