From 522cf8cb7af742064367703294757fe9f2877f3e Mon Sep 17 00:00:00 2001 From: elflo Date: Thu, 3 May 2012 17:25:40 +0200 Subject: [PATCH] This adds the option to enable or disable the relative urls functionality. I added a true/false switch to enable/disable the relative urls in roots_config.php. Relative urls are enabled by default. I moved the conditions that previously triggered the relative urls functionality to a new function enable_root_relative_urls() which returns a boolean true/false. I replaced the conditions i moved by a test for enable_root_relative_urls() true/false value. --- inc/roots-cleanup.php | 24 ++++++++++++++---------- inc/roots-config.php | 1 + 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/inc/roots-cleanup.php b/inc/roots-cleanup.php index 5b85cd7..1c240f0 100644 --- a/inc/roots-cleanup.php +++ b/inc/roots-cleanup.php @@ -65,7 +65,19 @@ function roots_fix_duplicate_subfolder_urls($input) { return $output; } -if (!is_admin() && !in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) { +// remove root relative URLs on any attachments in the feed +function roots_root_relative_attachment_urls() { + if (!is_feed()) { + add_filter('wp_get_attachment_url', 'roots_root_relative_url'); + add_filter('wp_get_attachment_link', 'roots_root_relative_url'); + } +} + +function enable_root_relative_urls() { + return !(is_admin() && in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) && ROOT_RELATIVE_URLS; +} + +if (enable_root_relative_urls()) { $tags = array( 'bloginfo_url', 'theme_root_uri', @@ -91,18 +103,10 @@ if (!is_admin() && !in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-regi add_filter('script_loader_src', 'roots_fix_duplicate_subfolder_urls'); add_filter('style_loader_src', 'roots_fix_duplicate_subfolder_urls'); -} -// remove root relative URLs on any attachments in the feed -function roots_root_relative_attachment_urls() { - if (!is_feed()) { - add_filter('wp_get_attachment_url', 'roots_root_relative_url'); - add_filter('wp_get_attachment_link', 'roots_root_relative_url'); - } + add_action('pre_get_posts', 'roots_root_relative_attachment_urls'); } -add_action('pre_get_posts', 'roots_root_relative_attachment_urls'); - // set lang="en" as default (rather than en-US) function roots_language_attributes() { $attributes = array(); diff --git a/inc/roots-config.php b/inc/roots-config.php index a21932b..8f797ea 100644 --- a/inc/roots-config.php +++ b/inc/roots-config.php @@ -1,5 +1,6 @@