innhold/custom/plugins/global/scheduled-publisher.php

25 lines
741 B
PHP
Raw Normal View History

<?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;
});