dev: rename hook prefixes in helpers.php#315
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
This PR standardizes the public hook/filter names used by includes/helpers.php from the legacy ai_experiments_* prefix to wpai_*, and introduces a compatibility layer so existing third-party code using the old hooks continues to work (with deprecation warnings).
Changes:
- Renames helper-related filters from
ai_experiments_*towpai_*inincludes/helpers.php. - Adds
includes/Deprecated.phpand initializes it during bootstrap to bridge legacy hooks viaapply_filters_deprecated(). - Updates integration tests and docs to reference the new
wpai_*hook names.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| includes/helpers.php | Switches helper apply_filters() calls to the new wpai_* hook names. |
| includes/bootstrap.php | Initializes the new deprecation/compatibility layer during plugin load. |
| includes/Deprecated.php | Adds hook-bridging logic so legacy ai_experiments_* filters still run (deprecated). |
| tests/Integration/Includes/HelpersTest.php | Updates helper tests to use wpai_* filters. |
| tests/Integration/Includes/Experiments/Title_Generation/Title_GenerationTest.php | Updates credentials-check mocking filter to wpai_*. |
| tests/Integration/Includes/Experiments/Summarization/SummarizationTest.php | Updates credentials-check mocking filter to wpai_*. |
| tests/Integration/Includes/Experiments/Review_Notes/Review_NotesTest.php | Updates credentials-check mocking filter to wpai_*. |
| tests/Integration/Includes/Experiments/Image_Generation/Image_GenerationTest.php | Updates credentials-check mocking filter to wpai_*. |
| tests/Integration/Includes/Experiments/Excerpt_Generation/Excerpt_GenerationTest.php | Updates credentials-check mocking filter to wpai_*. |
| tests/Integration/Includes/Experiments/Example_Experiment/Example_ExperimentTest.php | Updates credentials-check mocking filter to wpai_*. |
| tests/Integration/Includes/Experiments/Alt_Text_Generation/Alt_Text_GenerationTest.php | Updates credentials-check mocking filter to wpai_*. |
| tests/Integration/Includes/Experiments/Abilities_Explorer/Abilities_ExplorerTest.php | Updates credentials-check mocking filter to wpai_*. |
| tests/Integration/Includes/Experiment_RegistryTest.php | Updates credentials-check mocking filter to wpai_*. |
| tests/Integration/Includes/Experiment_LoaderTest.php | Updates credentials-check mocking filter to wpai_*. |
| tests/Integration/Includes/Abstracts/Abstract_AbilityTest.php | Updates credentials-check mocking filter to wpai_*. |
| docs/experiments/summarization.md | Updates examples to reference wpai_* normalization hooks. |
| docs/experiments/image-generation.md | Updates examples to reference wpai_preferred_image_models. |
| docs/experiments/excerpt-generation.md | Updates examples to reference wpai_* normalization hooks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #315 +/- ##
=============================================
- Coverage 58.72% 57.63% -1.10%
- Complexity 573 580 +7
=============================================
Files 37 38 +1
Lines 2951 3026 +75
=============================================
+ Hits 1733 1744 +11
- Misses 1218 1282 +64
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
PCP is warning about prefixes which should be fixed in #316 |
…_result filters - Rename all hook prefixes from ai_experiments_ to wpai_ per WordPress#315 decision - Replace @SInCE 0.5.0 with @SInCE x.x.x for release-time replacement - Remove ability_result and ability_result_{$name} filters (to be proposed for WP core per @gziolo's feedback) - Replace filtered_execute_callback with simple do_execute wrapper - Remove related tests and Test_Error_Ability class
What?
Migrates the functions in
helpers.phpto usewpai_*prefixed hooks. Old hooks are deprecated via a newWordPress\AI\DeprecatedclassSpecifically:
ai_experiments_pre_normalize_content->wpai_pre_normalize_contentai_experiments_normalize_content->wpai_normalize_contentai_experiments_preferred_models_for_text_generation->wpai_preferred_models_for_text_generationai_experiments_preferred_image_models->wpai_preferred_image_modelsai_experiments_preferred_vision_models->wpai_preferred_vision_modelsai_experiments_pre_has_valid_credentials_check->wpai_pre_has_valid_credentials_checkWhy?
Isolated from #309 , these renames won't cause conflicts with the namespace.
How?
A new
Deprecated.phpchecks for use of the old filters and if so adds anapply_filter_deprecated. This keeps the diff of the main files uninterrupted for when we're ready to remove.Use of AI Tools
Copilot Autocomplete.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast