Apparently, a lot of us have been using wp_editor incorrectly and didn’t even know it. As of the WordPress version 3.9, you will receive an error if you are still using it this way:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is how NOT to do it | |
**/ | |
// Codex usage: | |
wp_editor( $content, $editor_id, $settings = array() ); | |
// Example of inproper use (in a widget) | |
wp_editor( 'content', $this->get_field_id( 'content' ) ); | |
// Example of inproper use elsewhere | |
// Change settings_field_name[content] to the correct settings field and field name | |
wp_editor( 'content', 'settings_field_name[content]' ) ); |
The actual method is to place your field id in the textarea_name
argument in the settings paramenter, like this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is the correct method of using wp_editor() | |
**/ | |
// Codex usage: | |
wp_editor( $content, $editor_id, $settings = array() ); | |
// Example of proper use in a widget | |
wp_editor( 'content', 'content', array( 'textarea_name' => $this->get_field_id( 'content' ), ) ); | |
// Alternate method when get_field_id is not available (options page or other) | |
// Change settings_field_name[content] to the correct settings field and field name | |
wp_editor( 'content', 'content', array( 'textarea_name' => 'settings_field_name[content]' ), ) ); |
It’s an easy fix, one that I’ve already seen a few plugins make since WordPress 3.9 was released. See the codex for more information on using wp_editor()
.
Update February 26, 2015: The code above originally showed the error using the Widget API get_field_id()
, I’ve updated this to show how it might be used in/correctly elsewhere in WordPress.
Hi you.
I have a custom wp_editor
in wp 3.8 it run very good
but after i update wp 3.9
it was error.
Pls help me
wp_editor( '', 'comment', array(
'media_buttons' => false,
'textarea_rows' => '3',
'tinymce' => array(
'plugins' => 'inlinepopups, wordpress, wplink, wpdialogs',
'theme_advanced_buttons1' => 'bold, italic, underline, strikethrough, forecolor, separator, bullist, numlist, separator, link, unlink, image','theme_advanced_buttons2' => ''),
'quicktags' => array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close')
)
);
Bao,
I would suggest you reach out to the WordPress Support forums. I don’t think you’re getting the same error that I am talking about in this post. I’d have to see the warning itself to know.
Also, please post your code in a gist, linked into your comment.
Best of luck,
Joshua