Skip to content

Commit

Permalink
Add theme wrapper, re-organize template files
Browse files Browse the repository at this point in the history
- 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
retlehs committed Aug 18, 2012
1 parent b54328c commit db41099
Show file tree
Hide file tree
Showing 34 changed files with 274 additions and 554 deletions.
39 changes: 15 additions & 24 deletions 404.php
@@ -1,24 +1,15 @@
<?php get_header(); ?> <?php get_template_part('templates/page', 'header'); ?>
<?php roots_content_before(); ?>
<div id="content" class="<?php echo CONTAINER_CLASSES; ?>"> <div class="alert alert-block fade in">
<?php roots_main_before(); ?> <a class="close" data-dismiss="alert">&times;</a>
<div id="main" class="<?php echo FULLWIDTH_CLASSES; ?>" role="main"> <p><?php _e('The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.', 'roots'); ?></p>
<div class="page-header"> </div>
<h1><?php _e('File Not Found', 'roots'); ?></h1>
</div> <p><?php _e('Please try the following:', 'roots'); ?></p>
<div class="alert alert-block fade in"> <ul>
<a class="close" data-dismiss="alert">&times;</a> <li><?php _e('Check your spelling', 'roots'); ?></li>
<p><?php _e('The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.', 'roots'); ?></p> <li><?php printf(__('Return to the <a href="%s">home page</a>', 'roots'), home_url()); ?></li>
</div> <li><?php _e('Click the <a href="javascript:history.back()">Back</a> button', 'roots'); ?></li>
<p><?php _e('Please try the following:', 'roots'); ?></p> </ul>
<ul>
<li><?php _e('Check your spelling', 'roots'); ?></li> <?php get_search_form(); ?>
<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(); ?>
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -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 ### 5.2.0: August 18th, 2012
* Update to jQuery 1.8.0 and Modernizr 2.6.1 * Update to jQuery 1.8.0 and Modernizr 2.6.1
* Fix duplicate active class in `wp_nav_menu` items * Fix duplicate active class in `wp_nav_menu` items
Expand Down
44 changes: 0 additions & 44 deletions archive.php

This file was deleted.

31 changes: 31 additions & 0 deletions base.php
@@ -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>
16 changes: 8 additions & 8 deletions css/app.css
@@ -1,4 +1,4 @@
/* ============================================================================= /* ==========================================================================
Base Base
========================================================================== */ ========================================================================== */


Expand All @@ -18,31 +18,31 @@ body.admin-bar .navbar-fixed-top { top: 28px; }






/* ============================================================================= /* ==========================================================================
Content Content
========================================================================== */ ========================================================================== */


#content { } #content { }






/* ============================================================================= /* ==========================================================================
Primary Content Primary Content
========================================================================== */ ========================================================================== */


#main { } #main { }






/* ============================================================================= /* ==========================================================================
Sidebar Sidebar
========================================================================== */ ========================================================================== */


#sidebar { } #sidebar { }






/* ============================================================================= /* ==========================================================================
Posts Posts
========================================================================== */ ========================================================================== */


Expand All @@ -54,15 +54,15 @@ body.admin-bar .navbar-fixed-top { top: 28px; }






/* ============================================================================= /* ==========================================================================
Footer Footer
========================================================================== */ ========================================================================== */


#content-info { } #content-info { }






/* ============================================================================= /* ==========================================================================
WordPress Generated Classes WordPress Generated Classes
See: http://codex.wordpress.org/CSS#WordPress_Generated_Classes See: http://codex.wordpress.org/CSS#WordPress_Generated_Classes
========================================================================== */ ========================================================================== */
Expand All @@ -74,7 +74,7 @@ figure.alignnone { margin-left: 0; margin-right: 0; }






/* ============================================================================= /* ==========================================================================
Media Queries Media Queries
========================================================================== */ ========================================================================== */


Expand Down
134 changes: 0 additions & 134 deletions css/main.css

This file was deleted.

16 changes: 0 additions & 16 deletions footer.php

This file was deleted.

20 changes: 0 additions & 20 deletions front-page.php

This file was deleted.

11 comments on commit db41099

@lucasRolff
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@retlehs
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@Foxaii Foxaii commented on db41099 Aug 19, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@retlehs
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@Foxaii Foxaii commented on db41099 Aug 19, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@retlehs
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@Foxaii Foxaii commented on db41099 Aug 19, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@lucasRolff
Copy link

@lucasRolff lucasRolff commented on db41099 Aug 19, 2012 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Incubalab
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@retlehs
Copy link
Member Author

@retlehs retlehs commented on db41099 Sep 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.