Updates to make roots dir/theme renameable

This commit is contained in:
Scott Walkinshaw
2011-03-30 20:27:51 -06:00
parent f03f744372
commit c6fdd5f320
4 changed files with 22 additions and 11 deletions

View File

@@ -1,5 +1,8 @@
<?php
//get active theme directory name (lets you rename roots)
$theme_name = next(explode('/themes/', get_template_directory()));
include_once('includes/roots-activation.php'); // activation
include_once('includes/roots-admin.php'); // admin additions/mods
include_once('includes/roots-options.php'); // theme options menu

View File

@@ -9,9 +9,11 @@ function roots_admin_init() {
//wp_register_script('roots_codemirror', "$site_url/wp-content/themes/roots/includes/js/codemirror/codemirror.js");
//wp_enqueue_script('roots_codemirror');
$theme_name = next(explode('/themes/', get_template_directory()));
wp_enqueue_script('jquery-ui-tabs');
wp_register_style('roots_admin', "$site_url/wp-content/themes/roots/includes/css/admin.css");
wp_register_script('roots_admin', "$site_url/wp-content/themes/roots/includes/js/scripts.js");
wp_register_style('roots_admin', "$site_url/wp-content/themes/$theme_name/includes/css/admin.css");
wp_register_script('roots_admin', "$site_url/wp-content/themes/$theme_name/includes/js/scripts.js");
wp_enqueue_style('roots_admin');
wp_enqueue_script('roots_admin');
}

View File

@@ -10,12 +10,13 @@ function roots_flush_rewrites() {
$wp_rewrite->flush_rules();
}
function roots_add_rewrites() {
function roots_add_rewrites($content) {
$theme_name = next(explode('/themes/', get_template_directory()));
global $wp_rewrite;
$roots_new_non_wp_rules = array(
'css/(.*)' => 'wp-content/themes/roots/css/$1',
'js/(.*)' => 'wp-content/themes/roots/js/$1',
'img/(.*)' => 'wp-content/themes/roots/img/$1',
'css/(.*)' => 'wp-content/themes/'. $theme_name . '/css/$1',
'js/(.*)' => 'wp-content/themes/'. $theme_name . '/js/$1',
'img/(.*)' => 'wp-content/themes/'. $theme_name . '/img/$1',
'plugins/(.*)' => 'wp-content/plugins/$1'
);
$wp_rewrite->non_wp_rules += $roots_new_non_wp_rules;
@@ -25,7 +26,9 @@ add_action('generate_rewrite_rules', 'roots_add_rewrites');
add_action('admin_init', 'roots_flush_rewrites');
function roots_clean_assets($content) {
$current_path = '/wp-content/themes/roots';
$theme_name = next(explode('/themes/', $content));
$current_path = '/wp-content/themes/' . $theme_name;
//$current_path = '/wp-content/themes/roots';
$new_path = '';
$content = str_replace($current_path, $new_path, $content);
return $content;

View File

@@ -6,8 +6,11 @@ add_action('admin_menu', 'roots_create_menu');
function roots_create_menu() {
$icon = get_template_directory_uri() . '/includes/images/icon-roots.png';
// create menu
add_object_page('Roots Settings', 'Roots', 'administrator', 'roots', 'roots_settings_page', $icon);
// create menu
$theme_name = get_current_theme();
add_object_page($theme_name . ' Settings', $theme_name, 'administrator', 'roots', 'roots_settings_page', $icon);
// call register settings function
add_action('admin_init', 'roots_register_settings');
@@ -40,7 +43,7 @@ function roots_settings_page() { ?>
<div class="wrap">
<div id="icon-options-general" class="icon32"></div>
<h2>Roots Settings</h2>
<h2><?php echo get_current_theme(); ?> Settings</h2>
<?php if (isset($_GET['settings-updated']) && $_GET['settings-updated'] === 'true') { ?>
<div id="setting-error-settings_updated" class="updated settings-error"><p><strong>Settings saved.</strong></p></div>