wordpress “CONCATENATE_SCRIPTS”如何在 wp-config 上工作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32588692/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How does 'CONCATENATE_SCRIPTS' work on wp-config?
提问by eyyo
The text on my wordpress text editor is white on a white background so its invisible for most people..
我的 wordpress 文本编辑器上的文本是白色背景上的白色,因此对大多数人来说是不可见的。
I searched it and the solution I found was to add the following code to wp-config.php
我搜索了一下,找到的解决方案是将以下代码添加到 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 herebut it didn't get an answer.
我只在这里找到了一个提出同样问题的问题,但没有得到答案。
Could someone explain what the code above does and why it works?
有人能解释一下上面的代码是做什么的以及它为什么起作用吗?
回答by Obmerk Kronen
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 ).
CONCATENATE_SCRIPTS
是告诉 wordpress 的常量,好吧.. 将所有依赖项连接到一个 URL 中并将其加载在一起(我猜是为了保存 http 请求)。
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.
这是正常的默认行为,如果您遇到问题,可能是因为javascript
主题或插件存在冲突。
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 )
另一种可能(虽然不太频繁)是由于 TinyMCE 缓存导致的浏览器问题。清除浏览器缓存。(编辑:对Sep.2015
- 未验证但仍然值得尝试)
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 individuallyrater than collectively.
So in that case - If one script fails to load and work correctly, the others can still continue to operate correctly.
无论如何,通过定义常量,false
您实际上是在强制 WordPress 在管理页面上单独加载每个脚本而不是集体加载。所以在这种情况下 - 如果一个脚本无法加载并正常工作,其他脚本仍然可以继续正常运行。
This is a recommended setting for debugging
and local development.
However, in your case, it is a symptomof a problem, and not the problem itself. you should isolate the problem and fix it ( probably a plugin like said before )
这是debugging
本地开发的推荐设置。但是,就您而言,这是问题的症状,而不是问题本身。您应该隔离问题并修复它(可能是之前所说的插件)
回答by Phil Hilton
To expand upon Obmerk's answer, in my case setting CONCATENATE_SCRIPTS
to false simply enabled me to see the individual failure in the browser console as it then showed the javascript for tinymce was not loading properly. Then looking at server logs showed that wp-tinymce.php
was not executing properly. In the end, I needed to fix the permissions of {sitepath}/wp-includes/js/tinymce/wp-tinymce.php
so that the security settings of the server I was on would allow it to run.
为了扩展 Obmerk 的答案,在我的情况下,设置CONCATENATE_SCRIPTS
为 false 只是让我能够在浏览器控制台中看到单个故障,因为它随后显示 tinymce 的 javascript 未正确加载。然后查看服务器日志显示wp-tinymce.php
未正确执行。最后,我需要修复 的权限,{sitepath}/wp-includes/js/tinymce/wp-tinymce.php
以便我所在服务器的安全设置允许它运行。
In my case the server did not allow it to be group-writable so a chmod 755
took care of it. The actual solution will vary based on your server configuration.
在我的情况下,服务器不允许它是组可写的,所以chmod 755
处理了它。实际解决方案将根据您的服务器配置而有所不同。