Repository navigation
Add ActionHook and FilterHook helpers and prefix the view path filter - #23
Merged
Merged
Conversation
Add Framework\Wordpress\ActionHook and Framework\Wordpress\FilterHook, static
helpers that fire and register WordPress hooks with names that say what the
call does:
- ActionHook::fire() / ActionHook::add() pass through to do_action() / add_action()
- FilterHook::apply() / FilterHook::add() pass through to apply_filters() / add_filter()
The verbs differ on purpose: `apply` returns the filtered value, so a filter
call without an assignment looks wrong. Each method passes its arguments to
the core function unchanged and returns what it returns.
The framework's own hook calls in src/ now go through these helpers. The
callback must be callable when it is registered, and priority and
accepted-args must be integers, so a HookSubscriber returning a non-integer
from get_priority() or get_args_count() now throws a TypeError.
Breaking: the view path filter in TemplateEngine::resolve_path() is renamed
from `framework/view/path` to `{prefix}view_path` (for example
`kirki_view_path`). The old string was the same for every plugin that bundles
the framework, because php-scoper does not prefix string literals, so one
plugin's callback also changed another plugin's view paths.
Tests cover both helpers and the prefixed filter. Adds a __return_false stub
for the test suite. CHANGELOG (3.3.5), README and docs/routing-examples.md
are updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Framework\Wordpress\ActionHook and Framework\Wordpress\FilterHook, static helpers that fire and register WordPress hooks with names that say what the call does:
The verbs differ on purpose:
applyreturns the filtered value, so a filter call without an assignment looks wrong. Each method passes its arguments to the core function unchanged and returns what it returns.The framework's own hook calls in src/ now go through these helpers. The callback must be callable when it is registered, and priority and accepted-args must be integers, so a HookSubscriber returning a non-integer from get_priority() or get_args_count() now throws a TypeError.
Breaking: the view path filter in TemplateEngine::resolve_path() is renamed from
framework/view/pathto{prefix}view_path(for examplekirki_view_path). The old string was the same for every plugin that bundles the framework, because php-scoper does not prefix string literals, so one plugin's callback also changed another plugin's view paths.Tests cover both helpers and the prefixed filter. Adds a __return_false stub for the test suite. CHANGELOG (3.3.5), README and docs/routing-examples.md are updated.