Skip to content

Instantly share code, notes, and snippets.

@badsyntax
Last active July 11, 2018 13:09
Show Gist options
  • Select an option

  • Save badsyntax/8f2bc73b87dacb69299f to your computer and use it in GitHub Desktop.

Select an option

Save badsyntax/8f2bc73b87dacb69299f to your computer and use it in GitHub Desktop.
<?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'));
@badsyntax
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment