Advertisement
Chouby

Polylang translates Pagelines strings

Oct 8th, 2012
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Polylang translates Pagelines strings
  4. */
  5.  
  6. add_action('pagelines_hook_pre', 'pll_pagelines_settings');
  7.  
  8. function pll_pagelines_settings() {
  9.     if (function_exists('pll_register_string'))
  10.         add_filter('option_pagelines-settings-two', 'translate_pagelines_settings');
  11.  
  12.     $pll_options = get_option('polylang');
  13.     if (!($GLOBALS['wp_rewrite']->using_permalinks() && $pll_options['force_lang']))
  14.         add_action('wp', 'pll_reload_pl_settings');
  15. }
  16.  
  17. // reload pagelines settings to translate them when Polylang defers language loading
  18. function pll_reload_pl_settings() {
  19.     $GLOBALS['global_pagelines_settings'] = ( array ) get_option(PAGELINES_SETTINGS);
  20. }
  21.  
  22. // translates strings in the array $to_translate
  23. function translate_pagelines_settings($values) {
  24.     $to_translate = array(
  25.         'metabar_standard',
  26.         'continue_reading_text'
  27.     );
  28.     foreach ($values as $key=>$value) {
  29.         if (in_array($key, $to_translate)) {
  30.             pll_register_string($key, $value);
  31.             $values[$key] = pll__($value);     
  32.         }
  33.     }
  34.     return $values;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement