How To Change Text in a WordPress Plugin?

If you want to change some of the predefined texts in the user interface in any properly coded WordPress plugin you must translate it.

Many users are confused and think plugin translation is useful only if you want to use the plugin in another language.


Translation is what you need to do even if you only want to change some words. It’s translation from English to English – there is no difference. So please check the link above, translation a plugin is not scary at all.

In case your WordPress installation is default, your plugin language files need to end in en_US.po and Not en_EN please, there is no such locale.

HostelPRO 1.5

Our WordPress plugin for hostels, small hotels and BnB owners – Hostel PRO – has been updated to version 1.5. Here are the changes and improvements from version 1.4 to version 1.5:

  • Manage addon services – bike rentals, extra bed price, cleaning, extra linen etc
  • Added optional description to addon services and option to deactivate them
  • Added “vertical_after” parameter to the rooms listing shortcode. It allows you to change the “availability dates” from horizontal (table cells) to vertical (one under the other) after the selected period exceeds the given number of days
  • Added option to reorder the custom fields in the automatically generated booking form
  • Added “minimum stay” option
  • Option to automatically delete the unconfirmed bookings
  • Added default content for the booking email messages (you can of course change it)
  • Optional payment instructions can be added. You can use this field to add HTML payment button code from payment system of your choice.
  • The date format of the date selectors now use the date format from your WordPress Settings page

[WatuPRO] How To Display Different Content Depending on Last / Not Last Quiz Attempt

WatuPRO has a setting to limit the number of quiz attempts by IP addres (or by username if your quiz requires user login). Sometimes you may want to display different message to the user depending on whether this is their last quiz attempt or not. For example you may want to conditionally display text like “Try again!” and “Sorry, you have no more attempts!”.

WatuPRO doesn’t yet have such configuration but it’s easy to build a custom filter using our barebone customization plugin.

If you are not interested in the code, read only the following section which also gives download link for the . The third section of this article will show and explain the code.

Customized Filter Download and Usage

In order to use the new filter you need to download and install this plugin:


How to use it? Simply include your conditional content between “tags”:

{last} This content will be shown only after the last user’s attempt on the quiz. {/last}

{notlast} This content will be shown only if the user has more attempts. {/notlast}

You can include these tags in the “Final page / quiz output” tab or in the grade descriptions in case you are showing grade descriptions in your quiz output.

Here’s an example:


You completed quiz %%QUIZ-NAME%%.

You got %%PERCENTAGE%%% correct answers.

{last}You have no more attempts.

Here are your answers: %%ANSWERS%%{/last}

{notlast}You can try again{/notlast}

Programming Code

If you are interested in the code, here’s how we did it. In the watuprocustom_init() function we added a filter for the “watupro_content” filer:

add_filter(‘watupro_content’, array(‘WatuPROCustomFilters’, ‘last_attempt’));

And below is the filter function. It works only by IP but it’s easy to change it to work with quizzes restricted by “user_id” as well.

class WatuPROCustomFilters {
	// replace contents of  &  pseudo-tags
	//   & 
	// currently used for %%ANSWERS%% variable
   static function last_attempt($content) {
   	global $wpdb;
		if(empty($_POST['watupro_current_taking_id'])) return $content;   
		// now get the contents between last-attempts and not-last-attempts tags
		// in case tags are not there return content
		if(!strstr($content, '{last}') and !strstr($content, '{notlast}')) return $content; 	
   	// select taking
		$taking = $wpdb->get_row($wpdb->prepare("SELECT exam_id, ip, user_id 
			FROM ".WATUPRO_TAKEN_EXAMS." WHERE ID=%d", $_POST['watupro_current_taking_id']));
		// select quiz allowed num takings	
		$quiz = $wpdb->get_row($wpdb->prepare("SELECT takings_by_ip FROM ".WATUPRO_EXAMS." 
			WHERE ID=%d", $taking->exam_id));
		$is_last_attempt = false;
		if($quiz->takings_by_ip) {
			// select num takings
			$num_takings = $wpdb->get_var($wpdb->prepare("SELECT COUNT(ID) FROM ".WATUPRO_TAKEN_EXAMS."
			WHERE exam_id=%d AND ip=%s", $taking->exam_id, $_SERVER['REMOTE_ADDR']));
			if($num_takings >= $quiz->takings_by_ip) $is_last_attempt = true;
		// now replace properly
		if($is_last_attempt) {
			// the content between  and  should be shown. The other should be removed
			$content = str_replace(array('{last}','{/last}'), '', $content);
			$content = preg_replace('#\{notlast\}(.+?)\{\/notlast\}#s', '', $content);
		else {
			echo 'werehere';
			$content = str_replace(array('{notlast}','{/notlast}'), '', $content);
			$content = preg_replace('#\{last\}(.+?)\{\/last\}#s', '', $content);
		return $content;		
   }	// end last_attempt filter