Skip to content

fix: use add_filter() for plugin_action_links hook#368

Open
thisismyurl wants to merge 1 commit into
rtCamp:developfrom
thisismyurl:fix/plugin-action-links-use-filter
Open

fix: use add_filter() for plugin_action_links hook#368
thisismyurl wants to merge 1 commit into
rtCamp:developfrom
thisismyurl:fix/plugin-action-links-use-filter

Conversation

@thisismyurl

Copy link
Copy Markdown

What

plugin_action_links_{$plugin} is a filter, not an action — callbacks
must return the modified $links array. The hook in Plugin::run() was
registered with add_action(), which silently discards the return value
of add_plugin_action_links(), so the Settings link was never injected
into the Plugins list table.

Before:

add_action( 'plugin_action_links_' . plugin_basename( $this->path ) . '/login-with-google.php', [ $this, 'add_plugin_action_links' ] );

After:

add_filter( 'plugin_action_links_' . plugin_basename( $this->path ) . '/login-with-google.php', [ $this, 'add_plugin_action_links' ] );

Why add_filter()?

add_action() passes null as the first argument to the callback and
ignores the return value. add_filter() passes the existing $links array
and uses the returned value to replace it — which is exactly what
add_plugin_action_links() relies on when calling array_merge().

Testing

  1. Install the plugin on a fresh WordPress site.
  2. Go to Plugins → Installed Plugins.
  3. Confirm a Settings link appears under "Login With Google."

Closes #331


Development and testing assisted by AI. All code reviewed and verified manually.

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
Copilot AI review requested due to automatic review settings June 9, 2026 13:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Adjusts WordPress hook registration to use the correct API for modifying plugin action links.

Changes:

  • Switches from add_action to add_filter for the plugin_action_links_{plugin} hook.

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

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.

2 participants