From ba56e0fa4ddec1175da78addf32189616a176cd1 Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Fri, 21 Sep 2012 16:20:03 -0400 Subject: [PATCH 1/4] Re-organize theme configuration and setup functions.php should not contain any Roots specific code. It's just used to require files and bootstrap Roots. lib/init.php now handles initial theme setup and defines helper constants which did not belong in lib/config.php. config.php should be limited to strictly configuration settings. --- CHANGELOG.md | 1 + doc/README.md | 6 ++---- doc/lib.md | 4 ++++ functions.php | 34 +++++----------------------------- lib/config.php | 16 ++++++---------- lib/init.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 60 insertions(+), 43 deletions(-) create mode 100644 lib/init.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 628b330..9f28fdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ### HEAD +* Re-organize configuration/setup files * Update to jQuery 1.8.2 * Refactor/simplify Roots vCard Widget * Move custom entry_meta code into template diff --git a/doc/README.md b/doc/README.md index b38cce1..4760dc2 100755 --- a/doc/README.md +++ b/doc/README.md @@ -15,7 +15,5 @@ Roots is a starting WordPress theme made for developers that’s based on [HTML5 ## Development -* [Contributing to Roots](/retlehs/roots/blob/master/CONTRIBUTING.md) — Guidelines on how to - contribute effectively. -* [Extending and customizing Roots](extend.md) — Going further with - Roots. \ No newline at end of file +* [Contributing to Roots](/retlehs/roots/blob/master/CONTRIBUTING.md) — Guidelines on how to contribute effectively. +* [Extending and customizing Roots](extend.md) — Going further with Roots. diff --git a/doc/lib.md b/doc/lib.md index 73014aa..b173127 100644 --- a/doc/lib.md +++ b/doc/lib.md @@ -51,6 +51,10 @@ This file contains HTML5 Boilerplate's `.htaccess` which is automatically added This file handles the clean URL rewrites and HTML5 Boilerplate `.htaccess`. [About the rewrites](rewrites.md). +### init.php + +This file runs the initial theme setup and defines helper constants for later use + ### metaboxes.php 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). diff --git a/functions.php b/functions.php index 16a8c6b..9a685c9 100644 --- a/functions.php +++ b/functions.php @@ -1,12 +1,13 @@ __('Primary Navigation', 'roots'), - )); - - // 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) - - // Add post formats (http://codex.wordpress.org/Post_Formats) - // add_theme_support('post-formats', array('aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat')); - - // Tell the TinyMCE editor to use a custom stylesheet - add_editor_style('assets/css/editor-style.css'); - -} - -add_action('after_setup_theme', 'roots_setup'); diff --git a/lib/config.php b/lib/config.php index e3a657b..6dead0d 100644 --- a/lib/config.php +++ b/lib/config.php @@ -1,7 +1,9 @@ __('Primary Navigation', 'roots'), + )); + + // 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) + + // Add post formats (http://codex.wordpress.org/Post_Formats) + // add_theme_support('post-formats', array('aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat')); + + // Tell the TinyMCE editor to use a custom stylesheet + add_editor_style('assets/css/editor-style.css'); + +} + +add_action('after_setup_theme', 'roots_setup'); From 03a6ad078442694b57dab3de398eafddca2c7598 Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Fri, 21 Sep 2012 16:24:57 -0400 Subject: [PATCH 2/4] Fix require order --- functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.php b/functions.php index 9a685c9..9fde0de 100644 --- a/functions.php +++ b/functions.php @@ -5,8 +5,8 @@ * Keep this file clean and only use it for requires. */ -require_once locate_template('/lib/init.php'); // Initial theme setup and constants require_once locate_template('/lib/utils.php'); // Utility functions +require_once locate_template('/lib/init.php'); // Initial theme setup and constants require_once locate_template('/lib/config.php'); // Configuration require_once locate_template('/lib/activation.php'); // Theme activation require_once locate_template('/lib/cleanup.php'); // Cleanup From eec11c76b9d54c208a540918adc559b8afd49fe1 Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Fri, 21 Sep 2012 16:27:33 -0400 Subject: [PATCH 3/4] Re-order init file --- lib/init.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/init.php b/lib/init.php index 47f1c1b..65c440c 100644 --- a/lib/init.php +++ b/lib/init.php @@ -3,19 +3,6 @@ * Roots initial setup and constants */ -// Backwards compatibility for older than PHP 5.3.0 -if (!defined('__DIR__')) { define('__DIR__', dirname(__FILE__)); } - -// Define helper constants -$get_theme_name = explode('/themes/', get_template_directory()); - -define('WP_BASE', wp_base_dir()); -define('THEME_NAME', next($get_theme_name)); -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); - function roots_setup() { // Make theme available for translation @@ -40,3 +27,16 @@ function roots_setup() { } add_action('after_setup_theme', 'roots_setup'); + +// Backwards compatibility for older than PHP 5.3.0 +if (!defined('__DIR__')) { define('__DIR__', dirname(__FILE__)); } + +// Define helper constants +$get_theme_name = explode('/themes/', get_template_directory()); + +define('WP_BASE', wp_base_dir()); +define('THEME_NAME', next($get_theme_name)); +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); From af1b44e3dcc2c0eab63b06d32fb2770d2d6b4527 Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Mon, 24 Sep 2012 13:08:16 -0400 Subject: [PATCH 4/4] Better comment regarding $content_width --- lib/config.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/config.php b/lib/config.php index 6dead0d..165001b 100644 --- a/lib/config.php +++ b/lib/config.php @@ -36,5 +36,13 @@ function roots_sidebar_class() { define('GOOGLE_ANALYTICS_ID', ''); // UA-XXXXX-Y define('POST_EXCERPT_LENGTH', 40); -// Set the content width based on the theme's design and stylesheet +/** +* $content_width is a global variable used by WordPress for max image upload sizes and media embeds (in pixels) +* +* Example: If the content area is 640px wide, set $content_width = 620; so images and videos will not overflow. +* +* Default: 940px is the default Bootstrap container width. +* +* This is not required or used by Roots. +*/ if (!isset($content_width)) { $content_width = 940; }