TinyMCE 4 & wp_editor multiple editor issue

admin2025-06-05  4

Just updated WordPress to new 3.9, new features are great, love them. Only got some issues with tinyMCE 4. I use wp_editor to create multiple tinyMCE editors with custom field.

Here is the code:

$tinymce_opt = array(
 'height'    => "250",
 'plugins'  => "nz_button, line, gap, slider_colorbox, icon_list, icons, font_size",
 'toolbar1' => "formatselect,fontselect, styleselect,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink,|,forecolor,removeformat,charmap,undo,redo",
 'toolbar2' => "nz_button, line, gap, slider_colorbox, icon_list, icons, font_size",
 'toolbar3' => ""
);

 $settings = array (
    'tinymce'       => $tinymce_opt
   );
  wp_editor( ${"layer_$i"}, "layer_$i", $settings);

Everything is fine. The problem is that it does not understand plugins (my custom shortcodes, that i created). Custom shortcodes work fine in regular wp editor, but in multiple wp_editor, it just does not find them.

In colsole i get error 404 can’t find

for example “line” shortcode

.min.js 404 (Not Found)

All my custom shortcodes are ignored, not found.

Does anyone know, how to tell tinyMCE + wp_editor to use custom shortcodes?

My custom shortcodes are located in my theme

P.S. It worked fine with old tinyMCE.

Just updated WordPress to new 3.9, new features are great, love them. Only got some issues with tinyMCE 4. I use wp_editor to create multiple tinyMCE editors with custom field.

Here is the code:

$tinymce_opt = array(
 'height'    => "250",
 'plugins'  => "nz_button, line, gap, slider_colorbox, icon_list, icons, font_size",
 'toolbar1' => "formatselect,fontselect, styleselect,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,link,unlink,|,forecolor,removeformat,charmap,undo,redo",
 'toolbar2' => "nz_button, line, gap, slider_colorbox, icon_list, icons, font_size",
 'toolbar3' => ""
);

 $settings = array (
    'tinymce'       => $tinymce_opt
   );
  wp_editor( ${"layer_$i"}, "layer_$i", $settings);

Everything is fine. The problem is that it does not understand plugins (my custom shortcodes, that i created). Custom shortcodes work fine in regular wp editor, but in multiple wp_editor, it just does not find them.

In colsole i get error 404 can’t find

for example “line” shortcode

http://mywebsite/wp-includes/js/tinymce/plugins/line/plugin.min.js 404 (Not Found)

All my custom shortcodes are ignored, not found.

Does anyone know, how to tell tinyMCE + wp_editor to use custom shortcodes?

My custom shortcodes are located in my theme

P.S. It worked fine with old tinyMCE.

Share Improve this question edited Apr 23, 2014 at 10:56 Mayeenul Islam 12.9k21 gold badges85 silver badges169 bronze badges asked Apr 23, 2014 at 10:28 shagalshagal 11 bronze badge 2
  • What is the actual value of ${"layer_$i"}? – fuxia Commented Apr 23, 2014 at 10:30
  • I don't have an answer for your question, but I wanted to point out that the text alignment button names have changed (possibly without warning... grrrr) in WordPress 3.9. You'll need to change "justifyleft,justifycenter,justifyright" to "alignleft,aligncenter,alignright". – Andy Giesler Commented May 15, 2014 at 15:25
Add a comment  | 

1 Answer 1

Reset to default 1

Since 3.9 some parts of the settings for the original Editor are wrapped in a self::first_init condition. This includes the plugins filter for external tinymce plugins. So, in a subsequent call for an editor, the filter won't run.

Solution: One can pass a tinymce settings array to the settings of wp_editor(), that's where I would start. Or enqueue the script manually as explained here:

http://www.tinymce/wiki.php/Tutorials:Creating_a_plugin

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749093327a316306.html

最新回复(0)