Allow plugins to include Less files (#6051)

pull/6043/head
Aleksander Machniak 7 years ago
parent 3ed6418d55
commit 1cf72fa2b6

@ -1716,8 +1716,13 @@ EOF;
) {
$css = '';
foreach ($this->css_files as $file) {
$css .= html::tag('link', array('rel' => 'stylesheet',
'type' => 'text/css', 'href' => $file, 'nl' => true));
$is_less = substr_compare($file, '.less', -5, 5, true) === 0;
$css .= html::tag('link', array(
'rel' => $is_less ? 'stylesheet/less' : 'stylesheet',
'type' => 'text/css',
'href' => $file,
'nl' => true,
));
}
$output = substr_replace($output, $css, $pos, 0);
}

@ -612,7 +612,17 @@ class rcube_plugin_api
if (is_object($this->output) && $this->output->type == 'html') {
if ($if_exists && $fn[0] != '/' && !preg_match('|^https?://|i', $fn)) {
$rcube = rcube::get_instance();
$path = unslashify($rcube->config->get('assets_dir') ?: RCUBE_INSTALL_PATH);
$devel_mode = $rcube->config->get('devel_mode');
$assets_dir = $rcube->config->get('assets_dir');
$path = unslashify($assets_dir ?: RCUBE_INSTALL_PATH);
// Prefer .less files in devel_mode (assume less.js is loaded)
if ($devel_mode) {
$less = preg_replace('/\.css$/i', '.less', $fn);
if ($less != $fn && is_file("$path/plugins/$less")) {
$fn = $less;
}
}
if (!is_file("$path/plugins/$fn")) {
return;

Loading…
Cancel
Save