Skip to content

try: check for wp_supports_ai in WP_AI_Client_Prompt_Builder::__call()#2

Closed
justlevine wants to merge 1 commit intofix/wp_supports_aifrom
try/this-error-in-call
Closed

try: check for wp_supports_ai in WP_AI_Client_Prompt_Builder::__call()#2
justlevine wants to merge 1 commit intofix/wp_supports_aifrom
try/this-error-in-call

Conversation

@justlevine
Copy link
Copy Markdown
Owner

Trac ticket:


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props justlevine.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

*/
public function __call( string $name, array $arguments ) {
// Check whether AI is supported before proceeding with any method call.
if ( null === $this->error && ! wp_supports_ai() ) {
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

The downside to this approach is that this check runs on every single successful call. We could mitigate it by adding a state property to the class, something which isn't necessary when the ::$error is set in the constructor.

@justlevine justlevine closed this Mar 12, 2026
@justlevine justlevine deleted the try/this-error-in-call branch March 12, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant