From 0839b9c838570a9daae63d5daa584cffe5259705 Mon Sep 17 00:00:00 2001 From: Jasper Frumau Date: Mon, 25 May 2026 14:58:16 +0700 Subject: [PATCH 1/3] feat: add client-side ability waygate/insert-pattern for block editor Registers a waygate-editor ability category and the waygate/insert-pattern ability via @wordpress/abilities. The ability inserts a core/pattern block at the current cursor position in the block editor, accepting a slug param. Admin::enqueue_editor_abilities() hooks into enqueue_block_editor_assets to load @wordpress/core-abilities (pulls server abilities into the editor store) and the waygate-editor-abilities ES module; skips gracefully on WP < 6.5. --- assets/js/abilities.js | 32 ++++++++++++++++++++++++++++++++ includes/class-admin.php | 21 +++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 assets/js/abilities.js diff --git a/assets/js/abilities.js b/assets/js/abilities.js new file mode 100644 index 0000000..ba92fb9 --- /dev/null +++ b/assets/js/abilities.js @@ -0,0 +1,32 @@ +import { registerAbility, registerAbilityCategory } from '@wordpress/abilities'; + +registerAbilityCategory( 'waygate-editor', { + label: 'Waygate Editor', + description: 'Pattern insertion and management in the block editor', +} ); + +registerAbility( { + name: 'waygate/insert-pattern', + label: 'Insert Pattern', + description: 'Insert a block pattern at the current cursor position in the editor', + category: 'waygate-editor', + input_schema: { + type: 'object', + properties: { + slug: { type: 'string', description: 'Pattern slug to insert, e.g. "elayne/hero-centered"' }, + }, + required: [ 'slug' ], + }, + output_schema: { + type: 'object', + properties: { + success: { type: 'boolean' }, + }, + required: [ 'success' ], + }, + callback: async ( { slug } ) => { + const block = wp.blocks.createBlock( 'core/pattern', { slug } ); + await wp.data.dispatch( 'core/block-editor' ).insertBlock( block ); + return { success: true }; + }, +} ); diff --git a/includes/class-admin.php b/includes/class-admin.php index 6a830ce..f2d1288 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -20,6 +20,27 @@ class Admin { public static function init(): void { add_action( 'admin_menu', array( self::class, 'register_menu' ) ); add_action( 'add_meta_boxes', array( self::class, 'register_meta_box' ) ); + add_action( 'enqueue_block_editor_assets', array( self::class, 'enqueue_editor_abilities' ) ); + } + + /** + * Enqueues the Waygate client-side abilities script module for the block editor. + */ + public static function enqueue_editor_abilities(): void { + if ( ! function_exists( 'wp_enqueue_script_module' ) ) { + return; + } + + wp_enqueue_script_module( '@wordpress/core-abilities' ); + + wp_register_script_module( + 'waygate-editor-abilities', + WAYGATE_PLUGIN_URL . 'assets/js/abilities.js', + array( '@wordpress/abilities' ), + WAYGATE_VERSION + ); + + wp_enqueue_script_module( 'waygate-editor-abilities' ); } /** From 83b1fd9ce447d775bee0e23a0182cf17196d5230 Mon Sep 17 00:00:00 2001 From: Jasper Frumau Date: Mon, 25 May 2026 14:58:21 +0700 Subject: [PATCH 2/3] chore: bump version to 0.8.0 --- waygate.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/waygate.php b/waygate.php index 11c0f22..db79cb6 100644 --- a/waygate.php +++ b/waygate.php @@ -3,7 +3,7 @@ * Plugin Name: Waygate * Plugin URI: https://github.com/imagewize/waygate * Description: AI-powered pattern page builder for the Elayne block theme. Lists registered patterns, creates pages from pattern slugs, and integrates with WordPress AI Client for natural-language page generation. - * Version: 0.7.0 + * Version: 0.8.0 * Author: Jasper Frumau * Author URI: https://imagewize.com * License: GPL-2.0-or-later @@ -18,7 +18,7 @@ defined( 'ABSPATH' ) || exit; -define( 'WAYGATE_VERSION', '0.7.0' ); +define( 'WAYGATE_VERSION', '0.8.0' ); define( 'WAYGATE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'WAYGATE_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); From 1cd20fe1b6b617f011634338d504fc7c612c138a Mon Sep 17 00:00:00 2001 From: Jasper Frumau Date: Mon, 25 May 2026 14:58:27 +0700 Subject: [PATCH 3/3] docs: update README and CHANGELOG for v0.8.0 --- CHANGELOG.md | 7 +++++++ README.md | 17 ++++++++++------- docs/ROADMAP.md | 7 ++++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a2dda2..e3800f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to Waygate will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.8.0] - 2026-05-25 + +### Added +- Client-side ability `waygate/insert-pattern` registered via `@wordpress/abilities`: inserts a `core/pattern` block at the current cursor position in the block editor, accepting a `slug` parameter +- Ability category `waygate-editor` groups all Waygate block editor abilities +- `Admin::enqueue_editor_abilities()` enqueues `@wordpress/core-abilities` (auto-loads server abilities into the editor store) and the `waygate-editor-abilities` ES module on `enqueue_block_editor_assets`; gracefully skips when `wp_enqueue_script_module()` is unavailable + ## [0.7.0] - 2026-05-25 ### Added diff --git a/README.md b/README.md index 0e33f49..a42b1ca 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Waygate lets you assemble WordPress pages from block patterns — manually or via a natural-language AI prompt powered by the WordPress AI Client (WordPress 7.0+). Works with any block theme; [Elayne](https://github.com/imagewize/elayne) is the primary supported theme. -> **Beta** — v0.7.0. Use on staging/development sites; not yet recommended for production. +> **Beta** — v0.8.0. Use on staging/development sites; not yet recommended for production. --- @@ -16,7 +16,7 @@ Waygate lets you assemble WordPress pages from block patterns — manually or vi - **Developer debug info** — When `WP_ENV=development`, the page editor sidebar and the generation notice also show the ordered pattern slugs and generation timestamp - **Prompt templates** — Six built-in page templates (Homepage, About, Services, Contact, Landing Page, Portfolio) pre-fill the AI prompt; extend via the `waygate_prompt_templates` filter - **Feature detection** — AI form is hidden automatically when no provider supports text generation -- **Abilities API** — Exposes `elayne/list-patterns` and `elayne/create-page` abilities for WP 7.0+ +- **Abilities API** — Exposes `elayne/list-patterns` and `elayne/create-page` server abilities plus a `waygate/insert-pattern` client-side ability for the block editor (WP 7.0+) - **REST API** — `GET /wp-json/waygate/v1/patterns` and `POST /wp-json/waygate/v1/pages` for headless and external tool integration - **Multi-provider** — Works with Mistral, Claude, OpenAI, or Gemini via WP AI Client - **Any block theme** — Default prefix is `elayne/`; extend via the `waygate_pattern_prefixes` filter @@ -95,12 +95,15 @@ Waygate registers this provider manually since the library distribution excludes ## Abilities API (WordPress 7.0+) -When WordPress 7.0's Abilities API is available, Waygate registers two abilities: +When WordPress 7.0's Abilities API is available, Waygate registers three abilities: -| Ability | Description | -|---|---| -| `elayne/list-patterns` | Returns patterns, optionally filtered by category | -| `elayne/create-page` | Creates a draft page from an ordered list of pattern slugs | +| Ability | Type | Description | +|---|---|---| +| `elayne/list-patterns` | Server | Returns patterns, optionally filtered by category | +| `elayne/create-page` | Server | Creates a draft page from an ordered list of pattern slugs | +| `waygate/insert-pattern` | Client (editor) | Inserts a pattern block at the current cursor position in the block editor | + +The client-side ability is registered via `@wordpress/abilities` and is available whenever the block editor is open. Pass a `slug` parameter (e.g. `"elayne/hero-centered"`) to insert any registered pattern. --- diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 7626fe8..d0468b9 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -220,7 +220,7 @@ class RestApi { **Benefit**: Headless WordPress support, external tool integration. -#### 7. Add Client-Side Abilities for Editor Integration +#### 7. Add Client-Side Abilities for Editor Integration ✅ **New file**: `assets/js/abilities.js` ```javascript @@ -457,8 +457,8 @@ public static function track_pattern_usage( string $pattern_slug ): void { 1. ~~Feature detection, ability annotations, generic prefixes — *Phase 1*~~ ✅ Done 2. ~~Prompt templates — *Phase 2* (1–2 days)~~ ✅ Done 3. ~~REST API endpoints — *Phase 2* (2–3 days)~~ ✅ Done -4. Client-side abilities for editor integration — *Phase 2* (2–3 days) ← **Start here** -5. Image generation for previews — *Phase 2* (2–3 days) +4. ~~Client-side abilities for editor integration — *Phase 2* (2–3 days)~~ ✅ Done +5. Image generation for previews — *Phase 2* (2–3 days) ← **Start here** 6. Batch page creation — *Phase 2* (1–2 days) 7. Cost tracking, pattern popularity — *Phase 3* (2–3 days) 8. Advanced features based on user feedback — *Phase 3, speculative* @@ -586,3 +586,4 @@ const abilities = getAbilities(); | 2026-05-22 | Initial draft | Created roadmap document | | 2026-05-24 | Jasper Frumau | Marked Phase 1 complete; Phase 2 is next | | 2026-05-25 | Jasper Frumau | Marked Prompt Templates (#8) complete; REST API is next | +| 2026-05-25 | Jasper Frumau | Marked Client-side abilities (#7) complete; Image generation is next |