Plugin SDK

Writing a plugin

A Pressline plugin is a folder dropped into /plugins/. Two files matter: a plugin.json manifest and an entry script (default plugin.php).

Minimal plugin

/plugins/hello-world/plugin.json:

{
  "id": "hello-world",
  "name": "Hello World",
  "version": "1.0.0",
  "author": "You",
  "description": "Logs every article save.",
  "min_pressline": "2.0",
  "entry": "plugin.php"
}

/plugins/hello-world/plugin.php:

<?php
PL_Plugin::register('hello-world')
    ->onArticleSave(function ($article, $id, $action) {
        error_log("Article #$id saved: " . ($article['name'] ?? '?'));
    })
    ->addAdminMenuItem('Hello', './plugins/hello-world/page.php', 'ic:round-waving-hand', 2)
    ->addDashboardCard(function () {
        echo '<section class="dashboard-block"><h2>Hello!</h2></section>';
    });

Open Rozšíření in the admin, click Aktivovat, done.

Folder layout

/plugins/<plugin-id>/
  plugin.json     # manifest (required)
  plugin.php      # entry point (or whatever 'entry' says)
  readme.md       # optional
  assets/         # optional CSS / JS
  migrations/     # optional *.sql, run on activation
  templates/      # optional

plugin.json reference

FieldRequiredNotes
idyesUnique slug, used as the folder name
namenoDisplay name
versionnoSemver
authorno
descriptionno
homepageno
min_presslinenoMinimum core version
permissionsnoReserved for future scoped grants
hooksnoDeclarative hook list (informational)
entrynoEntry script, defaults to plugin.php