You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
3.3 KiB
98 lines
3.3 KiB
8 years ago
|
<?php
|
||
|
|
||
|
/**
|
||
|
* Do not edit anything in this file unless you know what you're doing
|
||
|
*/
|
||
|
|
||
|
use Roots\Sage\Config;
|
||
|
use Roots\Sage\Container;
|
||
|
|
||
|
/**
|
||
|
* Helper function for prettying up errors
|
||
|
* @param string $message
|
||
|
* @param string $subtitle
|
||
|
* @param string $title
|
||
|
*/
|
||
|
$sage_error = function ($message, $subtitle = '', $title = '') {
|
||
7 years ago
|
$title = $title ?: __('Sage › Error', 'aldine');
|
||
8 years ago
|
$footer = '<a href="https://roots.io/sage/docs/">roots.io/sage/docs/</a>';
|
||
|
$message = "<h1>{$title}<br><small>{$subtitle}</small></h1><p>{$message}</p><p>{$footer}</p>";
|
||
|
wp_die($message, $title);
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Ensure compatible version of PHP is used
|
||
|
*/
|
||
7 years ago
|
if (version_compare('7', phpversion(), '>=')) {
|
||
7 years ago
|
$sage_error(__('You must be using PHP 7 or greater.', 'aldine'), __('Invalid PHP version', 'aldine'));
|
||
8 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
* Ensure compatible version of WordPress is used
|
||
|
*/
|
||
|
if (version_compare('4.7.0', get_bloginfo('version'), '>=')) {
|
||
7 years ago
|
$sage_error(
|
||
|
__('You must be using WordPress 4.7.0 or greater.', 'aldine'),
|
||
|
__('Invalid WordPress version', 'aldine')
|
||
|
);
|
||
8 years ago
|
}
|
||
|
|
||
|
/**
|
||
|
* Ensure dependencies are loaded
|
||
|
*/
|
||
|
if (!class_exists('Roots\\Sage\\Container')) {
|
||
7 years ago
|
if (!file_exists($composer = __DIR__.'/vendor/autoload.php')) {
|
||
8 years ago
|
$sage_error(
|
||
7 years ago
|
__('You must run <code>composer install</code> from the Sage directory.', 'aldine'),
|
||
|
__('Autoloader not found.', 'aldine')
|
||
8 years ago
|
);
|
||
|
}
|
||
|
require_once $composer;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Sage required files
|
||
|
*
|
||
|
* The mapped array determines the code library included in your theme.
|
||
|
* Add or remove files to the array as needed. Supports child theme overrides.
|
||
|
*/
|
||
|
array_map(function ($file) use ($sage_error) {
|
||
7 years ago
|
$file = "/app/{$file}.php";
|
||
8 years ago
|
if (!locate_template($file, true, true)) {
|
||
7 years ago
|
$sage_error(sprintf(__('Error locating <code>%s</code> for inclusion.', 'aldine'), $file), 'File not found');
|
||
8 years ago
|
}
|
||
7 years ago
|
}, [
|
||
|
'helpers',
|
||
|
'setup',
|
||
|
'filters',
|
||
7 years ago
|
'intervention',
|
||
7 years ago
|
'activation',
|
||
7 years ago
|
'admin',
|
||
|
]);
|
||
8 years ago
|
|
||
|
/**
|
||
|
* Here's what's happening with these hooks:
|
||
|
* 1. WordPress initially detects theme in themes/sage/resources
|
||
|
* 2. Upon activation, we tell WordPress that the theme is actually in themes/sage/resources/views
|
||
|
* 3. When we call get_template_directory() or get_template_directory_uri(), we point it back to themes/sage/resources
|
||
|
*
|
||
|
* We do this so that the Template Hierarchy will look in themes/sage/resources/views for core WordPress themes
|
||
|
* But functions.php, style.css, and index.php are all still located in themes/sage/resources
|
||
|
*
|
||
|
* This is not compatible with the WordPress Customizer theme preview prior to theme activation
|
||
|
*
|
||
|
* get_template_directory() -> /srv/www/example.com/current/web/app/themes/sage/resources
|
||
|
* get_stylesheet_directory() -> /srv/www/example.com/current/web/app/themes/sage/resources
|
||
|
* locate_template()
|
||
|
* ├── STYLESHEETPATH -> /srv/www/example.com/current/web/app/themes/sage/resources/views
|
||
|
* └── TEMPLATEPATH -> /srv/www/example.com/current/web/app/themes/sage/resources
|
||
|
*/
|
||
|
Container::getInstance()
|
||
|
->bindIf('config', function () {
|
||
|
return new Config([
|
||
7 years ago
|
'assets' => require __DIR__.'/config/assets.php',
|
||
|
'theme' => require __DIR__.'/config/theme.php',
|
||
|
'view' => require __DIR__.'/config/view.php',
|
||
8 years ago
|
]);
|
||
|
}, true);
|