Skip to content
This repository
Browse code

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>
  • Loading branch information...
commit db41099f5b4be8166390408aa4f285b131e17ec0 1 parent b54328c
Ben Word authored August 18, 2012
39  404.php
... ...
@@ -1,24 +1,15 @@
1  
-<?php get_header(); ?>
2  
-  <?php roots_content_before(); ?>
3  
-    <div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
4  
-    <?php roots_main_before(); ?>
5  
-      <div id="main" class="<?php echo FULLWIDTH_CLASSES; ?>" role="main">
6  
-        <div class="page-header">
7  
-          <h1><?php _e('File Not Found', 'roots'); ?></h1>
8  
-        </div>
9  
-        <div class="alert alert-block fade in">
10  
-          <a class="close" data-dismiss="alert">&times;</a>
11  
-          <p><?php _e('The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.', 'roots'); ?></p>
12  
-        </div>
13  
-        <p><?php _e('Please try the following:', 'roots'); ?></p>
14  
-        <ul>
15  
-          <li><?php _e('Check your spelling', 'roots'); ?></li>
16  
-          <li><?php printf(__('Return to the <a href="%s">home page</a>', 'roots'), home_url()); ?></li>
17  
-          <li><?php _e('Click the <a href="javascript:history.back()">Back</a> button', 'roots'); ?></li>
18  
-        </ul>
19  
-        <?php get_search_form(); ?>
20  
-      </div><!-- /#main -->
21  
-    <?php roots_main_after(); ?>
22  
-    </div><!-- /#content -->
23  
-  <?php roots_content_after(); ?>
24  
-<?php get_footer(); ?>
  1
+<?php get_template_part('templates/page', 'header'); ?>
  2
+
  3
+<div class="alert alert-block fade in">
  4
+  <a class="close" data-dismiss="alert">&times;</a>
  5
+  <p><?php _e('The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.', 'roots'); ?></p>
  6
+</div>
  7
+
  8
+<p><?php _e('Please try the following:', 'roots'); ?></p>
  9
+<ul>
  10
+  <li><?php _e('Check your spelling', 'roots'); ?></li>
  11
+  <li><?php printf(__('Return to the <a href="%s">home page</a>', 'roots'), home_url()); ?></li>
  12
+  <li><?php _e('Click the <a href="javascript:history.back()">Back</a> button', 'roots'); ?></li>
  13
+</ul>
  14
+
  15
+<?php get_search_form(); ?>
8  CHANGELOG.md
Source Rendered
... ...
@@ -1,3 +1,11 @@
  1
+### HEAD
  2
+* Implement scribu's [Theme Wrapper](http://scribu.net/wordpress/theme-wrappers.html) (see `base.php`)
  3
+* Move templates, `comments.php`, and `searchform.php` to `templates/` folder
  4
+* Rename `loop-` files to `content-`
  5
+* Remove all hooks except `roots_head` and `roots_footer`
  6
+* Use `templates/page-header.php` for page titles
  7
+* Use `head.php` for everything in `<head>`
  8
+
1 9
 ### 5.2.0: August 18th, 2012
2 10
 * Update to jQuery 1.8.0 and Modernizr 2.6.1
3 11
 * Fix duplicate active class in `wp_nav_menu` items
44  archive.php
... ...
@@ -1,44 +0,0 @@
1  
-<?php get_header(); ?>
2  
-  <?php roots_content_before(); ?>
3  
-    <div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
4  
-    <?php roots_main_before(); ?>
5  
-      <div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
6  
-        <div class="page-header">
7  
-          <h1>
8  
-            <?php
9  
-              $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
10  
-              if ($term) {
11  
-                echo $term->name;
12  
-              } elseif (is_post_type_archive()) {
13  
-                echo get_queried_object()->labels->name;
14  
-              } elseif (is_day()) {
15  
-                printf(__('Daily Archives: %s', 'roots'), get_the_date());
16  
-              } elseif (is_month()) {
17  
-                printf(__('Monthly Archives: %s', 'roots'), get_the_date('F Y'));
18  
-              } elseif (is_year()) {
19  
-                printf(__('Yearly Archives: %s', 'roots'), get_the_date('Y'));
20  
-              } elseif (is_author()) {
21  
-                global $post;
22  
-                $author_id = $post->post_author;
23  
-                printf(__('Author Archives: %s', 'roots'), get_the_author_meta('display_name', $author_id));
24  
-              } else {
25  
-                single_cat_title();
26  
-              }
27  
-            ?>
28  
-          </h1>
29  
-        </div>
30  
-        <?php roots_loop_before(); ?>
31  
-        <?php get_template_part('loop', 'category'); ?>
32  
-        <?php roots_loop_after(); ?>
33  
-      </div><!-- /#main -->
34  
-    <?php roots_main_after(); ?>
35  
-    <?php roots_sidebar_before(); ?>
36  
-      <aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
37  
-      <?php roots_sidebar_inside_before(); ?>
38  
-        <?php get_sidebar(); ?>
39  
-      <?php roots_sidebar_inside_after(); ?>
40  
-      </aside><!-- /#sidebar -->
41  
-    <?php roots_sidebar_after(); ?>
42  
-    </div><!-- /#content -->
43  
-  <?php roots_content_after(); ?>
44  
-<?php get_footer(); ?>
31  base.php
... ...
@@ -0,0 +1,31 @@
  1
+<?php get_template_part('templates/head'); ?>
  2
+<body <?php body_class(); ?>>
  3
+
  4
+  <!--[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]-->
  5
+
  6
+  <?php
  7
+    // Use Bootstrap's navbar if enabled in config.php
  8
+    if (current_theme_supports('bootstrap-top-navbar')) {
  9
+      get_template_part('templates/header-top-navbar');
  10
+    } else {
  11
+      get_template_part('templates/header');
  12
+    }
  13
+  ?>
  14
+
  15
+  <div id="wrap" class="container" role="document">
  16
+    <div id="content" class="row">
  17
+      <div id="main" class="<?php roots_main_class(); ?>" role="main">
  18
+        <?php include roots_template_path(); ?>
  19
+      </div>
  20
+      <?php if (roots_sidebar()) { ?>
  21
+      <aside id="sidebar" class="<?php roots_sidebar_class(); ?>" role="complementary">
  22
+        <?php get_template_part('templates/sidebar'); ?>
  23
+      </aside>
  24
+      <?php } ?>
  25
+    </div><!-- /#content -->
  26
+  </div><!-- /#wrap -->
  27
+
  28
+  <?php get_template_part('templates/footer'); ?>
  29
+
  30
+</body>
  31
+</html>
16  css/app.css
... ...
@@ -1,4 +1,4 @@
1  
-/* =============================================================================
  1
+/* ==========================================================================
2 2
    Base
3 3
    ========================================================================== */
4 4
 
@@ -18,7 +18,7 @@ body.admin-bar .navbar-fixed-top { top: 28px; }
18 18
 
19 19
 
20 20
 
21  
-/* =============================================================================
  21
+/* ==========================================================================
22 22
    Content
23 23
    ========================================================================== */
24 24
 
@@ -26,7 +26,7 @@ body.admin-bar .navbar-fixed-top { top: 28px; }
26 26
 
27 27
 
28 28
 
29  
-/* =============================================================================
  29
+/* ==========================================================================
30 30
    Primary Content
31 31
    ========================================================================== */
32 32
 
@@ -34,7 +34,7 @@ body.admin-bar .navbar-fixed-top { top: 28px; }
34 34
 
35 35
 
36 36
 
37  
-/* =============================================================================
  37
+/* ==========================================================================
38 38
    Sidebar
39 39
    ========================================================================== */
40 40
 
@@ -42,7 +42,7 @@ body.admin-bar .navbar-fixed-top { top: 28px; }
42 42
 
43 43
 
44 44
 
45  
-/* =============================================================================
  45
+/* ==========================================================================
46 46
    Posts
47 47
    ========================================================================== */
48 48
 
@@ -54,7 +54,7 @@ body.admin-bar .navbar-fixed-top { top: 28px; }
54 54
 
55 55
 
56 56
 
57  
-/* =============================================================================
  57
+/* ==========================================================================
58 58
    Footer
59 59
    ========================================================================== */
60 60
 
@@ -62,7 +62,7 @@ body.admin-bar .navbar-fixed-top { top: 28px; }
62 62
 
63 63
 
64 64
 
65  
-/* =============================================================================
  65
+/* ==========================================================================
66 66
    WordPress Generated Classes
67 67
    See: http://codex.wordpress.org/CSS#WordPress_Generated_Classes
68 68
    ========================================================================== */
@@ -74,7 +74,7 @@ figure.alignnone { margin-left: 0; margin-right: 0; }
74 74
 
75 75
 
76 76
 
77  
-/* =============================================================================
  77
+/* ==========================================================================
78 78
    Media Queries
79 79
    ========================================================================== */
80 80
 
134  css/main.css
... ...
@@ -1,134 +0,0 @@
1  
-/*
2  
- * HTML5 Boilerplate
3  
- *
4  
- * What follows is the result of much research on cross-browser styling.
5  
- * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
6  
- * Kroc Camen, and the H5BP dev community and team.
7  
- *
8  
- * Detailed information about this CSS: h5bp.com/css
9  
- *
10  
- * ==|== normalize ==========================================================
11  
- */
12  
-
13  
-article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { display: block; }
14  
-audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; }
15  
-audio:not([controls]) { display: none; }
16  
-[hidden] { display: none; }
17  
-
18  
-html { font-size: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
19  
-html, button, input, select, textarea { font-family: sans-serif; color: #222; }
20  
-body { margin: 0; font-size: 1em; line-height: 1.4; }
21  
-
22  
-::-moz-selection { background: #b3d4fc; text-shadow: none; }
23  
-::selection { background: #b3d4fc; text-shadow: none; }
24  
-
25  
-a { color: #00e; }
26  
-a:visited { color: #551a8b; }
27  
-a:hover { color: #06e; }
28  
-a:focus { outline: thin dotted; }
29  
-a:hover, a:active { outline: 0; }
30  
-
31  
-abbr[title] { border-bottom: 1px dotted; }
32  
-b, strong { font-weight: bold; }
33  
-blockquote { margin: 1em 40px; }
34  
-dfn { font-style: italic; }
35  
-hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; }
36  
-ins { background: #ff9; color: #000; text-decoration: none; }
37  
-mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; }
38  
-pre, code, kbd, samp { font-family: monospace, serif; _font-family: 'courier new', monospace; font-size: 1em; }
39  
-pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; }
40  
-q { quotes: none; }
41  
-q:before, q:after { content: ""; content: none; }
42  
-small { font-size: 85%; }
43  
-sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
44  
-sup { top: -0.5em; }
45  
-sub { bottom: -0.25em; }
46  
-ul, ol { margin: 1em 0; padding: 0 0 0 40px; }
47  
-dd { margin: 0 0 0 40px; }
48  
-nav ul, nav ol { list-style: none; list-style-image: none; margin: 0; padding: 0; }
49  
-img { border: 0; -ms-interpolation-mode: bicubic; vertical-align: middle; }
50  
-svg:not(:root) { overflow: hidden; }
51  
-figure { margin: 0; }
52  
-
53  
-form { margin: 0; }
54  
-fieldset { border: 0; margin: 0; padding: 0; }
55  
-label { cursor: pointer; }
56  
-legend { border: 0; *margin-left: -7px; padding: 0; white-space: normal; }
57  
-button, input, select, textarea { font-size: 100%; margin: 0; vertical-align: baseline; *vertical-align: middle; }
58  
-button, input { line-height: normal; }
59  
-button, input[type="button"], input[type="reset"], input[type="submit"] { cursor: pointer; -webkit-appearance: button; *overflow: visible; }
60  
-button[disabled], input[disabled] { cursor: default; }
61  
-input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; *width: 13px; *height: 13px; }
62  
-input[type="search"] { -webkit-appearance: textfield; -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; }
63  
-input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
64  
-button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; }
65  
-textarea { overflow: auto; vertical-align: top; resize: vertical; }
66  
-input:valid, textarea:valid {  }
67  
-input:invalid, textarea:invalid { background-color: #f0dddd; }
68  
-
69  
-table { border-collapse: collapse; border-spacing: 0; }
70  
-td { vertical-align: top; }
71  
-
72  
-.chromeframe { margin: 0.2em 0; background: #ccc; color: black; padding: 0.2em 0; }
73  
-
74  
-
75  
-/* ==|== primary styles =====================================================
76  
-   Author:
77  
-   ========================================================================== */
78  
-
79  
-
80  
-
81  
-
82  
-
83  
-
84  
-
85  
-
86  
-
87  
-
88  
-
89  
-
90  
-
91  
-
92  
-
93  
-
94  
-/* ==|== media queries ======================================================
95  
-   EXAMPLE Media Query for Responsive Design.
96  
-   This example overrides the primary ('mobile first') styles
97  
-   Modify as content requires.
98  
-   ========================================================================== */
99  
-
100  
-@media only screen and (min-width: 35em) {
101  
-  /* Style adjustments for viewports that meet the condition */
102  
-}
103  
-
104  
-
105  
-
106  
-/* ==|== non-semantic helper classes ======================================== */
107  
-
108  
-.ir { border: 0; font: 0/0 a; text-shadow: none; color: transparent; background-color: transparent; }
109  
-.hidden { display: none !important; visibility: hidden; }
110  
-.visuallyhidden { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }
111  
-.visuallyhidden.focusable:active, .visuallyhidden.focusable:focus { clip: auto; height: auto; margin: 0; overflow: visible; position: static; width: auto; }
112  
-.invisible { visibility: hidden; }
113  
-.clearfix:before, .clearfix:after { content: ""; display: table; }
114  
-.clearfix:after { clear: both; }
115  
-.clearfix { *zoom: 1; }
116  
-
117  
-
118  
-
119  
-/* ==|== print styles ======================================================= */
120  
-
121  
-@media print {
122  
-  * { background: transparent !important; color: black !important; box-shadow:none !important; text-shadow: none !important; }
123  
-  a, a:visited { text-decoration: underline; }
124  
-  a[href]:after { content: " (" attr(href) ")"; }
125  
-  abbr[title]:after { content: " (" attr(title) ")"; }
126  
-  .ir a:after, a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; }
127  
-  pre, blockquote { border: 1px solid #999; page-break-inside: avoid; }
128  
-  thead { display: table-header-group; }
129  
-  tr, img { page-break-inside: avoid; }
130  
-  img { max-width: 100% !important; }
131  
-  @page { margin: 0.5cm; }
132  
-  p, h2, h3 { orphans: 3; widows: 3; }
133  
-  h2, h3 { page-break-after: avoid; }
134  
-}
16  footer.php
... ...
@@ -1,16 +0,0 @@
20  front-page.php
... ...
@@ -1,20 +0,0 @@
1  
-<?php get_header(); ?>
2  
-  <?php roots_content_before(); ?>
3  
-    <div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
4  
-    <?php roots_main_before(); ?>
5  
-      <div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
6  
-        <?php roots_loop_before(); ?>
7  
-        <?php get_template_part('loop', 'page'); ?>
8  
-        <?php roots_loop_after(); ?>
9  
-      </div><!-- /#main -->
10  
-    <?php roots_main_after(); ?>
11  
-    <?php roots_sidebar_before(); ?>
12  
-      <aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
13  
-      <?php roots_sidebar_inside_before(); ?>
14  
-        <?php get_sidebar(); ?>
15  
-      <?php roots_sidebar_inside_after(); ?>
16  
-      </aside><!-- /#sidebar -->
17  
-    <?php roots_sidebar_after(); ?>
18  
-    </div><!-- /#content -->
19  
-  <?php roots_content_after(); ?>
20  
-<?php get_footer(); ?>
38  header.php
... ...
@@ -1,38 +0,0 @@
1  
-<!DOCTYPE html>
2  
-<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" <?php language_attributes(); ?>> <![endif]-->
3  
-<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" <?php language_attributes(); ?>> <![endif]-->
4  
-<!--[if IE 8]>    <html class="no-js lt-ie9" <?php language_attributes(); ?>> <![endif]-->
5  
-<!--[if gt IE 8]><!--> <html class="no-js" <?php language_attributes(); ?>> <!--<![endif]-->
6  
-<head>
7  
-  <meta charset="utf-8">
8  
-
9  
-  <title><?php wp_title('|', true, 'right'); bloginfo('name'); ?></title>
10  
-
11  
-  <?php if (current_theme_supports('bootstrap-responsive')) { ?><meta name="viewport" content="width=device-width, initial-scale=1.0"><?php } ?>
12  
-
13  
-  <script src="<?php echo get_template_directory_uri(); ?>/js/vendor/modernizr-2.6.1.min.js"></script>
14  
-
15  
-  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
16  
-  <script>window.jQuery || document.write('<script src="<?php echo get_template_directory_uri(); ?>/js/vendor/jquery-1.8.0.min.js"><\/script>')</script>
17  
-
18  
-  <?php roots_head(); ?>
19  
-  <?php wp_head(); ?>
20  
-
21  
-</head>
22  
-
23  
-<body <?php body_class(); ?>>
24  
-
25  
-  <!--[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]-->
26  
-
27  
-  <?php roots_header_before(); ?>
28  
-  <?php
29  
-    if (current_theme_supports('bootstrap-top-navbar')) {
30  
-      get_template_part('templates/header', 'top-navbar');
31  
-    } else {
32  
-      get_template_part('templates/header', 'default');
33  
-    }
34  
-  ?>
35  
-  <?php roots_header_after(); ?>
36  
-
37  
-  <?php roots_wrap_before(); ?>
38  
-  <div id="wrap" class="<?php echo WRAP_CLASSES; ?>" role="document">
33  inc/cleanup.php
@@ -435,11 +435,7 @@ function check_current($classes) {
435 435
   }
436 436
 
437 437
   function start_lvl(&$output, $depth) {
438  
-    if (current_theme_supports('bootstrap-top-navbar')) {
439  
-      $output .= "\n<ul class=\"dropdown-menu\">\n";
440  
-    } else {
441  
-      $output .= "\n<ul class=\"sub-menu\">\n";
442  
-    }
  438
+    $output .= "\n<ul class=\"dropdown-menu\">\n";
443 439
   }
444 440
 
445 441
   function start_el(&$output, $item, $depth, $args) {
@@ -455,11 +451,9 @@ function start_el(&$output, $item, $depth, $args) {
455 451
 
456 452
     $classes = array_filter($classes, array(&$this, 'check_current'));
457 453
 
458  
-    if (current_theme_supports('bootstrap-top-navbar')) {
459  
-      if ($args->has_children) {
460  
-        $classes[]      = 'dropdown';
461  
-        $li_attributes .= ' data-dropdown="dropdown"';
462  
-      }
  454
+    if ($args->has_children) {
  455
+      $classes[]      = 'dropdown';
  456
+      $li_attributes .= ' data-dropdown="dropdown"';
463 457
     }
464 458
 
465 459
     if ($custom_classes = get_post_meta($item->ID, '_menu_item_classes', true)) {
@@ -477,16 +471,12 @@ function start_el(&$output, $item, $depth, $args) {
477 471
     $attributes .= ! empty($item->target)     ? ' target="' . esc_attr($item->target    ) .'"' : '';
478 472
     $attributes .= ! empty($item->xfn)        ? ' rel="'    . esc_attr($item->xfn       ) .'"' : '';
479 473
     $attributes .= ! empty($item->url)        ? ' href="'   . esc_attr($item->url       ) .'"' : '';
480  
-    if (current_theme_supports('bootstrap-top-navbar')) {
481  
-      $attributes .= ($args->has_children)    ? ' class="dropdown-toggle" data-toggle="dropdown"' : '';
482  
-    }
  474
+    $attributes .= ($args->has_children)    ? ' class="dropdown-toggle" data-toggle="dropdown"' : '';
483 475
 
484 476
     $item_output  = $args->before;
485 477
     $item_output .= '<a'. $attributes .'>';
486 478
     $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
487  
-    if (current_theme_supports('bootstrap-top-navbar')) {
488  
-      $item_output .= ($args->has_children) ? ' <b class="caret"></b>' : '';
489  
-    }
  479
+    $item_output .= ($args->has_children) ? ' <b class="caret"></b>' : '';
490 480
     $item_output .= '</a>';
491 481
     $item_output .= $args->after;
492 482
 
@@ -531,8 +521,6 @@ function display_element($element, &$children_elements, $max_depth, $depth = 0,
531 521
   }
532 522
 }
533 523
 
534  
-
535  
-
536 524
 /**
537 525
  * Cleanup wp_nav_menu_args
538 526
  *
@@ -677,3 +665,12 @@ function roots_embed_wrap($cache, $url, $attr = '', $post_ID = '') {
677 665
 
678 666
 add_filter('embed_oembed_html', 'roots_embed_wrap', 10, 4);
679 667
 add_filter('embed_googlevideo', 'roots_embed_wrap', 10, 2);
  668
+
  669
+/**
  670
+ * Tell WordPress to use searchform.php from the templates/ directory
  671
+ */
  672
+function roots_get_search_form() {
  673
+  locate_template('/templates/searchform.php', true, true);
  674
+}
  675
+
  676
+add_filter('get_search_form', 'roots_get_search_form');
37  inc/config.php
@@ -2,27 +2,42 @@
2 2
 /**
3 3
  * Roots configuration and constants
4 4
  */
5  
-
6 5
 add_theme_support('root-relative-urls');    // Enable relative URLs
7 6
 add_theme_support('rewrite-urls');          // Enable URL rewrites
8 7
 add_theme_support('h5bp-htaccess');         // Enable HTML5 Boilerplate's .htaccess
9  
-add_theme_support('bootstrap-responsive');  // Enable Bootstrap's responsive CSS
10 8
 add_theme_support('bootstrap-top-navbar');  // Enable Bootstrap's fixed navbar
11 9
 
12  
-// Set the content width based on the theme's design and stylesheet
13  
-if (!isset($content_width)) { $content_width = 940; }
  10
+// Define which pages shouldn't have the sidebar
  11
+function roots_sidebar() {
  12
+  if (is_404() || is_page_template('page-custom.php')) {
  13
+    return false;
  14
+  } else {
  15
+    return true;
  16
+  }
  17
+}
14 18
 
15  
-define('POST_EXCERPT_LENGTH',       40);
16  
-define('WRAP_CLASSES',              'container');
17  
-define('CONTAINER_CLASSES',         'row');
18  
-define('MAIN_CLASSES',              'span8');
19  
-define('SIDEBAR_CLASSES',           'span4');
20  
-define('FULLWIDTH_CLASSES',         'span12');
21  
-define('GOOGLE_ANALYTICS_ID',       '');        // UA-XXXXX-Y
  19
+// #main CSS classes
  20
+function roots_main_class() {
  21
+  if (roots_sidebar()) {
  22
+    echo 'span8';
  23
+  } else {
  24
+    echo 'span12';
  25
+  }
  26
+}
  27
+
  28
+// #sidebar CSS classes
  29
+function roots_sidebar_class() {
  30
+  echo 'span4';
  31
+}
22 32
 
  33
+define('GOOGLE_ANALYTICS_ID',       ''); // UA-XXXXX-Y
  34
+define('POST_EXCERPT_LENGTH',       40);
23 35
 define('WP_BASE',                   wp_base_dir());
24 36
 define('THEME_NAME',                next(explode('/themes/', get_template_directory())));
25 37
 define('RELATIVE_PLUGIN_PATH',      str_replace(site_url() . '/', '', plugins_url()));
26 38
 define('FULL_RELATIVE_PLUGIN_PATH', WP_BASE . '/' . RELATIVE_PLUGIN_PATH);
27 39
 define('RELATIVE_CONTENT_PATH',     str_replace(site_url() . '/', '', content_url()));
28 40
 define('THEME_PATH',                RELATIVE_CONTENT_PATH . '/themes/' . THEME_NAME);
  41
+
  42
+// Set the content width based on the theme's design and stylesheet
  43
+if (!isset($content_width)) { $content_width = 940; }
26  inc/hooks.php
... ...
@@ -1,31 +1,7 @@
1 1
 <?php
2 2
 
3  
-// header.php
  3
+// head.php
4 4
 function roots_head() { do_action('roots_head'); }
5  
-function roots_wrap_before() { do_action('roots_wrap_before'); }
6  
-function roots_header_before() { do_action('roots_header_before'); }
7  
-function roots_header_inside() { do_action('roots_header_inside'); }
8  
-function roots_header_after() { do_action('roots_header_after'); }
9  
-
10  
-// 404.php, archive.php, front-page.php, index.php, loop-page.php, loop-single.php,
11  
-// loop.php, page-custom.php, page-full.php, page.php, search.php, single.php
12  
-function roots_content_before() { do_action('roots_content_before'); }
13  
-function roots_content_after() { do_action('roots_content_after'); }
14  
-function roots_main_before() { do_action('roots_main_before'); }
15  
-function roots_main_after() { do_action('roots_main_after'); }
16  
-function roots_post_before() { do_action('roots_post_before'); }
17  
-function roots_post_after() { do_action('roots_post_after'); }
18  
-function roots_post_inside_before() { do_action('roots_post_inside_before'); }
19  
-function roots_post_inside_after() { do_action('roots_post_inside_after'); }
20  
-function roots_loop_before() { do_action('roots_loop_before'); }
21  
-function roots_loop_after() { do_action('roots_loop_after'); }
22  
-function roots_sidebar_before() { do_action('roots_sidebar_before'); }
23  
-function roots_sidebar_inside_before() { do_action('roots_sidebar_inside_before'); }
24  
-function roots_sidebar_inside_after() { do_action('roots_sidebar_inside_after'); }
25  
-function roots_sidebar_after() { do_action('roots_sidebar_after'); }
26 5
 
27 6
 // footer.php
28  
-function roots_footer_before() { do_action('roots_footer_before'); }
29  
-function roots_footer_inside() { do_action('roots_footer_inside'); }
30  
-function roots_footer_after() { do_action('roots_footer_after'); }
31 7
 function roots_footer() { do_action('roots_footer'); }
15  inc/scripts.php
@@ -4,27 +4,20 @@
4 4
  *
5 5
  * Enqueue stylesheets in the following order:
6 6
  * 1. /theme/css/bootstrap.css
7  
- * 2. /theme/css/bootstrap-responsive.css      (if enabled in config.php)
  7
+ * 2. /theme/css/bootstrap-responsive.css
8 8
  * 3. /theme/css/app.css
9 9
  * 4. /child-theme/style.css                   (if a child theme is activated)
10 10
  *
11 11
  * Enqueue scripts in the following order:
12  
- * 1. /theme/js/vendor/modernizr-2.6.1.min.js  (in header.php)
13  
- * 2. jquery-1.8.0.min.js via Google CDN       (in header.php)
  12
+ * 1. /theme/js/vendor/modernizr-2.6.1.min.js  (in head.php)
  13
+ * 2. jquery-1.8.0.min.js via Google CDN       (in head.php)
14 14
  * 3. /theme/js/plugins.js
15 15
  * 4. /theme/js/main.js
16 16
  */
17 17
 
18 18
 function roots_scripts() {
19 19
   wp_enqueue_style('roots_bootstrap', get_template_directory_uri() . '/css/bootstrap.css', false, null);
20  
-
21  
-  if (current_theme_supports('bootstrap-responsive')) {
22  
-    wp_enqueue_style('roots_bootstrap_responsive', get_template_directory_uri() . '/css/bootstrap-responsive.css', array('roots_bootstrap'), null);
23  
-  }
24  
-
25  
-  // If you're not using Bootstrap, include HTML5 Boilerplate's main.css:
26  
-  // wp_enqueue_style('roots_h5bp', get_template_directory_uri() . '/css/main.css', false, null);
27  
-
  20
+  wp_enqueue_style('roots_bootstrap_responsive', get_template_directory_uri() . '/css/bootstrap-responsive.css', array('roots_bootstrap'), null);
28 21
   wp_enqueue_style('roots_app', get_template_directory_uri() . '/css/app.css', false, null);
29 22
 
30 23
   // Load style.css from child theme
40  inc/util.php
... ...
@@ -1,5 +1,44 @@
1 1
 <?php
2 2
 
  3
+/**
  4
+ * Theme Wrapper
  5
+ *
  6
+ * @link http://scribu.net/wordpress/theme-wrappers.html
  7
+ */
  8
+
  9
+function roots_template_path() {
  10
+  return Roots_Wrapping::$main_template;
  11
+}
  12
+
  13
+class Roots_Wrapping {
  14
+
  15
+  // Stores the full path to the main template file
  16
+  static $main_template;
  17
+
  18
+  // Stores the base name of the template file; e.g. 'page' for 'page.php' etc.
  19
+  static $base;
  20
+
  21
+  static function wrap($template) {
  22
+    self::$main_template = $template;
  23
+
  24
+    self::$base = substr(basename(self::$main_template), 0, -4);
  25
+
  26
+    if ('index' == self::$base) {
  27
+      self::$base = false;
  28
+    }
  29
+
  30
+    $templates = array('base.php');
  31
+
  32
+    if (self::$base) {
  33
+      array_unshift($templates, sprintf('base-%s.php', self::$base ));
  34
+    }
  35
+
  36
+    return locate_template($templates);
  37
+  }
  38
+}
  39
+
  40
+add_filter('template_include', array('Roots_Wrapping', 'wrap'), 99);
  41
+
3 42
 // returns WordPress subdirectory if applicable
4 43
 function wp_base_dir() {
5 44
   preg_match('!(https?://[^/|"]+)([^"]+)?!', site_url(), $matches);
@@ -24,4 +63,3 @@ function add_filters($tags, $function) {
24 63
     add_filter($tag, $function);
25 64
   }
26 65
 }
27  
-
23  index.php
... ...
@@ -1,21 +1,2 @@
1  
-<?php get_header(); ?>
2  
-  <?php roots_content_before(); ?>
3  
-    <div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
4  
-    <?php roots_main_before(); ?>
5  
-      <div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
6  
-        <div class="page-header">
7  
-          <h1><?php _e('Latest Posts', 'roots');?></h1>
8  
-        </div>
9  
-        <?php get_template_part('loop', 'index'); ?>
10  
-      </div><!-- /#main -->
11  
-    <?php roots_main_after(); ?>
12  
-    <?php roots_sidebar_before(); ?>
13  
-      <aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
14  
-      <?php roots_sidebar_inside_before(); ?>
15  
-        <?php get_sidebar(); ?>
16  
-      <?php roots_sidebar_inside_after(); ?>
17  
-      </aside><!-- /#sidebar -->
18  
-    <?php roots_sidebar_after(); ?>
19  
-    </div><!-- /#content -->
20  
-  <?php roots_content_after(); ?>
21  
-<?php get_footer(); ?>
  1
+<?php get_template_part('templates/page', 'header'); ?>
  2
+<?php get_template_part('templates/content', get_post_format()); ?>
12  loop-page.php
... ...
@@ -1,12 +0,0 @@
1  
-<?php /* Start loop */ ?>
2  
-<?php while (have_posts()) : the_post(); ?>
3  
-  <?php roots_post_before(); ?>
4  
-    <?php roots_post_inside_before(); ?>
5  
-      <div class="page-header">
6  
-      	<h1><?php the_title(); ?></h1>
7  
-      </div>
8  
-      <?php the_content(); ?>
9  
-      <?php wp_link_pages(array('before' => '<nav class="pagination">', 'after' => '</nav>')); ?>
10  
-    <?php roots_post_inside_after(); ?>
11  
-  <?php roots_post_after(); ?>
12  
-<?php endwhile; /* End loop */ ?>
21  loop-single.php
... ...
@@ -1,21 +0,0 @@
1  
-<?php /* Start loop */ ?>
2  
-<?php while (have_posts()) : the_post(); ?>
3  
-  <?php roots_post_before(); ?>
4  
-    <article <?php post_class() ?> id="post-<?php the_ID(); ?>">
5  
-    <?php roots_post_inside_before(); ?>
6  
-      <header>
7  
-        <h1 class="entry-title"><?php the_title(); ?></h1>
8  
-        <?php roots_entry_meta(); ?>
9  
-      </header>
10  
-      <div class="entry-content">
11  
-        <?php the_content(); ?>
12  
-      </div>
13  
-      <footer>
14  
-        <?php wp_link_pages(array('before' => '<nav id="page-nav"><p>' . __('Pages:', 'roots'), 'after' => '</p></nav>')); ?>
15  
-        <?php $tags = get_the_tags(); if ($tags) { ?><p><?php the_tags(); ?></p><?php } ?>
16  
-      </footer>
17  
-      <?php comments_template(); ?>
18  
-      <?php roots_post_inside_after(); ?>
19  
-    </article>
20  
-  <?php roots_post_after(); ?>
21  
-<?php endwhile; /* End loop */ ?>
40  loop.php
... ...
@@ -1,40 +0,0 @@
1  
-<?php /* If there are no posts to display, such as an empty archive page */ ?>
2  
-<?php if (!have_posts()) { ?>
3  
-  <div class="alert alert-block fade in">
4  
-    <a class="close" data-dismiss="alert">&times;</a>
5  
-    <p><?php _e('Sorry, no results were found.', 'roots'); ?></p>
6  
-  </div>
7  
-  <?php get_search_form(); ?>
8  
-<?php } ?>
9  
-
10  
-<?php /* Start loop */ ?>
11  
-<?php while (have_posts()) : the_post(); ?>
12  
-  <?php roots_post_before(); ?>
13  
-    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
14  
-    <?php roots_post_inside_before(); ?>
15  
-      <header>
16  
-        <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
17  
-        <?php roots_entry_meta(); ?>
18  
-      </header>
19  
-      <div class="entry-content">
20  
-        <?php if (is_archive() || is_search()) { ?>
21  
-          <?php the_excerpt(); ?>
22  
-        <?php } else { ?>
23  
-          <?php the_content(); ?>
24  
-        <?php } ?>
25  
-      </div>
26  
-      <footer>
27  
-        <?php $tags = get_the_tags(); if ($tags) { ?><p><?php the_tags(); ?></p><?php } ?>
28  
-      </footer>
29  
-    <?php roots_post_inside_after(); ?>
30  
-    </article>
31  
-  <?php roots_post_after(); ?>
32  
-<?php endwhile; /* End loop */ ?>
33  
-
34  
-<?php /* Display navigation to next/previous pages when applicable */ ?>
35  
-<?php if ($wp_query->max_num_pages > 1) { ?>
36  
-  <nav id="post-nav" class="pager">
37  
-    <div class="previous"><?php next_posts_link(__('&larr; Older posts', 'roots')); ?></div>
38  
-    <div class="next"><?php previous_posts_link(__('Newer posts &rarr;', 'roots')); ?></div>
39  
-  </nav>
40  
-<?php } ?>
26  page-custom.php
... ...
@@ -1,24 +1,8 @@
1 1
 <?php
2 2
 /*
3  
-Template Name: Custom
  3
+Template Name: Custom Template
4 4
 */
5  
-get_header(); ?>
6  
-  <?php roots_content_before(); ?>
7  
-    <div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
8  
-    <?php roots_main_before(); ?>
9  
-      <div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
10  
-        <?php roots_loop_before(); ?>
11  
-        <?php get_template_part('loop', 'page'); ?>
12  
-        <?php roots_loop_after(); ?>
13  
-      </div><!-- /#main -->
14  
-    <?php roots_main_after(); ?>
15  
-    <?php roots_sidebar_before(); ?>
16  
-      <aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
17  
-      <?php roots_sidebar_inside_before(); ?>
18  
-        <?php get_sidebar(); ?>
19  
-      <?php roots_sidebar_inside_after(); ?>
20  
-      </aside><!-- /#sidebar -->
21  
-    <?php roots_sidebar_after(); ?>
22  
-    </div><!-- /#content -->
23  
-  <?php roots_content_after(); ?>
24  
-<?php get_footer(); ?>
  5
+?>
  6
+
  7
+<?php get_template_part('templates/page', 'header'); ?>
  8
+<?php get_template_part('templates/content', 'page'); ?>
17  page-full.php
... ...
@@ -1,17 +0,0 @@
1  
-<?php
2  
-/*
3  
-Template Name: Full Width
4  
-*/
5  
-get_header(); ?>
6  
-  <?php roots_content_before(); ?>
7  
-    <div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
8  
-    <?php roots_main_before(); ?>
9  
-      <div id="main" class="<?php echo FULLWIDTH_CLASSES; ?>" role="main">
10  
-        <?php roots_loop_before(); ?>
11  
-        <?php get_template_part('loop', 'page'); ?>
12  
-        <?php roots_loop_after(); ?>
13  
-      </div><!-- /#main -->
14  
-    <?php roots_main_after(); ?>
15  
-    </div><!-- /#content -->
16  
-  <?php roots_content_after(); ?>
17  
-<?php get_footer(); ?>
22  page.php
... ...
@@ -1,20 +1,2 @@
1  
-<?php get_header(); ?>
2  
-  <?php roots_content_before(); ?>
3  
-    <div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
4  
-    <?php roots_main_before(); ?>
5  
-      <div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
6  
-        <?php roots_loop_before(); ?>
7  
-        <?php get_template_part('loop', 'page'); ?>
8  
-        <?php roots_loop_after(); ?>
9  
-      </div><!-- /#main -->
10  
-    <?php roots_main_after(); ?>
11  
-    <?php roots_sidebar_before(); ?>
12  
-      <aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
13  
-      <?php roots_sidebar_inside_before(); ?>
14  
-        <?php get_sidebar(); ?>
15  
-      <?php roots_sidebar_inside_after(); ?>
16  
-      </aside><!-- /#sidebar -->
17  
-    <?php roots_sidebar_after(); ?>
18  
-    </div><!-- /#content -->
19  
-  <?php roots_content_after(); ?>
20  
-<?php get_footer(); ?>
  1
+<?php get_template_part('templates/page', 'header'); ?>
  2
+<?php get_template_part('templates/content', 'page'); ?>
23  search.php
... ...
@@ -1,23 +0,0 @@
1  
-<?php get_header(); ?>
2  
-  <?php roots_content_before(); ?>
3  
-    <div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
4  
-    <?php roots_main_before(); ?>
5  
-      <div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
6  
-        <div class="page-header">
7  
-          <h1><?php _e('Search Results for', 'roots'); ?> <?php echo get_search_query(); ?></h1>
8  
-        </div>
9  
-        <?php roots_loop_before(); ?>
10  
-        <?php get_template_part('loop', 'search'); ?>
11  
-        <?php roots_loop_after(); ?>
12  
-      </div><!-- /#main -->
13  
-    <?php roots_main_after(); ?>
14  
-    <?php roots_sidebar_before(); ?>
15  
-      <aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
16  
-      <?php roots_sidebar_inside_before(); ?>
17  
-        <?php get_sidebar(); ?>
18  
-      <?php roots_sidebar_inside_after(); ?>
19  
-      </aside><!-- /#sidebar -->
20  
-    <?php roots_sidebar_after(); ?>
21  
-    </div><!-- /#content -->
22  
-  <?php roots_content_after(); ?>
23  
-<?php get_footer(); ?>
21  single.php
... ...
@@ -1,20 +1 @@
1  
-<?php get_header(); ?>
2  
-  <?php roots_content_before(); ?>
3  
-    <div id="content" class="<?php echo CONTAINER_CLASSES; ?>">
4  
-    <?php roots_main_before(); ?>
5  
-      <div id="main" class="<?php echo MAIN_CLASSES; ?>" role="main">
6  
-        <?php roots_loop_before(); ?>
7  
-        <?php get_template_part('loop', 'single'); ?>
8  
-        <?php roots_loop_after(); ?>
9  
-      </div><!-- /#main -->
10  
-    <?php roots_main_after(); ?>
11  
-    <?php roots_sidebar_before(); ?>
12  
-      <aside id="sidebar" class="<?php echo SIDEBAR_CLASSES; ?>" role="complementary">
13  
-      <?php roots_sidebar_inside_before(); ?>
14  
-        <?php get_sidebar(); ?>
15  
-      <?php roots_sidebar_inside_after(); ?>
16  
-      </aside><!-- /#sidebar -->
17  
-    <?php roots_sidebar_after(); ?>
18  
-    </div><!-- /#content -->
19  
-  <?php roots_content_after(); ?>
20  
-<?php get_footer(); ?>
  1
+<?php get_template_part('templates/content', 'single'); ?>
0  comments.php → templates/comments.php
File renamed without changes
4  templates/content-page.php
... ...
@@ -0,0 +1,4 @@
  1
+<?php while (have_posts()) : the_post(); ?>
  2
+  <?php the_content(); ?>
  3
+  <?php wp_link_pages(array('before' => '<nav class="pagination">', 'after' => '</nav>')); ?>
  4
+<?php endwhile; ?>
16  templates/content-single.php
... ...
@@ -0,0 +1,16 @@
  1
+<?php while (have_posts()) : the_post(); ?>
  2
+  <article <?php post_class() ?> id="post-<?php the_ID(); ?>">
  3
+    <header>
  4
+      <h1 class="entry-title"><?php the_title(); ?></h1>
  5
+      <?php roots_entry_meta(); ?>
  6
+    </header>
  7
+    <div class="entry-content">
  8
+      <?php the_content(); ?>
  9
+    </div>
  10
+    <footer>
  11
+      <?php wp_link_pages(array('before' => '<nav id="page-nav"><p>' . __('Pages:', 'roots'), 'after' => '</p></nav>')); ?>
  12
+      <?php $tags = get_the_tags(); if ($tags) { ?><p><?php the_tags(); ?></p><?php } ?>
  13
+    </footer>
  14
+    <?php comments_template('/templates/comments.php'); ?>
  15
+  </article>
  16
+<?php endwhile; ?>
29  templates/content.php
... ...
@@ -0,0 +1,29 @@
  1
+<?php if (!have_posts()) { ?>
  2
+  <div class="alert alert-block fade in">
  3
+    <a class="close" data-dismiss="alert">&times;</a>
  4
+    <p><?php _e('Sorry, no results were found.', 'roots'); ?></p>
  5
+  </div>
  6
+  <?php get_search_form(); ?>
  7
+<?php } ?>
  8
+
  9
+<?php while (have_posts()) : the_post(); ?>
  10
+  <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  11
+    <header>
  12
+      <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  13
+      <?php roots_entry_meta(); ?>
  14
+    </header>
  15
+    <div class="entry-content">
  16
+      <?php the_excerpt(); ?>
  17
+    </div>
  18
+    <footer>
  19
+      <?php the_tags('<ul class="entry-tags"><li>','</li><li>','</li></ul>'); ?>
  20
+    </footer>
  21
+  </article>
  22
+<?php endwhile; ?>
  23
+
  24
+<?php if ($wp_query->max_num_pages > 1) { ?>
  25
+  <nav id="post-nav" class="pager">
  26
+    <div class="previous"><?php next_posts_link(__('&larr; Older posts', 'roots')); ?></div>
  27
+    <div class="next"><?php previous_posts_link(__('Newer posts &rarr;', 'roots')); ?></div>
  28
+  </nav>
  29
+<?php } ?>
7  templates/footer.php
... ...
@@ -0,0 +1,7 @@
18  templates/head.php
... ...
@@ -0,0 +1,18 @@
  1
+<!DOCTYPE html>
  2
+<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" <?php language_attributes(); ?>> <![endif]-->
  3
+<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" <?php language_attributes(); ?>> <![endif]-->
  4
+<!--[if IE 8]>         <html class="no-js lt-ie9" <?php language_attributes(); ?>> <![endif]-->
  5
+<!--[if gt IE 8]><!--> <html class="no-js" <?php language_attributes(); ?>> <!--<![endif]-->
  6
+<head>
  7
+  <meta charset="utf-8">
  8
+  <title><?php wp_title('|', true, 'right'); bloginfo('name'); ?></title>
  9
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  10
+
  11
+  <script src="<?php echo get_template_directory_uri(); ?>/js/vendor/modernizr-2.6.1.min.js"></script>
  12
+
  13
+  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
  14
+  <script>window.jQuery || document.write('<script src="<?php echo get_template_directory_uri(); ?>/js/vendor/jquery-1.8.0.min.js"><\/script>')</script>
  15
+
  16
+  <?php wp_head(); ?>
  17
+  <?php roots_head(); ?>
  18
+</head>
5  templates/header-top-navbar.php
... ...
@@ -1,8 +1,7 @@
1 1
 <header id="banner" class="navbar navbar-fixed-top" role="banner">
2  
-  <?php roots_header_inside(); ?>
3 2
   <div class="navbar-inner">
4  
-    <div class="<?php echo WRAP_CLASSES; ?>">
5  
-     <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
  3
+    <div class="container">
  4
+      <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
6 5
         <span class="icon-bar"></span>
7 6
         <span class="icon-bar"></span>
8 7
         <span class="icon-bar"></span>
7  templates/header-default.php → templates/header.php
... ...
@@ -1,9 +1,6 @@
1 1
 <header id="banner" role="banner">
2  
-  <?php roots_header_inside(); ?>
3  
-  <div class="<?php echo WRAP_CLASSES; ?>">
4  
-    <a class="brand" href="<?php echo home_url(); ?>/">
5  
-      <?php bloginfo('name'); ?>
6  
-    </a>
  2
+  <div class="container">
  3
+    <a class="brand" href="<?php echo home_url(); ?>/"><?php bloginfo('name'); ?></a>
7 4
     <nav id="nav-main" role="navigation">
8 5
       <?php wp_nav_menu(array('theme_location' => 'primary_navigation', 'menu_class' => 'nav nav-pills')); ?>
9 6
     </nav>
38  templates/page-header.php
... ...
@@ -0,0 +1,38 @@
  1
+<div class="page-header">
  2
+  <h1>
  3
+    <?php
  4
+      if (is_home()) {
  5
+        if (get_option('page_for_posts', true)) {
  6
+          echo get_the_title(get_option('page_for_posts', true));
  7
+        } else {
  8
+          _e('Latest Posts', 'roots');
  9
+        }
  10
+      } elseif (is_archive()) {
  11
+        $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
  12
+        if ($term) {
  13
+          echo $term->name;
  14
+        } elseif (is_post_type_archive()) {
  15
+          echo get_queried_object()->labels->name;
  16
+        } elseif (is_day()) {
  17
+          printf(__('Daily Archives: %s', 'roots'), get_the_date());
  18
+        } elseif (is_month()) {
  19
+          printf(__('Monthly Archives: %s', 'roots'), get_the_date('F Y'));
  20
+        } elseif (is_year()) {
  21
+          printf(__('Yearly Archives: %s', 'roots'), get_the_date('Y'));
  22
+        } elseif (is_author()) {
  23
+          global $post;
  24
+          $author_id = $post->post_author;
  25
+          printf(__('Author Archives: %s', 'roots'), get_the_author_meta('display_name', $author_id));
  26
+        } else {
  27
+          single_cat_title();
  28
+        }
  29
+      } elseif (is_search()) {
  30
+        printf(__('Search Results for %s', 'roots'), get_search_query());
  31
+      } elseif (is_404()) {
  32
+        _e('File Not Found', 'roots');
  33
+      } else {
  34
+        the_title();
  35
+      }
  36
+    ?>
  37
+  </h1>
  38
+</div>
2  searchform.php → templates/searchform.php
... ...
@@ -1,5 +1,5 @@
1 1
 <form role="search" method="get" id="searchform" class="form-search" action="<?php echo home_url('/'); ?>">
2  
-  <label class="hide-text" for="s"><?php _e('Search for:', 'roots'); ?></label>
  2
+  <label class="hide" for="s"><?php _e('Search for:', 'roots'); ?></label>
3 3
   <input type="text" value="" name="s" id="s" class="search-query" placeholder="<?php _e('Search', 'roots'); ?> <?php bloginfo('name'); ?>">
4 4
   <input type="submit" id="searchsubmit" value="<?php _e('Search', 'roots'); ?>" class="btn">
5 5
 </form>
0  sidebar.php → templates/sidebar.php
File renamed without changes

11 notes on commit db41099

Lucas Rolff

looks nice - a lot less code!

But I'm wondering, if you've put the sidebar stuff in the base.php file, and we want to change the front-page.php file, to not have any sidebar, but still being able to do it on the other pages, are we still able to do this? And how?

Ben Word
Owner

yes, based off the current code you'll just open up config.php and add is_front_page() to the first if statement in roots_sidebar()

you can also override base.php with base-{template}.php

Foxaii
Collaborator

Why the sudden hatred of theme hooks? Is there no longer any impetus on making Roots the perfect parent theme? Hooks are a key part of that.

Granted the lovely addition of scribu's theme wrapper makes it easy enough to reintroduce my own hooks or those of the Theme Hook Alliance, but is this the only logic behind such a major change?

The rest of the changes look fantastic. Thanks for all the hard work.

Ben Word
Owner

well, i've always hated theme hooks (and child themes) so it's nothing sudden. they've been brought up a few times recently by users not understanding what the purpose of them is. what's really lost by taking out all the hooks? i didn't think removing the hooks was that big of a change, but i don't really use them that much. when i do use them it's something that could have been done just as easy by editing a template file (and now, not in so many places).

do we really need all those hooks all over the place?

Foxaii
Collaborator

My interest with WordPress started with Thematic, a theme heavily reliant upon child themes and hooks, hence my bias.

I can completely understand why the questions on hooks would frustrate you, but I disagree with removing a feature just because some people don't understand it. I actually think many would start using hooks if they realised how useful they can be.

When used properly hooks and child themes allow you to transparently upgrade to the latest version of the parent theme, great for new features, bug fixes or security. They also help you change from one theme to another simply by editing the hook prefix, especially useful when transitioning a client's site to a new Roots based responsive design. You can also easily reposition elements on the page simply by changing the hook suffix. Maintaining hooks also means that if you have several custom post templates and need to add something new to all of them you can do it with one new function, instead of changing all the custom templates.

Granted most of this can be done by editing the wrapper's base.php but it's not as straightforward, as flexible or as well documented as using hooks.

Ben Word
Owner

hooks weren't removed just because some people don't understand it. also, thematic is a perfect example of a theme i'd want roots to be nothing like.. the amount of hooks in that theme is insane and it's very difficult to work with.

also, there's no way that you can upgrade your parent roots theme without running into issues all the time, which is why we've never recommended the use of child themes. we don't keep backwards compatibility functionality, we're always re-arranging the hell out of things and completely removing/adding different features.

when the documentation is re-done (#264 - which i'd like to knock out soon) we can provide examples on how to extend base.php

roots is a starting theme at heart. i understand some people use it as a framework and use child themes (and we do our best to make that work smoothly), but that's really not how it's meant to be used.

Foxaii
Collaborator

I agree that Thematic went overkill with hooks, but you only need to look at premium themes like Genesis to see that they do have a place within WordPress frameworks. It won't stop me using Roots, I'll just adopt and incorporate the hooks from the Theme Hook Alliance.

I also respect your decision to be a starter theme instead of a framework, as I wouldn't like to deal with the additional hassle either. Such is the quality and simplicity of the code, it's not a big leap to use Roots as a framework.

Lucas Rolff
Incubalab

For my part a few weeks ago I am developing child themes to keep updated my theme father and with this new update be quite desconsertado not serve because older versions and already done. Anyway this update seems unbelievable to me and then giving me a while to realize that to achieve the realization of new issues has no problem children, the creation of new base-{template}.php, add my own hook and let your imagination. Congratulations and sorry for my English.
PD: the simplicity and the small number of files I'm thinking of leaving child themes.

gibrankhan

I'm trying to get my head around this new theme wrapping stuff. If I wanted a certain page to have a different sidebar or different header or footer etc, then the base.php file is useless for that page. How do I override the base.php for an individual page? I tried using base-page-{slug}.php and base-{slug}.php but they both do not work. Thanks.

Ben Word
Owner

if you can't figure it out after reviewing http://scribu.net/wordpress/theme-wrappers.html then please post a question on the google group

Please sign in to comment.
Something went wrong with that request. Please try again.