Plugin CSS isn't cached into its own subdir

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670
Plugin CSS isn't cached into its own subdir
« on June 11th, 2013, 08:01 AM »
Tagging @Nao


Code: [Select]
@@ -430,7 +430,7 @@
  <link rel="stylesheet" href="' . $final_script . '">';
 }
 
-function add_plugin_css_file($plugin_name, $original_files = array(), $add_link = false)
+function add_plugin_css_file($plugin_name, $original_files = array(), $add_link = false, $ignore_files = array())
 {
  global $context, $settings, $theme, $boardurl, $pluginsdir, $board_info;
 
@@ -483,8 +483,11 @@
  $can_gzip = !empty($settings['enableCompressedData']) && function_exists('gzencode') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
  $ext = $can_gzip ? (we::is('safari') ? '.cgz' : '.css.gz') : '.css';
 
+ // Build the target folder from our skin's folder names and main file name. We don't need to show 'common-index-sections-extra-custom' in the main filename, though!
+ $target_folder = trim(implode('-', array_filter(array_diff($original_files, (array) 'common', $ignore_files))), '-');
+
  // Cache final file and retrieve its name.
- $final_script = $boardurl . '/css/' . wedge_cache_css_files('', $id, $latest_date, $files, $can_gzip, $ext, array('$plugindir' => $context['plugins_url'][$plugin_name]));
+ $final_script = $boardurl . '/css/' . wedge_cache_css_files($target_folder . ($target_folder ? '/' : ''), $id, $latest_date, $files, $can_gzip, $ext, array('$plugindir' => $context['plugins_url'][$plugin_name]));
 
  if ($final_script == $boardurl . '/css/')
  return false;
A confident man keeps quiet.whereas a frightened man keeps talking, hiding his fear.

Nao

  • Dadman with a boy
  • Posts: 16,080

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Plugin CSS isn't cached into its own subdir
« Reply #3, on June 14th, 2013, 11:53 PM »
Okay, it's on my local install, for now. ;)

I'm surprised the code isn't more broken actually, ah ah...
Maybe in the plugin JS equivalent, though....!

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Plugin CSS isn't cached into its own subdir
« Reply #4, on June 14th, 2013, 11:57 PM »
Most of the reason for that is that the plugin CSS and JS files never got kept in step with the various improvements to the mainline functions, but I never knew what was best for backporting to the plugins to be honest.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Plugin CSS isn't cached into its own subdir
« Reply #5, on June 15th, 2013, 12:07 AM »
Plus, the JS version underwent a really HEAVY rewrite recently, and I deliberately left the plugin version out, because I didn't deem it to be as important, considering it's unlikely many people would use @if / suffixes in their CSS for now, eh. I like risky situations, I guess..?!