Custom Pattern Text Generation#11
Merged
Merged
Conversation
After the AI selects patterns, an optional second AI call rewrites all visible text (headings, paragraphs, button labels) inside each pattern's block markup to match the prompt topic. Block comment markup, HTML tags, attributes, and CSS classes are left untouched. The page is stored with the rewritten block content instead of wp:pattern references. - Pattern_Lab::get_pattern_content() fetches raw block markup by slug - Pattern_Lab::create_page_from_content() inserts a page from block strings - AI_Integration::rewrite_pattern_texts() batches all patterns in one AI call - AI_Integration::generate_page() accepts $personalize_text (default true) - Admin form adds an opt-out checkbox with speed trade-off noted in the hint - Result notice shows personalization status; _waygate_personalized post meta stored
…ntent Extract duplicated model preference list into get_model_preferences() so both AI calls share a single source of truth. Apply wp_kses_post() to each block content string in create_page_from_content() before insertion to strip disallowed HTML from AI responses.
…t, and rewrite_pattern_texts Add get_registered() to the WP_Block_Patterns_Registry stub and a wp_kses_post() stub in the test bootstrap. Cover the three methods that had no tests: get_pattern_content (missing slug, present content, absent field), create_page_from_content (empty input, valid input, status fallback, script tag stripping), and rewrite_pattern_texts (empty slugs, no content, unregistered slugs, AI unavailable).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request delivers version 0.9.0 of the Waygate plugin, introducing AI-powered themed text personalization for generated pages alongside a security fix that sanitizes AI-rewritten post content before database insertion. The central new capability allows the AI integration layer to rewrite pattern text to match a user-supplied theme or tone, making generated pages more contextually coherent rather than relying solely on static pattern copy. A companion refactor extracts model preference configuration into a dedicated structure within
class-ai-integration.php, improving maintainability of the provider fallback chain. The release is accompanied by comprehensive unit test coverage for three previously untested methods and updated documentation across CHANGELOG, README, ROADMAP, and a new code review document.Feature: Themed Text Personalization
class-ai-integration.phpgains arewrite_pattern_texts()method that sends pattern content to the AI with a user-defined theme prompt, returning rewritten copy before the page is assembled.class-pattern-lab.phpandclass-admin.phpare updated to pass theme context through the page creation pipeline, connecting the admin form input to the AI rewriting step.Security and Code Quality
wp_kses_post()before being passed towp_insert_post(), preventing potential XSS from untrusted model output.Test Coverage
AiIntegrationTest.phpandPatternLabTest.phpcoveringget_pattern_content(),create_page_from_content(), andrewrite_pattern_texts(), including bootstrap updates to support the new test cases.docs/CODE-REVIEW-text-personalization.mddocuments the design decisions and security considerations reviewed during development of the personalization feature.Documentation and Tooling
.vibe/config.tomlupdated to permitcdin the command allowlist, aligning the development environment configuration with current workflow requirements.Files Changed:
.vibe/config.toml(Modified)CHANGELOG.md(Modified)README.md(Modified)docs/ROADMAP.md(Modified)includes/class-admin.php(Modified)includes/class-ai-integration.php(Modified)includes/class-pattern-lab.php(Modified)tests/Unit/AiIntegrationTest.php(Modified)tests/Unit/PatternLabTest.php(Modified)tests/bootstrap.php(Modified)waygate.php(Modified)docs/CODE-REVIEW-text-personalization.md(Added)