Skip to content
webmanufakturPublic

About

ProcessWire module: keeps pages with an embargo_date unpublished until that date and releases them automatically — save guard, LazyCron release, edit-form hint

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Embargo

Publishing embargoes for ProcessWire: a page with a future embargo_date stays unpublished — and releases itself automatically once the date has arrived.

Embargo adds a single date field, embargo_date. Attach it to any template whose pages should go live on a planned date (articles, recipes, campaign pages …). Editors pick a date; the page is unpublished until that day and appears on its own — no external cron, no manual republishing.

The module creates the field on install but attaches it to no template: you stay in control of where embargoes exist.

Features

  • Save guard: any save of a page whose template has the field and whose date is in the future switches the page to unpublished. The save succeeds; nothing is blocked with an exception. Field-only saves ($pages->saveField()) are corrected right after the field is written.
  • Automatic release: a LazyCron job publishes pages with embargo_date <= today (00:00 local time). The page save triggers the regular ProCache, IndexNow and sitemap hooks.
  • Guard rails: hidden pages stay hidden, trash and drafts are ignored, at most 100 pages per cron run within a ~20 s budget — the rest is deferred to the next run.
  • Edit-form hint: below the date field the editor sees whether the embargo is active (and until when) or already expired.
  • Bypass for migrations and imports: $embargo->setBypass(true) skips all guard checks for the current request.
  • Status panel: the module config shows whether the field exists, which templates use it, when the cron last ran and the last log lines.
  • Optional ProCache clear after a release (normally not needed — the page save already triggers the regular hooks).
  • No dependencies beyond the ProcessWire core (LazyCron). All strings are translatable.

Requirements

  • ProcessWire >= 3.0.260
  • LazyCron (core module, must be installed)

Installation

  1. Copy the module to site/modules/Embargo/ (or clone this repository into it).
  2. Modules → Refresh, install Embargo. It creates the date field embargo_date.
  3. Attach embargo_date to the templates that should support embargoes. The module does not attach it anywhere.

If you manage templates with RockMigrations, add embargo_date to site/RockMigrations/templates/<template>.php as well — otherwise the next RockMigrations run can drop the field from the template.

Behaviour

  • The field is a date-only FieldtypeDatetime input; the page is released at 00:00 local time ($config->timezone) on that date.
  • Guard: whenever a page whose template has the field is saved with a date after today, the page is switched to unpublished. The save succeeds; nothing is blocked with an exception.
    • Also applies to field-only saves ($pages->saveField()): the status is corrected right after the field is written.
    • Pages already unpublished, trashed/deleted pages and ProDrafts drafts are left alone.
    • A page that is already live gets taken offline when a future date is saved.
    • Both the normal save and the field-only save are logged to site/assets/logs/embargo.txt.
  • Release: a LazyCron job releases pages with embargo_date <= today that are unpublished and not hidden. The page save triggers the regular ProCache/IndexNow/sitemap hooks.
    • Hidden pages are not released (deliberate). Pages in the trash are ignored.
    • At most 100 pages per run and a ~20 s budget; the rest is handled by the next run.
  • Page edit hint: below the date field the editor shows whether the embargo is active (and when it ends) or already expired.

Settings

Setting Default Description
Enabled on Master switch for guard and cron.
Cron interval everyHour Any LazyCron interval (everyMinute … every4Weeks).
Clear ProCache completely off Emergency exit; normally the normal page-save hooks are enough.

The settings screen also shows whether the field exists, which templates use it, and the last log lines.

Manual run / CLI

LazyCron only runs on web requests. To release due pages immediately:

php index.php embargo run

This bypasses the interval timestamp and is safe to run repeatedly.

Bypass for imports and migrations

$embargo = $modules->get('Embargo');
$embargo->setBypass(true);  // skip guard for the current request
$embargo->setBypass(false); // restore

Autoload modules also run in CLI requests (e.g. migration or import scripts), so use the bypass whenever such a script must publish pages with a future embargo date.

Uninstall

Uninstalling keeps the field and its data. Remove the field manually if you no longer need it. Template assignments are not touched either.

Notes

  • No multilingual support: the field is language-independent.
  • No frontend code: unpublished pages drop out of all selectors and listings automatically.
  • ProcessWire has no FieldtypeDate; the field is a FieldtypeDatetime with an empty time input.

License

MIT, see LICENSE.

About

ProcessWire module: keeps pages with an embargo_date unpublished until that date and releases them automatically — save guard, LazyCron release, edit-form hint

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages