Update all guides (NL + EN) for CodePress 2.5.2 features

- Admin guide: RBAC roles, role-based dashboard, plugin types (content/system)
- CodePress developer guide: plugin types, admin plugin API, SCSS compilation, asset serving
- Theme developer guide: SCSS sole CSS source, css_compiled read-only, guide layout
- Content manager guide: layout selection from theme.json, plugin order in frontmatter
- Both NL and EN updated with identical structure
- 35 files updated
This commit is contained in:
2026-08-12 12:05:53 +02:00
parent a9e3b023de
commit 9a5ab351ba
35 changed files with 1493 additions and 255 deletions
@@ -1,43 +1,144 @@
# Plugin Development
## Plugin types
CodePress kent twee soorten plugins, bepaald door het `type` veld in `plugin.json`:
- **Content plugins** (`type: "content"`) — Verschijnen in de sidebar en in de plugin selectie op content-edit pagina's. Bieden sidebar content via `getSidebarContent()`.
- **Systeem plugins** (`type: "system"`) — Worden geladen door PluginManager maar verschijnen NIET in de sidebar. Bieden functionaliteit via admin menu, routes en de CMSAPI.
Bij afwezigheid van een `type` veld wordt `content` aangenomen.
## Plugin structuur
```
plugins/MijnPlugin/
├── plugin.json # Plugin metadata
├── plugin.php # Plugin code
── config.json # Optionele configuratie
├── MijnPlugin.php # Plugin code (NIET plugin.php)
├── plugin.json # Metadata met type veld
── config.json # Optionele configuratie
└── assets/
├── scss/mijnplugin.scss # SCSS bron (optioneel)
└── css/mijnplugin.css # CSS (handmatig onderhouden)
```
Plugin bestanden heten `<PluginName>.php` (bijv. `Navigation.php`, `HTMLBlock.php`). `PluginManager` laadt `$pluginDir . '/' . $pluginName . '.php'`.
## plugin.json
```json
{
"name": "Mijn Plugin",
"version": "1.0.0",
"author": "Jouw Naam",
"description": "Beschrijving"
"name": "Mijn Plugin",
"version": "1.0.0",
"author": "Jouw Naam",
"description": "Beschrijving",
"type": "content"
}
```
## plugin.php voorbeeld
- `name` — Weergavenaam
- `type``"content"` of `"system"` (default: `content`)
## Content plugin voorbeeld
```php
<?php
/**
* Plugin: MijnPlugin
* Plugin: MijnPlugin (content)
*/
class MijnPlugin
{
public function getConfig(): array
{
return [
'title' => 'Mijn Plugin',
'type' => 'content',
];
}
echo '<div class="mijn-plugin">Hello World</div>';
public function getSidebarContent(): string
{
return '<p>Hello World</p>';
}
}
```
## Systeem plugin voorbeeld
```php
<?php
/**
* Plugin: MijnSysteem (system)
*/
class MijnSysteem
{
public function getConfig(): array
{
return [
'title' => 'Mijn Systeem',
'type' => 'system',
];
}
public function getAdminMenu(): array
{
return [
['label' => 'Mijn Systeem', 'route' => 'mijn-systeem', 'icon' => 'bi-gear'],
];
}
public function getAdminRoutes(): array
{
return ['mijn-systeem'];
}
public function handleAdminRoute(string $route): void
{
echo '<h1>Mijn Systeem pagina</h1>';
}
}
```
Systeem plugins worden via `PluginManager::getAdminMenuItems()` in de admin sidebar getoond en via `PluginManager::handleAdminRoute()` afgehandeld.
## CMSAPI gebruiken
```php
<?php
require_once '../../cms/core/class/PluginManager.php';
$api = PluginManager::getAPI();
$config = $api->getConfig();
$content = $api->getContent();
```
$page = $api->getPage($path);
```
`setAPI()` wordt automatisch aangeroepen door `PluginManager` als de plugin de methode heeft.
## Plugin CSS
- Plugin CSS in `assets/css/` is handmatig te onderhouden (SCSS compilatie voor plugins is nog niet automatisch)
- Plugin CSS wordt automatisch geladen ná theme CSS (in `base.twig`), zodat thema's plugin styling kunnen overschrijven
- Plugin assets worden geserveerd via `cms/router.php` op URL `/plugins/<Name>/assets/...`
- Implementeer `getCssUrl()` in de plugin klasse om de CSS URL terug te geven
```php
public function getCssUrl(): string
{
return '/plugins/MijnPlugin/assets/css/mijnplugin.css';
}
```
## Hooks en filters
PluginManager auto-registert deze methoden als hooks/filters:
- **Hooks**: `onPageLoad`, `onBeforeRender`, `onAfterRender`, `onSearch`, `onMenuBuild`
- **Filters**: `onContentFilter`, `onTitleFilter`, `onMenuFilter`
```php
public function onPageLoad($page) { /* ... */ }
public function onContentFilter($content) { return $content; }
```
## Essentiële plugins
Essentiële plugins zijn gedefinieerd in `getProtectedPlugins()` in `public/admin.php`. Huidige essentiële plugin: **Navigation**.
Deze plugins kunnen niet worden gedeactiveerd, bewerkt of verwijderd. Voeg altijd de `isProtectedPlugin()` check toe aan nieuwe plugin handlers.