#43969 closed defect (bug) (fixed)
Custom themes will not work in TinyMCE 4.7
Reported by: | programmin | Owned by: | azaozz |
---|---|---|---|
Milestone: | 4.9.6 | Priority: | normal |
Severity: | normal | Version: | 5.1 |
Component: | TinyMCE | Keywords: | dev-feedback needs-patch |
Focuses: | ui | Cc: |
Description
Themes (meaning Tinymce js themes) that previously worked with TinyMCE <= 4.6 will not work in the upcoming 4.7.
For example if you have been filtering wp_editor_settings and change the array with:
'theme' => 'myspecialtheme',
'theme_url' => 'full url of js file'
it looks quite broken because the format of the theme.js file (generally the js/tinymce/themes/modern/theme.js) is vastly different format pre-4.7.
Attachments (1)
Change History (22)
This ticket was mentioned in Slack in #core by desrosj. View the logs.
7 years ago
#6
@
7 years ago
Confusingly it looks like if SCRIPT_DEBUG is TRUE it actually does work if you set a custom theme js, but on a production test site in which it references wp-includes/js/tinymce/wp-tinymce.php (which includes modern theme) it doesn't work and the option no longer overrides the modern theme.
#7
@
7 years ago
The root of the problem may be that previously mce-themes were:
tinymce.ThemeManager.add('nameoftheme', function... )
and now the theme is
(function () { var modern = (function () {...})() } ) ()
Note that before the function does not immediately run... now it does meaning there is no way to tell mce php loader to not run that modern theme behavior.
This ticket was mentioned in Slack in #core-tinymce by azaozz. View the logs.
7 years ago
This ticket was mentioned in Slack in #core by desrosj. View the logs.
7 years ago
#10
@
7 years ago
@programmin do you use a custom TinyMCE theme somewhere? Asking as this seems very rare :) If this is in a WP plugin, could you update the plugin to fix this issue?
#11
@
7 years ago
Yes, and it looks like it can work fine, but only when turning off the $compress_scripts or $concatenate_scripts so that it doesn't output the highly optimized wp-tinymce.php while in print_tinymce_scripts(). Not optimal but that works.
#12
follow-up:
↓ 13
@
7 years ago
Really a TinyMCE bug as that code is coming from their default modern theme...
#13
in reply to:
↑ 12
@
7 years ago
Replying to programmin:
Really a TinyMCE bug as that code is coming from their default modern theme...
Yeah, I see.
it can work fine, but only when turning off the $compress_scripts or $concatenate_scripts...
Yes, not optimal but better than reverting to the old version imho. We can turn off concatenation "automatically" when theme_url
is set in the init array. Patch coming up.
#14
@
7 years ago
In 43969.patch: disable concatenation if a custom TinyMCE theme is used (theme_url
is set).
@programmin could you test this fast please, so we can add before RC :)
#15
follow-up:
↓ 16
@
7 years ago
@azaozz Yes, that patch looks good and seems to do the exact same thing as my hacky filter fix. Would be awesomer to have the scripts included in wp-tinymce.php filterable or have one for the base TinyMCE though.
#16
in reply to:
↑ 15
;
follow-up:
↓ 19
@
7 years ago
Replying to programmin:
Would be awesomer to have the scripts included in wp-tinymce.php filterable or have one for the base TinyMCE though.
That's not possible :( wp-tinymce.js.gz
(that is outputted from wp-tinymce.php) is concatenated and compressed at build time by Grunt.
#17
@
7 years ago
- Owner set to azaozz
- Resolution set to fixed
- Status changed from new to closed
In 43222:
#19
in reply to:
↑ 16
;
follow-up:
↓ 20
@
7 years ago
Replying to azaozz:
Replying to programmin:
Would be awesomer to have the scripts included in wp-tinymce.php filterable or have one for the base TinyMCE though.
That's not possible :(
wp-tinymce.js.gz
(that is outputted from wp-tinymce.php) is concatenated and compressed at build time by Grunt.
Where is that compiled? Can one autobuild a copy with a replacement for "modern" theme?
#20
in reply to:
↑ 19
@
7 years ago
Replying to programmin:
Where is that compiled? Can one autobuild a copy with a replacement for "modern" theme?
Probably. Can try to adjust the build script for your plugin. Mostly here: https://core.trac.wordpress.org/browser/trunk/Gruntfile.js#L567 and https://core.trac.wordpress.org/browser/trunk/Gruntfile.js#L596.
#21
@
6 years ago
@programmin there have been few fixes to the "modern" theme since this ticket. Could you test if this works properly now even if the modern theme is already loaded so we can remove that fix from PHP :)
(As far as I can see the fix is not needed any more as the modern theme is initialized properly by tinymce.ThemeManager
, but not sure if there may be other "side effects" from always loading the js file.)
Related: #43862.