Where to place PHP for shortcodes

Shortcodes are processed on display so the code must be available on the front end when the shortcode is processed. Superficially, that means frontend.php.

I have never tried to split shortcode code in this way. You may have trouble splitting it off from the backend. The add_shortcode function is in wp-includes/shortcodes.php which loads for both back and front, suggesting that it is at least possible that it is needed on the back end. I’d have to run some experiments…