fix: use add_filter() for plugin_action_links hook#368
Open
thisismyurl wants to merge 1 commit into
Open
Conversation
plugin_action_links_{$plugin} is a filter, not an action — callbacks
must return the modified \$links array. Registering it with add_action()
silently discards the return value, so the Settings link is never shown.
Fixes rtCamp#331
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adjusts WordPress hook registration to use the correct API for modifying plugin action links.
Changes:
- Switches from
add_actiontoadd_filterfor theplugin_action_links_{plugin}hook.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
plugin_action_links_{$plugin}is a filter, not an action — callbacksmust return the modified
$linksarray. The hook inPlugin::run()wasregistered with
add_action(), which silently discards the return valueof
add_plugin_action_links(), so the Settings link was never injectedinto the Plugins list table.
Before:
After:
Why
add_filter()?add_action()passesnullas the first argument to the callback andignores the return value.
add_filter()passes the existing$linksarrayand uses the returned value to replace it — which is exactly what
add_plugin_action_links()relies on when callingarray_merge().Testing
Closes #331
Development and testing assisted by AI. All code reviewed and verified manually.