Skip to content

Instantly share code, notes, and snippets.

@barrd
Last active April 16, 2021 18:51
Show Gist options
  • Save barrd/ddad60f77b3a3b2224b6f2a9900875e7 to your computer and use it in GitHub Desktop.
Save barrd/ddad60f77b3a3b2224b6f2a9900875e7 to your computer and use it in GitHub Desktop.
WordPress load all required theme dependencies using RecursiveDirectoryIterator from inc
<?php
/**
* Required Dependencies
*/
// Construct the iterator.
$rdi = new RecursiveDirectoryIterator( get_template_directory() . '/inc' );
// Loop through PHP files.
foreach ( new RecursiveIteratorIterator( $rdi ) as $file ) {
if ( $file->getExtension() === 'php' ) {
require $file;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment