0

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!

0

If 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;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.