Skip Navigation

WPML Version: 3.2.3-dev


WPML String Translation filters theme/plugin setting options in order to return translations of their values in the current language.
This means that on a WordPress installation with WPML languages set for example to English as primary and German as secondary language, you can expect the German translations to be the values retrieved when calling:get_option('{theme_name}_settings'); while the current language is German. Then while the current language is English, the English values will be displayed.

This also means however, that when an option value is updated with: update_option('{theme_name}_settings', $new_value); the option value will be updated in both languages. This may not be always desirable.

This is where the above filter is helpful. The filter allows retrieving an option value by-passing WPML String Translation filters. What is returned is the value in the language it is retrieved in so that further operations taken such as updating it the value in the database will not affect languages other than the one you are working with.

Retrieving Localized Content
apply_filters( 'wpml_unfiltered_admin_string', mixed $default_value, string $option_name )
(mixed) (Required) The value to return in case the string does not exist
(string) (Optional) The name of the option to retrieve. A non SQL-escaped name is expected.
hook example usage:

For the example that follows below, imagine you are viewing a language other than the default.
The option value you are retrieving is saved as a serialized array. You want to update a single key-value pair in the array and save it to the database. You expect that only the current language will be affected.


// retrieve option value is current language
$a = apply_filters( 'wpml_unfiltered_admin_string', get_option( 'my_option_name' ), 'my_option_name' );

// some operations ...

//update the value for the current language only
update_option('my_option_name', $a);