jarrowwx
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Custom shortcode'sWhat isn’t the way you want it? What doesn’t work?
Forum: Plugins
In reply to: Third parameter to shortcode callback is never populatedPost your code that you are using. Then also, post the way you are using the shortcode. That is, are you using it with content, or not, with attributes, or not, and is the shortcode name the same as your function name, or not. Lay it all out so we can look at what you did.
Forum: Requests and Feedback
In reply to: Ability to create default/unrecognized shortcode handlerBut 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. ??
Forum: Plugins
In reply to: Third parameter to shortcode callback is never populatedNevermind, it is in $attr[0] – here’s where I went wrong:
function shortcode_template( $attr = null, $content = null, $shortcode = null ) { ... if ( ! isset( $shortcode ) ) {
It should have been
if ( empty( $shortcode ) ) {
Silly me. Why did I think isset() would return false?