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

Austin Matzko if.website at gmail.com
Thu Sep 18 01:41:45 GMT 2008


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.


More information about the wp-hackers mailing list