Content MarketingMarketing Tools

String Locator: How To Locate Code In A WordPress Theme or Plugin

The theme Martech Zone is using is no longer supported and the developers have disappeared, so I’ve been managing development myself. It’s been quite a challenge but the theme was pretty well-developed so I’ve been able to make a ton of customizations as well as retire some of the features that I’d never be using.

Most recently, my host offered me the ability to upgrade PHP to version 8.1 from 7.4. Upgrading PHP is often an excellent means of improving site performance. However, with every upgrade typically comes some deprecated code. Many times, there are security holes that are shored up in these updates… and PHP 8.1 was no different.

How to Search For PHP in Your Theme Or Plugin

As soon as I staged and tested my site on PHP 8.1, the site had a fatal error and wouldn’t load. After checking the log files, I identified the issue… a deprecated function that was a vulnerability:

create_function()

Of course, the issue was how do I find where the function was actually used? I could download the theme and plugin files and search through them using some desktop tools. However, a much easier way was just to load the String Locator WordPress plugin. The plugin enables you to search for any string and it responds with the file and line of where it’s located.

I was able to identify every file where the deprecated function was located, quickly replaced it with updated code, and get my site live in a matter of minutes.

How to Search For A File Reference in Your Theme or Plugin

In another example, I noticed that a reference to a freely hosted stylesheet for Font Awesome was being loaded on my site and I wanted to remove it to increase the speed of my site. I searched for the string and the plugin returned the plugin, line, and position of the code:

Locate string in WordPress theme or plugin.

I was able to remove the plugin and start working on a new solution with similar features.

Search For A String In A Specific Theme Or Plugin

The theme offers the ability to limit your searches to a specific theme or plugin, making it extremely useful. In a situation like above where I had no clue where the code might be, I simply asked it to search everything in wp-content… and it did a perfect job! The plugin also supports using regular expressions (RegEx) for more complex searches.

This is an incredibly useful plugin for anyone looking to troubleshoot errors in their WordPress theme or plugin. I like it so much that I’ve added it to my best WordPress plugins article!

Appreciate this content?

Sign up for our weekly newsletter, which delivers our latest posts every Monday morning.

We don’t spam! Read our privacy policy for more info.

Douglas Karr

Douglas Karr is a fractional Chief Marketing Officer specializing in SaaS and AI companies, where he helps scale marketing operations, drive demand generation, and implement AI-powered strategies. He is the founder and publisher of Martech Zone, a leading publication in marketing technology, and a trusted advisor to startups and enterprises alike. With a track record spanning more than $5 billion in MarTech acquisitions and investments, Douglas has led go-to-market strategy, brand positioning, and digital transformation initiatives for companies ranging from early-stage startups to global tech leaders like Dell, GoDaddy, Salesforce, Oracle, and Adobe. A published author of Corporate Blogging for Dummies and contributor to The Better Business Book, Douglas is also a recognized speaker, curriculum developer, and Forbes contributor. A U.S. Navy veteran, he combines strategic leadership with hands-on execution to help organizations achieve measurable growth.

Related Articles

Back to top button
Close

Adblock Detected

We rely on ads and sponsorships to keep Martech Zone free. Please consider disabling your ad blocker—or support us with an affordable, ad-free annual membership ($10 US):

Sign Up For An Annual Membership