Skip to content

fix: use add_action() for ACF options-page submitbox hook#104

Merged
herewithme merged 1 commit into
BeAPI:masterfrom
thisismyurl:fix/use-add-action-for-acf-hook
Jun 15, 2026
Merged

fix: use add_action() for ACF options-page submitbox hook#104
herewithme merged 1 commit into
BeAPI:masterfrom
thisismyurl:fix/use-add-action-for-acf-hook

Conversation

@thisismyurl

@thisismyurl thisismyurl commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

What

acf/options_page/submitbox_before_major_actions is fired by ACF Pro via do_action(), not apply_filters(). The hook registration in Admin::init() used add_filter(), which is semantically incorrect for an action hook.

Before:

add_filter( 'acf/options_page/submitbox_before_major_actions', [ $this, 'submitbox_before_major_actions' ], 10 );

After:

add_action( 'acf/options_page/submitbox_before_major_actions', [ $this, 'submitbox_before_major_actions' ], 10 );

Why it matters

The submitbox_before_major_actions callback echoes output and does not return the $page argument — it is action-shaped. WordPress does not error when add_filter() is used for a do_action() hook, so the current code works today. However, if ACF ever migrates this hook to apply_filters(), the page data will be silently lost because the callback returns nothing. Using add_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 shows do_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 of add_filter() on acf/options_page/submitbox_before_major_actions, matching how ACF Pro fires the hook via do_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.

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().
Copilot AI review requested due to automatic review settings June 9, 2026 14:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_filter with add_action for the acf/options_page/submitbox_before_major_actions hook.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread classes/admin.php
@herewithme herewithme self-assigned this Jun 15, 2026
@herewithme herewithme self-requested a review June 15, 2026 11:20
@herewithme herewithme merged commit 3cd08ca into BeAPI:master Jun 15, 2026
2 of 11 checks passed
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.

3 participants