Re-organization

This commit is contained in:
Ben Word
2012-05-09 00:55:09 -06:00
parent d4ec36331b
commit 7d2b3c1e07
17 changed files with 95 additions and 90 deletions

View File

@@ -4,7 +4,7 @@
<?php roots_footer_before(); ?>
<footer id="content-info" class="<?php echo WRAP_CLASSES; ?>" role="contentinfo">
<?php roots_footer_inside(); ?>
<?php dynamic_sidebar('roots-footer'); ?>
<?php dynamic_sidebar('sidebar-footer'); ?>
<p class="copy"><small>&copy; <?php echo date('Y'); ?> <?php bloginfo('name'); ?></small></p>
</footer>
<?php roots_footer_after(); ?>

View File

@@ -1,76 +1,43 @@
<?php // https://github.com/retlehs/roots/wiki
<?php
/**
* Roots functions
*/
if (!defined('__DIR__')) { define('__DIR__', dirname(__FILE__)); }
require_once locate_template('/inc/roots-config.php'); // config
require_once locate_template('/inc/roots-utils.php'); // utility functions
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);
require_once locate_template('/inc/roots-activation.php'); // activation
require_once locate_template('/inc/roots-cleanup.php'); // cleanup
require_once locate_template('/inc/roots-scripts.php'); // modified scripts output
require_once locate_template('/inc/roots-htaccess.php'); // rewrites for assets, h5bp htaccess
require_once locate_template('/inc/roots-hooks.php'); // hooks
require_once locate_template('/inc/roots-actions.php'); // actions
require_once locate_template('/inc/roots-widgets.php'); // widgets
require_once locate_template('/inc/roots-custom.php'); // custom functions
// set the maximum 'Large' image width to the maximum grid width
// http://wordpress.stackexchange.com/q/11766
if (!isset($content_width)) { $content_width = 940; }
require_once locate_template('/inc/util.php'); // Utility functions
require_once locate_template('/inc/config.php'); // Configuration and constants
require_once locate_template('/inc/activation.php'); // Theme activation
require_once locate_template('/inc/template-tags.php'); // Template tags
require_once locate_template('/inc/cleanup.php'); // Cleanup
require_once locate_template('/inc/scripts.php'); // Scripts and stylesheets
require_once locate_template('/inc/htaccess.php'); // Rewrites for assets, H5BP .htaccess
require_once locate_template('/inc/hooks.php'); // Hooks
require_once locate_template('/inc/actions.php'); // Actions
require_once locate_template('/inc/widgets.php'); // Sidebars and widgets
require_once locate_template('/inc/custom.php'); // Custom functions
function roots_setup() {
// Make theme available for translation
load_theme_textdomain('roots', get_template_directory() . '/lang');
// tell the TinyMCE editor to use editor-style.css
// if you have issues with getting the editor to show your changes then
// use this instead: add_editor_style('editor-style.css?' . time());
add_editor_style('editor-style.css');
// Register wp_nav_menu() menus (http://codex.wordpress.org/Function_Reference/register_nav_menus)
register_nav_menus(array(
'primary_navigation' => __('Primary Navigation', 'roots'),
));
// http://codex.wordpress.org/Post_Thumbnails
// Add post thumbnails (http://codex.wordpress.org/Post_Thumbnails)
add_theme_support('post-thumbnails');
// set_post_thumbnail_size(150, 150, false);
// add_image_size('category-thumb', 300, 9999); // 300px wide (and unlimited height)
// http://codex.wordpress.org/Post_Formats
// Add post formats (http://codex.wordpress.org/Post_Formats)
// add_theme_support('post-formats', array('aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat'));
// http://codex.wordpress.org/Function_Reference/register_nav_menus
register_nav_menus(array(
'primary_navigation' => __('Primary Navigation', 'roots')
));
// Tell the TinyMCE editor to use a custom stylesheet
add_editor_style('css/editor-style.css');
}
add_action('after_setup_theme', 'roots_setup');
// http://codex.wordpress.org/Function_Reference/register_sidebar
function roots_register_sidebars() {
$sidebars = array('Sidebar', 'Footer');
foreach($sidebars as $sidebar) {
register_sidebar(
array(
'id' => 'roots-' . sanitize_title($sidebar),
'name' => __($sidebar, 'roots'),
'description' => __($sidebar, 'roots'),
'before_widget' => '<section id="%1$s" class="widget %2$s"><div class="widget-inner">',
'after_widget' => '</div></section>',
'before_title' => '<h3>',
'after_title' => '</h3>'
)
);
}
}
add_action('widgets_init', 'roots_register_sidebars');
// return post entry meta information
function roots_entry_meta() {
echo '<time class="updated" datetime="'. get_the_time('c') .'" pubdate>'. sprintf(__('Posted on %s at %s.', 'roots'), get_the_date(), get_the_time()) .'</time>';
echo '<p class="byline author vcard">'. __('Written by', 'roots') .' <a href="'. get_author_posts_url(get_the_author_meta('id')) .'" rel="author" class="fn">'. get_the_author() .'</a></p>';
}

View File

@@ -20,4 +20,4 @@ function roots_google_analytics() {
}
}
add_action('roots_footer', 'roots_google_analytics');
add_action('roots_footer', 'roots_google_analytics');

View File

@@ -74,7 +74,7 @@ function roots_root_relative_attachment_urls() {
}
function enable_root_relative_urls() {
return !(is_admin() && in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) && ROOT_RELATIVE_URLS;
return !(is_admin() && in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) && current_theme_supports('root-relative-urls');
}
if (enable_root_relative_urls()) {

24
inc/config.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
add_theme_support('root-relative-urls');
add_theme_support('rewrite-urls');
add_theme_support('h5bp-htaccess');
add_theme_support('bootstrap-responsive');
// Set the content width based on the theme's design and stylesheet
if (!isset($content_width)) { $content_width = 940; }
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', '');
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);

View File

@@ -44,15 +44,15 @@ if (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') || stristr($_SERVER['SERVER_S
// only use clean urls if the theme isn't a child or an MU (Network) install
if (!is_multisite() && !is_child_theme() && get_option('permalink_structure')) {
if (REWRITE_URLS) {
if (current_theme_supports('rewrite-urls')) {
add_action('generate_rewrite_rules', 'roots_add_rewrites');
}
if (H5BP_HTACCESS) {
if (current_theme_supports('h5bp-htaccess')) {
add_action('generate_rewrite_rules', 'roots_add_h5bp_htaccess');
}
if (!is_admin() && REWRITE_URLS) {
if (!is_admin() && current_theme_supports('rewrite-urls')) {
$tags = array(
'plugins_url',
'bloginfo',

View File

@@ -1,13 +0,0 @@
<?php
define('ROOT_RELATIVE_URLS', true); // Use root relative URLs
define('REWRITE_URLS', true); // Use rewrites for theme assets and plugin folders
define('H5BP_HTACCESS', true); // Include the HTML5 Boilerplate .htaccess
define('POST_EXCERPT_LENGTH', 40);
define('BOOTSTRAP_RESPONSIVE', true);
define('WRAP_CLASSES', 'container');
define('CONTAINER_CLASSES', 'row');
define('MAIN_CLASSES', 'span8');
define('SIDEBAR_CLASSES', 'span4');
define('FULLWIDTH_CLASSES', 'span12');
define('GOOGLE_ANALYTICS_ID', '');

View File

@@ -1,11 +1,11 @@
<?php
function roots_scripts() {
// Not included by default since Bootstrap's reset supersedes h5bp's. Include if you aren't using Bootstrap.
// Not included by default since Bootstrap's reset supersedes h5bp's. Include if you aren't using Bootstrap.
//wp_enqueue_style('roots_style', get_template_directory_uri() . '/css/style.css', false, null);
wp_enqueue_style('roots_bootstrap_style', get_template_directory_uri() . '/css/bootstrap.css', false, null);
if (BOOTSTRAP_RESPONSIVE) {
if (current_theme_supports('bootstrap-responsive')) {
wp_enqueue_style('roots_bootstrap_responsive_style', get_template_directory_uri() . '/css/bootstrap-responsive.css', array('roots_bootstrap_style'), null);
}

7
inc/template-tags.php Normal file
View File

@@ -0,0 +1,7 @@
<?php
// Return post entry meta information
function roots_entry_meta() {
echo '<time class="updated" datetime="'. get_the_time('c') .'" pubdate>'. sprintf(__('Posted on %s at %s.', 'roots'), get_the_date(), get_the_time()) .'</time>';
echo '<p class="byline author vcard">'. __('Written by', 'roots') .' <a href="'. get_author_posts_url(get_the_author_meta('id')) .'" rel="author" class="fn">'. get_the_author() .'</a></p>';
}

View File

@@ -23,4 +23,5 @@ function add_filters($tags, $function) {
foreach($tags as $tag) {
add_filter($tag, $function);
}
}
}

View File

@@ -1,5 +1,30 @@
<?php
function roots_widgets_init() {
// Register widgetized areas
register_sidebar(array(
'name' => __('Primary Sidebar', 'roots'),
'id' => 'sidebar-primary',
'before_widget' => '<section id="%1$s" class="widget %2$s"><div class="widget-inner">',
'after_widget' => '</div></section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => __('Footer', 'roots'),
'id' => 'sidebar-footer',
'before_widget' => '<section id="%1$s" class="widget %2$s"><div class="widget-inner">',
'after_widget' => '</div></section>',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
// Register widgets
register_widget('Roots_Vcard_Widget');
}
add_action('widgets_init', 'roots_widgets_init');
// Example vCard widget
class Roots_Vcard_Widget extends WP_Widget {
function Roots_Vcard_Widget() {
$widget_ops = array('classname' => 'widget_roots_vcard', 'description' => __('Use this widget to add a vCard', 'roots'));
@@ -126,9 +151,3 @@ class Roots_Vcard_Widget extends WP_Widget {
<?php
}
}
function roots_widget_init() {
register_widget('Roots_Vcard_Widget');
}
add_action('widgets_init', 'roots_widget_init');

View File

@@ -1,3 +1,3 @@
<div class="well">
<?php dynamic_sidebar('roots-sidebar'); ?>
<?php dynamic_sidebar('sidebar-primary'); ?>
</div>

View File

@@ -1,6 +1,6 @@
/*
Theme Name: Roots
Theme URI: http://rootstheme.com/
Theme URI: http://www.rootstheme.com/
Description: Roots is a starting WordPress theme made for developers that's based on HTML5 Boilerplate and Bootstrap from Twitter. <a href="https://github.com/retlehs/roots/contributors">Contribute on GitHub</a>
Version: 5.1.0
Author: Ben Word