9

Can the new 4.8 widget visual editor in the default text widget be unhooked or removed and the widget restored to the pre-4.8 editor style?

I don't need or want the visual editor in widgets; I use them for plain text and html and don't need other users adding anything other than plain text.

I did learn how to remove the new video, audio and image widgets in functions.php as I don't need them:

// Unregister default WP Widgets
function unregister_default_wp_widgets() {
    unregister_widget('WP_Widget_Media_Audio' );
    unregister_widget('WP_Widget_Media_Image');
    unregister_widget( 'WP_Widget_Media_Video' );

}
add_action('widgets_init', 'unregister_default_wp_widgets', 1);

But I also want to remove the visual editor tab from the default text widget.

Edit: I can use the PHP Code Widget https://wordpress.org/plugins/php-code-widget/ which does not have the visual editor, and though I don't usually need php execution, it is useful. But this adds the "break things" vector for users who might play with php.

4

The answer is mostly no. The "enhanced" text widget was designed to work like the post editor as much as possible, including autop which might break whatever HTML that can not stand the conversion of lines into paragraphs.

Several people have released plugins to restore the former functionality, but 4.8.1 will also include an "code" widget that can be used to add unaltered HTML. The problem is that there is no, and unlikely to be a plain upgrade path. Best advice right now if you use the html widget is to skip 4.8 and wait for 4.8.1 and allocate some time in advance to migrate the widgets.

If you are just looking to hide the "visual" tab, you are most like also out of luck best to open a ticket at trac to add such possibility, specifically for the widget without impact on the post editor (4.8.1 plan right now is to use the same setting for both)

  • Good point; maybe the code widget be wordpress.org/plugins/php-code-widget added to core? – BlueDogRanch Jun 10 '17 at 16:37
  • @BlueDogRanch I love the PHP code widget, and use it, but it can actually be a huge security issue, since it allows you to do anything in a widget for anyone with widget creation privilege. – Jack Johansson Jun 10 '17 at 16:42
  • @BlueDogRanch the PHP code widget is huge security risk, any user that can gain access to create widgets can take control of your site and maybe also the server – Mark Kaplun Jun 10 '17 at 17:20
1

I am not sure you can remove the visual tab from the widget. It is however possible te remove the wpautop filter.

If you add remove_filter('widget_text_content', 'wpautop'); to your functions.php it should stop wordpress from adding the <p>, <br/>, &nbsp; tags to your text widget output.

This way, you can write all the html you want in your text editor without wordpress messing it up.

  • I'm not asking about removing wpautop; I want to remove GUI functionality. – BlueDogRanch Jun 14 '17 at 14:50
0

I wrote this plugin to handle the issues of upgrading to 4.8.

https://wordpress.org/plugins/add-paragraphs-option-to-text-widget/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.