From 23ab579f37db2fab2d5f11885b8876119f6387aa Mon Sep 17 00:00:00 2001 From: Ben Word Date: Sat, 10 Oct 2015 13:09:20 -0500 Subject: [PATCH] Move init.php to config.php --- functions.php | 11 ++++----- lib/config.php | 63 ++++++++++++++++++++++++++++++++++++++++++++++- lib/init.php | 66 -------------------------------------------------- 3 files changed, 67 insertions(+), 73 deletions(-) delete mode 100644 lib/init.php diff --git a/functions.php b/functions.php index 81913ecfa8..97b3299552 100644 --- a/functions.php +++ b/functions.php @@ -10,12 +10,11 @@ * @link https://github.com/roots/sage/pull/1042 */ $sage_includes = [ - 'lib/init.php', // Initial theme setup and constants - 'lib/wrapper.php', // Theme wrapper class - 'lib/config.php', // Configuration - 'lib/assets.php', // Scripts and stylesheets - 'lib/titles.php', // Page titles - 'lib/extras.php', // Custom functions + 'lib/assets.php', // Scripts and stylesheets + 'lib/config.php', // Configuration + 'lib/extras.php', // Custom functions + 'lib/titles.php', // Page titles + 'lib/wrapper.php' // Theme wrapper class ]; foreach ($sage_includes as $file) { diff --git a/lib/config.php b/lib/config.php index d51b96bb67..c2838cc63b 100644 --- a/lib/config.php +++ b/lib/config.php @@ -2,7 +2,7 @@ namespace Roots\Sage\Config; -use Roots\Sage\ConditionalTagCheck; +use Roots\Sage\Assets; /** * Enable theme features @@ -21,6 +21,67 @@ define('DIST_DIR', '/dist/'); } +/** + * Theme setup + */ +function setup() { + // Make theme available for translation + // Community translations can be found at https://github.com/roots/sage-translations + load_theme_textdomain('sage', get_template_directory() . '/lang'); + + // Enable plugins to manage the document title + // http://codex.wordpress.org/Function_Reference/add_theme_support#Title_Tag + add_theme_support('title-tag'); + + // Register wp_nav_menu() menus + // http://codex.wordpress.org/Function_Reference/register_nav_menus + register_nav_menus([ + 'primary_navigation' => __('Primary Navigation', 'sage') + ]); + + // Add post thumbnails + // http://codex.wordpress.org/Post_Thumbnails + // http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size + // http://codex.wordpress.org/Function_Reference/add_image_size + add_theme_support('post-thumbnails'); + + // Add post formats + // http://codex.wordpress.org/Post_Formats + add_theme_support('post-formats', ['aside', 'gallery', 'link', 'image', 'quote', 'video', 'audio']); + + // Add HTML5 markup for captions + // http://codex.wordpress.org/Function_Reference/add_theme_support#HTML5 + add_theme_support('html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form']); + + // Tell the TinyMCE editor to use a custom stylesheet + add_editor_style(Assets\asset_path('styles/editor-style.css')); +} +add_action('after_setup_theme', __NAMESPACE__ . '\\setup'); + +/** + * Register sidebars + */ +function widgets_init() { + register_sidebar([ + 'name' => __('Primary', 'sage'), + 'id' => 'sidebar-primary', + 'before_widget' => '
', + 'after_widget' => '
', + 'before_title' => '

', + 'after_title' => '

' + ]); + + register_sidebar([ + 'name' => __('Footer', 'sage'), + 'id' => 'sidebar-footer', + 'before_widget' => '
', + 'after_widget' => '
', + 'before_title' => '

', + 'after_title' => '

' + ]); +} +add_action('widgets_init', __NAMESPACE__ . '\\widgets_init'); + /** * Determine which pages should NOT display the sidebar */ diff --git a/lib/init.php b/lib/init.php deleted file mode 100644 index 8f525b864c..0000000000 --- a/lib/init.php +++ /dev/null @@ -1,66 +0,0 @@ - __('Primary Navigation', 'sage') - ]); - - // Add post thumbnails - // http://codex.wordpress.org/Post_Thumbnails - // http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size - // http://codex.wordpress.org/Function_Reference/add_image_size - add_theme_support('post-thumbnails'); - - // Add post formats - // http://codex.wordpress.org/Post_Formats - add_theme_support('post-formats', ['aside', 'gallery', 'link', 'image', 'quote', 'video', 'audio']); - - // Add HTML5 markup for captions - // http://codex.wordpress.org/Function_Reference/add_theme_support#HTML5 - add_theme_support('html5', ['caption', 'comment-form', 'comment-list', 'gallery', 'search-form']); - - // Tell the TinyMCE editor to use a custom stylesheet - add_editor_style(Assets\asset_path('styles/editor-style.css')); -} -add_action('after_setup_theme', __NAMESPACE__ . '\\setup'); - -/** - * Register sidebars - */ -function widgets_init() { - register_sidebar([ - 'name' => __('Primary', 'sage'), - 'id' => 'sidebar-primary', - 'before_widget' => '
', - 'after_widget' => '
', - 'before_title' => '

', - 'after_title' => '

' - ]); - - register_sidebar([ - 'name' => __('Footer', 'sage'), - 'id' => 'sidebar-footer', - 'before_widget' => '
', - 'after_widget' => '
', - 'before_title' => '

', - 'after_title' => '

' - ]); -} -add_action('widgets_init', __NAMESPACE__ . '\\widgets_init');