Move theme wrapper into separate file
This commit is contained in:
@@ -1,56 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Theme wrapper
|
||||
*
|
||||
* @link http://scribu.net/wordpress/theme-wrappers.html
|
||||
*/
|
||||
function roots_template_path() {
|
||||
return Roots_Wrapping::$main_template;
|
||||
}
|
||||
|
||||
function roots_sidebar_path() {
|
||||
return Roots_Wrapping::sidebar();
|
||||
}
|
||||
|
||||
class Roots_Wrapping {
|
||||
// Stores the full path to the main template file
|
||||
static $main_template;
|
||||
|
||||
// Stores the base name of the template file; e.g. 'page' for 'page.php' etc.
|
||||
static $base;
|
||||
|
||||
static function wrap($template) {
|
||||
self::$main_template = $template;
|
||||
|
||||
self::$base = substr(basename(self::$main_template), 0, -4);
|
||||
|
||||
if (self::$base === 'index') {
|
||||
self::$base = false;
|
||||
}
|
||||
|
||||
$templates = array('base.php');
|
||||
|
||||
if (self::$base) {
|
||||
array_unshift($templates, sprintf('base-%s.php', self::$base));
|
||||
}
|
||||
|
||||
$templates = apply_filters('roots_wrap_base', $templates);
|
||||
return locate_template($templates);
|
||||
}
|
||||
|
||||
static function sidebar() {
|
||||
$templates = array('templates/sidebar.php');
|
||||
|
||||
if (self::$base) {
|
||||
array_unshift($templates, sprintf('templates/sidebar-%s.php', self::$base));
|
||||
}
|
||||
|
||||
$templates = apply_filters('roots_wrap_sidebar', $templates);
|
||||
return locate_template($templates);
|
||||
}
|
||||
}
|
||||
add_filter('template_include', array('Roots_Wrapping', 'wrap'), 99);
|
||||
|
||||
/**
|
||||
* Page titles
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user