Move rewrites to a plugin, Roots 6.5.1
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
* Enable theme features
|
||||
*/
|
||||
add_theme_support('root-relative-urls'); // Enable relative URLs
|
||||
add_theme_support('rewrites'); // Enable URL rewrites
|
||||
add_theme_support('bootstrap-top-navbar'); // Enable Bootstrap's top navbar
|
||||
add_theme_support('bootstrap-gallery'); // Enable Bootstrap's thumbnails component on [gallery]
|
||||
add_theme_support('nice-search'); // Enable /?s= to /search/ redirect
|
||||
@@ -78,13 +77,3 @@ function roots_display_sidebar() {
|
||||
* Default: 1140px is the default Bootstrap container width.
|
||||
*/
|
||||
if (!isset($content_width)) { $content_width = 1140; }
|
||||
|
||||
/**
|
||||
* Define helper constants
|
||||
*/
|
||||
$get_theme_name = explode('/themes/', get_template_directory());
|
||||
|
||||
define('RELATIVE_PLUGIN_PATH', str_replace(home_url() . '/', '', plugins_url()));
|
||||
define('RELATIVE_CONTENT_PATH', str_replace(home_url() . '/', '', content_url()));
|
||||
define('THEME_NAME', next($get_theme_name));
|
||||
define('THEME_PATH', RELATIVE_CONTENT_PATH . '/themes/' . THEME_NAME);
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* URL rewriting
|
||||
*
|
||||
* Rewrites do not happen for multisite installations or child themes
|
||||
*
|
||||
* Rewrite:
|
||||
* /wp-content/themes/themename/assets/css/ to /assets/css/
|
||||
* /wp-content/themes/themename/assets/js/ to /assets/js/
|
||||
* /wp-content/themes/themename/assets/img/ to /assets/img/
|
||||
* /wp-content/plugins/ to /plugins/
|
||||
*
|
||||
* If you aren't using Apache, alternate configuration settings can be found in the docs.
|
||||
*
|
||||
*
|
||||
*/
|
||||
function roots_add_rewrites($content) {
|
||||
global $wp_rewrite;
|
||||
$roots_new_non_wp_rules = array(
|
||||
'assets/(.*)' => THEME_PATH . '/assets/$1',
|
||||
'plugins/(.*)' => RELATIVE_PLUGIN_PATH . '/$1'
|
||||
);
|
||||
$wp_rewrite->non_wp_rules = array_merge($wp_rewrite->non_wp_rules, $roots_new_non_wp_rules);
|
||||
return $content;
|
||||
}
|
||||
|
||||
function roots_clean_urls($content) {
|
||||
if (strpos($content, RELATIVE_PLUGIN_PATH) > 0) {
|
||||
return str_replace('/' . RELATIVE_PLUGIN_PATH, '/plugins', $content);
|
||||
} else {
|
||||
return str_replace('/' . THEME_PATH, '', $content);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_multisite() && !is_child_theme()) {
|
||||
if (current_theme_supports('rewrites')) {
|
||||
add_action('generate_rewrite_rules', 'roots_add_rewrites');
|
||||
}
|
||||
|
||||
if (!is_admin() && current_theme_supports('rewrites')) {
|
||||
$tags = array(
|
||||
'plugins_url',
|
||||
'bloginfo',
|
||||
'stylesheet_directory_uri',
|
||||
'template_directory_uri',
|
||||
'script_loader_src',
|
||||
'style_loader_src'
|
||||
);
|
||||
|
||||
add_filters($tags, 'roots_clean_urls');
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
* 3. /theme/assets/js/main.min.js (in footer)
|
||||
*/
|
||||
function roots_scripts() {
|
||||
wp_enqueue_style('roots_main', get_template_directory_uri() . '/assets/css/main.min.css', false, '9a2dd99b82ca338b034e8730b94139d2');
|
||||
wp_enqueue_style('roots_main', get_template_directory_uri() . '/assets/css/main.min.css', false, 'eb6334a114ec5f4f5c96dff76170aade');
|
||||
|
||||
// jQuery is loaded using the same method from HTML5 Boilerplate:
|
||||
// Grab Google CDN's latest jQuery with a protocol relative URL; fallback to local if offline
|
||||
@@ -27,7 +27,7 @@ function roots_scripts() {
|
||||
}
|
||||
|
||||
wp_register_script('modernizr', get_template_directory_uri() . '/assets/js/vendor/modernizr-2.6.2.min.js', false, null, false);
|
||||
wp_register_script('roots_scripts', get_template_directory_uri() . '/assets/js/scripts.min.js', false, '2a3e700c4c6e3d70a95b00241a845695', true);
|
||||
wp_register_script('roots_scripts', get_template_directory_uri() . '/assets/js/scripts.min.js', false, 'e976bc66a7d279f3d265efbe1e0e14fb', true);
|
||||
wp_enqueue_script('modernizr');
|
||||
wp_enqueue_script('jquery');
|
||||
wp_enqueue_script('roots_scripts');
|
||||
|
||||
Reference in New Issue
Block a user