diff --git a/inc/roots-cleanup.php b/inc/roots-cleanup.php index 8c27347..eb823d1 100644 --- a/inc/roots-cleanup.php +++ b/inc/roots-cleanup.php @@ -44,23 +44,24 @@ function roots_root_relative_url($input) { // Terrible workaround to remove the duplicate subfolder in the src of JS/CSS tags // Example: /subfolder/subfolder/css/style.css function roots_fix_duplicate_subfolder_urls($input) { - $output = roots_root_relative_url($input); - preg_match_all('!([^/]+)/([^/]+)!', $output, $matches); - if (isset($matches[1]) && isset($matches[2])) { - if ($matches[1][0] === $matches[2][0]) { - $output = substr($output, strlen($matches[1][0]) + 1); - } - } - return $output; + $output = roots_root_relative_url($input); + preg_match_all('!([^/]+)/([^/]+)!', $output, $matches); + if (isset($matches[1]) && isset($matches[2])) { + if ($matches[1][0] === $matches[2][0]) { + $output = substr($output, strlen($matches[1][0]) + 1); + } + } + return $output; } -if (!is_admin()) { +$roots_options = roots_get_theme_options(); +if (!is_admin() && $roots_options['root_relative_urls']) { add_filter('bloginfo_url', 'roots_root_relative_url'); add_filter('theme_root_uri', 'roots_root_relative_url'); add_filter('stylesheet_directory_uri', 'roots_root_relative_url'); add_filter('template_directory_uri', 'roots_root_relative_url'); - add_filter('script_loader_src', 'roots_fix_duplicate_subfolder_urls'); - add_filter('style_loader_src', 'roots_fix_duplicate_subfolder_urls'); + add_filter('script_loader_src', 'roots_fix_duplicate_subfolder_urls'); + add_filter('style_loader_src', 'roots_fix_duplicate_subfolder_urls'); add_filter('plugins_url', 'roots_root_relative_url'); add_filter('the_permalink', 'roots_root_relative_url'); add_filter('wp_list_pages', 'roots_root_relative_url'); diff --git a/inc/roots-options.php b/inc/roots-options.php index c18f825..1777ea2 100644 --- a/inc/roots-options.php +++ b/inc/roots-options.php @@ -150,6 +150,7 @@ function roots_get_default_theme_options() { 'main_class' => $default_framework_settings['classes']['main'], 'sidebar_class' => $default_framework_settings['classes']['sidebar'], 'google_analytics_id' => '', + 'root_relative_urls' => true, 'clean_menu' => true, 'fout_b_gone' => false ); @@ -218,7 +219,18 @@ function roots_theme_options_render_page() { - + + +