hasProvider(NvidiaProvider::class)) { return; } $registry->registerProvider(NvidiaProvider::class); } add_action('init', __NAMESPACE__ . '\\register_provider', 5); /** * AJAX action name used to dismiss the missing-client notice. * * @since 1.0.0 */ const DISMISS_NOTICE_ACTION = 'dbaipfn_dismiss_notice'; /** * User meta key storing the per-user dismissal of the missing-client notice. * * @since 1.0.0 */ const DISMISS_NOTICE_META = 'dbaipfn_notice_dismissed'; /** * Shows an admin notice when the PHP AI Client is not available. * * The provider can only register when the AI Client is present (bundled with * WordPress 7.0 or the WordPress AI plugin). Without it the plugin degrades * gracefully; this notice tells administrators why nothing is happening. * * The notice is scoped to the Dashboard and Plugins screens and is dismissible * per user, so it never behaves as a site-wide, persistent nag. * * @since 1.0.0 * * @return void */ function maybe_show_missing_client_notice(): void { if (class_exists(AiClient::class)) { return; } if (!current_user_can('manage_options')) { return; } // Only show on the Dashboard and Plugins screens, not on every admin page. $screen = function_exists('get_current_screen') ? get_current_screen() : null; if (!$screen || !in_array($screen->id, ['dashboard', 'plugins'], true)) { return; } // Respect a previous per-user dismissal. if (get_user_meta(get_current_user_id(), DISMISS_NOTICE_META, true)) { return; } printf( // phpcs:ignore Generic.Files.LineLength.TooLong -- Static notice markup. '
%s