Merge branch 'master' into grunt
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
### HEAD
|
||||||
|
* Return instead of echo class names in `roots_main_class` and `roots_sidebar_class`
|
||||||
|
* Move nav customizations into `lib/nav.php`
|
||||||
|
|
||||||
### 6.1.0: October 2nd, 2012
|
### 6.1.0: October 2nd, 2012
|
||||||
* Change roots_sidebar into a more explicit configuration array
|
* Change roots_sidebar into a more explicit configuration array
|
||||||
* Re-organize configuration/setup files
|
* Re-organize configuration/setup files
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -9,7 +9,9 @@ Roots is a starting WordPress theme made for developers that’s based on [HTML5
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Edit `lib/config.php` to enable support for major functionality and to define constants that are used throughout the theme.
|
Edit `lib/config.php` to enable or disable support for various theme functions and to define constants that are used throughout the theme.
|
||||||
|
|
||||||
|
Edit `lib/init.php` to setup custom navigation menus and post thumbnail sizes.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
@@ -37,12 +39,12 @@ Everyone is welcome to help [contribute](/retlehs/roots/blob/master/CONTRIBUTING
|
|||||||
* Writing or editing [docs](/retlehs/roots/blob/master/doc/TOC.md)
|
* Writing or editing [docs](/retlehs/roots/blob/master/doc/TOC.md)
|
||||||
* Writing or refactoring code
|
* Writing or refactoring code
|
||||||
* Fixing [issues](https://github.com/retlehs/roots/issues)
|
* Fixing [issues](https://github.com/retlehs/roots/issues)
|
||||||
* Replying to questions on the [mailing list](http://groups.google.com/group/roots-theme)
|
* Replying to questions on the [Google Group](http://groups.google.com/group/roots-theme)
|
||||||
|
|
||||||
## Project information
|
## Project information
|
||||||
|
|
||||||
* Source: [https://github.com/retlehs/roots](https://github.com/retlehs/roots)
|
* Source: [https://github.com/retlehs/roots](https://github.com/retlehs/roots)
|
||||||
* Web: [http://www.rootstheme.com/](http://www.rootstheme.com/)
|
* Web: [http://www.rootstheme.com/](http://www.rootstheme.com/)
|
||||||
* Mailing list: [http://groups.google.com/group/roots-theme](http://groups.google.com/group/roots-theme)
|
* Google Group: [http://groups.google.com/group/roots-theme](http://groups.google.com/group/roots-theme)
|
||||||
* Twitter: [@retlehs](https://twitter.com/#!/retlehs)
|
* Twitter Updates: [@retlehs](https://twitter.com/#!/retlehs)
|
||||||
* Contributors: [https://github.com/retlehs/roots/contributors](https://github.com/retlehs/roots/contributors)
|
* Contributors: [https://github.com/retlehs/roots/contributors](https://github.com/retlehs/roots/contributors)
|
||||||
4
base.php
4
base.php
@@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
<div id="wrap" class="container" role="document">
|
<div id="wrap" class="container" role="document">
|
||||||
<div id="content" class="row">
|
<div id="content" class="row">
|
||||||
<div id="main" class="<?php roots_main_class(); ?>" role="main">
|
<div id="main" class="<?php echo roots_main_class(); ?>" role="main">
|
||||||
<?php include roots_template_path(); ?>
|
<?php include roots_template_path(); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php if (roots_display_sidebar()) : ?>
|
<?php if (roots_display_sidebar()) : ?>
|
||||||
<aside id="sidebar" class="<?php roots_sidebar_class(); ?>" role="complementary">
|
<aside id="sidebar" class="<?php echo roots_sidebar_class(); ?>" role="complementary">
|
||||||
<?php get_template_part('templates/sidebar'); ?>
|
<?php get_template_part('templates/sidebar'); ?>
|
||||||
</aside>
|
</aside>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
11
doc/lib.md
11
doc/lib.md
@@ -28,12 +28,7 @@ If you don't want to use one of the features, either comment out the line or rem
|
|||||||
|
|
||||||
#### Define which pages shouldn't have the sidebar
|
#### Define which pages shouldn't have the sidebar
|
||||||
|
|
||||||
`roots_sidebar()` is used to define which pages shouldn't get the sidebar. By default, the 404 and `page-custom.php` template are full width. If you would like to remove the sidebar from additional pages, add in a proper conditional to the first `if` statement.
|
`roots_display_sidebar()` is used to define which pages shouldn't get the sidebar. By default, the 404, front `front-page.php` and `page-custom.php` templates are full width. If you would like to remove the sidebar from additional pages, add in the appropriate conditional or page template name.
|
||||||
|
|
||||||
If you had a page named Contact, you would update the statement to look like:
|
|
||||||
|
|
||||||
if (is_404() || is_page_template('page-custom.php') || is_page('contact')) {
|
|
||||||
|
|
||||||
|
|
||||||
### h5bp-htaccess
|
### h5bp-htaccess
|
||||||
|
|
||||||
@@ -59,6 +54,10 @@ This file runs the initial theme setup and defines helper constants for later us
|
|||||||
|
|
||||||
This file is a placeholder for you to put in custom metaboxes. We recommend the use of [Custom Metaboxes and Fields for WordPress](https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress).
|
This file is a placeholder for you to put in custom metaboxes. We recommend the use of [Custom Metaboxes and Fields for WordPress](https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress).
|
||||||
|
|
||||||
|
### nav.php
|
||||||
|
|
||||||
|
This file contains all the custom nav modifications (for Bootstrap) and clean up.
|
||||||
|
|
||||||
### post-types.php
|
### post-types.php
|
||||||
|
|
||||||
This file is a placeholder for you to put in [custom post types](http://codex.wordpress.org/Function_Reference/register_post_type) and [taxonomies](http://codex.wordpress.org/Function_Reference/register_taxonomy).
|
This file is a placeholder for you to put in [custom post types](http://codex.wordpress.org/Function_Reference/register_post_type) and [taxonomies](http://codex.wordpress.org/Function_Reference/register_taxonomy).
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ require_once locate_template('/lib/sidebar.php'); // Sidebar class
|
|||||||
require_once locate_template('/lib/config.php'); // Configuration
|
require_once locate_template('/lib/config.php'); // Configuration
|
||||||
require_once locate_template('/lib/activation.php'); // Theme activation
|
require_once locate_template('/lib/activation.php'); // Theme activation
|
||||||
require_once locate_template('/lib/cleanup.php'); // Cleanup
|
require_once locate_template('/lib/cleanup.php'); // Cleanup
|
||||||
|
require_once locate_template('/lib/nav.php'); // Custom nav modifications
|
||||||
require_once locate_template('/lib/htaccess.php'); // Rewrites for assets, H5BP .htaccess
|
require_once locate_template('/lib/htaccess.php'); // Rewrites for assets, H5BP .htaccess
|
||||||
require_once locate_template('/lib/widgets.php'); // Sidebars and widgets
|
require_once locate_template('/lib/widgets.php'); // Sidebars and widgets
|
||||||
require_once locate_template('/lib/scripts.php'); // Scripts and stylesheets
|
require_once locate_template('/lib/scripts.php'); // Scripts and stylesheets
|
||||||
|
|||||||
103
lib/cleanup.php
103
lib/cleanup.php
@@ -160,7 +160,7 @@ function roots_fix_duplicate_subfolder_urls($input) {
|
|||||||
$output = roots_root_relative_url($input);
|
$output = roots_root_relative_url($input);
|
||||||
preg_match_all('!([^/]+)/([^/]+)!', $output, $matches);
|
preg_match_all('!([^/]+)/([^/]+)!', $output, $matches);
|
||||||
|
|
||||||
if (isset($matches[1]) && isset($matches[2])) {
|
if (isset($matches[1][0]) && isset($matches[2][0])) {
|
||||||
if ($matches[1][0] === $matches[2][0]) {
|
if ($matches[1][0] === $matches[2][0]) {
|
||||||
$output = substr($output, strlen($matches[1][0]) + 1);
|
$output = substr($output, strlen($matches[1][0]) + 1);
|
||||||
}
|
}
|
||||||
@@ -407,107 +407,6 @@ function roots_excerpt_more($more) {
|
|||||||
add_filter('excerpt_length', 'roots_excerpt_length');
|
add_filter('excerpt_length', 'roots_excerpt_length');
|
||||||
add_filter('excerpt_more', 'roots_excerpt_more');
|
add_filter('excerpt_more', 'roots_excerpt_more');
|
||||||
|
|
||||||
/**
|
|
||||||
* Cleaner walker for wp_nav_menu()
|
|
||||||
*
|
|
||||||
* Walker_Nav_Menu (WordPress default) example output:
|
|
||||||
* <li id="menu-item-8" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-8"><a href="/">Home</a></li>
|
|
||||||
* <li id="menu-item-9" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9"><a href="/sample-page/">Sample Page</a></l
|
|
||||||
*
|
|
||||||
* Roots_Nav_Walker example output:
|
|
||||||
* <li class="menu-home"><a href="/">Home</a></li>
|
|
||||||
* <li class="menu-sample-page"><a href="/sample-page/">Sample Page</a></li>
|
|
||||||
*/
|
|
||||||
class Roots_Nav_Walker extends Walker_Nav_Menu {
|
|
||||||
function check_current($classes) {
|
|
||||||
return preg_match('/(current[-_])|active|dropdown/', $classes);
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_lvl(&$output, $depth = 0, $args = array()) {
|
|
||||||
$output .= "\n<ul class=\"dropdown-menu\">\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
|
|
||||||
$item_html = '';
|
|
||||||
parent::start_el($item_html, $item, $depth, $args);
|
|
||||||
|
|
||||||
if ($item->is_dropdown && ($depth === 0)) {
|
|
||||||
$item_html = str_replace('<a', '<a class="dropdown-toggle" data-toggle="dropdown" data-target="#"', $item_html);
|
|
||||||
$item_html = str_replace('</a>', ' <b class="caret"></b></a>', $item_html);
|
|
||||||
}
|
|
||||||
elseif (in_array('divider-vertical', $item->classes)) {
|
|
||||||
$item_html = '<li class="divider-vertical">';
|
|
||||||
}
|
|
||||||
elseif (in_array('divider', $item->classes)) {
|
|
||||||
$item_html = '<li class="divider">';
|
|
||||||
}
|
|
||||||
elseif (in_array('nav-header', $item->classes)) {
|
|
||||||
$item_html = '<li class="nav-header">' . $item->title;
|
|
||||||
}
|
|
||||||
|
|
||||||
$output .= $item_html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) {
|
|
||||||
$element->is_dropdown = !empty($children_elements[$element->ID]);
|
|
||||||
|
|
||||||
if ($element->is_dropdown) {
|
|
||||||
if ($depth === 0) {
|
|
||||||
$element->classes[] = 'dropdown';
|
|
||||||
} elseif ($depth === 1) {
|
|
||||||
$element->classes[] = 'dropdown-submenu';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the id="" on nav menu items
|
|
||||||
* Return 'menu-slug' for nav menu classes
|
|
||||||
*/
|
|
||||||
function roots_nav_menu_css_class($classes, $item) {
|
|
||||||
$slug = sanitize_title($item->title);
|
|
||||||
$classes = preg_replace('/(current(-menu-|[-_]page[-_])(item|parent|ancestor))/', 'active', $classes);
|
|
||||||
$classes = preg_replace('/((menu|page)[-_\w+]+)+/', '', $classes);
|
|
||||||
|
|
||||||
$classes[] = 'menu-' . $slug;
|
|
||||||
|
|
||||||
$classes = array_unique($classes);
|
|
||||||
|
|
||||||
return array_filter($classes, 'is_element_empty');
|
|
||||||
}
|
|
||||||
|
|
||||||
add_filter('nav_menu_css_class', 'roots_nav_menu_css_class', 10, 2);
|
|
||||||
add_filter('nav_menu_item_id', '__return_null');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clean up wp_nav_menu_args
|
|
||||||
*
|
|
||||||
* Remove the container
|
|
||||||
* Use Roots_Nav_Walker() by default
|
|
||||||
*/
|
|
||||||
function roots_nav_menu_args($args = '') {
|
|
||||||
$roots_nav_menu_args['container'] = false;
|
|
||||||
|
|
||||||
if (!$args['items_wrap']) {
|
|
||||||
$roots_nav_menu_args['items_wrap'] = '<ul class="%2$s">%3$s</ul>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current_theme_supports('bootstrap-top-navbar')) {
|
|
||||||
$roots_nav_menu_args['depth'] = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$args['walker']) {
|
|
||||||
$roots_nav_menu_args['walker'] = new Roots_Nav_Walker();
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_merge($args, $roots_nav_menu_args);
|
|
||||||
}
|
|
||||||
|
|
||||||
add_filter('wp_nav_menu_args', 'roots_nav_menu_args');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove unnecessary self-closing tags
|
* Remove unnecessary self-closing tags
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ function roots_display_sidebar() {
|
|||||||
/**
|
/**
|
||||||
* Conditional tag checks (http://codex.wordpress.org/Conditional_Tags)
|
* Conditional tag checks (http://codex.wordpress.org/Conditional_Tags)
|
||||||
* Any of these conditional tags that return true won't show the sidebar
|
* Any of these conditional tags that return true won't show the sidebar
|
||||||
|
*
|
||||||
|
* To use a function that accepts arguments, use the following format:
|
||||||
|
*
|
||||||
|
* array('function_name', array('arg1', 'arg2'))
|
||||||
|
*
|
||||||
|
* The second element must be an array even if there's only 1 argument.
|
||||||
*/
|
*/
|
||||||
array(
|
array(
|
||||||
'is_404',
|
'is_404',
|
||||||
@@ -40,15 +46,17 @@ function roots_display_sidebar() {
|
|||||||
// #main CSS classes
|
// #main CSS classes
|
||||||
function roots_main_class() {
|
function roots_main_class() {
|
||||||
if (roots_display_sidebar()) {
|
if (roots_display_sidebar()) {
|
||||||
echo 'span8';
|
$class = 'span8';
|
||||||
} else {
|
} else {
|
||||||
echo 'span12';
|
$class = 'span12';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #sidebar CSS classes
|
// #sidebar CSS classes
|
||||||
function roots_sidebar_class() {
|
function roots_sidebar_class() {
|
||||||
echo 'span4';
|
return 'span4';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configuration values
|
// Configuration values
|
||||||
|
|||||||
101
lib/nav.php
Normal file
101
lib/nav.php
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleaner walker for wp_nav_menu()
|
||||||
|
*
|
||||||
|
* Walker_Nav_Menu (WordPress default) example output:
|
||||||
|
* <li id="menu-item-8" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-8"><a href="/">Home</a></li>
|
||||||
|
* <li id="menu-item-9" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9"><a href="/sample-page/">Sample Page</a></l
|
||||||
|
*
|
||||||
|
* Roots_Nav_Walker example output:
|
||||||
|
* <li class="menu-home"><a href="/">Home</a></li>
|
||||||
|
* <li class="menu-sample-page"><a href="/sample-page/">Sample Page</a></li>
|
||||||
|
*/
|
||||||
|
class Roots_Nav_Walker extends Walker_Nav_Menu {
|
||||||
|
function check_current($classes) {
|
||||||
|
return preg_match('/(current[-_])|active|dropdown/', $classes);
|
||||||
|
}
|
||||||
|
|
||||||
|
function start_lvl(&$output, $depth = 0, $args = array()) {
|
||||||
|
$output .= "\n<ul class=\"dropdown-menu\">\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) {
|
||||||
|
$item_html = '';
|
||||||
|
parent::start_el($item_html, $item, $depth, $args);
|
||||||
|
|
||||||
|
if ($item->is_dropdown && ($depth === 0)) {
|
||||||
|
$item_html = str_replace('<a', '<a class="dropdown-toggle" data-toggle="dropdown" data-target="#"', $item_html);
|
||||||
|
$item_html = str_replace('</a>', ' <b class="caret"></b></a>', $item_html);
|
||||||
|
}
|
||||||
|
elseif (stristr($item_html, 'li class="divider')) {
|
||||||
|
$item_html = preg_replace('/<a[^>]*>.*?<\/a>/iU', '', $item_html);
|
||||||
|
}
|
||||||
|
elseif (stristr($item_html, 'li class="nav-header')) {
|
||||||
|
$item_html = preg_replace('/<a[^>]*>(.*)<\/a>/iU', '$1', $item_html);
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= $item_html;
|
||||||
|
}
|
||||||
|
|
||||||
|
function display_element($element, &$children_elements, $max_depth, $depth = 0, $args, &$output) {
|
||||||
|
$element->is_dropdown = !empty($children_elements[$element->ID]);
|
||||||
|
|
||||||
|
if ($element->is_dropdown) {
|
||||||
|
if ($depth === 0) {
|
||||||
|
$element->classes[] = 'dropdown';
|
||||||
|
} elseif ($depth === 1) {
|
||||||
|
$element->classes[] = 'dropdown-submenu';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the id="" on nav menu items
|
||||||
|
* Return 'menu-slug' for nav menu classes
|
||||||
|
*/
|
||||||
|
function roots_nav_menu_css_class($classes, $item) {
|
||||||
|
$slug = sanitize_title($item->title);
|
||||||
|
$classes = preg_replace('/(current(-menu-|[-_]page[-_])(item|parent|ancestor))/', 'active', $classes);
|
||||||
|
$classes = preg_replace('/((menu|page)[-_\w+]+)+/', '', $classes);
|
||||||
|
|
||||||
|
$classes[] = 'menu-' . $slug;
|
||||||
|
|
||||||
|
$classes = array_unique($classes);
|
||||||
|
|
||||||
|
return array_filter($classes, 'is_element_empty');
|
||||||
|
}
|
||||||
|
|
||||||
|
add_filter('nav_menu_css_class', 'roots_nav_menu_css_class', 10, 2);
|
||||||
|
add_filter('nav_menu_item_id', '__return_null');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up wp_nav_menu_args
|
||||||
|
*
|
||||||
|
* Remove the container
|
||||||
|
* Use Roots_Nav_Walker() by default
|
||||||
|
*/
|
||||||
|
function roots_nav_menu_args($args = '') {
|
||||||
|
$roots_nav_menu_args['container'] = false;
|
||||||
|
|
||||||
|
if (!$args['items_wrap']) {
|
||||||
|
$roots_nav_menu_args['items_wrap'] = '<ul class="%2$s">%3$s</ul>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current_theme_supports('bootstrap-top-navbar')) {
|
||||||
|
$roots_nav_menu_args['depth'] = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$args['walker']) {
|
||||||
|
$roots_nav_menu_args['walker'] = new Roots_Nav_Walker();
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_merge($args, $roots_nav_menu_args);
|
||||||
|
}
|
||||||
|
|
||||||
|
add_filter('wp_nav_menu_args', 'roots_nav_menu_args');
|
||||||
|
|
||||||
|
|
||||||
@@ -29,7 +29,11 @@ class Roots_Sidebar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function check_conditional_tag($conditional_tag) {
|
private function check_conditional_tag($conditional_tag) {
|
||||||
return $conditional_tag();
|
if (is_array($conditional_tag)) {
|
||||||
|
return call_user_func_array($conditional_tag[0], $conditional_tag[1]);
|
||||||
|
} else {
|
||||||
|
return $conditional_tag();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function check_page_template($page_template) {
|
private function check_page_template($page_template) {
|
||||||
|
|||||||
Reference in New Issue
Block a user