Restructure theme, use autoloader

This commit is contained in:
QWp6t
2015-12-18 16:41:37 -08:00
committed by Ben Word
parent 463d6bcf07
commit 3f9b112ffa
13 changed files with 608 additions and 6 deletions

55
app/filters.php Normal file
View File

@@ -0,0 +1,55 @@
<?php namespace App;
use Roots\Sage\Template;
use Roots\Sage\Template\Wrapper;
/**
* Determine which pages should NOT display the sidebar
* @link https://codex.wordpress.org/Conditional_Tags
*/
add_filter('sage/display_sidebar', function ($display) {
/** The sidebar will NOT be displayed if ANY of the following return true. */
return $display ? !in_array(true, [
is_404(),
is_front_page(),
is_page_template('template-custom.php'),
]) : $display;
});
/**
* Add <body> classes
*/
add_filter('body_class', function (array $classes) {
// Add page slug if it doesn't exist
if (is_single() || is_page() && !is_front_page()) {
if (!in_array(basename(get_permalink()), $classes)) {
$classes[] = basename(get_permalink());
}
}
// Add class if sidebar is active
if (display_sidebar()) {
$classes[] = 'sidebar-primary';
}
return $classes;
});
/**
* Clean up the_excerpt()
*/
add_filter('excerpt_more', function () {
return ' &hellip; <a href="' . get_permalink() . '">' . __('Continued', 'sage') . '</a>';
});
/**
* Use Wrapper by default
*/
add_filter('template_include', function ($main) {
if (!is_string($main) || !(string) $main) {
return $main;
}
$main = basename($main, '.php');
return Template::wrap(new Wrapper($main, 'layouts/base.php'))->locate();
}, 109);