[wp-hackers] What does the last line in the wpautop function do?

DD32 wordpress at dd32.id.au
Thu Sep 18 01:34:54 GMT 2008

Are you using any plugins which add custom shortcodes?

I'd add in a die(get_shortcode_regex()); and post that back to the list to  
try and work it out along with the above question..

But it does what the comment says, It replaces

<p>[gallery or other shortcode]</p> to the correct [shortcode] so that  
when the shortcode replaces it, it doesnt end up with extra <p> tags, eg:
<p><div class="myshortcode">...</p>

On Thu, 18 Sep 2008 11:21:45 +1000, Glenn Ansley <glenn at glennansley.com>  

> Hi,
> I have a single post that isn't making it through the wpautop filter (  
> all
> the others do ).
> I can remove the filter and the post prints without formatting.
> I've gone into the wpautop function itself for testing and found that the
> problem is in the last line that runs preg_replace.
> If I die( $pee ); directly before the last preg_replace I get the post
> content as expected.
> If I die( $pee ); directly after the last preg_replace I get nothing at  
> all
> ( $pee is empty ).
> I need to find out what about this individual post in relation to the  
> final
> line of wpautop is not jiving correctly. Unfortunately, I don't have any
> bragging rights in the regex arena (I can tell it has to do with  
> shortags).
> Could anyone help me understand what this line is doing so that I might
> better troubleshoot why the post isn't making it through (length,
> characters, etc).
> Thanks.
> Final Replacement line in wpautop:
> $pee = preg_replace('/<p>\s*?(' . get_shortcode_regex() . ')\s*<\/p>/s',
> '$1', $pee); // don't auto-p wrap shortcodes that stand alone
> _______________________________________________
> 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