Overview
WPZylos Views provides a PHP template engine with optional Twig adapter, DaisyUI CSS prefix isolation, and Vue.js/React mount point helpers.
Key Features
- PHP Templates - Simple output buffering with safe extraction
- Dot Notation -
admin.settings->admin/settings.php - Twig Adapter - Optional Twig with autoescape enabled
- Shared Data - Share data across all views
- CssHelper - DaisyUI CSS prefix isolation (
cls(),prefix(),adminRootId()) - JsMount - Vue.js/React mount point renderer (
adminMount(),frontendMount(),shortcodeMount()) - Vue.js 3 - Options API support (default framework)
- React 19 - Opt-in support via config toggle
- DaisyUI v5 + Tailwind v4 - Per-plugin prefixed component and utility classes
Quick Start
use WPZylos\Framework\Views\ViewFactory;
$views = new ViewFactory($context);
$html = $views->render('admin.settings', ['title' => 'Settings']);
Template Files
// resources/views/admin/settings.php
<h1><?= esc_html($title) ?></h1>
<form method="post">
<?= wp_kses_post($content) ?>
</form>
API Reference
| Method | Parameters | Returns | Description |
|---|---|---|---|
render | string $view, array $data = [] | string | Render template |
make | string $view, array $data = [] | View | Create View object |
share | string|array $key, mixed $value | static | Share globally |
exists | string $view | bool | Template exists |
addEngine | EngineInterface $engine | static | Register engine |
getBasePath | (none) | string | Get base views path |
CssHelper Quick Example
$css = $app->make(CssHelper::class);
echo $css->cls('btn', 'btn-primary'); // 'fcds-btn fcds-btn-primary'
echo $css->prefix(); // 'fcds-'
echo $css->adminRootId(); // 'fcds-admin'
JsMount Quick Example
$mount = $app->make(JsMount::class);
// Admin page with Vue/React mount point
echo $mount->adminMount('my-app', [
'nonce' => wp_create_nonce('save'),
'settings' => get_option('my_settings', []),
]);
// Frontend widget mount
echo $mount->frontendMount('widget', ['items' => $items]);
// Shortcode mount
echo $mount->shortcodeMount('form', ['id' => $post_id]);
See Usage Guide and API Reference for full documentation.