innhold/custom/plugins/global/scheduled-publisher.php
Ruben b609c8596c Add standalone /publiser admin application
Implement a minimal, dependency-free publishing tool to manage news
and articles. The app includes:

- A Markdown-based block editor with rich-text capabilities.
- Image upload and resizing using GD.
- Support for drafts, scheduled publishing, and a trash system.
- Integrated Basic Auth protection via PHP and .htpasswd.
- A global plugin for automatic execution of scheduled posts.

The tool reuses core site logic in custom/plugins/publiser-lib.php to
ensure consistency between the editor and the live site.
2026-08-30 21:54:17 +02:00

24 lines
741 B
PHP

<?php
/**
* Scheduled Publisher Plugin
*
* Publishes due scheduled posts created via /publiser. Runs on every page
* request (piggybacking on normal site traffic) instead of relying on a
* cron job - there's nothing to configure on the host, and with regular
* traffic a scheduled post goes live within moments of its scheduled time.
*
* Usage: add to custom/config.ini:
* [plugins]
* enabled = "languages, scheduled-publisher"
*/
require_once __DIR__ . '/../publiser-lib.php';
Hooks::add(Hook::CONTEXT_READY, function (Context $ctx, array $config) {
try {
publiserPublishDueScheduledItems();
} catch (Throwable $e) {
error_log('scheduled-publisher: ' . $e->getMessage());
}
return $ctx;
});