I'm using MyMail plugin to manage my newsletter.
I'm also using WPML to manage translations, there is no compatibility between the two plugins.
The subscription form, is placed in the footer area, through a MyMail shortcode and the wordpress text widget.
I want to translate the field labels, to the active language: So I was thinking on writing a filter for the "widget_text", search the "label name" and preg_replace() its output... But I don't find the way to achieve it.
Looking in the php class that manage the form, I could see that the function that outputs the form, stores the final code as:
return apply_filters('mymail_form', $html, $formid, $form);
So I guess that I need "search and replace" in the $html variable.
Any ideas? Many thanks!
I'm using MyMail plugin to manage my newsletter.
I'm also using WPML to manage translations, there is no compatibility between the two plugins.
The subscription form, is placed in the footer area, through a MyMail shortcode and the wordpress text widget.
I want to translate the field labels, to the active language: So I was thinking on writing a filter for the "widget_text", search the "label name" and preg_replace() its output... But I don't find the way to achieve it.
Looking in the php class that manage the form, I could see that the function that outputs the form, stores the final code as:
return apply_filters('mymail_form', $html, $formid, $form);
So I guess that I need "search and replace" in the $html variable.
Any ideas? Many thanks!
Share Improve this question asked Dec 1, 2013 at 15:39 CapiedgeCapiedge 7881 gold badge7 silver badges17 bronze badges1 Answer
Reset to default 0If anyone is looking for a solution, here is a way (probably not the better one) to achieve it:
add_filter('widget_text', 'filtering_form_labels');
function filtering_form_labels($html) {
if ( ICL_LANGUAGE_CODE=='en' ) {/*ICL_LANGUAGE_CODE used in WPML to know the active language*/
$esp = array('Nombre', 'Apellidos', 'Suscribirse'); /*Array with words to be replaced*/
$eng = array('First Name', 'Last Name', 'Subscribe'); /*Array with new words*/
ob_start();
$html = str_replace($esp, $eng, $html);
ob_end_clean();
}
return $html;
}