How does 'CONCATENATE_SCRIPTS' work on wp-

2020-05-30 04:00发布

问题:

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?

回答1:

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 )



回答2:

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.

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.



标签: wordpress