It is always necessary to delete the xhstyles.css file manually, just when you work with new plugins or core styles and especially when you restore an older version.
Should there be a way to delete this file via the backend? If so - where?
Deleting the xhstyles.css file via the backend
Re: Deleting the xhstyles.css file via the backend
If the necessity to delete the file is a standard, deletion may be hardcoded in functions.php directly after any new plugin is installed/removed, core styles are manipulated, or an older version is restored(?).
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.
Re: Deleting the xhstyles.css file via the backend
I agree with Tata. Maybe replace XH_pluginStylesheet with the following:
This does no longer check for the file modification time, but rather calculates SHA1 hashes, and compares these. It is likely a bit slower than the old code, but I guess that is acceptable.
Code: Select all
function XH_pluginStylesheet()
{
global $pth;
$plugins = XH_plugins();
// create array of pluginname => hash of CSS file contents
$hashes = ['core' => sha1_file($pth['file']['corestyle'])];
foreach ($plugins as $plugin) {
$fn = $pth['folder']['plugins'] . $plugin . '/css/stylesheet.css';
if (is_file($fn)) {
$hashes[$plugin] = sha1_file($fn);
} else {
$hashes[$plugin] = '';
}
}
$ofn = $pth['folder']['corestyle'] . 'xhstyles.css';
$expired = !file_exists($ofn);
// check for newly (un)installed plugins and changes in the individual plugin stylesheets
if (!$expired) {
if (($ofp = fopen($ofn, 'r')) !== false
&& fgets($ofp) && fgets($ofp)
&& ($oldPlugins = fgets($ofp))
) {
$oldPlugins = explode(',', trim($oldPlugins, " *\r\n"));
$oldhashes = [];
foreach ($oldPlugins as $oldPlugin) {
list($plugin, $hash) = explode(':', $oldPlugin);
$oldhashes[$plugin] = $hash;
}
$expired = $hashes != $oldhashes;
} else {
$expired = true;
}
if ($ofp !== false) {
fclose($ofp);
}
}
// create combined plugin stylesheet
if ($expired) {
var_dump("expired");
$o = array(
PHP_EOL . '/' . str_pad(' ' . $pth['file']['corestyle'], 76, '*', STR_PAD_LEFT) . ' */'
. PHP_EOL . PHP_EOL . file_get_contents($pth['file']['corestyle'])
);
foreach ($plugins as $plugin) {
$fn = $pth['folder']['plugins'] . $plugin . '/css/stylesheet.css';
if (file_exists($fn)) {
$css = file_get_contents($fn);
if (substr($css, 0, 3) === "\xEF\xBB\xBF") {
$css = substr($css, 3);
}
$css = XH_adjustStylesheetURLs($plugin, $css);
$css = PHP_EOL
. '/' . str_pad(' ' . $fn, 76, '*', STR_PAD_LEFT) . ' */'
. PHP_EOL . PHP_EOL . $css;
$o[] = $css;
}
}
$pluginline = '';
foreach ($hashes as $plugin => $hash) {
if ($pluginline) {
$pluginline .= ',';
}
$pluginline .= "$plugin:$hash";
}
$o = '/*' . PHP_EOL
. ' * Automatically created by CMSimple_XH. DO NOT MODIFY!' . PHP_EOL
. ' * ' . $pluginline . PHP_EOL
. ' */' . PHP_EOL . PHP_EOL
. implode(PHP_EOL . PHP_EOL, $o);
if (!XH_writeFile($ofn, $o)) {
e('cntwriteto', 'stylesheet', $ofn);
}
}
return $ofn;
}
Christoph M. Becker – Plugins for CMSimple_XH
Re: Deleting the xhstyles.css file via the backend
It seems to me that this hash method is more effective than just comparing modification time.
Besides, it actually makes the work easier - you don't have to shimmy through folders all the time.
I would be in favor of adopting this in one of the next XH versions.
Re: Deleting the xhstyles.css file via the backend
Well then 1.7.5
Gruß Olaf, Plugins for CMSimple_XH
Ich habe schon lange den Verdacht, dass so viele so eifrig auf Gender, Trans und Queer machen:
Weil sie für das Fachliche ganz einfach zu doof sind.
Ich habe schon lange den Verdacht, dass so viele so eifrig auf Gender, Trans und Queer machen:
Weil sie für das Fachliche ganz einfach zu doof sind.