Finding hooks in WordPress plugins with Atom editor

I mentioned in my post, “Safely adding code to WordPress” that you can add code to WordPress plugins, themes and even the core, without altering core functionality. That’s done using action and filter hooks, as explained in that post.

Sometimes it’s not easy to find those hooks. So here’s a guide on how to find them quickly using the free and cross-platform Atom editor.

THE details

To search for hooks in a plugin, download the plugin .zip file that you’d like to search through. I mentioned MarketPress in the walkthrough video, you can use any plugin though.

MarketPress download

Extract the plugin’s .zip file on your hard drive, then go into the extracted folder and open one of the files in Atom.

Then press Ctrl Shift F to open the Find/Replace panel.

Atom find/replace

Enter “do_action” if you’d like to find action hooks, or “apply_filters” if you’d like to find filter hooks. Then press ENTER to commence the search. You’ll see a new panel full of search results.

Atom search results

Simply click any of the items in the search results panel and Atom will open the file and take you to the respective line of code.

Simplifying the search

The Minimap package (I often call them plugins) for Atom makes searches much easier. Just install it through the built-in installer in Atom. Press CTRL , to open the settings panel, then click on Install. Type ‘minimap‘ in the search bar and click the Install button for the respective packages.

Install minimap package in Atom

By installing all the minimap packages, you should be able to select a portion of code and see all occurrences of that selected code highlighted in the minimap.Atom Minimap Highlight

Please feel free to ask if you have any questions about all this.


Finding hooks in WordPress plugins with Atom editor

2 thoughts on “Finding hooks in WordPress plugins with Atom editor

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s