Is there a method to force the refresh of editor-style.css
, when I change manually the stylesheet for the TinyMCE editor? Modification doesn’t show immediately but they will be cached in the admin side of administration backend.
For example like this:
editor-style.css?ver=3393201
There is a hook for that:
'mce_css'
. It is called in_WP_Editors::editor_settings()
and you get all loaded stylesheets comma separated as the first and only parameter.Now it is easy: Use the global variable
$editor_styles
(here are your themeâs and parent themeâs editor stylesheets stored already), add the time of the fileâs last modification as a parameter and rebuild the string.As a plugin:
Instead of just calling
add_editor_style
with your CSS file, add a cache buster query string parameter:I couldn’t get toscho’s answer to work for the current version of WordPress (4.7.2), and that seems to be because the TinyMCE init array has a cache_suffix set to
'wp-mce-' . $tinymce_version
.So instead, you can just overwrite that with the tiny_mce_before_init filter, like so:
Of course, this isn’t nearly as good as
filemtime()
, but at least this works in 4.7.2.Note: This also adds the cache buster to other editor styles (like skin.min.css, content.min.css, dashicons.min.css, and wp-content.css)
I had the same issue (2012, WP 3.4.2 !!). Possible solutions while this bug is around:
1) If you use firebug, [x]Disable Browser Cache in the Net panel helps.
I even had a very strange issue, that the cached editor-style briefly appears (in a css-filtered) Firebug net panel for a split second, than disappears again. Took screenshots to prove to myself.
2) A full browser cache clear helps. For whatever reason thereafter the issue did not reappear.
3) Lastly, my preferred advice, if you have to also make sure, i.e. your clients on staging or live server get your incremental improvements (w/o any annoying cache clearance advice):
Relocate the file and keep counting up:
Hacky, but reliable.
The problem with accepted answer in latest versions I assume is
$editor_styles
array only contains stylesheets added using theme, so as a result it strips rest of the stylesheets added by core wordpress or plugins from the returning string.Following is the solution I came up with after tweaking the code, you can use it in your functions.php file. My solution uses nested loop and checks for stylesheets present in
$editor_styles
array, and appends the last modified time as parameter to query string and updates the value in array.