fix: use add_action() for ACF options-page submitbox hook#104
Merged
herewithme merged 1 commit intoJun 15, 2026
Merged
Conversation
acf/options_page/submitbox_before_major_actions is fired by ACF Pro via do_action(), not apply_filters(). The callback submitbox_before_major_actions echoes output and does not return the $page argument — it is action-shaped, not filter-shaped. Using add_filter() for a do_action() hook works today because WordPress does not error on it, but it is semantically wrong and fragile: if ACF ever switches to apply_filters(), the page object will be lost. The correct registration is add_action().
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the ACF options page hook registration to use an action instead of a filter, aligning the hook type with how it is intended to be invoked.
Changes:
- Replaced
add_filterwithadd_actionfor theacf/options_page/submitbox_before_major_actionshook.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
herewithme
approved these changes
Jun 15, 2026
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.
What
acf/options_page/submitbox_before_major_actionsis fired by ACF Pro viado_action(), notapply_filters(). The hook registration inAdmin::init()usedadd_filter(), which is semantically incorrect for an action hook.Before:
After:
Why it matters
The
submitbox_before_major_actionscallback echoes output and does not return the$pageargument — it is action-shaped. WordPress does not error whenadd_filter()is used for ado_action()hook, so the current code works today. However, if ACF ever migrates this hook toapply_filters(), the page data will be silently lost because the callback returns nothing. Usingadd_action()makes the intent explicit and future-proof.The fix was confirmed by reading the ACF Pro source (
pro/admin/admin-options-page.php), which showsdo_action( 'acf/options_page/submitbox_before_major_actions', $page )at the call site.Development and testing assisted by AI. All code reviewed and verified manually.
Note
Low Risk
Single-line hook registration change with no logic or output changes; low risk aside from future-proofing hook type.
Overview
Registers the ACF options-page submitbox callback with
add_action()instead ofadd_filter()onacf/options_page/submitbox_before_major_actions, matching how ACF Pro fires the hook viado_action().Behavior is unchanged today; the callback still only echoes admin notice HTML and does not return
$page. The change makes the registration action-shaped and avoids silent breakage if ACF ever switches the hook to a filter.Reviewed by Cursor Bugbot for commit f2f3731. Bugbot is set up for automated code reviews on this repo. Configure here.