Lee Willis

How to change text in a WordPress plugin

| 21 Comments

One of the great things about using an out-of-the-box solution like WordPress is that you can get something up and running pretty quickly. That’s been one of WordPress’ strengths over the years. However, if you’re building sites for other people then sometimes parts of the generic-ness seep through and detract from the overall feel of the solution. Specifically – terminology that is great in a generic solution isn’t always helpful in a custom, or specific solution.

None of this is a criticism of WordPress, but as you start building larger, or more complex sites you’ll probably want to start smoothing off some of these rough edges, and make sure the language of the site (frontend or admin side) makes sense in the specific context of the site you’re working on.

That’s something I come across frequently in my day job as a Drupal developer. Fortunately Drupal has the excellent String Overrides module. This lets you specify the current string, and a replacement, and will change the text whenever that string is used, with the caveat that the original string has to be passed through Drupal’s translation function t().

When someone recently asked me how to change some text in one of my own WordPress plugins – my first suggestion was this exact same approach. After all, all of my Premium plugins use translatable strings, and suggesting to someone that they should create a translation file just to change one or two strings for their needs has always seemed a bit excessive. So – I had a hunt around the WordPress.org repo for something similar, but couldn’t really find anything that did the job.

Figuring it’d be something fairly simple to achieve I set out to knock up a plugin that did the job. So next time you need to quickly change a string in WordPress, or a plugin you’re using – don’t hack it in the plugin – or in WordPress core, leaving your client unable to upgrade, give “Say What?” a go:

The strings we want to change

The strings we want to change

The say what page - setting up our string replacements

The say what page – setting up our string replacements

The text - automatically replaced for us

The text – automatically replaced for us

 

Say what?
by Ademti Software

An easy-to-use plugin that allows you to change translatable strings from plugins / themes and WordPress core without editing code. Simply enter the current string, and what you want to replace it with and the plugin will automatically do the rest!

The plugin’s available for forking and contribution over on GitHub

Check out Say What Pro for:

  • String Discovery and autocomplete – find the strings you need without diving through code. Works with server-side and Javascript-rendered strings
  • Improved performance using text-domain-specific filters
  • Wildcard string replacements – replace individual words, or fragments across your whole site
  • Multi-lingual support – set different replacements for different languages on multi-lingual sites
  • Import/export features – Easy import/export of replacements through the user interface

Support this free plugin

As a business, we already donate a percentage of our profits from premium plugins to global climate change projects. You’re free to use this plugin free of charge, but if you do, please consider buying the world some trees in return. You’ll be creating employment for local families and restoring wildlife habitats.

Stats:

  • Current version: 2.2.2
  • Rating: 86(90 ratings)
  • Downloaded 548,299 times

21 Comments

Leave a Reply

Required fields are marked *.