Reducing duplication and better utilizing the WP built-in locate_template()

Re recommendations from @QWp6t in roots/roots#1042
This commit is contained in:
David Rogers
2014-05-22 16:25:22 -04:00
parent 47e0558c0d
commit a19b89f023

View File

@@ -2,18 +2,29 @@
/** /**
* Roots includes * Roots includes
*/ */
require_once locate_template('/lib/utils.php'); // Utility functions $roots_includes = array(
require_once locate_template('/lib/init.php'); // Initial theme setup and constants '/lib/utils.php', // Utility functions
require_once locate_template('/lib/wrapper.php'); // Theme wrapper class '/lib/init.php', // Initial theme setup and constants
require_once locate_template('/lib/sidebar.php'); // Sidebar class '/lib/wrapper.php', // Theme wrapper class
require_once locate_template('/lib/config.php'); // Configuration '/lib/sidebar.php', // Sidebar class
require_once locate_template('/lib/activation.php'); // Theme activation '/lib/config.php', // Configuration
require_once locate_template('/lib/titles.php'); // Page titles '/lib/activation.php', // Theme activation
require_once locate_template('/lib/cleanup.php'); // Cleanup '/lib/titles.php', // Page titles
require_once locate_template('/lib/nav.php'); // Custom nav modifications '/lib/cleanup.php', // Cleanup
require_once locate_template('/lib/gallery.php'); // Custom [gallery] modifications '/lib/nav.php', // Custom nav modifications
require_once locate_template('/lib/comments.php'); // Custom comments modifications '/lib/gallery.php', // Custom [gallery] modifications
require_once locate_template('/lib/relative-urls.php'); // Root relative URLs '/lib/comments.php', // Custom comments modifications
require_once locate_template('/lib/widgets.php'); // Sidebars and widgets '/lib/relative-urls.php', // Root relative URLs
require_once locate_template('/lib/scripts.php'); // Scripts and stylesheets '/lib/widgets.php', // Sidebars and widgets
require_once locate_template('/lib/custom.php'); // Custom functions '/lib/scripts.php', // Scripts and stylesheets
'/lib/custom.php', // Custom functions
);
foreach($roots_includes as $file){
if(!$filepath = locate_template($file)) {
trigger_error("Error locating `$file` for inclusion!", E_USER_ERROR);
}
require_once $filepath;
}
unset($file, $filepath);