[wp-hackers] Shortcodes and formatting
Mark Jaquith
mark.wordpress at txfx.net
Tue Apr 1 23:11:44 GMT 2008
On Apr 1, 2008, at 3:37 PM, Andy Skelton wrote:
> On Tue, Apr 1, 2008 at 2:33 PM, Mark Jaquith
> <mark.wordpress at txfx.net> wrote:
>> How would we know which plugin adds which tag? i.e. how do we
>> automatically queue up the deactivation hook to remove the tag?
>
> We don't. The plugin would have to call this on its own deactivation.
But then some plugins will clean up their shortcodes when they're
gone, and others won't.
<!--[shortcode]--> would have been nice, because it is self-cleaning.
But it's probably too late to change it. So let's not cry over
spilled milk.
Here's my idea:
We keep an array of added shortcodes in the options table:
installed_shortcodes. add_shortcode() will check this array, and
update it as necessary (first time a shortcode plugin is run, for
example). But it will also keep an array of shortcodes in memory.
in do_shortcodes(), we compare the option with the in-memory list of
shortcodes. If a plugin is deactivated, it'll be in the
"installed_shortcodes" option, but *not* in the in-memory array. We
can then easily strip out these shortcodes from the content.
Sidenote: we'd need to strip <p>\[$shortcode( .*?\]|\])</p> out, for
shortcodes entered on their own line.
--
Mark Jaquith • http://markjaquith.com/
More information about the wp-hackers
mailing list