Rename config.php to setup.php
This commit is contained in:
100
lib/setup.php
Normal file
100
lib/setup.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Roots\Sage\Setup;
|
||||
|
||||
use Roots\Sage\Assets;
|
||||
|
||||
/**
|
||||
* Enable theme features
|
||||
*/
|
||||
add_theme_support('soil-clean-up'); // Enable clean up from Soil
|
||||
add_theme_support('soil-nav-walker'); // Enable cleaner nav walker from Soil
|
||||
add_theme_support('soil-relative-urls'); // Enable relative URLs from Soil
|
||||
add_theme_support('soil-nice-search'); // Enable nice search from Soil
|
||||
add_theme_support('soil-jquery-cdn'); // Enable to load jQuery from the Google CDN
|
||||
|
||||
/**
|
||||
* Configuration values
|
||||
*/
|
||||
if (!defined('DIST_DIR')) {
|
||||
// Path to the build directory for front-end assets
|
||||
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' => '<section class="widget %1$s %2$s">',
|
||||
'after_widget' => '</section>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>'
|
||||
]);
|
||||
|
||||
register_sidebar([
|
||||
'name' => __('Footer', 'sage'),
|
||||
'id' => 'sidebar-footer',
|
||||
'before_widget' => '<section class="widget %1$s %2$s">',
|
||||
'after_widget' => '</section>',
|
||||
'before_title' => '<h3>',
|
||||
'after_title' => '</h3>'
|
||||
]);
|
||||
}
|
||||
add_action('widgets_init', __NAMESPACE__ . '\\widgets_init');
|
||||
|
||||
/**
|
||||
* Determine which pages should NOT display the sidebar
|
||||
*/
|
||||
function display_sidebar() {
|
||||
static $display;
|
||||
|
||||
isset($display) || $display = !in_array(true, [
|
||||
// The sidebar will NOT be displayed if ANY of the following return true.
|
||||
// @link https://codex.wordpress.org/Conditional_Tags
|
||||
is_404(),
|
||||
is_front_page(),
|
||||
is_page_template('template-custom.php'),
|
||||
]);
|
||||
|
||||
return apply_filters('sage/display_sidebar', $display);
|
||||
}
|
||||
Reference in New Issue
Block a user