Add theme wrapper, re-organize template files
- Implement scribu’s Theme Wrapper (see base.php) - Move templates, comments.php, and searchform.php to templates/ folder - Rename loop- files to content- - Remove all hooks except roots_head and roots_footer - Use templates/page-header.php for page titles - Use head.php for everything in <head>
This commit is contained in:
40
inc/util.php
40
inc/util.php
@@ -1,5 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Theme Wrapper
|
||||
*
|
||||
* @link http://scribu.net/wordpress/theme-wrappers.html
|
||||
*/
|
||||
|
||||
function roots_template_path() {
|
||||
return Roots_Wrapping::$main_template;
|
||||
}
|
||||
|
||||
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 ('index' == self::$base) {
|
||||
self::$base = false;
|
||||
}
|
||||
|
||||
$templates = array('base.php');
|
||||
|
||||
if (self::$base) {
|
||||
array_unshift($templates, sprintf('base-%s.php', self::$base ));
|
||||
}
|
||||
|
||||
return locate_template($templates);
|
||||
}
|
||||
}
|
||||
|
||||
add_filter('template_include', array('Roots_Wrapping', 'wrap'), 99);
|
||||
|
||||
// returns WordPress subdirectory if applicable
|
||||
function wp_base_dir() {
|
||||
preg_match('!(https?://[^/|"]+)([^"]+)?!', site_url(), $matches);
|
||||
@@ -24,4 +63,3 @@ function add_filters($tags, $function) {
|
||||
add_filter($tag, $function);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user