Automatically Include All Class Files in Subdirectory (e.g. inc/ or class/)

Easy as pie!

Here’s an example to include all PHP files in a subdirectory named class.

N.B. Make sure you are one level below the class folder.

 

foreach (glob(plugin_dir_path(__FILE__) . "class/*.php") as $filename) include $filename;

Leave a Reply