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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
* [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.
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Roots functions
|
||||
* Required by WordPress.
|
||||
*
|
||||
* Keep this file clean and only use it for requires.
|
||||
*/
|
||||
|
||||
if (!defined('__DIR__')) { define('__DIR__', dirname(__FILE__)); }
|
||||
|
||||
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/config.php'); // Configuration 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
|
||||
require_once locate_template('/lib/htaccess.php'); // Rewrites for assets, H5BP .htaccess
|
||||
@@ -15,28 +16,3 @@ require_once locate_template('/lib/scripts.php'); // Scripts and stylesh
|
||||
require_once locate_template('/lib/post-types.php'); // Custom post types
|
||||
require_once locate_template('/lib/metaboxes.php'); // Custom metaboxes
|
||||
require_once locate_template('/lib/custom.php'); // Custom functions
|
||||
|
||||
function roots_setup() {
|
||||
|
||||
// Make theme available for translation
|
||||
load_theme_textdomain('roots', get_template_directory() . '/lang');
|
||||
|
||||
// Register wp_nav_menu() menus (http://codex.wordpress.org/Function_Reference/register_nav_menus)
|
||||
register_nav_menus(array(
|
||||
'primary_navigation' => __('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');
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Roots configuration and constants
|
||||
* Roots configuration
|
||||
*/
|
||||
|
||||
// Enable theme features
|
||||
add_theme_support('root-relative-urls'); // Enable relative URLs
|
||||
add_theme_support('rewrite-urls'); // Enable URL rewrites
|
||||
add_theme_support('h5bp-htaccess'); // Enable HTML5 Boilerplate's .htaccess
|
||||
@@ -30,15 +32,9 @@ function roots_sidebar_class() {
|
||||
echo 'span4';
|
||||
}
|
||||
|
||||
$get_theme_name = explode('/themes/', get_template_directory());
|
||||
define('GOOGLE_ANALYTICS_ID', ''); // UA-XXXXX-Y
|
||||
define('POST_EXCERPT_LENGTH', 40);
|
||||
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);
|
||||
// Configuration values
|
||||
define('GOOGLE_ANALYTICS_ID', ''); // UA-XXXXX-Y
|
||||
define('POST_EXCERPT_LENGTH', 40);
|
||||
|
||||
// Set the content width based on the theme's design and stylesheet
|
||||
if (!isset($content_width)) { $content_width = 940; }
|
||||
|
||||
42
lib/init.php
Normal file
42
lib/init.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
load_theme_textdomain('roots', get_template_directory() . '/lang');
|
||||
|
||||
// Register wp_nav_menu() menus (http://codex.wordpress.org/Function_Reference/register_nav_menus)
|
||||
register_nav_menus(array(
|
||||
'primary_navigation' => __('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');
|
||||
Reference in New Issue
Block a user