Safe way to change text in layout
Hello, forum!
I want to share a way as to change the text in the site layout - without changing ClassiPress files.
This will avoid unnecessary work when you will upgrading ClassiPress!
For example i want to replace text on button "Post an Ad" to "Post Your Property"
and also change button text "Manage Ads" to "Dashboard"
Ok, it's just examples!
Let's see how to do it:
PHP Code:
function ohh_my_change_text( $text ){
switch ( $text ) {
case 'Post an Ad' : // what we have
$text = 'Post Your Property'; // what we want
break;
case 'Manage Ads' :
$text = 'Dashboard';
break;
// this can be continued within reasonable limits
/*case 'Email' :
$text = 'Email Address';
break;*/
}
return $text;
}
add_filter( 'gettext', 'ohh_my_change_text', 10 );
Insert this into the file
functions.php of your active theme or child theme.
NOTICE: It will work only if original text wrapped into functions __(),_e(), _x(), etc.
for example it will work with _e( 'Post an Ad', APP_TD ); - what we already changed.
Agree, that it is much easier than looking for the text in the code and edit it manually after each update. Yes?
Link to the documentation where i found it
http://codex.wordpress.org/Plugin_AP...erence/gettext
Any questions?
Use and enjoy!
Good Luck!