2022-12-28 23:31:24 +00:00
|
|
|
<?php
|
2022-12-31 13:28:34 +00:00
|
|
|
/**
|
|
|
|
* @brief moreCSS, a plugin for Dotclear 2
|
|
|
|
*
|
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
|
|
|
*
|
|
|
|
* @author Osku and contributors
|
|
|
|
*
|
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2023-03-24 23:19:15 +00:00
|
|
|
declare(strict_types=1);
|
2022-12-28 23:31:24 +00:00
|
|
|
|
2023-03-24 23:19:15 +00:00
|
|
|
namespace Dotclear\Plugin\moreCSS;
|
|
|
|
|
|
|
|
use dcCore;
|
|
|
|
use dcNsProcess;
|
|
|
|
use dcUtils;
|
2022-12-31 13:28:34 +00:00
|
|
|
|
2023-03-24 23:19:15 +00:00
|
|
|
class Frontend extends dcNsProcess
|
|
|
|
{
|
|
|
|
public static function init(): bool
|
|
|
|
{
|
|
|
|
static::$init = defined('DC_RC_PATH');
|
|
|
|
|
|
|
|
return static::$init;
|
2022-12-31 13:28:34 +00:00
|
|
|
}
|
2023-03-24 23:19:15 +00:00
|
|
|
|
|
|
|
public static function process(): bool
|
|
|
|
{
|
|
|
|
if (!static::$init || !dcCore::app()->blog->settings->get('themes')->get('morecss_active')) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
dcCore::app()->addBehavior('publicHeadContent', function (): void {
|
|
|
|
$css = (string) base64_decode((string) dcCore::app()->blog->settings->get('themes')->get('morecss_min'));
|
|
|
|
if (!empty($css)) {
|
|
|
|
echo dcUtils::cssLoad(
|
|
|
|
dcCore::app()->blog->url . dcCore::app()->url->getURLFor(My::id()),
|
|
|
|
'screen',
|
|
|
|
md5($css) //no cache on content change
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|