By RachieVee

2014-11-13 22:30:14 8 Comments

This is more of an excercise than something for a client.

Anyway, I'm trying to disable the quicktags when you're on the dashboard and you click on Comments > Edit Comment. On that screen, there's a TinyMCE with quicktags and the textarea has an id of "content".

I know in the WordPress core, this can be changed on line 67 of wp-admin/edit-form-comment.php by changing this:

wp_editor( $comment->comment_content, 'content', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings ) );

To this (quicktags set to false):

wp_editor( $comment->comment_content, 'content', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => false ) );

But I obviously don't want to edit core and want to do this via filter/hook. This is what I tried.

function disable_tinymce_quicktags_comments ( $args ) {
  $comment = get_comment_to_edit( $comment_id );
  wp_editor( $comment->comment_content, 'content', array( 'quicktags' => false ) );
  $args = ob_get_contents(); 
  return $args;

add_filter( 'admin_init', 'disable_tinymce_quicktags_comments' );

A var_dump of $args is revealing nothing after the return, and this is what the text editor looks like on the Edit Comment screen with this function happening:

enter image description here

Am I just trying to achieve the impossible or am I just using the wrong hook? I'm still learning about hooks and PHP. Any suggestions? Thanks. :-)


@doublesharp 2014-11-14 04:38:11

After checking out the code, the best way to do this would be to use the wp_editor_settings filter in /wp-includes/class-wp-editor.php. When you call wp_editor() it internally makes a call to _WP_Editors::editor($content, $editor_id, $settings);. This function first passes the $settings array through parse_settings() which uses that filter.

add_filter( 'wp_editor_settings', 'remove_editor_quicktags', 10, 2 );
function remove_editor_quicktags( $settings, $id ){
    // $id will be 'content' in your example
    // use it in an if or make it gone for everything...

    // use $pagenow to determine if you are on the edit comments page.
    global $pagenow; 
    if ( $pagenow === 'comment.php' ){
        $settings['quicktags'] = false;
    return $settings;

Note - I just realized this filter is new as of WordPress 4.0, so you will need it or newer to take advantage. This also affects all instances of TinyMCE on the admin.

@RachieVee 2014-11-14 14:27:46

Hmm it looks like the wp_editor_settings hook works but it affects all instances of the TinyMCE on the admin, not just the Edit Comment admin page. So it removes the "text" tab on the post/page editors. Is there any way to target specific admin pages to run this? Looks like there isn't a conditional that would help as is_admin just generally checks if you're on the dash, correct?

@RachieVee 2014-11-14 15:34:20

I also credited this answer to another person's question with just one line changed, hope you don't mind. Added it as a comment and it's somewhat relevant to my question:…

@RachieVee 2014-11-14 16:24:18

Ah I missed the comment for the $id - unfortunately this doesn't work in this case because the editor on Edit Comment and the editor on a post/page (text mode) both use the same id which is "content". So I can't target a specific editor using this method.

@doublesharp 2014-11-14 19:43:14

If it is on the admin side you can use the global $pagenow to control it too.

@doublesharp 2014-11-14 19:47:24

Updated the answer to show this.

@doublesharp 2014-11-14 19:49:09

And I will post an answer to the other question, thanks!

@RachieVee 2014-11-14 20:24:19

it works except $pagenow === 'edit-comments.php' didn't work on the Edit Comment page, but $pagenow === 'comment.php' did. If you add that in your answer, I'll mark as correct so we can shorten our comment spam. :-) Thanks.

Related Questions

Sponsored Content

1 Answered Questions

Show All Posts Insert Edit Link

  • 2012-10-17 16:53:10
  • Macgyver
  • 508 View
  • 2 Score
  • 1 Answer
  • Tags:   query tinymce

2 Answered Questions

[SOLVED] Removing the TinyMCE editor for a given page template

3 Answered Questions

[SOLVED] add_filter comment_edit_redirect not working

1 Answered Questions

wpeditor issue - shows both mode and not able to focus/edit during visual mode

  • 2015-08-18 12:01:57
  • Subharanjan
  • 292 View
  • 2 Score
  • 1 Answer
  • Tags:   tinymce wp-editor

2 Answered Questions

1 Answered Questions

[SOLVED] Adding TinyMCE buttons without removing plugin buttons?

1 Answered Questions

[SOLVED] WordPress (TinyMCE) not removing script tags

  • 2014-04-22 16:19:01
  • toby1kenobi
  • 623 View
  • 0 Score
  • 1 Answer
  • Tags:   tinymce

1 Answered Questions

[SOLVED] enable TinyMCE for comment forms

1 Answered Questions

Sponsored Content