Skip to content

Name the plugin or theme behind deprecated hook listeners in the System Report #2022

Open

Description

@gravitypdf-bot

Problem

When third-party code listens to a removed Gravity PDF hook, the System Report and Site Health only give a count, such as gfpdf_settings_tools has 1 listener. The admin notice says "A plugin or custom code on this site...". A site owner has no way to tell which plugin or theme to update, or what to tell their developer.

Proposal

Name the source of each listener on the System Report and Site Health screens, for example:

gfpdf_settings_tools has 1 listener (My Add-on)

Deprecation::get_hooks_with_listeners() already walks each listener on the hook. For each callback, use reflection to find the file that defines it (ReflectionFunction / ReflectionMethod, covering function names, Class::method strings, [ object_or_class, method ] arrays, closures and invokable objects), then map that path to a name:

  • Under WP_PLUGIN_DIR: the plugin's name from its header.
  • Under WPMU_PLUGIN_DIR: the must-use plugin's file name.
  • Under a theme root: the theme's name.
  • Anything else: keep the existing "custom code" wording.

This applies to every hook-only feature (see #2009), so it covers tools_tab_hooks and the v3 deprecated_filters entries together.

Limits

  • WordPress doesn't record who called add_filter(), so this finds where the callback is defined, not where it was registered. The two are nearly always the same.
  • A callback defined in WordPress itself, like __return_empty_array, can't be traced and falls back to "custom code".
  • Code in a shared library names the plugin that holds the library file.

Scope

  • Include System Status and Site Health, where detection already runs.
  • Leave the admin notice generic. It shows on every admin page and reads a stored list of feature IDs rather than detecting, so naming the source there means storing names that can go stale until detection next runs.
  • The signal is currently hook name mapped to listener count, so its shape, or a companion lookup alongside it, needs to change. Consumers of Deprecation::get_signals() should be checked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions