[wp-hackers] disabling wpautop

Ken Brucker Ken at pumastudios.com
Tue May 3 14:07:14 UTC 2011


You don't need to save the original copies as it's already done in the caller.

Try:

(function() {
   jQuery('body').bind({
       afterPreWpautop: function(e, o) {
           o.data = o.unfiltered;
       },
       afterWpautop: function(e, o) {
           o.data = o.unfiltered;
       }
   });
})();

--Ken

On Mar 16, 2011, at 9:59 PM, Kevin Newman wrote:

> This seems to keep the editor from stripping out <p> tags when you switch between tabs. That's a start. :-)
> 
> (function() {
>    var unFltr, unFltrPre;
>    jQuery('body').bind({
>        beforePreWpautop: function(e, o) {
>            unFltrPre = o.data;
>        },
>        afterPreWpautop: function(e, o) {
>            o.data = unFltrPre;
>        },
>        beforeWpautop: function(e, o) {
>            unFltr = o.data;
>        },
>        afterWpautop: function(e, o) {
>            o.data = unFltr;
>        }
>    });
> })();
> 
> Kevin N.
> 
> 
> On 3/16/2011 4:23 PM, Kevin Newman wrote:
>> Hi there,
>> 
>> I want to kill off wpautop using a plugin.
>> 
>> It looks like this may be all I need to do this on the server side:
>> 
>> remove_filter ('the_content',  'wpautop');
>> remove_filter ('comment_text', 'wpautop');
>> 
>> But the place it's most annoying, is in the editor. Even the server side autop is not so bad, because if you use <p> in the text field, it pretty much leaves them alone - but if you do something like go to another page, switch to Rich Text mode, then go back and edit a page you set carefully with wpautop incompatible html code, it decimates everything without asking questions. Hence my quest to, as Chris Rock might say, turn that shit off.
>> 
>> Ok, so it looks like the offensive JS is this:
>> 
>>    pre_wpautop : function(content) {
>>        var t = this, o = { o: t, data: content, unfiltered: content };
>> 
>>        jQuery('body').trigger('beforePreWpautop', [o]);
>>        o.data = t._wp_Nop(o.data);
>>        jQuery('body').trigger('afterPreWpautop', [o]);
>>        return o.data;
>>    },
>> 
>>    wpautop : function(pee) {
>>        var t = this, o = { o: t, data: pee, unfiltered: pee };
>> 
>>        jQuery('body').trigger('beforeWpautop', [o]);
>>        o.data = t._wp_Autop(o.data);
>>        jQuery('body').trigger('afterWpautop', [o]);
>>        return o.data;
>>    }
>> 
>> My first thought was to just overwrite those functions with compatible functions that don't actually do the wpautop thing - but maybe it would be better to actually use those hooks. This is the point of this post.
>> 
>> What is the right way to disable this part of wpautop?
>> 
>> Thanks,
>> 
>> Kevin N.
>> 
>> PS If you are interested, the plan is to add an option per post to disable wpautop, rather than going all nuclear.
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
> 
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list