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

Glenn Ansley glenn at glennansley.com
Thu Sep 18 02:00:15 GMT 2008

Thanks for the responses. The site I'm working on has several plugins but I
can reproduce the error on a local, clean installation w/o any plugins by
creating a post with the same content as the problem post on the site.

Both instances result in the same printout for die( get_shortcode_regex() );
Here it is:

----- Written 10 minutes later ------

After understanding what the preg_replace was doing (thanks to you) I
decided to look through the lengthy content for any random square brackets
(I didn't write the content).

I found a rouge line that started with [caption] and ended with [/caption]
but it did not appear to be generated by WP. I'm pretty sure the author
pasted it from some other engine. After deleting that line, the post comes
through with flying colors.

So, problem is resolved but I'm not sure if I understand the root of it.
Feel free to induldge if you wish.

Thanks again!

On Wed, Sep 17, 2008 at 9:41 PM, Austin Matzko <if.website at gmail.com> wrote:

> On Wed, Sep 17, 2008 at 9:21 PM, Glenn Ansley <glenn at glennansley.com>
> wrote:
> > 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).
> > $pee = preg_replace('/<p>\s*?(' . get_shortcode_regex() . ')\s*<\/p>/s',
> '$1', $pee);
> > <p>\s*?
> Find an opening paragraph tag and a minimum number of space characters
> (i.e. not greedy).
> > (' . get_shortcode_regex() . ')
> Match any shortcodes and save them to the first backreference.
> > \s*<\/<p>
> Match space characters to a closing paragraph tag.
> > /s
> "s" is a modifier for dot-matches-all mode, meaning that preg_replace
> should treat everything like it's one big line.
> So replace everything that matches all that with the backreference
> that just matches the get_shortcode_regex() pattern.
> _______________________________________________
> 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