I tried to change text using the below code
function ctxtlearn_gettext( $ctxttranslation, $ctxttext ) {
$ctxttrans = array_values(changeTxt_setting('trans',true));
$ctxtdirty = false;
$ctxtstrings_map = array();
$ctxttext_words = explode( ' ', $ctxttext );
foreach($ctxttrans as $ctxtmytrans) {
$ctxtstrings_map[$ctxtmytrans['key']] = $ctxtmytrans['val'];
}
foreach ( $ctxttext_words as $ctxtk => $ctxtword ) {
$ctxtw = trim( $ctxtword, '.,:!?-_()' );
if ( isset( $ctxtstrings_map[ $ctxtw ] ) ) {
$ctxttext_words[ $ctxtk ] = str_replace( $ctxtw, $ctxtstrings_map[ $ctxtw ], $ctxtword );
$ctxtdirty = true;
}
}
if ( $ctxtdirty ) {
return implode( ' ', $ctxttext_words );
}
return $ctxttranslation;
}
add_filter( 'gettext', 'ctxtlearn_gettext', 10, 2 );
If i give the below input it works
Post => My Book
Page => My Vertical
Comments => My Feedback
The Word before => is old string and after that is new string. if i pass it as an array it work's. but if i provide the below input
First Name => My Name
Username => User ID
The username text changes but First Name Not Changing in profile page. But if i split and provide its getting changed.
Who i can do this by providing Whole String..?