Change your Simple:Press button text without editing the theme (using translations instead)

Do you or anyone you know suffer from color blindness? choosing the right Simple:Press button The person is unable to distinguish the differences between certain colors. So when there are two similar objects with different colors,they find it hard to select the desired object.

Now this is exactly the kind of problem I found certain users were having with a client’s Simple:Press forum. They were always getting confused on how to reply to a post.

They would see two buttons ‘Add a Topic’ and ‘Add a Reply’. And no matter how clear the help text was, 9 times out of 10 they would choose ‘Add a Topic’ when they really meant click on ‘Add a Reply.

Change Simple:Press Button text

It seemed like the forum users had a kind of color blindness to the buttons. So I decided to change the default button text, to make it more intuitive.

And yes there is a way to change the button text without touching the Simple:Press theme files.  First let’s see what most developers would do.

The usual solution

Most developers will usually create a Simple:Press Child theme and work from there. A really bad developer may actually change the core theme files (and yes I have seen this happen too often than not). I decided not to go down the create the child theme route — creating a child theme for this simple change would be overkill. Besides, by staying with the default theme I would benefit from any new enhancements or features that get published. Instead, for a small change like this I chose to leverage the translation files.

Simple:Press and translations

Translation is the ability for the content of the website to be translated into another language. This then makes it easy for a person to see the same website in another language.  I decided to leverage this translation ability to change the button text.

Now Simple:Press does provide translation files for a few languages. But it does not provide translation files for US English. This is not surprising since the default text hard-coded in the themes and in Simple:Press is already US English. So I created a custom translation file for US English.  This can be done in three steps.

Step 1: Find the text that needs to be replaced.

This can be done by simply searching through the code. I knew I was looking for occurrences of the phrase “Add Topic”.
So I searched for all occurrences of “Add Topic” in all .php files under ‘public_html/wp-content/’.

Remember that the Simple:Press core files are under ‘wp-content/plugins/simple-press’ but the Simple:Press themes and plugins are under a different directory – viz under ‘wp-content/sp-resources/’.

Hence to search through all Simple:Press files it is not sufficient to search only under ‘wp-content/plugins/simple-press’. If you are familiar with unix, here is the search command to use from the command line:

$ cd ~/public_html/wp-content/
$ grep -n --color -r --include="*.php" "Add Topic"

The search results included some files in the Simple:Press theme and some in Simple:Press core. After looking at each file I knew that the text that needed replacing was in the theme – not in the core files. Also, I confirmed that the theme was using the wordpress __() function to translate the text for the buttons. Without this function, this solution would not work.

Knowing whether the text is in the theme or a plugin or in Simple:Press core is important as it determines where the translation files have to be placed.

The translation files for Simple:Press themes have to be placed under ‘wp-content/sp-resources/forum-language/sp-themes/’.

Step 2: Create the translation file

Next, create a file called spDefault-en_US.po and add the following content:

Simple:Press change button text

Step 3: Convert the file

The .po file is a text version of the translation file. It needs to be converted to a binary format called Machine Object which has a .mo extension.

This conversion can be done using the unix gettext utility as follows:

$ msgcat spDefault-en_US.po | msgfmt -o spDefault-en_US.mo -

If you prefer, there is also an app called POEDIT that offers a GUI interface for creating translation files (https://poedit.net/).

Finally, place the resulting spDefault-en_US.mo file under ‘wp-content/sp-resources/forum-language/sp-themes/’.  And you are done.
New Simple:Press buttons with changed text
And there you have it a more intuitive button text. Now it’s clear to the forum users that if they have to reply to a post, they just hit the reply button. Just a simple change but it made things so much clearer.

In Conclusion

There are many ways to change the button text.  Instead of touching the Simple:Press files, we have done it using the translation files in three steps.

If you are still unsure on how to proceed or have any questions contact StressLessWeb. I will be happy to help you out.


Announcing new Products & Services from StressLessWeb

We recently started offering website maintenance services to our existing clients. If you are not an existing client and are interested in availing of this service, contact us to see how we can help you.

Do you use Simple:Press? We have a new e-book out to help your Simple:Press members get started.