admin管理员组文章数量:1398773
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;
}
本文标签: translationTranslating form labels shortcode output
版权声明:本文标题:translation - Translating form labels shortcode output 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744669103a2618715.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论