Add Option To Turn Off wpautop

Before I start my petition, I’ve seen one petition that does not focus in one feature, but multiple features. Plus, some commenters in one thread suggest disabling wpautop (use your browser’s Find feature to look for “wpautop”), however wpautop does have its uses when writing using a visual text editor. As an experienced web developer, I don’t use a visual text editor, so why would I need wpautop enabled if I’m only writing HTML code?

I can’t post more than 2 links as I’m a new user. For the two threads I was talking about, my apologies but you may have to search for threads that mention the wpautop function. I wanted to post a link to my tweets that started before I start my petition.

What Am I Trying To Accomplish?

I want to see an option to disable wpautop. Disabling visual text editor in the Your Profile should disable wpautop. I tried disabling wpautop in functions.php inside my custom theme folder but mine does not work. See my tweets for details. And yes, I use a plugin called “Toggle wpautop,” but that functionality should be built into ClassicPress. I simply want to create a petition for this one feature that I don’t use.

Looking through the plugin, I saw the PHP code for disabling wpautop:

                /**
                 * Add or remove the wpautop filter
                 *
                 * @access public
                 * @param  mixed $post Current Post Object.
                 * @return void
                 */
                public function the_post( $post ) {
                        if ( get_post_meta( $post->ID, '_lp_disable_wpautop', true ) ) {
                                remove_filter( 'the_content', 'wpautop' );
                                remove_filter( 'the_excerpt', 'wpautop' );
                        } // ...

When comparing against my code in my custom theme’s functions.php:

<?php
remove_filter( ‘the_content’, ‘wpautop’ );
remove_filter( ‘the_excerpt’, ‘wpautop’ );

I even wrapped the remove_filter functions inside the wp_init() function:

<?php
add_action('init','init_wp');
function init_wp() {
    remove_filter( ‘the_content’, ‘wpautop’ );
    remove_filter( ‘the_excerpt’, ‘wpautop’ );
}

And none of the two worked. I struggled with the issue a lot, so I really would want to have the option of disabling wpautop so that experienced web developers such as myself don’t need to have a plugin installed. And this petition is not my place to get help with getting my functions.php to work.

Plus, shouldn’t there be an option for the user profile section or can the option be added globally? If the option can be added globally, then it would make sense to have visual text editor disabled and have the “disable visual editor” checkbox grayed out per user. It would not make sense to have wpautop disabled while the visual text editor is enabled.

Am I being unclear in my petition? I tried to elaborate as best I can to get my point across.

4 Likes

I like wpautop…until I don’t. :slight_smile: …and sure wouldn’t mind a checkbox (enabled by default) to disable it on a post-by-post basis. Upvote from me on the overall idea and explanation.


Regarding the issues you experienced – in some cases, you can work around wpautop issues by removing and then re-adding that filter at a later priority, like 99. These calls don’t need to be wrapped, they can be dropped right into your functions.php file.

remove_filter('the_content', 'wpautop');
add_filter('the_content', 'wpautop', 99);

Anyway, the wpautop filter is applied to quite a few contexts – so, one possibility on why your remove_filter() calls didn’t work could be that you didn’t remove the filter from the relevant context.


From core:

image


Another possibility is… the quotes in your code…

It doesn’t work with funky quotes:
remove_filter( ‘the_content’, ‘wpautop’ );

It only works with single or double quotes:
remove_filter( 'the_content', 'wpautop' );
remove_filter( "the_content", "wpautop" );

3 Likes

Other relevant threads:

This is a really well put together petition, thank you! :slight_smile:

3 Likes

In my case, I have decided to use a “Toggle wpautop” plugin instead of implementing remove_filter() in my own custom theme. I must have copied a code from one thread that can mess up quotes. Not in ClassicPress, but somewhere in the Internet. Probably WordPress forum…

Thank you everyone for the feedback. Much appreciated.

3 Likes

I have disabled wpautop with a filter by default for years. Everything was cool until one of the sites I manage that had Easy Digital Downloads refused to allow checkout to complete (after filling in all the card info, etc, you’d click the ‘buy now’ button and nothing happened).

Turned out EDD had begun using wpautop in the checkout process, and not having an empty paragraph broke their checkout. I forget the details of how that worked, but the bottom line is, I now leave wpautop on for all sites that have EDD.

2 Likes

I found it strange how some plugins rely on wpautop to work… wpautop is just for adding paragraph and line break tags… I do think plugin developers should check to see if wpautop filter is removed.

1 Like

In my opinion – and I’m a prolific plugin developer as well as a longtime plugin user :slight_smile: – a plugin should never wholesale disable something like wpautop unless that is what the plugin is specifically built to do.

Removing this filter will drastically change the functionality and output of a user’s site far beyond whatever the single plugin is doing. This is bad form, terrible UX, and leads to wild-goose-chase support tickets being submitted to the wrong parties.

If the filter is causing issues with a plugin’s output (whether as general content or as a rendered shortcode) it’s up to the developer to solve the problem with creative filtering and/or string manipulation to Make It Right™ without affecting the entire site in fundamental ways.

6 Likes

So does this mean that my petition will not get the votes needed for implementing the option for turning on/off the wpautop? Just because of some WordPress plugins that mishandle wpautop and rely on some empty paragraphs just to put data in? I kind of want to show a Picard facepalm while in the bridge from Twitter in my thread, but I’m not going to deal with copyright issues here. :slight_smile:

For my blog (graysonpeddie.com), I won’t be downloading plugins unless it is absolutely necessary. The only two plugins that I have are “Google XML Sitemaps” and “Toggle wpautop.”

And besides, I only want to have the option to turn off wpautop by clearing the checkbox for my blog posts and that’s it. wpautop does have its uses for comments, which I have not implemented in my custom theme.

No – people are free to vote on the idea. :slight_smile: This is all just related discussion.

2 Likes

@GraysonPeddie Why do you want this in core? Why is using a plugin, as you already do, not sufficient?

2 Likes

It’s to make it easy for anyone who simply wanted to write in HTML to turn of wpautop without searching and installing a plugin. It shouldn’t take as much code to write and make it be part of the core for the admin dashboard.

I too write in HTML and disable TinyMCE in the back-end. But, by default, I don’t do anything with wpautop because the effect of doing so can (as others have already noted) be unpredictable. Sometimes I find that it’s necessary to disable it for something specific but (as @anon71687268 said), I deal with that with some filtering that’s strictly tied to the issue at hand. Sometimes, on the other hand, I very much need explicitly to enable wpautop to get something to work as I intend.

My point is that I don’t think that it is convenient to offer a setting in core to turn this on and off. What is likely to happen is that people will turn it off without realizing the ramifications and then will have a nightmare of troubleshooting. If there’s a good plugin that already does what is required, then I’m all for using that.

In fact, it seems that your real motivation is to limit the number of plugins. So again I ask why. (There is an urban myth that the number of plugins should be limited, so I hope that’s not the issue here. What matters is the quality, and not the number, of plugins). I ask particularly because the plan for ClassicPress is to spin out several parts of core into their own plugins so that they can be deactivated by those who don’t have use for them. But, of course, for those who do have such a use, they will, by definition, be running plugins in order to do so.

5 Likes

:100:

2 Likes

Some things ‘should not’ be easy for everyone, IMO. If someone is not knowledgeable enough to turn off wpautop with a filter, they’re probably not someone who should be making that decision.

5 Likes

I understand. Then my petition does not make any sense for those who should be using a plugin for turning off wpautop instead.

What if the setting can fall under “Advanced Options” with a warning label saying “please do not modify the settings unless you know what you are doing?” I was thinking about that before I edit my post.

As majority of participants pointed out, this shouldn’t be an option in the core and the petition will be closed. Especially since this can be easily handled by a plugin. Anyone who needs to turn off wpautop will know how to do it with a plugin or a snippet in functions.php. They don’t need a UI.

In reality, what will happen is clients will unintentionally disable wpautop and frantically blow up their developer’s inbox/phone because the page is broken. Then wonder why CP is so user unfriendly since they can easily break pages.

1 Like

This topic was automatically closed after 2 days. New replies are no longer allowed.