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 CMO of OpenINSIGHTS and the founder of the Martech Zone. Douglas has helped dozens of successful MarTech startups, has assisted in the due diligence of over $5 bil in Martech acquisitions and investments, and continues to assist companies in implementing and automating their sales and marketing strategies. Douglas is an internationally recognized digital transformation and MarTech expert and speaker. Douglas is also a published author of a Dummie's guide and a business leadership book.
Back to top button
Close

Adblock Detected

Martech Zone is able to provide you this content at no cost because we monetize our site through ad revenue, affiliate links, and sponsorships. We would appreciate if you would remove your ad blocker as you view our site.