I’m working with a shortcode [translate lang=eng]Apple[/translate]
which will be shown only if the “current language” is eng
. If the post contains, in addition to the above, the declaration [translate lang=rus]Яаблоко[/translate]
and the current language is neither rus
nor eng
, neither of Яаблоко
or Apple
is printed.
My objective is to print the message in the default language when current language does not match that of the [translate lang]
attribute. This implies that the message (in the default language) will be printed as many times as [translate]
is used in the post, but that’s for me to worry about…
What I need to know is if there is a get_shortcodes()
function what will give me an array
(or whatever) of all shortcodes in the post. Would I have to parse the post with regex if not? Do you have better suggestions?
Please refrain from telling me about “superior” translation plugins.
That’s the best I can come up with:
there is a get_shortcode_regex() function in wp-include/shortcodes.php. It is used by do_shortcode() and others. It’s fairly easy to adopt the regex expression.