Hello Everyone!
I'm working on a plugin that supports certain shortcode. Let's say it's: [my_shortcode]. Now as I can only have one handler function and a function may return (return "something") value only once and then terminates I've got this problem.
Assume pseudocode:
function my_shortcode_handler($attr) {
return '<p id="msg">Hello world!</p>";
/... do something complicated .../
<script>
var m = getElementById("msg");
m.innerHTML = 'Goodbye world!';
</script>
}
add_shortcode('my_shortcode', 'my_shortcode_handler');
What I need is to immediatly output some text (visible in post) in place of shortcode but then let shortcode handler function do some work and when it's finished change already outputted text to something else.
The problem is:
1) Obviously I can't use "echo" inside plugin
2) I also (contrary to the pseudocode above) cannot use "return" on the beggining of the function in order not to terminate it
3) I need to change already outputted text, so I guess JS would be an answer her but I might as well be wrong...
Anyway, I'm pretty sure there's a solution, however I can find it. Do you have any ideas?
Thanks in advance,
A.