[wp-hackers] Shortcodes and formatting
docwhat at gmail.com
Wed Apr 2 20:09:31 GMT 2008
On Apr 1, 2008, at 7:11 PM, Mark Jaquith wrote:
> 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.
And you'll be able to show on a page what shortcodes once were used
but are no longer and include some management functions like:
* null out shortcodes
* place shortcodes in comments (so they can be found again and
reactivated on a case by case basis)
* Upgrade shortcodes from one version to another or even to a new
Maybe the name of the plugin that defined them, so that plugin foo
won't accidentally start using plugin bar's frotz shortcode?
More information about the wp-hackers