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 @@