| 开发者 |
presswell
benplum |
|---|---|
| 更新时间 | 2026年11月4日 23:42 |
| PHP版本: | 8.2 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
pwatg_available_services — Modify the available AI providerspwatg_available_models — Modify the available models for a provider (receives the models and the provider slug; the first model is the default; providers added with pwatg_provider_registry have no models until you list them here)pwatg_provider_registry — Map provider slugs to custom service classes (each slug is listed in the settings, with its own API key field)pwatg_generate_on_upload — Return false to skip generating alt text for a new upload (receives the attachment ID)pwatg_debug_log_max_bytes — Size at which the debug log rotates (default 5 MB)pwatg_image_max_dimension — Long edge, in pixels, of the image copy sent to the provider (default 1024, minimum 256)pwatg_alt_text_language — Language the alt text is written in (defaults to the site language; return an empty string to leave it to the model)pwatg_include_filename_in_prompt — Return false to leave the image's filename out of the prompt (receives the attachment ID)pwatg_use_wp_ai_client — Return false to call the provider directly instead of through the WordPress AI Client in Core mode (receives the provider ID)pwatg_core_connector_service_map — Map WordPress AI Connector IDs to this plugin's provider slugspwatg_service_connector_candidates — Connector IDs checked for each provider's API keypwatg_debug_log_filename — Filename of the private debug logpwatg_status_rows — Rows of the Debug tab's status table (each an array with string label and value, and status of ok, warning, or an empty string; rows without a string label and value are dropped)pwatg_should_generate — Return false to skip an image on every path: uploads, the Media Library and Image block, bulk runs, WP-CLI, and pwatg_generate_alt_text() (receives the attachment ID and the context: upload, single, bulk, cli, or api)pwatg_prompt — The full prompt sent to the provider (receives the attachment ID, the provider slug, and the context; an empty or non-string value keeps the original)pwatg_alt_text — Generated alt text before it's saved (receives the attachment ID, the current alt text, and the context; returning an empty string fails the generation and saves nothing)pwatg_alt_text_generated — After generated alt text is saved (receives the attachment ID, the new alt text, the alt text it replaced, and the context)pwatg_generation_failed — When generation fails, not when it's skipped (receives the attachment ID, the WP_Error, and the context)pwatg_generate_alt_text( $attachment_id, $args = [] ) — Generate and save alt text for an image with the saved settings. Pass [ 'force' => true ] to replace existing alt text. Returns true when saved, false when skipped, or a WP_Error. It doesn't check the current user's capabilities.wp pwatg generate <attachment-id>wp pwatg bulk-generatewp pwatg count-missingwp pwatg network-bulk-generatewp pwatg generate <attachment-id> --forcewp pwatg bulk-generate --force — reports how many images would be overwritten; add --dry-run=false to generatewp pwatg bulk-generate --dry-runwp pwatg bulk-generate --limit=<int>wp pwatg bulk-generate --missing-onlywp pwatg network-bulk-generate --force — a dry run unless --dry-run=false is givenwp pwatg network-bulk-generate --limit=<int>wp pwatg network-bulk-generate --missing-onlywp pwatg network-bulk-generate --sites=<id,id,...>wp-content/plugins/.
Configuration
OpenAI (GPT-4.1 and GPT-4o, including the mini models), Anthropic Claude (Haiku 4.5, Sonnet 5, Opus 5.5), and Google Gemini (2.5 Flash, Flash-Lite, and Pro). In Core mode on WordPress 7.0+, the OpenAI, Anthropic, and Google connectors in Settings -> Connectors can be used; other connectors are offered only once the pwatg_core_connector_service_map filter maps them to one of the plugin's providers. The pwatg_available_models filter changes the model list, and the pwatg_provider_registry filter adds provider classes.
In Core mode (recommended), keys are managed by WordPress in Settings -> Connectors. In the deprecated Plugin mode, keys are stored in the site's options (the network's, when the plugin is network-activated on Multisite) and sent only to the selected provider, from your server. Saved keys are never printed in the settings page, and they are removed when the plugin is deleted. Plugin mode will be removed in a future release, so switch to WordPress AI Connectors when you can.
Yes. Use the inline "Regenerate Alt Text" link in the Media Library or media modal to update a single attachment without affecting the rest of the queue, or run wp pwatg generate <attachment-id> --force.
Yes. Use wp pwatg generate <attachment-id> for one image, wp pwatg bulk-generate for a batch run, and wp pwatg count-missing to check remaining backlog.
It depends on how the plugin is activated.
Yes. Use wp pwatg network-bulk-generate to process all sites in the network, or pass --sites=<id,id,...> to target specific site IDs.
Deleting the plugin (not deactivating it) always removes saved API keys, debug logs, rate-limit pauses, and bulk run state. With Remove Data on, it also removes the settings and generation history (when each image was last generated, and the alt text kept for Restore previous alt text). Alt text itself is never removed.
When a provider reports a rate limit, the plugin pauses requests to that provider for the time it asks for, between 1 and 30 minutes (5 minutes when it doesn't say). An out-of-credit or quota error pauses it for an hour. Bulk runs stop and say why, and the image that hit the limit is retried when you continue.