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:
Ben Word
2012-08-18 18:49:45 -05:00
parent b54328ce33
commit db41099f5b
34 changed files with 274 additions and 554 deletions

39
404.php
View File

@@ -1,24 +1,15 @@
<?php get_header(); ?>
<?php roots_content_before(); ?>
<div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
<?php roots_main_before(); ?>
<div id="main" class="<?php echo FULLWIDTH_CLASSES; ?>" role="main">
<div class="page-header">
<h1><?php _e('File Not Found', 'roots'); ?></h1>
</div>
<div class="alert alert-block fade in">
<a class="close" data-dismiss="alert">&times;</a>
<p><?php _e('The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.', 'roots'); ?></p>
</div>
<p><?php _e('Please try the following:', 'roots'); ?></p>
<ul>
<li><?php _e('Check your spelling', 'roots'); ?></li>
<li><?php printf(__('Return to the <a href="%s">home page</a>', 'roots'), home_url()); ?></li>
<li><?php _e('Click the <a href="javascript:history.back()">Back</a> button', 'roots'); ?></li>
</ul>
<?php get_search_form(); ?>
</div><!-- /#main -->
<?php roots_main_after(); ?>
</div><!-- /#content -->
<?php roots_content_after(); ?>
<?php get_footer(); ?>
<?php get_template_part('templates/page', 'header'); ?>
<div class="alert alert-block fade in">
<a class="close" data-dismiss="alert">&times;</a>
<p><?php _e('The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.', 'roots'); ?></p>
</div>
<p><?php _e('Please try the following:', 'roots'); ?></p>
<ul>
<li><?php _e('Check your spelling', 'roots'); ?></li>
<li><?php printf(__('Return to the <a href="%s">home page</a>', 'roots'), home_url()); ?></li>
<li><?php _e('Click the <a href="javascript:history.back()">Back</a> button', 'roots'); ?></li>
</ul>
<?php get_search_form(); ?>

View File

@@ -1,3 +1,11 @@
### HEAD
* Implement scribu's [Theme Wrapper](http://scribu.net/wordpress/theme-wrappers.html) (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>`
### 5.2.0: August 18th, 2012
* Update to jQuery 1.8.0 and Modernizr 2.6.1
* Fix duplicate active class in `wp_nav_menu` items

View File

@@ -1,44 +0,0 @@
<?php get_header(); ?>
<?php roots_content_before(); ?>
<div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
<?php roots_main_before(); ?>
<div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
<div class="page-header">
<h1>
<?php
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
if ($term) {
echo $term->name;
} elseif (is_post_type_archive()) {
echo get_queried_object()->labels->name;
} elseif (is_day()) {
printf(__('Daily Archives: %s', 'roots'), get_the_date());
} elseif (is_month()) {
printf(__('Monthly Archives: %s', 'roots'), get_the_date('F Y'));
} elseif (is_year()) {
printf(__('Yearly Archives: %s', 'roots'), get_the_date('Y'));
} elseif (is_author()) {
global $post;
$author_id = $post->post_author;
printf(__('Author Archives: %s', 'roots'), get_the_author_meta('display_name', $author_id));
} else {
single_cat_title();
}
?>
</h1>
</div>
<?php roots_loop_before(); ?>
<?php get_template_part('loop', 'category'); ?>
<?php roots_loop_after(); ?>
</div><!-- /#main -->
<?php roots_main_after(); ?>
<?php roots_sidebar_before(); ?>
<aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
<?php roots_sidebar_inside_before(); ?>
<?php get_sidebar(); ?>
<?php roots_sidebar_inside_after(); ?>
</aside><!-- /#sidebar -->
<?php roots_sidebar_after(); ?>
</div><!-- /#content -->
<?php roots_content_after(); ?>
<?php get_footer(); ?>

31
base.php Normal file
View File

@@ -0,0 +1,31 @@
<?php get_template_part('templates/head'); ?>
<body <?php body_class(); ?>>
<!--[if lt IE 7]><div class="alert">Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</div><![endif]-->
<?php
// Use Bootstrap's navbar if enabled in config.php
if (current_theme_supports('bootstrap-top-navbar')) {
get_template_part('templates/header-top-navbar');
} else {
get_template_part('templates/header');
}
?>
<div id="wrap" class="container" role="document">
<div id="content" class="row">
<div id="main" class="<?php roots_main_class(); ?>" role="main">
<?php include roots_template_path(); ?>
</div>
<?php if (roots_sidebar()) { ?>
<aside id="sidebar" class="<?php roots_sidebar_class(); ?>" role="complementary">
<?php get_template_part('templates/sidebar'); ?>
</aside>
<?php } ?>
</div><!-- /#content -->
</div><!-- /#wrap -->
<?php get_template_part('templates/footer'); ?>
</body>
</html>

View File

@@ -1,4 +1,4 @@
/* =============================================================================
/* ==========================================================================
Base
========================================================================== */
@@ -18,7 +18,7 @@ body.admin-bar .navbar-fixed-top { top: 28px; }
/* =============================================================================
/* ==========================================================================
Content
========================================================================== */
@@ -26,7 +26,7 @@ body.admin-bar .navbar-fixed-top { top: 28px; }
/* =============================================================================
/* ==========================================================================
Primary Content
========================================================================== */
@@ -34,7 +34,7 @@ body.admin-bar .navbar-fixed-top { top: 28px; }
/* =============================================================================
/* ==========================================================================
Sidebar
========================================================================== */
@@ -42,7 +42,7 @@ body.admin-bar .navbar-fixed-top { top: 28px; }
/* =============================================================================
/* ==========================================================================
Posts
========================================================================== */
@@ -54,7 +54,7 @@ body.admin-bar .navbar-fixed-top { top: 28px; }
/* =============================================================================
/* ==========================================================================
Footer
========================================================================== */
@@ -62,7 +62,7 @@ body.admin-bar .navbar-fixed-top { top: 28px; }
/* =============================================================================
/* ==========================================================================
WordPress Generated Classes
See: http://codex.wordpress.org/CSS#WordPress_Generated_Classes
========================================================================== */
@@ -74,7 +74,7 @@ figure.alignnone { margin-left: 0; margin-right: 0; }
/* =============================================================================
/* ==========================================================================
Media Queries
========================================================================== */

View File

@@ -1,134 +0,0 @@
/*
* HTML5 Boilerplate
*
* What follows is the result of much research on cross-browser styling.
* Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
* Kroc Camen, and the H5BP dev community and team.
*
* Detailed information about this CSS: h5bp.com/css
*
* ==|== normalize ==========================================================
*/
article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { display: block; }
audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; }
audio:not([controls]) { display: none; }
[hidden] { display: none; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
html, button, input, select, textarea { font-family: sans-serif; color: #222; }
body { margin: 0; font-size: 1em; line-height: 1.4; }
::-moz-selection { background: #b3d4fc; text-shadow: none; }
::selection { background: #b3d4fc; text-shadow: none; }
a { color: #00e; }
a:visited { color: #551a8b; }
a:hover { color: #06e; }
a:focus { outline: thin dotted; }
a:hover, a:active { outline: 0; }
abbr[title] { border-bottom: 1px dotted; }
b, strong { font-weight: bold; }
blockquote { margin: 1em 40px; }
dfn { font-style: italic; }
hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; }
ins { background: #ff9; color: #000; text-decoration: none; }
mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; }
pre, code, kbd, samp { font-family: monospace, serif; _font-family: 'courier new', monospace; font-size: 1em; }
pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; }
q { quotes: none; }
q:before, q:after { content: ""; content: none; }
small { font-size: 85%; }
sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
sup { top: -0.5em; }
sub { bottom: -0.25em; }
ul, ol { margin: 1em 0; padding: 0 0 0 40px; }
dd { margin: 0 0 0 40px; }
nav ul, nav ol { list-style: none; list-style-image: none; margin: 0; padding: 0; }
img { border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; }
svg:not(:root) { overflow: hidden; }
figure { margin: 0; }
form { margin: 0; }
fieldset { border: 0; margin: 0; padding: 0; }
label { cursor: pointer; }
legend { border: 0; *margin-left: -7px; padding: 0; white-space: normal; }
button, input, select, textarea { font-size: 100%; margin: 0; vertical-align: baseline; *vertical-align: middle; }
button, input { line-height: normal; }
button, input[type="button"], input[type="reset"], input[type="submit"] { cursor: pointer; -webkit-appearance: button; *overflow: visible; }
button[disabled], input[disabled] { cursor: default; }
input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; *width: 13px; *height: 13px; }
input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; }
input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; }
textarea { overflow: auto; vertical-align: top; resize: vertical; }
input:valid, textarea:valid { }
input:invalid, textarea:invalid { background-color: #f0dddd; }
table { border-collapse: collapse; border-spacing: 0; }
td { vertical-align: top; }
.chromeframe { margin: 0.2em 0; background: #ccc; color: black; padding: 0.2em 0; }
/* ==|== primary styles =====================================================
Author:
========================================================================== */
/* ==|== media queries ======================================================
EXAMPLE Media Query for Responsive Design.
This example overrides the primary ('mobile first') styles
Modify as content requires.
========================================================================== */
@media only screen and (min-width: 35em) {
/* Style adjustments for viewports that meet the condition */
}
/* ==|== non-semantic helper classes ======================================== */
.ir { border: 0; font: 0/0 a; text-shadow: none; color: transparent; background-color: transparent; }
.hidden { display: none !important; visibility: hidden; }
.visuallyhidden { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }
.visuallyhidden.focusable:active, .visuallyhidden.focusable:focus { clip: auto; height: auto; margin: 0; overflow: visible; position: static; width: auto; }
.invisible { visibility: hidden; }
.clearfix:before, .clearfix:after { content: ""; display: table; }
.clearfix:after { clear: both; }
.clearfix { *zoom: 1; }
/* ==|== print styles ======================================================= */
@media print {
* { background: transparent !important; color: black !important; box-shadow:none !important; text-shadow: none !important; }
a, a:visited { text-decoration: underline; }
a[href]:after { content: " (" attr(href) ")"; }
abbr[title]:after { content: " (" attr(title) ")"; }
.ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; }
pre, blockquote { border: 1px solid #999; page-break-inside: avoid; }
thead { display: table-header-group; }
tr, img { page-break-inside: avoid; }
img { max-width: 100% !important; }
@page { margin: 0.5cm; }
p, h2, h3 { orphans: 3; widows: 3; }
h2, h3 { page-break-after: avoid; }
}

View File

@@ -1,16 +0,0 @@
</div><!-- /#wrap -->
<?php roots_footer_before(); ?>
<footer id="content-info" class="<?php echo WRAP_CLASSES; ?>" role="contentinfo">
<?php roots_footer_inside(); ?>
<?php dynamic_sidebar('sidebar-footer'); ?>
<p>&copy; <?php echo date('Y'); ?> <?php bloginfo('name'); ?></p>
</footer>
<?php roots_footer_after(); ?>
<?php wp_footer(); ?>
<?php roots_footer(); ?>
</body>
</html>

View File

@@ -1,20 +0,0 @@
<?php get_header(); ?>
<?php roots_content_before(); ?>
<div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
<?php roots_main_before(); ?>
<div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
<?php roots_loop_before(); ?>
<?php get_template_part('loop', 'page'); ?>
<?php roots_loop_after(); ?>
</div><!-- /#main -->
<?php roots_main_after(); ?>
<?php roots_sidebar_before(); ?>
<aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
<?php roots_sidebar_inside_before(); ?>
<?php get_sidebar(); ?>
<?php roots_sidebar_inside_after(); ?>
</aside><!-- /#sidebar -->
<?php roots_sidebar_after(); ?>
</div><!-- /#content -->
<?php roots_content_after(); ?>
<?php get_footer(); ?>

View File

@@ -1,38 +0,0 @@
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" <?php language_attributes(); ?>> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" <?php language_attributes(); ?>> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title><?php wp_title('|', true, 'right'); bloginfo('name'); ?></title>
<?php if (current_theme_supports('bootstrap-responsive')) { ?><meta name="viewport" content="width=device-width, initial-scale=1.0"><?php } ?>
<script src="<?php echo get_template_directory_uri(); ?>/js/vendor/modernizr-2.6.1.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="<?php echo get_template_directory_uri(); ?>/js/vendor/jquery-1.8.0.min.js"><\/script>')</script>
<?php roots_head(); ?>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<!--[if lt IE 7]><div class="alert">Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</div><![endif]-->
<?php roots_header_before(); ?>
<?php
if (current_theme_supports('bootstrap-top-navbar')) {
get_template_part('templates/header', 'top-navbar');
} else {
get_template_part('templates/header', 'default');
}
?>
<?php roots_header_after(); ?>
<?php roots_wrap_before(); ?>
<div id="wrap" class="<?php echo WRAP_CLASSES; ?>" role="document">

View File

@@ -435,11 +435,7 @@ class Roots_Nav_Walker extends Walker_Nav_Menu {
}
function start_lvl(&$output, $depth) {
if (current_theme_supports('bootstrap-top-navbar')) {
$output .= "\n<ul class=\"dropdown-menu\">\n";
} else {
$output .= "\n<ul class=\"sub-menu\">\n";
}
$output .= "\n<ul class=\"dropdown-menu\">\n";
}
function start_el(&$output, $item, $depth, $args) {
@@ -455,11 +451,9 @@ class Roots_Nav_Walker extends Walker_Nav_Menu {
$classes = array_filter($classes, array(&$this, 'check_current'));
if (current_theme_supports('bootstrap-top-navbar')) {
if ($args->has_children) {
$classes[] = 'dropdown';
$li_attributes .= ' data-dropdown="dropdown"';
}
if ($args->has_children) {
$classes[] = 'dropdown';
$li_attributes .= ' data-dropdown="dropdown"';
}
if ($custom_classes = get_post_meta($item->ID, '_menu_item_classes', true)) {
@@ -477,16 +471,12 @@ class Roots_Nav_Walker extends Walker_Nav_Menu {
$attributes .= ! empty($item->target) ? ' target="' . esc_attr($item->target ) .'"' : '';
$attributes .= ! empty($item->xfn) ? ' rel="' . esc_attr($item->xfn ) .'"' : '';
$attributes .= ! empty($item->url) ? ' href="' . esc_attr($item->url ) .'"' : '';
if (current_theme_supports('bootstrap-top-navbar')) {
$attributes .= ($args->has_children) ? ' class="dropdown-toggle" data-toggle="dropdown"' : '';
}
$attributes .= ($args->has_children) ? ' class="dropdown-toggle" data-toggle="dropdown"' : '';
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
if (current_theme_supports('bootstrap-top-navbar')) {
$item_output .= ($args->has_children) ? ' <b class="caret"></b>' : '';
}
$item_output .= ($args->has_children) ? ' <b class="caret"></b>' : '';
$item_output .= '</a>';
$item_output .= $args->after;
@@ -531,8 +521,6 @@ class Roots_Nav_Walker extends Walker_Nav_Menu {
}
}
/**
* Cleanup wp_nav_menu_args
*
@@ -677,3 +665,12 @@ function roots_embed_wrap($cache, $url, $attr = '', $post_ID = '') {
add_filter('embed_oembed_html', 'roots_embed_wrap', 10, 4);
add_filter('embed_googlevideo', 'roots_embed_wrap', 10, 2);
/**
* Tell WordPress to use searchform.php from the templates/ directory
*/
function roots_get_search_form() {
locate_template('/templates/searchform.php', true, true);
}
add_filter('get_search_form', 'roots_get_search_form');

View File

@@ -2,27 +2,42 @@
/**
* Roots configuration and constants
*/
add_theme_support('root-relative-urls'); // Enable relative URLs
add_theme_support('rewrite-urls'); // Enable URL rewrites
add_theme_support('h5bp-htaccess'); // Enable HTML5 Boilerplate's .htaccess
add_theme_support('bootstrap-responsive'); // Enable Bootstrap's responsive CSS
add_theme_support('bootstrap-top-navbar'); // Enable Bootstrap's fixed navbar
// Set the content width based on the theme's design and stylesheet
if (!isset($content_width)) { $content_width = 940; }
// Define which pages shouldn't have the sidebar
function roots_sidebar() {
if (is_404() || is_page_template('page-custom.php')) {
return false;
} else {
return true;
}
}
// #main CSS classes
function roots_main_class() {
if (roots_sidebar()) {
echo 'span8';
} else {
echo 'span12';
}
}
// #sidebar CSS classes
function roots_sidebar_class() {
echo 'span4';
}
define('GOOGLE_ANALYTICS_ID', ''); // UA-XXXXX-Y
define('POST_EXCERPT_LENGTH', 40);
define('WRAP_CLASSES', 'container');
define('CONTAINER_CLASSES', 'row');
define('MAIN_CLASSES', 'span8');
define('SIDEBAR_CLASSES', 'span4');
define('FULLWIDTH_CLASSES', 'span12');
define('GOOGLE_ANALYTICS_ID', ''); // UA-XXXXX-Y
define('WP_BASE', wp_base_dir());
define('THEME_NAME', next(explode('/themes/', get_template_directory())));
define('RELATIVE_PLUGIN_PATH', str_replace(site_url() . '/', '', plugins_url()));
define('FULL_RELATIVE_PLUGIN_PATH', WP_BASE . '/' . RELATIVE_PLUGIN_PATH);
define('RELATIVE_CONTENT_PATH', str_replace(site_url() . '/', '', content_url()));
define('THEME_PATH', RELATIVE_CONTENT_PATH . '/themes/' . THEME_NAME);
// Set the content width based on the theme's design and stylesheet
if (!isset($content_width)) { $content_width = 940; }

View File

@@ -1,31 +1,7 @@
<?php
// header.php
// head.php
function roots_head() { do_action('roots_head'); }
function roots_wrap_before() { do_action('roots_wrap_before'); }
function roots_header_before() { do_action('roots_header_before'); }
function roots_header_inside() { do_action('roots_header_inside'); }
function roots_header_after() { do_action('roots_header_after'); }
// 404.php, archive.php, front-page.php, index.php, loop-page.php, loop-single.php,
// loop.php, page-custom.php, page-full.php, page.php, search.php, single.php
function roots_content_before() { do_action('roots_content_before'); }
function roots_content_after() { do_action('roots_content_after'); }
function roots_main_before() { do_action('roots_main_before'); }
function roots_main_after() { do_action('roots_main_after'); }
function roots_post_before() { do_action('roots_post_before'); }
function roots_post_after() { do_action('roots_post_after'); }
function roots_post_inside_before() { do_action('roots_post_inside_before'); }
function roots_post_inside_after() { do_action('roots_post_inside_after'); }
function roots_loop_before() { do_action('roots_loop_before'); }
function roots_loop_after() { do_action('roots_loop_after'); }
function roots_sidebar_before() { do_action('roots_sidebar_before'); }
function roots_sidebar_inside_before() { do_action('roots_sidebar_inside_before'); }
function roots_sidebar_inside_after() { do_action('roots_sidebar_inside_after'); }
function roots_sidebar_after() { do_action('roots_sidebar_after'); }
// footer.php
function roots_footer_before() { do_action('roots_footer_before'); }
function roots_footer_inside() { do_action('roots_footer_inside'); }
function roots_footer_after() { do_action('roots_footer_after'); }
function roots_footer() { do_action('roots_footer'); }

View File

@@ -4,27 +4,20 @@
*
* Enqueue stylesheets in the following order:
* 1. /theme/css/bootstrap.css
* 2. /theme/css/bootstrap-responsive.css (if enabled in config.php)
* 2. /theme/css/bootstrap-responsive.css
* 3. /theme/css/app.css
* 4. /child-theme/style.css (if a child theme is activated)
*
* Enqueue scripts in the following order:
* 1. /theme/js/vendor/modernizr-2.6.1.min.js (in header.php)
* 2. jquery-1.8.0.min.js via Google CDN (in header.php)
* 1. /theme/js/vendor/modernizr-2.6.1.min.js (in head.php)
* 2. jquery-1.8.0.min.js via Google CDN (in head.php)
* 3. /theme/js/plugins.js
* 4. /theme/js/main.js
*/
function roots_scripts() {
wp_enqueue_style('roots_bootstrap', get_template_directory_uri() . '/css/bootstrap.css', false, null);
if (current_theme_supports('bootstrap-responsive')) {
wp_enqueue_style('roots_bootstrap_responsive', get_template_directory_uri() . '/css/bootstrap-responsive.css', array('roots_bootstrap'), null);
}
// If you're not using Bootstrap, include HTML5 Boilerplate's main.css:
// wp_enqueue_style('roots_h5bp', get_template_directory_uri() . '/css/main.css', false, null);
wp_enqueue_style('roots_bootstrap_responsive', get_template_directory_uri() . '/css/bootstrap-responsive.css', array('roots_bootstrap'), null);
wp_enqueue_style('roots_app', get_template_directory_uri() . '/css/app.css', false, null);
// Load style.css from child theme

View File

@@ -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);
}
}

View File

@@ -1,21 +1,2 @@
<?php get_header(); ?>
<?php roots_content_before(); ?>
<div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
<?php roots_main_before(); ?>
<div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
<div class="page-header">
<h1><?php _e('Latest Posts', 'roots');?></h1>
</div>
<?php get_template_part('loop', 'index'); ?>
</div><!-- /#main -->
<?php roots_main_after(); ?>
<?php roots_sidebar_before(); ?>
<aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
<?php roots_sidebar_inside_before(); ?>
<?php get_sidebar(); ?>
<?php roots_sidebar_inside_after(); ?>
</aside><!-- /#sidebar -->
<?php roots_sidebar_after(); ?>
</div><!-- /#content -->
<?php roots_content_after(); ?>
<?php get_footer(); ?>
<?php get_template_part('templates/page', 'header'); ?>
<?php get_template_part('templates/content', get_post_format()); ?>

View File

@@ -1,12 +0,0 @@
<?php /* Start loop */ ?>
<?php while (have_posts()) : the_post(); ?>
<?php roots_post_before(); ?>
<?php roots_post_inside_before(); ?>
<div class="page-header">
<h1><?php the_title(); ?></h1>
</div>
<?php the_content(); ?>
<?php wp_link_pages(array('before' => '<nav class="pagination">', 'after' => '</nav>')); ?>
<?php roots_post_inside_after(); ?>
<?php roots_post_after(); ?>
<?php endwhile; /* End loop */ ?>

View File

@@ -1,21 +0,0 @@
<?php /* Start loop */ ?>
<?php while (have_posts()) : the_post(); ?>
<?php roots_post_before(); ?>
<article <?php post_class() ?> id="post-<?php the_ID(); ?>">
<?php roots_post_inside_before(); ?>
<header>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php roots_entry_meta(); ?>
</header>
<div class="entry-content">
<?php the_content(); ?>
</div>
<footer>
<?php wp_link_pages(array('before' => '<nav id="page-nav"><p>' . __('Pages:', 'roots'), 'after' => '</p></nav>')); ?>
<?php $tags = get_the_tags(); if ($tags) { ?><p><?php the_tags(); ?></p><?php } ?>
</footer>
<?php comments_template(); ?>
<?php roots_post_inside_after(); ?>
</article>
<?php roots_post_after(); ?>
<?php endwhile; /* End loop */ ?>

View File

@@ -1,40 +0,0 @@
<?php /* If there are no posts to display, such as an empty archive page */ ?>
<?php if (!have_posts()) { ?>
<div class="alert alert-block fade in">
<a class="close" data-dismiss="alert">&times;</a>
<p><?php _e('Sorry, no results were found.', 'roots'); ?></p>
</div>
<?php get_search_form(); ?>
<?php } ?>
<?php /* Start loop */ ?>
<?php while (have_posts()) : the_post(); ?>
<?php roots_post_before(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php roots_post_inside_before(); ?>
<header>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php roots_entry_meta(); ?>
</header>
<div class="entry-content">
<?php if (is_archive() || is_search()) { ?>
<?php the_excerpt(); ?>
<?php } else { ?>
<?php the_content(); ?>
<?php } ?>
</div>
<footer>
<?php $tags = get_the_tags(); if ($tags) { ?><p><?php the_tags(); ?></p><?php } ?>
</footer>
<?php roots_post_inside_after(); ?>
</article>
<?php roots_post_after(); ?>
<?php endwhile; /* End loop */ ?>
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ($wp_query->max_num_pages > 1) { ?>
<nav id="post-nav" class="pager">
<div class="previous"><?php next_posts_link(__('&larr; Older posts', 'roots')); ?></div>
<div class="next"><?php previous_posts_link(__('Newer posts &rarr;', 'roots')); ?></div>
</nav>
<?php } ?>

View File

@@ -1,24 +1,8 @@
<?php
/*
Template Name: Custom
Template Name: Custom Template
*/
get_header(); ?>
<?php roots_content_before(); ?>
<div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
<?php roots_main_before(); ?>
<div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
<?php roots_loop_before(); ?>
<?php get_template_part('loop', 'page'); ?>
<?php roots_loop_after(); ?>
</div><!-- /#main -->
<?php roots_main_after(); ?>
<?php roots_sidebar_before(); ?>
<aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
<?php roots_sidebar_inside_before(); ?>
<?php get_sidebar(); ?>
<?php roots_sidebar_inside_after(); ?>
</aside><!-- /#sidebar -->
<?php roots_sidebar_after(); ?>
</div><!-- /#content -->
<?php roots_content_after(); ?>
<?php get_footer(); ?>
?>
<?php get_template_part('templates/page', 'header'); ?>
<?php get_template_part('templates/content', 'page'); ?>

View File

@@ -1,17 +0,0 @@
<?php
/*
Template Name: Full Width
*/
get_header(); ?>
<?php roots_content_before(); ?>
<div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
<?php roots_main_before(); ?>
<div id="main" class="<?php echo FULLWIDTH_CLASSES; ?>" role="main">
<?php roots_loop_before(); ?>
<?php get_template_part('loop', 'page'); ?>
<?php roots_loop_after(); ?>
</div><!-- /#main -->
<?php roots_main_after(); ?>
</div><!-- /#content -->
<?php roots_content_after(); ?>
<?php get_footer(); ?>

View File

@@ -1,20 +1,2 @@
<?php get_header(); ?>
<?php roots_content_before(); ?>
<div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
<?php roots_main_before(); ?>
<div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
<?php roots_loop_before(); ?>
<?php get_template_part('loop', 'page'); ?>
<?php roots_loop_after(); ?>
</div><!-- /#main -->
<?php roots_main_after(); ?>
<?php roots_sidebar_before(); ?>
<aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
<?php roots_sidebar_inside_before(); ?>
<?php get_sidebar(); ?>
<?php roots_sidebar_inside_after(); ?>
</aside><!-- /#sidebar -->
<?php roots_sidebar_after(); ?>
</div><!-- /#content -->
<?php roots_content_after(); ?>
<?php get_footer(); ?>
<?php get_template_part('templates/page', 'header'); ?>
<?php get_template_part('templates/content', 'page'); ?>

View File

@@ -1,23 +0,0 @@
<?php get_header(); ?>
<?php roots_content_before(); ?>
<div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
<?php roots_main_before(); ?>
<div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
<div class="page-header">
<h1><?php _e('Search Results for', 'roots'); ?> <?php echo get_search_query(); ?></h1>
</div>
<?php roots_loop_before(); ?>
<?php get_template_part('loop', 'search'); ?>
<?php roots_loop_after(); ?>
</div><!-- /#main -->
<?php roots_main_after(); ?>
<?php roots_sidebar_before(); ?>
<aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
<?php roots_sidebar_inside_before(); ?>
<?php get_sidebar(); ?>
<?php roots_sidebar_inside_after(); ?>
</aside><!-- /#sidebar -->
<?php roots_sidebar_after(); ?>
</div><!-- /#content -->
<?php roots_content_after(); ?>
<?php get_footer(); ?>

View File

@@ -1,20 +1 @@
<?php get_header(); ?>
<?php roots_content_before(); ?>
<div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
<?php roots_main_before(); ?>
<div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
<?php roots_loop_before(); ?>
<?php get_template_part('loop', 'single'); ?>
<?php roots_loop_after(); ?>
</div><!-- /#main -->
<?php roots_main_after(); ?>
<?php roots_sidebar_before(); ?>
<aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
<?php roots_sidebar_inside_before(); ?>
<?php get_sidebar(); ?>
<?php roots_sidebar_inside_after(); ?>
</aside><!-- /#sidebar -->
<?php roots_sidebar_after(); ?>
</div><!-- /#content -->
<?php roots_content_after(); ?>
<?php get_footer(); ?>
<?php get_template_part('templates/content', 'single'); ?>

View File

@@ -0,0 +1,4 @@
<?php while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php wp_link_pages(array('before' => '<nav class="pagination">', 'after' => '</nav>')); ?>
<?php endwhile; ?>

View File

@@ -0,0 +1,16 @@
<?php while (have_posts()) : the_post(); ?>
<article <?php post_class() ?> id="post-<?php the_ID(); ?>">
<header>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php roots_entry_meta(); ?>
</header>
<div class="entry-content">
<?php the_content(); ?>
</div>
<footer>
<?php wp_link_pages(array('before' => '<nav id="page-nav"><p>' . __('Pages:', 'roots'), 'after' => '</p></nav>')); ?>
<?php $tags = get_the_tags(); if ($tags) { ?><p><?php the_tags(); ?></p><?php } ?>
</footer>
<?php comments_template('/templates/comments.php'); ?>
</article>
<?php endwhile; ?>

29
templates/content.php Normal file
View File

@@ -0,0 +1,29 @@
<?php if (!have_posts()) { ?>
<div class="alert alert-block fade in">
<a class="close" data-dismiss="alert">&times;</a>
<p><?php _e('Sorry, no results were found.', 'roots'); ?></p>
</div>
<?php get_search_form(); ?>
<?php } ?>
<?php while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php roots_entry_meta(); ?>
</header>
<div class="entry-content">
<?php the_excerpt(); ?>
</div>
<footer>
<?php the_tags('<ul class="entry-tags"><li>','</li><li>','</li></ul>'); ?>
</footer>
</article>
<?php endwhile; ?>
<?php if ($wp_query->max_num_pages > 1) { ?>
<nav id="post-nav" class="pager">
<div class="previous"><?php next_posts_link(__('&larr; Older posts', 'roots')); ?></div>
<div class="next"><?php previous_posts_link(__('Newer posts &rarr;', 'roots')); ?></div>
</nav>
<?php } ?>

7
templates/footer.php Normal file
View File

@@ -0,0 +1,7 @@
<footer id="content-info" class="container" role="contentinfo">
<?php dynamic_sidebar('sidebar-footer'); ?>
<p>&copy; <?php echo date('Y'); ?> <?php bloginfo('name'); ?></p>
</footer>
<?php wp_footer(); ?>
<?php roots_footer(); ?>

18
templates/head.php Normal file
View File

@@ -0,0 +1,18 @@
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" <?php language_attributes(); ?>> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" <?php language_attributes(); ?>> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title><?php wp_title('|', true, 'right'); bloginfo('name'); ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="<?php echo get_template_directory_uri(); ?>/js/vendor/modernizr-2.6.1.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="<?php echo get_template_directory_uri(); ?>/js/vendor/jquery-1.8.0.min.js"><\/script>')</script>
<?php wp_head(); ?>
<?php roots_head(); ?>
</head>

View File

@@ -1,8 +1,7 @@
<header id="banner" class="navbar navbar-fixed-top" role="banner">
<?php roots_header_inside(); ?>
<div class="navbar-inner">
<div class="<?php echo WRAP_CLASSES; ?>">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>

View File

@@ -1,9 +1,6 @@
<header id="banner" role="banner">
<?php roots_header_inside(); ?>
<div class="<?php echo WRAP_CLASSES; ?>">
<a class="brand" href="<?php echo home_url(); ?>/">
<?php bloginfo('name'); ?>
</a>
<div class="container">
<a class="brand" href="<?php echo home_url(); ?>/"><?php bloginfo('name'); ?></a>
<nav id="nav-main" role="navigation">
<?php wp_nav_menu(array('theme_location' => 'primary_navigation', 'menu_class' => 'nav nav-pills')); ?>
</nav>

38
templates/page-header.php Normal file
View File

@@ -0,0 +1,38 @@
<div class="page-header">
<h1>
<?php
if (is_home()) {
if (get_option('page_for_posts', true)) {
echo get_the_title(get_option('page_for_posts', true));
} else {
_e('Latest Posts', 'roots');
}
} elseif (is_archive()) {
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
if ($term) {
echo $term->name;
} elseif (is_post_type_archive()) {
echo get_queried_object()->labels->name;
} elseif (is_day()) {
printf(__('Daily Archives: %s', 'roots'), get_the_date());
} elseif (is_month()) {
printf(__('Monthly Archives: %s', 'roots'), get_the_date('F Y'));
} elseif (is_year()) {
printf(__('Yearly Archives: %s', 'roots'), get_the_date('Y'));
} elseif (is_author()) {
global $post;
$author_id = $post->post_author;
printf(__('Author Archives: %s', 'roots'), get_the_author_meta('display_name', $author_id));
} else {
single_cat_title();
}
} elseif (is_search()) {
printf(__('Search Results for %s', 'roots'), get_search_query());
} elseif (is_404()) {
_e('File Not Found', 'roots');
} else {
the_title();
}
?>
</h1>
</div>

View File

@@ -1,5 +1,5 @@
<form role="search" method="get" id="searchform" class="form-search" action="<?php echo home_url('/'); ?>">
<label class="hide-text" for="s"><?php _e('Search for:', 'roots'); ?></label>
<label class="hide" for="s"><?php _e('Search for:', 'roots'); ?></label>
<input type="text" value="" name="s" id="s" class="search-query" placeholder="<?php _e('Search', 'roots'); ?> <?php bloginfo('name'); ?>">
<input type="submit" id="searchsubmit" value="<?php _e('Search', 'roots'); ?>" class="btn">
</form>