From eb8ee8bf58325507f3c17eeb616fccb6f703b686 Mon Sep 17 00:00:00 2001 From: Wolfgang Reszel Date: Thu, 1 Mar 2012 14:42:05 +0100 Subject: [PATCH] Dev option to disable CacheBuster query strings for easier CSS styling --- template.php | 13 +++++++++++++ theme-settings.php | 12 ++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/template.php b/template.php index 7fc2408..c6f5377 100755 --- a/template.php +++ b/template.php @@ -179,6 +179,19 @@ function zentropy_preprocess_html(&$vars) { } /** + * Implements template_process_html(). + */ +function zentropy_process_html(&$variables) { + // Remove Query Strings from CSS filenames (CacheBuster) + global $user, $conf; + if (theme_get_setting('zentropy_cachebuster_css')) { + if (theme_get_setting('zentropy_cachebuster_css') == 'all' || (in_array("administrator",$user->roles) && @$conf['site_offline'] == 0 && !stristr($_GET['q'],'flush-cache'))) { + $variables['styles'] = preg_replace('/\.css\?.*"/','.css"', $variables['styles']); + } + } +} + +/** * Implements template_preprocess_page(). */ function zentropy_preprocess_page(&$vars) { diff --git a/theme-settings.php b/theme-settings.php index 642c313..2fb0e47 100755 --- a/theme-settings.php +++ b/theme-settings.php @@ -70,6 +70,18 @@ function zentropy_form_system_theme_settings_alter(&$form, &$form_state) { '#default_value' => theme_get_setting('zentropy_wireframe_mode'), ); + $form['zentropy_settings']['zentropy_dev']['zentropy_cachebuster_css'] = array( + '#type' => 'select', + '#title' => t('CachBuster CSS query strings'), + '#description' => t('During theme styling with CSSEdit’s or Espresso’s @override feature, it can be very useful to disable the CacheBuster CSS query strings. (style.css?XYZ)'), + '#default_value' => theme_get_setting('zentropy_cachebuster_css'), + '#options' => array( + '' => t('Don\'t remove query strings (Drupal default)'), + 'all' => t('Always remove query strings'), + 'onlyadmin' => t('Remove query strings for logged in admins only'), + ), + ); + /** * HTML5 settings. */ -- 1.7.8.3