How to Search Through a WordPress Plugin’s Files with Sublime Text
This Quick Guide walks you through searching through all the files in a WordPress plugin using the Sublime Text code editor. This process works not only for searching through WordPress plugin folders, but for searching the contents of any folder using Sublime Text.
Why You’d Need to Search Through a WordPress Plugin Folder’s Entire Contents
A plugin may have many thousands of lines of code across dozens of PHP files, organized however made sense to the plugin developers at the time. As a result, one of the hardest things about debugging or extending WordPress plugins is often simply finding where a piece of code lives.
If you think a particular plugin function’s causing problems, for example, you might want to find not only where that function is defined, but every place that function is called. The only good way to do this is to search the entire plugin folder using a text editor like Sublime Text.
All of this is true for WordPress themes, as well—or any folder with too many files to search through one-by-one. Fortunately, like any good text editor, Sublime Text makes it easy to search through a folder’s contents. This video Quick Guide shows you how.
Here’s a text summary:
How to Search a WordPress Plugin’s Contents with Sublime Text
- Get the plugin’s contents onto your local computer with FTP or by another method.
- In Sublime Text, go to “File > Open Folder&hellip” navigate to the plugin folder, and open it.
- In the new Sublime Text window that opens up, right-click on the folder and choose “Find in Folder…”
- Enter your search term to get all instances of that text in the plugin.
Gotta Catch ‘Em All: Tips for Writing Airtight Text Searches
There’s also the topic of writing good searches, so that you find what you’re looking for everywhere in the folder you’re looking through. Two pieces of advice:
- Write the smallest search you can, so that you don’t miss things by being overspecific. Don’t search for
<em>, because you’ll miss
<em style="color: red;">. Instead, search for
<em. Every tag is going to have those letters.
- Don’t assume that things are written the same way everywhere. Don’t search for
my_function('pizza')if you can avoid it, because
my_function( 'pizza' )is also valid PHP. Can you get away with just searching for
my_function(and then look for the instances that pass in “pizza” directly?
Although this guide is for Sublime Text, the process should be almost identical for any decent text editor. Give it a try!
And if you’re serious about the coding side of WordPress and want to learn hands-on plugin development, check out Up and Running, our comprehensive guide to WordPress’s core PHP systems:
The Best Way to Learn WordPress DevelopmentUp and Running is our complete “learn WordPress development” course. Now in its updated and expanded Third Edition, it’s helped hundreds of happy buyers learn WordPress development the fast, smart, and thorough way.
“Other courses I’ve tried nearly always lack clear explanations for why WordPress does things a certain way, or how things work together.
Up and Running does all of this, and everything is explained clearly and in easy-to-understand language.”
–Caroline, WordPress freelancer