Joshua David Nelson

Bullshit Free WordPress Development

  • Services
  • Code
  • About
  • Contact

Fixing the wp_editor Error in WordPress 3.9

April 23, 2014 by Joshua Nelson

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 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]' ) );
view raw original-bad-method.php hosted with ❤ by GitHub

The actual method is to place your field id in the textarea_name argument in the settings paramenter, like this:

/**
* 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]' ), ) );
view raw correct-wp_editor-method.php hosted with ❤ by GitHub

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.

Filed Under: WordPress Tagged With: bugs, codex, wp_editor

Discussion

  1. Bao says

    May 2, 2014 at 11:10

    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')
    )
    );

  2. Joshua Nelson says

    May 3, 2014 at 21:31

    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

  • Twitter
  • RSS Feed URL

About Me

I'm a WordPress Engineer. I build sleek, custom websites with WordPress and Genesis.

See my services and my recent work.

Contact me to get your project started.

Gravity Forms Plugin for WordPress Fastest WordPress Hosting

Recent Posts

  • Using Font Awesome Icons for WooCommerce Grid / List Toggle
  • Disable Blog: WordPress Gone Blog-less
  • Category (Taxonomy) Dropdown Filtered By Post Type
  • Weather in WordPress with Dark Sky
  • Fixing Your Deprecated Widget Constructors in WordPress 4.3
  • Twitter
  • RSS Feed URL
  • Code Snippets
  • My Plugins
  • Make a Payment

© Joshua David Nelson | Hand-Forged | WordPress + Genesis | Terms of Service | Legal | Contact