Restructure theme, use autoloader

This commit is contained in:
QWp6t
2015-12-18 16:41:37 -08:00
committed by Ben Word
parent 8d7bcee4c4
commit 9eaffa3a2d
47 changed files with 771 additions and 393 deletions

View File

@@ -1,28 +1,28 @@
<?php
/**
* Sage includes
*
* The $sage_includes array determines the code library included in your theme.
* Add or remove files to the array as needed. Supports child theme overrides.
*
* Please note that missing files will produce a fatal error.
*
* @link https://github.com/roots/sage/pull/1042
* Do not edit anything in this file unless you know what you're doing
*/
$sage_includes = [
'lib/assets.php', // Scripts and stylesheets
'lib/extras.php', // Custom functions
'lib/setup.php', // Theme setup
'lib/titles.php', // Page titles
'lib/wrapper.php', // Theme wrapper class
'lib/customizer.php' // Theme customizer
];
foreach ($sage_includes as $file) {
if (!$filepath = locate_template($file)) {
trigger_error(sprintf(__('Error locating %s for inclusion', 'sage'), $file), E_USER_ERROR);
}
/**
* Here's what's happening with these hooks:
* 1. WordPress detects theme in themes/sage
* 2. When we activate, we tell WordPress that the theme is actually in themes/sage/templates
* 3. When we call get_template_directory() or get_template_directory_uri(), we point it back to themes/sage
*
* We do this so that the Template Hierarchy will look in themes/sage/templates for core WordPress themes
* But functions.php, style.css, and index.php are all still located in themes/sage
*
* themes/sage/index.php also contains some self-correcting code, just in case the template option gets reset
*/
add_filter('template', function ($template) {
return dirname($template);
});
add_action('after_switch_theme', function () {
update_option('template', get_option('template') . '/templates');
});
require_once $filepath;
}
unset($file, $filepath);
/**
* Require composer autoloader
*/
require_once __DIR__ . '/vendor/autoload.php';