The right way would be via a plugin, but you’ve got an idea that would add a lot of overhead to WordPress (especially since things like [sic] are valid usage in English, and would rarely if ever want to be shortcoded… )
You’re basically adding in a feature to check EVERY possible [whatever] and [whatever]ksdfjdskhf[/whatever] call for a shortcode and I’m not sure that would work in core for everyone.
I would email this one to wp-hackers ( http://lists.automattic.com/mailman/listinfo/wp-hackers ) and ask there.
But yes, it would add overhead. I am not sure how much, but I acknowledge that it adds overhead. Every shortcode that gets added adds overhead, too.
What I want to do is, if there is a meta field defined for the post/page being processed (even inside a sub-query), say a meta field called “foo” then I would like to be able to turn [foo] into the value of that field. I can already do [meta key=”foo”] but I like the other much better from the standpoint of readability. If I find that the current post doesn’t contain a meta field by that name, I can just output ‘[foo]’ and call it good.
I suppose, if there is a way to query for all meta key names that exist in the database, I can just create a handler for each of those, and avoid the unnecessary overhead for all the other cases. It still adds overhead, but the amount of overhead will be small enough to be negligible for a relatively low-traffic site, and will add enough usability to make it better for those creating content on the site.
Another option for me is to create temporary shortcodes. I have created a [query] shortcode. Inside that, as part of processing each post, I could query for the list of meta keys associated with the post, create shortcode handlers for those that do not already exist, process the record normally, then delete any that are no longer relevant. Then, the overhead of the feature that I want is limited to the times when I actually want it.
Sounds good. Now all I need is a mechanism for detecting if a shortcode is already registered without having to peek into the internals of the shortcode module. 🙂