Skip to content

Conversation

@felixarntz
Copy link
Member

@felixarntz felixarntz commented Nov 8, 2025

Fixes #9

Supersedes #12

  • Uses decorator pattern to wrap original PromptBuilder in Prompt_Builder, allowing to use "snake_case" method names instead of "camelCase" method names, as per WordPress Coding Standards.
  • As an alternative flavor, Prompt_Builder_With_WP_Error extends Prompt_Builder and catches any exceptions thrown in the original PromptBuilder, turning them into WP_Error return values from the terminate methods.
    • Only the terminate methods return WP_Error objects, to maintain the fluent interface. As soon as an exception is caught in a chain of method calls, all subsequent calls become no-ops, and only the terminate method will return the WP_Error.
  • A very basic AI_Client is included to streamline instantiation of the prompt builder classes. While it is somewhat equivalent to AiClient from the underlying PHP AI Client SDK, there is no need for parity at this point, as most methods on AiClient are for more advanced use-cases. We can consider separately which other things we would want to include in the WordPress version of the class.

Developers are free to choose either class, depending on their preferences. There are no differences in their feature set, the only difference is the exception vs WP_Error piece.

@felixarntz felixarntz added this to the 0.1.0 milestone Nov 8, 2025
@felixarntz felixarntz added the [Feature] New feature to highlight in changelogs. label Nov 8, 2025
@felixarntz felixarntz mentioned this pull request Nov 8, 2025
2 tasks
Copy link
Member

@JasonTheAdams JasonTheAdams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Tiny nit comments, so I'll go ahead and approve.

@felixarntz felixarntz merged commit 33fac29 into trunk Nov 10, 2025
1 check passed
@JasonTheAdams JasonTheAdams deleted the add/prompt-builder branch November 10, 2025 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] New feature to highlight in changelogs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prefer WP_Error handling over PHP exception handling for consistency with WordPress standards.

3 participants