Opened 9 years ago
Closed 7 years ago
#28403 closed defect (bug) (fixed)
Multiple wp_editor's with different settings
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.5 | Priority: | normal |
Severity: | normal | Version: | 3.9.1 |
Component: | Editor | Keywords: | has-patch |
Focuses: | Cc: |
Description
Hello,
I found a bug in when using multiple wp_editor's with different settings.
Sample:
wp_editor('', 'field_1', array( 'textarea_name' => 'field_1', 'tinymce' => true, 'default_editor' => 'tinymce' ) ); wp_editor('', 'field_2', array( 'textarea_name' => 'field_2', 'tinymce' => false, 'default_editor' => 'html' ) );
Result: I see tinymce editor for 2nd editor
Excepted result: should be html editor for 2nd editor
Conjecture:
you have the following code in WP:
if ( 'html' === $default_editor ) { add_filter('the_editor_content', 'wp_htmledit_pre'); $switch_class = 'html-active'; } else { add_filter('the_editor_content', 'wp_richedit_pre'); $switch_class = 'tmce-active'; }
For the first editor (field_1) system creates filter add_filter('the_editor_content', 'wp_richedit_pre');
but we don't need it for the 2nd editor (field_2). But he has already been initialized and will be applied for both editors when calling apply_filter('the_editor_content',...). So, please apply filters only to necessary editors which have related settings, not to everyone.
Attachments (1)
Change History (8)
#6
@
7 years ago
- Keywords dev-feedback needs-refresh removed
- Milestone changed from Awaiting Review to 4.5
Most of this was fixed in 4.3. Both 'wp_htmledit_pre
and 'wp_richedit_pre
were deprecated in favor of format_for_editor
. However we should still remove the filtering after it runs in case the next editor instance on the same page doesn't need it.
I encountered this same bug today (on 4.0). The editor content filters should be removed after the editor is displayed, so that they will not affect the following instances.
This can be fixed by adding the following at the end of the "editor" method