[shortcode] Tell callback the shortcode name that matched the regex
I don’t see any way for a shortcode handler to determine which shortcode matched the regex that caused the callback. I use an overloaded handler to process a (large) number of different related cases, which I currently distinguish via their content or attributes. Using the shortcode name itself would be a much cleaner user interface. Example:
[Foo1 /] [Foo2 /]
[Foo arg='1']case1|args[/Foo] [Foo arg='2']case2|args[/Foo]
If this were the first release of the API we could just automatically add the shortcode name to the attribute list; but today that would break any existing plugins that are sensitive to the count of
But we could allow a magic default value in the call to
shortcode_atts(array('myname' <= '_shortcode_name'))
Or we could use a global variable (ugh) e.g.
(Sorry if I have overlooked any existing way to determine this; I couldn’t see one.)
- The topic ‘[shortcode] Tell callback the shortcode name that matched the regex’ is closed to new replies.