Skip to content

Add admin notice and safety checks - #38

Open
murshed wants to merge 3 commits into
WordPress:trunkfrom
murshed:trunk
Open

murshed wants to merge 3 commits into
WordPress:trunkfrom
murshed:trunk

Conversation

@murshed

@murshed murshed commented Aug 1, 2026

Copy link
Copy Markdown

Show an admin notice when the WordPress AI Client (AiClient) is missing — only for users with activate_plugins capability; uses localization and proper escaping (plugin.php). Add a function_exists check around _doing_it_wrong in GoogleImageGenerationModel to avoid fatal errors on installs lacking that helper. Also apply minor formatting / EOF newline fix in GoogleTextAndImageGenerationModel.php.

Modified files: plugin.php, src/Models/GoogleImageGenerationModel.php, src/Models/GoogleTextAndImageGenerationModel.php

Show an admin notice when the WordPress AI Client (AiClient) is missing — only for users with activate_plugins capability; uses localization and proper escaping (plugin.php). Add a function_exists check around _doing_it_wrong in GoogleImageGenerationModel to avoid fatal errors on installs lacking that helper. Also apply minor formatting / EOF newline fix in GoogleTextAndImageGenerationModel.php.

Modified files: plugin.php, src/Models/GoogleImageGenerationModel.php, src/Models/GoogleTextAndImageGenerationModel.php

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@murshed
murshed requested a review from a team August 1, 2026 03:20
@github-actions

github-actions Bot commented Aug 1, 2026 •

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: murshed <fahimmurshed@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: saarnilauri <laurisaarni@git.wordpress.org>

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

@jeffpaul jeffpaul added this to the 1.3.0 milestone Aug 17, 2026
@jeffpaul
jeffpaul requested a review from superdav42 August 17, 2026 17:58

@saarnilauri saarnilauri left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for contribution. Please simplify the code.

Comment thread plugin.php
return;
}

if (!function_exists('is_admin') || !is_admin()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The code is heavily over-defensive. Since this function is hooked to admin_notices, WordPress core is guaranteed to be fully loaded when it runs, so all the function_exists() checks for core functions (is_admin, current_user_can, __, esc_attr, esc_html) are unnecessary. The is_admin() check itself is also redundant, because admin_notices only fires on admin screens.

@jeffpaul

Copy link
Copy Markdown
Member

@murshed are you able to update the PR based on the feedback above?

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.

3 participants