Skip to content

dev: rename hook prefixes in helpers.php#315

Merged
dkotter merged 4 commits intodevelopfrom
dev/hooks-helpers
Mar 18, 2026
Merged

dev: rename hook prefixes in helpers.php#315
dkotter merged 4 commits intodevelopfrom
dev/hooks-helpers

Conversation

@justlevine
Copy link
Contributor

@justlevine justlevine commented Mar 17, 2026

What?

Migrates the functions in helpers.php to use wpai_* prefixed hooks. Old hooks are deprecated via a new WordPress\AI\Deprecated class

Specifically:

  • ai_experiments_pre_normalize_content -> wpai_pre_normalize_content
  • ai_experiments_normalize_content -> wpai_normalize_content
  • ai_experiments_preferred_models_for_text_generation -> wpai_preferred_models_for_text_generation
  • ai_experiments_preferred_image_models -> wpai_preferred_image_models
  • ai_experiments_preferred_vision_models -> wpai_preferred_vision_models
  • ai_experiments_pre_has_valid_credentials_check -> wpai_pre_has_valid_credentials_check

Why?

Isolated from #309 , these renames won't cause conflicts with the namespace.

How?

A new Deprecated.php checks for use of the old filters and if so adds an apply_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

Before After
Open WordPress Playground Preview

@justlevine justlevine requested a review from Copilot March 17, 2026 23:02
@justlevine justlevine self-assigned this Mar 17, 2026
@github-actions
Copy link

github-actions bot commented Mar 17, 2026

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: justlevine <[email protected]>
Co-authored-by: dkotter <[email protected]>
Co-authored-by: jeffpaul <[email protected]>

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_* to wpai_* in includes/helpers.php.
  • Adds includes/Deprecated.php and initializes it during bootstrap to bridge legacy hooks via apply_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
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 19.75309% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.63%. Comparing base (6f5db2a) to head (5fd13a7).
⚠️ Report is 5 commits behind head on develop.

Files with missing lines Patch % Lines
includes/Deprecated.php 14.86% 63 Missing ⚠️
includes/bootstrap.php 0.00% 1 Missing ⚠️
includes/helpers.php 83.33% 1 Missing ⚠️
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     
Flag Coverage Δ
unit 57.63% <19.75%> (-1.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@justlevine
Copy link
Contributor Author

PCP is warning about prefixes which should be fixed in #316

@justlevine justlevine requested a review from dkotter March 18, 2026 19:21
@dkotter dkotter merged commit c9c439d into develop Mar 18, 2026
15 of 18 checks passed
@dkotter dkotter deleted the dev/hooks-helpers branch March 18, 2026 19:47
Ryujiyasu added a commit to Ryujiyasu/ai that referenced this pull request Mar 24, 2026
…_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
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.

Rename plugin from “AI Experiments” to “AI” and define feature vs experiment classification

4 participants