Hi - we have a multilingual site with pages localised via Polylang. The one piece of text we're unable to localise is the footer text specified under Salient options > Footer > Copyright Section Text.
What is the recommended way to localise this text, without resorting to editing original Salient files, or duplicating the whole of footer.php (which is large so would be a maintenance headache during future upgrades)?
Polylang allows localised text to be accessed via the following PHP call, which is how we're localising other boilerplate elements:
<?= pll__('My text to localise') ?>
Could we perhaps filter Salient's footer option value via a WP filter -- "pre_option_footer-copyright-text" maybe, skim reading WP's built in get_option() if that's what is used to read Salient's options?
We managed to solve this - the code below intercepts retrieving the footer text and localises it. :
// replace footer text with localised version via Polylang custom string pll_register_string('Footer text', 'Footer text', 'My custom strings'); add_filter( 'option_salient_redux', function($val) { // don't modify if this is an admin page (e.g., options edit page), or if $val isn't valid if(strpos($_SERVER['REQUEST_URI'], '/wp-admin/')===FALSE) if(is_array($val) && array_key_exists('footer-copyright-text', $val)) $val['footer-copyright-text'] = pll__('Footer text');
return $val; });
The above actually ignores the footer text specified under Salient options, because passing the current value to pll__() would break the mapping if the text was changed. Instead the footer text can be modified across languages within Polylang options > Strings Translations.
Hi - we have a multilingual site with pages localised via Polylang. The one piece of text we're unable to localise is the footer text specified under Salient options > Footer > Copyright Section Text.
What is the recommended way to localise this text, without resorting to editing original Salient files, or duplicating the whole of footer.php (which is large so would be a maintenance headache during future upgrades)?
Polylang allows localised text to be accessed via the following PHP call, which is how we're localising other boilerplate elements:
<?= pll__('My text to localise') ?>
Could we perhaps filter Salient's footer option value via a WP filter -- "pre_option_footer-copyright-text" maybe, skim reading WP's built in get_option() if that's what is used to read Salient's options?
Thanks, Ben
We managed to solve this - the code below intercepts retrieving the footer text and localises it. :
// replace footer text with localised version via Polylang custom string
pll_register_string('Footer text', 'Footer text', 'My custom strings');
add_filter( 'option_salient_redux', function($val) {
// don't modify if this is an admin page (e.g., options edit page), or if $val isn't valid
if(strpos($_SERVER['REQUEST_URI'], '/wp-admin/')===FALSE)
if(is_array($val) && array_key_exists('footer-copyright-text', $val))
$val['footer-copyright-text'] = pll__('Footer text');
return $val;
});
The above actually ignores the footer text specified under Salient options, because passing the current value to pll__() would break the mapping if the text was changed. Instead the footer text can be modified across languages within Polylang options > Strings Translations.
We built a more powerful version that respects the text defined in Salient options, but replaces placeholder tokens with localised values instead - e.g., "{{Telephone}} | {{Email}} - Copyright © {{Company}}". It also allows any WP option (Salient and other) to be processed. Anyone interested in this version, get in touch: enquiries [AT] neogic.com.