[wp-hackers] disabling wpautop

Kevin Newman CaptainN at unFocus.com
Tue May 3 16:31:17 UTC 2011


Nice! Thanks for the tip. :-)

I've concluded since looking into this that disabling auto-p isn't the 
correct solution to the problem I was having - fixing the JS 
implementation to more closely match the PHP implementation is the 
correct solution.

I haven't made an further progress down this road, but my brother 
(WraithKenny) and I have been at least looking into it.

Kevin N.


On 5/3/11 10:07 AM, Ken Brucker wrote:
> 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
> _______________________________________________
> 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