WPML support of user Input fields on settings page
-
Hi Marco,
I am trying to make the user input fields of the tabs on the Tabify settings page translatable with WPML, so that I can register the Input text as translation strings. I wonder if you can help to understand this whole process, since I fail to register the fields.
So f.e. i have a CPT “Product” with a tab like “Produkt Description” and I want to translate it to the German “Produktbeschreibung”.
WPML offers the posibility to register and output translations from plugin input fields. Here is the link to the WPML site: Translating user input texts from plugins and themes
.Here it says by using following code, I can register those texts from the input fields.
do_action( 'wpml_register_single_string', string $context, string $name, string $value )
F.e. for a custom widget it would look like that:
function update($new_instance, $old_instance){ $instance = $old_instance; $instance['custom_input'] = strip_tags($new_instance['custom_input']); //WMPL /** * register strings for translation */ do_action( 'wpml_register_single_string', 'Widgets', 'Custom Widget - input field', $instance['custom_input'] ); //WMPL return $instance; }
I tried to register my first tab like that, but it did not work:
function update($new_instance, $old_instance){ $instance = $old_instance; $instance['tabify[posttypes][product][tabs][0][title]'] = strip_tags($new_instance['tabify[posttypes][product][tabs][0][title]']); //WMPL /** * register strings for translation */ do_action( 'wpml_register_single_string', 'Tabify edit screen', 'Tab 1', $instance['tabify[posttypes][product][tabs][0][title]'] ); //WMPL return $instance;}
In this WPML document it says I have to apply filters to make a things happen. I wonder what that means in the context of your plugin. And if that is the reason for why I do not get the input field registered.
Any help would be much appriciated. Thank you in advance.
Jan-Philipp
- The topic ‘WPML support of user Input fields on settings page’ is closed to new replies.