Last active
July 11, 2018 13:09
-
-
Save badsyntax/8f2bc73b87dacb69299f to your computer and use it in GitHub Desktop.
Studeo theme (themezilla) Polylang translated theme options. See: http://wordpress.org/support/topic/code-share-studeo-theme-themezilla-theme-options-translated?replies=1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /*-----------------------------------------------------------------------------------*/ | |
| /* Register theme options with polylang for language translations | |
| /*-----------------------------------------------------------------------------------*/ | |
| array_map(function($option) { | |
| if (!in_array($option['type'], array('textarea','text'))) { | |
| return; | |
| } | |
| $val = get_option($option['id']) ?: $option['std']; | |
| $multiline = ($option['type'] === 'textarea'); | |
| pll_register_string( | |
| $option['name'], | |
| '[Language Translation] '.$option['name'], | |
| 'Theme Options', | |
| $multiline | |
| ); | |
| add_filter('option_'.$option['id'] , function($str) use ($option) { | |
| return pll__('[Language Translation] '.$option['name']); | |
| }); | |
| }, get_option('tz_template')); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's important to note, after adding this, the theme options strings will be reset and you'll need to re-add them in the language settings, but this approach is MUCH more reliable, as it means you can't reset the strings again by changing them in theme options.