According to my previous understanding and WordPress’s documentation:
Note that the function called by the shortcode should never produce output of any kind. Shortcode functions should return the text that is to be used to replace the shortcode. Producing the output directly will lead to unexpected results
So, we’re limtied, shortcode functions must
Has been my understanding for years. Unless…
Yeah. Yeah. That’s right! You can use output buffering to collect your echo’ed HTML from printing, and return it instead.
file_get_contents() and reduce my PHP to being at the top of the script, or similar, but when the scripts not too long, it’s just so nice to have raw HTML inside the function, instead of dealing with everything else.