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

November 29th, 2012 by

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

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>