Rename to Sage
This commit is contained in:
@@ -7,29 +7,29 @@ if (is_admin() && isset($_GET['activated']) && 'themes.php' == $GLOBALS['pagenow
|
||||
exit;
|
||||
}
|
||||
|
||||
function roots_theme_activation_options_init() {
|
||||
function sage_theme_activation_options_init() {
|
||||
register_setting(
|
||||
'roots_activation_options',
|
||||
'roots_theme_activation_options'
|
||||
'sage_activation_options',
|
||||
'sage_theme_activation_options'
|
||||
);
|
||||
}
|
||||
add_action('admin_init', 'roots_theme_activation_options_init');
|
||||
add_action('admin_init', 'sage_theme_activation_options_init');
|
||||
|
||||
function roots_activation_options_page_capability() {
|
||||
function sage_activation_options_page_capability() {
|
||||
return 'edit_theme_options';
|
||||
}
|
||||
add_filter('option_page_capability_roots_activation_options', 'roots_activation_options_page_capability');
|
||||
add_filter('option_page_capability_sage_activation_options', 'sage_activation_options_page_capability');
|
||||
|
||||
function roots_theme_activation_options_add_page() {
|
||||
$roots_activation_options = roots_get_theme_activation_options();
|
||||
function sage_theme_activation_options_add_page() {
|
||||
$sage_activation_options = sage_get_theme_activation_options();
|
||||
|
||||
if (!$roots_activation_options) {
|
||||
if (!$sage_activation_options) {
|
||||
add_theme_page(
|
||||
__('Theme Activation', 'roots'),
|
||||
__('Theme Activation', 'roots'),
|
||||
__('Theme Activation', 'sage'),
|
||||
__('Theme Activation', 'sage'),
|
||||
'edit_theme_options',
|
||||
'theme_activation_options',
|
||||
'roots_theme_activation_options_render_page'
|
||||
'sage_theme_activation_options_render_page'
|
||||
);
|
||||
} else {
|
||||
if (is_admin() && isset($_GET['page']) && $_GET['page'] === 'theme_activation_options') {
|
||||
@@ -39,68 +39,68 @@ function roots_theme_activation_options_add_page() {
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action('admin_menu', 'roots_theme_activation_options_add_page', 50);
|
||||
add_action('admin_menu', 'sage_theme_activation_options_add_page', 50);
|
||||
|
||||
function roots_get_theme_activation_options() {
|
||||
return get_option('roots_theme_activation_options');
|
||||
function sage_get_theme_activation_options() {
|
||||
return get_option('sage_theme_activation_options');
|
||||
}
|
||||
|
||||
function roots_theme_activation_options_render_page() { ?>
|
||||
function sage_theme_activation_options_render_page() { ?>
|
||||
<div class="wrap">
|
||||
<h2><?php printf(__('%s Theme Activation', 'roots'), wp_get_theme()); ?></h2>
|
||||
<h2><?php printf(__('%s Theme Activation', 'sage'), wp_get_theme()); ?></h2>
|
||||
<div class="update-nag">
|
||||
<?php _e('These settings are optional and should usually be used only on a fresh installation', 'roots'); ?>
|
||||
<?php _e('These settings are optional and should usually be used only on a fresh installation', 'sage'); ?>
|
||||
</div>
|
||||
<?php settings_errors(); ?>
|
||||
|
||||
<form method="post" action="options.php">
|
||||
<?php settings_fields('roots_activation_options'); ?>
|
||||
<?php settings_fields('sage_activation_options'); ?>
|
||||
<table class="form-table">
|
||||
<tr valign="top"><th scope="row"><?php _e('Create static front page?', 'roots'); ?></th>
|
||||
<tr valign="top"><th scope="row"><?php _e('Create static front page?', 'sage'); ?></th>
|
||||
<td>
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text"><span><?php _e('Create static front page?', 'roots'); ?></span></legend>
|
||||
<select name="roots_theme_activation_options[create_front_page]" id="create_front_page">
|
||||
<option selected="selected" value="true"><?php echo _e('Yes', 'roots'); ?></option>
|
||||
<option value="false"><?php echo _e('No', 'roots'); ?></option>
|
||||
<legend class="screen-reader-text"><span><?php _e('Create static front page?', 'sage'); ?></span></legend>
|
||||
<select name="sage_theme_activation_options[create_front_page]" id="create_front_page">
|
||||
<option selected="selected" value="true"><?php echo _e('Yes', 'sage'); ?></option>
|
||||
<option value="false"><?php echo _e('No', 'sage'); ?></option>
|
||||
</select>
|
||||
<p class="description"><?php printf(__('Create a page called Home and set it to be the static front page', 'roots')); ?></p>
|
||||
<p class="description"><?php printf(__('Create a page called Home and set it to be the static front page', 'sage')); ?></p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top"><th scope="row"><?php _e('Change permalink structure?', 'roots'); ?></th>
|
||||
<tr valign="top"><th scope="row"><?php _e('Change permalink structure?', 'sage'); ?></th>
|
||||
<td>
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text"><span><?php _e('Update permalink structure?', 'roots'); ?></span></legend>
|
||||
<select name="roots_theme_activation_options[change_permalink_structure]" id="change_permalink_structure">
|
||||
<option selected="selected" value="true"><?php echo _e('Yes', 'roots'); ?></option>
|
||||
<option value="false"><?php echo _e('No', 'roots'); ?></option>
|
||||
<legend class="screen-reader-text"><span><?php _e('Update permalink structure?', 'sage'); ?></span></legend>
|
||||
<select name="sage_theme_activation_options[change_permalink_structure]" id="change_permalink_structure">
|
||||
<option selected="selected" value="true"><?php echo _e('Yes', 'sage'); ?></option>
|
||||
<option value="false"><?php echo _e('No', 'sage'); ?></option>
|
||||
</select>
|
||||
<p class="description"><?php printf(__('Change permalink structure to /%postname%/', 'roots')); ?></p>
|
||||
<p class="description"><?php printf(__('Change permalink structure to /%postname%/', 'sage')); ?></p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top"><th scope="row"><?php _e('Create navigation menu?', 'roots'); ?></th>
|
||||
<tr valign="top"><th scope="row"><?php _e('Create navigation menu?', 'sage'); ?></th>
|
||||
<td>
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text"><span><?php _e('Create navigation menu?', 'roots'); ?></span></legend>
|
||||
<select name="roots_theme_activation_options[create_navigation_menus]" id="create_navigation_menus">
|
||||
<option selected="selected" value="true"><?php echo _e('Yes', 'roots'); ?></option>
|
||||
<option value="false"><?php echo _e('No', 'roots'); ?></option>
|
||||
<legend class="screen-reader-text"><span><?php _e('Create navigation menu?', 'sage'); ?></span></legend>
|
||||
<select name="sage_theme_activation_options[create_navigation_menus]" id="create_navigation_menus">
|
||||
<option selected="selected" value="true"><?php echo _e('Yes', 'sage'); ?></option>
|
||||
<option value="false"><?php echo _e('No', 'sage'); ?></option>
|
||||
</select>
|
||||
<p class="description"><?php printf(__('Create the Primary Navigation menu and set the location', 'roots')); ?></p>
|
||||
<p class="description"><?php printf(__('Create the Primary Navigation menu and set the location', 'sage')); ?></p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top"><th scope="row"><?php _e('Add pages to menu?', 'roots'); ?></th>
|
||||
<tr valign="top"><th scope="row"><?php _e('Add pages to menu?', 'sage'); ?></th>
|
||||
<td>
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text"><span><?php _e('Add pages to menu?', 'roots'); ?></span></legend>
|
||||
<select name="roots_theme_activation_options[add_pages_to_primary_navigation]" id="add_pages_to_primary_navigation">
|
||||
<option selected="selected" value="true"><?php echo _e('Yes', 'roots'); ?></option>
|
||||
<option value="false"><?php echo _e('No', 'roots'); ?></option>
|
||||
<legend class="screen-reader-text"><span><?php _e('Add pages to menu?', 'sage'); ?></span></legend>
|
||||
<select name="sage_theme_activation_options[add_pages_to_primary_navigation]" id="add_pages_to_primary_navigation">
|
||||
<option selected="selected" value="true"><?php echo _e('Yes', 'sage'); ?></option>
|
||||
<option value="false"><?php echo _e('No', 'sage'); ?></option>
|
||||
</select>
|
||||
<p class="description"><?php printf(__('Add all current published pages to the Primary Navigation', 'roots')); ?></p>
|
||||
<p class="description"><?php printf(__('Add all current published pages to the Primary Navigation', 'sage')); ?></p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -111,8 +111,8 @@ function roots_theme_activation_options_render_page() { ?>
|
||||
|
||||
<?php }
|
||||
|
||||
function roots_theme_activation_action() {
|
||||
if (!($roots_theme_activation_options = roots_get_theme_activation_options())) {
|
||||
function sage_theme_activation_action() {
|
||||
if (!($sage_theme_activation_options = sage_get_theme_activation_options())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -120,10 +120,10 @@ function roots_theme_activation_action() {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($roots_theme_activation_options['create_front_page'] === 'true') {
|
||||
$roots_theme_activation_options['create_front_page'] = false;
|
||||
if ($sage_theme_activation_options['create_front_page'] === 'true') {
|
||||
$sage_theme_activation_options['create_front_page'] = false;
|
||||
|
||||
$default_pages = array(__('Home', 'roots'));
|
||||
$default_pages = array(__('Home', 'sage'));
|
||||
$existing_pages = get_pages();
|
||||
$temp = array();
|
||||
|
||||
@@ -144,7 +144,7 @@ function roots_theme_activation_action() {
|
||||
wp_insert_post($add_default_pages);
|
||||
}
|
||||
|
||||
$home = get_page_by_title(__('Home', 'roots'));
|
||||
$home = get_page_by_title(__('Home', 'sage'));
|
||||
update_option('show_on_front', 'page');
|
||||
update_option('page_on_front', $home->ID);
|
||||
|
||||
@@ -155,8 +155,8 @@ function roots_theme_activation_action() {
|
||||
wp_update_post($home_menu_order);
|
||||
}
|
||||
|
||||
if ($roots_theme_activation_options['change_permalink_structure'] === 'true') {
|
||||
$roots_theme_activation_options['change_permalink_structure'] = false;
|
||||
if ($sage_theme_activation_options['change_permalink_structure'] === 'true') {
|
||||
$sage_theme_activation_options['change_permalink_structure'] = false;
|
||||
|
||||
if (get_option('permalink_structure') !== '/%postname%/') {
|
||||
global $wp_rewrite;
|
||||
@@ -165,29 +165,29 @@ function roots_theme_activation_action() {
|
||||
}
|
||||
}
|
||||
|
||||
if ($roots_theme_activation_options['create_navigation_menus'] === 'true') {
|
||||
$roots_theme_activation_options['create_navigation_menus'] = false;
|
||||
if ($sage_theme_activation_options['create_navigation_menus'] === 'true') {
|
||||
$sage_theme_activation_options['create_navigation_menus'] = false;
|
||||
|
||||
$roots_nav_theme_mod = false;
|
||||
$sage_nav_theme_mod = false;
|
||||
|
||||
$primary_nav = wp_get_nav_menu_object(__('Primary Navigation', 'roots'));
|
||||
$primary_nav = wp_get_nav_menu_object(__('Primary Navigation', 'sage'));
|
||||
|
||||
if (!$primary_nav) {
|
||||
$primary_nav_id = wp_create_nav_menu(__('Primary Navigation', 'roots'), array('slug' => 'primary_navigation'));
|
||||
$roots_nav_theme_mod['primary_navigation'] = $primary_nav_id;
|
||||
$primary_nav_id = wp_create_nav_menu(__('Primary Navigation', 'sage'), array('slug' => 'primary_navigation'));
|
||||
$sage_nav_theme_mod['primary_navigation'] = $primary_nav_id;
|
||||
} else {
|
||||
$roots_nav_theme_mod['primary_navigation'] = $primary_nav->term_id;
|
||||
$sage_nav_theme_mod['primary_navigation'] = $primary_nav->term_id;
|
||||
}
|
||||
|
||||
if ($roots_nav_theme_mod) {
|
||||
set_theme_mod('nav_menu_locations', $roots_nav_theme_mod);
|
||||
if ($sage_nav_theme_mod) {
|
||||
set_theme_mod('nav_menu_locations', $sage_nav_theme_mod);
|
||||
}
|
||||
}
|
||||
|
||||
if ($roots_theme_activation_options['add_pages_to_primary_navigation'] === 'true') {
|
||||
$roots_theme_activation_options['add_pages_to_primary_navigation'] = false;
|
||||
if ($sage_theme_activation_options['add_pages_to_primary_navigation'] === 'true') {
|
||||
$sage_theme_activation_options['add_pages_to_primary_navigation'] = false;
|
||||
|
||||
$primary_nav = wp_get_nav_menu_object(__('Primary Navigation', 'roots'));
|
||||
$primary_nav = wp_get_nav_menu_object(__('Primary Navigation', 'sage'));
|
||||
$primary_nav_term_id = (int) $primary_nav->term_id;
|
||||
$menu_items= wp_get_nav_menu_items($primary_nav_term_id);
|
||||
|
||||
@@ -205,11 +205,11 @@ function roots_theme_activation_action() {
|
||||
}
|
||||
}
|
||||
|
||||
update_option('roots_theme_activation_options', $roots_theme_activation_options);
|
||||
update_option('sage_theme_activation_options', $sage_theme_activation_options);
|
||||
}
|
||||
add_action('admin_init','roots_theme_activation_action');
|
||||
add_action('admin_init','sage_theme_activation_action');
|
||||
|
||||
function roots_deactivation() {
|
||||
delete_option('roots_theme_activation_options');
|
||||
function sage_deactivation() {
|
||||
delete_option('sage_theme_activation_options');
|
||||
}
|
||||
add_action('switch_theme', 'roots_deactivation');
|
||||
add_action('switch_theme', 'sage_deactivation');
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* - An ID has been defined in config.php
|
||||
* - You're not logged in as an administrator
|
||||
*/
|
||||
function roots_asset_path($filename) {
|
||||
function sage_asset_path($filename) {
|
||||
if (WP_ENV === 'development') {
|
||||
return get_template_directory_uri() . '/dist/' . $filename;
|
||||
}
|
||||
@@ -32,8 +32,8 @@ function roots_asset_path($filename) {
|
||||
}
|
||||
}
|
||||
|
||||
function roots_assets() {
|
||||
wp_enqueue_style('roots_css', roots_asset_path('styles/main.css'), false, null);
|
||||
function sage_assets() {
|
||||
wp_enqueue_style('sage_css', sage_asset_path('styles/main.css'), false, null);
|
||||
|
||||
/**
|
||||
* Grab Google CDN's latest jQuery with a protocol relative URL; fallback to local if offline
|
||||
@@ -46,21 +46,21 @@ function roots_assets() {
|
||||
|
||||
wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.js', array(), null, true);
|
||||
|
||||
add_filter('script_loader_src', 'roots_jquery_local_fallback', 10, 2);
|
||||
add_filter('script_loader_src', 'sage_jquery_local_fallback', 10, 2);
|
||||
}
|
||||
|
||||
if (is_single() && comments_open() && get_option('thread_comments')) {
|
||||
wp_enqueue_script('comment-reply');
|
||||
}
|
||||
|
||||
wp_enqueue_script('modernizr', roots_asset_path('scripts/modernizr.js'), array(), null, true);
|
||||
wp_enqueue_script('modernizr', sage_asset_path('scripts/modernizr.js'), array(), null, true);
|
||||
wp_enqueue_script('jquery');
|
||||
wp_enqueue_script('roots_js', roots_asset_path('scripts/app.js'), array(), null, true);
|
||||
wp_enqueue_script('sage_js', sage_asset_path('scripts/app.js'), array(), null, true);
|
||||
}
|
||||
add_action('wp_enqueue_scripts', 'roots_assets', 100);
|
||||
add_action('wp_enqueue_scripts', 'sage_assets', 100);
|
||||
|
||||
// http://wordpress.stackexchange.com/a/12450
|
||||
function roots_jquery_local_fallback($src, $handle = null) {
|
||||
function sage_jquery_local_fallback($src, $handle = null) {
|
||||
static $add_jquery_fallback = false;
|
||||
|
||||
if ($add_jquery_fallback) {
|
||||
@@ -74,14 +74,14 @@ function roots_jquery_local_fallback($src, $handle = null) {
|
||||
|
||||
return $src;
|
||||
}
|
||||
add_action('wp_head', 'roots_jquery_local_fallback');
|
||||
add_action('wp_head', 'sage_jquery_local_fallback');
|
||||
|
||||
/**
|
||||
* Google Analytics snippet from HTML5 Boilerplate
|
||||
*
|
||||
* Cookie domain is 'auto' configured. See: http://goo.gl/VUCHKM
|
||||
*/
|
||||
function roots_google_analytics() { ?>
|
||||
function sage_google_analytics() { ?>
|
||||
<script>
|
||||
<?php if (WP_ENV === 'production') : ?>
|
||||
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
|
||||
@@ -99,5 +99,5 @@ function roots_google_analytics() { ?>
|
||||
|
||||
<?php }
|
||||
if (GOOGLE_ANALYTICS_ID && (WP_ENV !== 'production' || !current_user_can('manage_options'))) {
|
||||
add_action('wp_footer', 'roots_google_analytics', 20);
|
||||
add_action('wp_footer', 'sage_google_analytics', 20);
|
||||
}
|
||||
|
||||
@@ -20,24 +20,24 @@ if (!defined('WP_ENV')) {
|
||||
/**
|
||||
* Add body class if sidebar is active
|
||||
*/
|
||||
function roots_sidebar_body_class($classes) {
|
||||
if (roots_display_sidebar()) {
|
||||
function sage_sidebar_body_class($classes) {
|
||||
if (sage_display_sidebar()) {
|
||||
$classes[] = 'sidebar-primary';
|
||||
}
|
||||
return $classes;
|
||||
}
|
||||
add_filter('body_class', 'roots_sidebar_body_class');
|
||||
add_filter('body_class', 'sage_sidebar_body_class');
|
||||
|
||||
/**
|
||||
* Define which pages shouldn't have the sidebar
|
||||
*
|
||||
* See lib/sidebar.php for more details
|
||||
*/
|
||||
function roots_display_sidebar() {
|
||||
function sage_display_sidebar() {
|
||||
static $display;
|
||||
|
||||
if (!isset($display)) {
|
||||
$sidebar_config = new Roots_Sidebar(
|
||||
$sidebar_config = new Sage_Sidebar(
|
||||
/**
|
||||
* Conditional tag checks (http://codex.wordpress.org/Conditional_Tags)
|
||||
* Any of these conditional tags that return true won't show the sidebar
|
||||
@@ -60,8 +60,8 @@ function roots_display_sidebar() {
|
||||
'template-custom.php'
|
||||
)
|
||||
);
|
||||
$display = apply_filters('roots/display_sidebar', $sidebar_config->display);
|
||||
}
|
||||
$display = apply_filters('sage/display_sidebar', $sidebar_config->display);
|
||||
}
|
||||
|
||||
return $display;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Clean up the_excerpt()
|
||||
*/
|
||||
function roots_excerpt_more() {
|
||||
return ' … <a href="' . get_permalink() . '">' . __('Continued', 'roots') . '</a>';
|
||||
function sage_excerpt_more() {
|
||||
return ' … <a href="' . get_permalink() . '">' . __('Continued', 'sage') . '</a>';
|
||||
}
|
||||
add_filter('excerpt_more', 'roots_excerpt_more');
|
||||
add_filter('excerpt_more', 'sage_excerpt_more');
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* @link http://getbootstrap.com/components/#thumbnails
|
||||
*/
|
||||
function roots_gallery($attr) {
|
||||
function sage_gallery($attr) {
|
||||
$post = get_post();
|
||||
|
||||
static $instance = 0;
|
||||
@@ -115,15 +115,15 @@ function roots_gallery($attr) {
|
||||
}
|
||||
if (current_theme_supports('bootstrap-gallery')) {
|
||||
remove_shortcode('gallery');
|
||||
add_shortcode('gallery', 'roots_gallery');
|
||||
add_shortcode('gallery', 'sage_gallery');
|
||||
add_filter('use_default_gallery_style', '__return_null');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add class="thumbnail img-thumbnail" to attachment items
|
||||
*/
|
||||
function roots_attachment_link_class($html) {
|
||||
function sage_attachment_link_class($html) {
|
||||
$html = str_replace('<a', '<a class="thumbnail img-thumbnail"', $html);
|
||||
return $html;
|
||||
}
|
||||
add_filter('wp_get_attachment_link', 'roots_attachment_link_class', 10, 1);
|
||||
add_filter('wp_get_attachment_link', 'sage_attachment_link_class', 10, 1);
|
||||
|
||||
20
lib/init.php
20
lib/init.php
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Roots initial setup and constants
|
||||
* Sage initial setup and constants
|
||||
*/
|
||||
function roots_setup() {
|
||||
function sage_setup() {
|
||||
// Make theme available for translation
|
||||
// Community translations can be found at https://github.com/roots/roots-translations
|
||||
load_theme_textdomain('roots', get_template_directory() . '/lang');
|
||||
// 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
|
||||
@@ -14,7 +14,7 @@ function roots_setup() {
|
||||
// Register wp_nav_menu() menus
|
||||
// http://codex.wordpress.org/Function_Reference/register_nav_menus
|
||||
register_nav_menus(array(
|
||||
'primary_navigation' => __('Primary Navigation', 'roots')
|
||||
'primary_navigation' => __('Primary Navigation', 'sage')
|
||||
));
|
||||
|
||||
// Add post thumbnails
|
||||
@@ -34,14 +34,14 @@ function roots_setup() {
|
||||
// Tell the TinyMCE editor to use a custom stylesheet
|
||||
add_editor_style('/dist/css/editor-style.css');
|
||||
}
|
||||
add_action('after_setup_theme', 'roots_setup');
|
||||
add_action('after_setup_theme', 'sage_setup');
|
||||
|
||||
/**
|
||||
* Register sidebars
|
||||
*/
|
||||
function roots_widgets_init() {
|
||||
function sage_widgets_init() {
|
||||
register_sidebar(array(
|
||||
'name' => __('Primary', 'roots'),
|
||||
'name' => __('Primary', 'sage'),
|
||||
'id' => 'sidebar-primary',
|
||||
'before_widget' => '<section class="widget %1$s %2$s">',
|
||||
'after_widget' => '</section>',
|
||||
@@ -50,7 +50,7 @@ function roots_widgets_init() {
|
||||
));
|
||||
|
||||
register_sidebar(array(
|
||||
'name' => __('Footer', 'roots'),
|
||||
'name' => __('Footer', 'sage'),
|
||||
'id' => 'sidebar-footer',
|
||||
'before_widget' => '<section class="widget %1$s %2$s">',
|
||||
'after_widget' => '</section>',
|
||||
@@ -58,4 +58,4 @@ function roots_widgets_init() {
|
||||
'after_title' => '</h3>',
|
||||
));
|
||||
}
|
||||
add_action('widgets_init', 'roots_widgets_init');
|
||||
add_action('widgets_init', 'sage_widgets_init');
|
||||
|
||||
26
lib/nav.php
26
lib/nav.php
@@ -6,11 +6,11 @@
|
||||
* <li id="menu-item-8" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-8"><a href="/">Home</a></li>
|
||||
* <li id="menu-item-9" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9"><a href="/sample-page/">Sample Page</a></l
|
||||
*
|
||||
* Roots_Nav_Walker example output:
|
||||
* Sage_Nav_Walker example output:
|
||||
* <li class="menu-home"><a href="/">Home</a></li>
|
||||
* <li class="menu-sample-page"><a href="/sample-page/">Sample Page</a></li>
|
||||
*/
|
||||
class Roots_Nav_Walker extends Walker_Nav_Menu {
|
||||
class Sage_Nav_Walker extends Walker_Nav_Menu {
|
||||
function check_current($classes) {
|
||||
return preg_match('/(current[-_])|active|dropdown/', $classes);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class Roots_Nav_Walker extends Walker_Nav_Menu {
|
||||
$item_html = preg_replace('/<a[^>]*>(.*)<\/a>/iU', '$1', $item_html);
|
||||
}
|
||||
|
||||
$item_html = apply_filters('roots/wp_nav_menu_item', $item_html);
|
||||
$item_html = apply_filters('sage/wp_nav_menu_item', $item_html);
|
||||
$output .= $item_html;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class Roots_Nav_Walker extends Walker_Nav_Menu {
|
||||
* Remove the id="" on nav menu items
|
||||
* Return 'menu-slug' for nav menu classes
|
||||
*/
|
||||
function roots_nav_menu_css_class($classes, $item) {
|
||||
function sage_nav_menu_css_class($classes, $item) {
|
||||
$slug = sanitize_title($item->title);
|
||||
$classes = preg_replace('/(current(-menu-|[-_]page[-_])(item|parent|ancestor))/', 'active', $classes);
|
||||
$classes = preg_replace('/^((menu|page)[-_\w+]+)+/', '', $classes);
|
||||
@@ -64,28 +64,28 @@ function roots_nav_menu_css_class($classes, $item) {
|
||||
|
||||
return array_filter($classes, 'is_element_empty');
|
||||
}
|
||||
add_filter('nav_menu_css_class', 'roots_nav_menu_css_class', 10, 2);
|
||||
add_filter('nav_menu_css_class', 'sage_nav_menu_css_class', 10, 2);
|
||||
add_filter('nav_menu_item_id', '__return_null');
|
||||
|
||||
/**
|
||||
* Clean up wp_nav_menu_args
|
||||
*
|
||||
* Remove the container
|
||||
* Use Roots_Nav_Walker() by default
|
||||
* Use Sage_Nav_Walker() by default
|
||||
*/
|
||||
function roots_nav_menu_args($args = '') {
|
||||
$roots_nav_menu_args = array();
|
||||
function sage_nav_menu_args($args = '') {
|
||||
$sage_nav_menu_args = array();
|
||||
|
||||
$roots_nav_menu_args['container'] = false;
|
||||
$sage_nav_menu_args['container'] = false;
|
||||
|
||||
if (!$args['items_wrap']) {
|
||||
$roots_nav_menu_args['items_wrap'] = '<ul class="%2$s">%3$s</ul>';
|
||||
$sage_nav_menu_args['items_wrap'] = '<ul class="%2$s">%3$s</ul>';
|
||||
}
|
||||
|
||||
if (!$args['depth']) {
|
||||
$roots_nav_menu_args['depth'] = 2;
|
||||
$sage_nav_menu_args['depth'] = 2;
|
||||
}
|
||||
|
||||
return array_merge($args, $roots_nav_menu_args);
|
||||
return array_merge($args, $sage_nav_menu_args);
|
||||
}
|
||||
add_filter('wp_nav_menu_args', 'roots_nav_menu_args');
|
||||
add_filter('wp_nav_menu_args', 'sage_nav_menu_args');
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
*
|
||||
* If any of the is_* conditional tags or is_page_template(template_file) checks return true, the sidebar will NOT be displayed.
|
||||
*
|
||||
* @link http://roots.io/the-roots-sidebar/
|
||||
* @link http://roots.io/getting-started/theme-sidebar/
|
||||
*
|
||||
* @param array list of conditional tags (http://codex.wordpress.org/Conditional_Tags)
|
||||
* @param array list of page templates. These will be checked via is_page_template()
|
||||
*
|
||||
* @return boolean True will display the sidebar, False will not
|
||||
*/
|
||||
class Roots_Sidebar {
|
||||
class Sage_Sidebar {
|
||||
private $conditionals;
|
||||
private $templates;
|
||||
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
/**
|
||||
* Page titles
|
||||
*/
|
||||
function roots_title() {
|
||||
function sage_title() {
|
||||
if (is_home()) {
|
||||
if (get_option('page_for_posts', true)) {
|
||||
return get_the_title(get_option('page_for_posts', true));
|
||||
} else {
|
||||
return __('Latest Posts', 'roots');
|
||||
return __('Latest Posts', 'sage');
|
||||
}
|
||||
} elseif (is_archive()) {
|
||||
return get_the_archive_title();
|
||||
} elseif (is_search()) {
|
||||
return sprintf(__('Search Results for %s', 'roots'), get_search_query());
|
||||
return sprintf(__('Search Results for %s', 'sage'), get_search_query());
|
||||
} elseif (is_404()) {
|
||||
return __('Not Found', 'roots');
|
||||
return __('Not Found', 'sage');
|
||||
} else {
|
||||
return get_the_title();
|
||||
}
|
||||
|
||||
@@ -8,17 +8,17 @@ function is_element_empty($element) {
|
||||
}
|
||||
|
||||
// Tell WordPress to use searchform.php from the templates/ directory
|
||||
function roots_get_search_form() {
|
||||
function sage_get_search_form() {
|
||||
$form = '';
|
||||
locate_template('/templates/searchform.php', true, false);
|
||||
return $form;
|
||||
}
|
||||
add_filter('get_search_form', 'roots_get_search_form');
|
||||
add_filter('get_search_form', 'sage_get_search_form');
|
||||
|
||||
/**
|
||||
* Add page slug to body_class() classes if it doesn't exist
|
||||
*/
|
||||
function roots_body_class($classes) {
|
||||
function sage_body_class($classes) {
|
||||
// Add post/page slug
|
||||
if (is_single() || is_page() && !is_front_page()) {
|
||||
if (!in_array(basename(get_permalink()), $classes)) {
|
||||
@@ -27,4 +27,4 @@ function roots_body_class($classes) {
|
||||
}
|
||||
return $classes;
|
||||
}
|
||||
add_filter('body_class', 'roots_body_class');
|
||||
add_filter('body_class', 'sage_body_class');
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
/**
|
||||
* Theme wrapper
|
||||
*
|
||||
* @link http://roots.io/an-introduction-to-the-roots-theme-wrapper/
|
||||
* @link http://roots.io/getting-started/theme-wrapper/
|
||||
* @link http://scribu.net/wordpress/theme-wrappers.html
|
||||
*/
|
||||
function roots_template_path() {
|
||||
return Roots_Wrapping::$main_template;
|
||||
function sage_template_path() {
|
||||
return Sage_Wrapping::$main_template;
|
||||
}
|
||||
|
||||
function roots_sidebar_path() {
|
||||
return new Roots_Wrapping('templates/sidebar.php');
|
||||
function sage_sidebar_path() {
|
||||
return new Sage_Wrapping('templates/sidebar.php');
|
||||
}
|
||||
|
||||
class Roots_Wrapping {
|
||||
class Sage_Wrapping {
|
||||
// Stores the full path to the main template file
|
||||
public static $main_template;
|
||||
|
||||
@@ -37,7 +37,7 @@ class Roots_Wrapping {
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
$this->templates = apply_filters('roots/wrap_' . $this->slug, $this->templates);
|
||||
$this->templates = apply_filters('sage/wrap_' . $this->slug, $this->templates);
|
||||
return locate_template($this->templates);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class Roots_Wrapping {
|
||||
self::$base = false;
|
||||
}
|
||||
|
||||
return new Roots_Wrapping();
|
||||
return new Sage_Wrapping();
|
||||
}
|
||||
}
|
||||
add_filter('template_include', array('Roots_Wrapping', 'wrap'), 99);
|
||||
add_filter('template_include', array('Sage_Wrapping', 'wrap'), 99);
|
||||
|
||||
Reference in New Issue
Block a user