Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Polylang translates Pagelines strings
- */
- add_action('pagelines_hook_pre', 'pll_pagelines_settings');
- function pll_pagelines_settings() {
- if (function_exists('pll_register_string'))
- add_filter('option_pagelines-settings-two', 'translate_pagelines_settings');
- $pll_options = get_option('polylang');
- if (!($GLOBALS['wp_rewrite']->using_permalinks() && $pll_options['force_lang']))
- add_action('wp', 'pll_reload_pl_settings');
- }
- // reload pagelines settings to translate them when Polylang defers language loading
- function pll_reload_pl_settings() {
- $GLOBALS['global_pagelines_settings'] = ( array ) get_option(PAGELINES_SETTINGS);
- }
- // translates strings in the array $to_translate
- function translate_pagelines_settings($values) {
- $to_translate = array(
- 'metabar_standard',
- 'continue_reading_text'
- );
- foreach ($values as $key=>$value) {
- if (in_array($key, $to_translate)) {
- pll_register_string($key, $value);
- $values[$key] = pll__($value);
- }
- }
- return $values;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement