Skip to content

tommcfarlin/tm-callback-info

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Callback Info

Stable tag: 1.0.0
Requires at least: 6.5
Tested up to: 6.5.2
Requires PHP: 7.4
License: GPLv3 or later
Contributors: tommcfarlin
Tags: developer, debug, tools

Renders contextual information about every function registered with all WordPress hooks.

Description

This plugin renders contextual information about every function registered with all WordPress hooks.

Specifically, Callback Info looks at each hook used in the current WordPress instance including the active themes and plugins and renders:

  • the name of the hook,
  • the type of method (object, static, standard function, or anonymous),
  • the file in which it's registered,
  • the line on which the function starts,
  • the line on which the function ends.

Callback Info was originally developed as a plugin to demonstrate certain concepts outlined in a series of blog posts. As the plugin became more advanced, I found it's functionality useful in my day-to-day work so decided to release it for others to use, too.

This should only be used in development environments.

Pull Requests, Feedback, Questions, Bug Reports, and Feature Requests are welcome to be posted on the GitHub Issues page.

Installation

Install the Plugin From Within WordPress

  1. Visit the Plugins page from your WordPress dashboard and click "Add New" at the top of the page.
  2. Search for "callback-info" using the search bar on the right side.
  3. Click "Install Now" to install the plugin.
  4. After it's installed, click "Activate" to activate the plugin on your site.
  5. Navigate to any page on the front-end - any non-admin page - of your site.
  6. Once installed, add ?show-callback-info=true to your query string to render contextual information.

Install the Plugin Manually

  1. Download the plugin from WordPress.org or get the latest release from the Github Releases page.
  2. Unzip the downloaded archive.
  3. Upload the entire tm-callback-info folder to your /wp-content/plugins directory.
  4. Visit the Plugins page from your WordPress dashboard and look for the newly installed plugin.
  5. Click "Activate" to activate the plugin on your site.
  6. Navigate to any page on the front-end - any non-admin page - of your site.
  7. Once installed, add ?show-callback-info=true to your query string to render contextual information.

Usage Instructions

Running the Plugin

Once the plugin is activated, navigate to a page on the front-end of your site (that is, do not try to run this plugin within the administration area of your WordPress installation).

Assuming that your domain is https://plugin.test, append the query string ?show-callback-info=true to your URL such that the address is https://plugin.test?show-callback-info=true.

This will render all of the hooks along with each function that fires during that hook. Further, you'll see which file in which the function belongs as well as the starting line number and ending line number for the callback.

Include an Example Anonymous Function

Since not all plugins nor themes use anonymous functions, it's not possible to see how this plugin will detect anonymous functions and provide feedback.

To see how this works, you can also append a second query string to your URL: ?use-sample-anonymous-function=true. The full URL should look like this: https://plugin.test?show-callback-info=true&use-sample-anonymous-function=true

This will render a sample element at the bottom of the page (which you can view in the screenshot below) and you can see the anonymous function and its relevant information under the wp_enqueue_scripts hook.

Note: This plugin is not designed to run in a production environment.

Screenshots

1. All functions attached to each hook and contextual information for each function.

The wp_enqueue_script hook with related actions

Changelog

See the CHANGELOG.

About

Renders contextual information about every function registered with all WordPress hooks.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages