How and when to include shortcode source files

The pattern I use is:

  • break code into modules using classes
  • use spl_autoload_register() to load classes (thereby only included when used)
  • have a class that is the plugin controller, with a method for each shortcode
  • those methods generally do nothing but create instance of shortcode class and pass params

Works for me, simplifies things greatly, especially for large sites where I have dozens of classes. No need to carefully manage what gets included where because the class autoloader handles that.