Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter BraveThrasher

    (@bravethrasher)

    Easy way to find out. Can you post a link to your site?

    But it does sound like you have a Jetpack question.

    Here is the link to my site http://bensblog.schalley.be

    Thread Starter BraveThrasher

    (@bravethrasher)

    Is this regarding a WordPress.com site?

    I don’t know why this is important for a feature request.
    In my own case I’m using a self hosted WordPress blog with Jetpack plugin. In Jetpack Site Stats there is a line of text which reads “Did you know you can view enhanced stats on WordPress.com?” and behind that line of text is a button with the text “Show Me”. Clicking that button opens a page on wordpress.com with stats for my self hosted blog. The exact url being opened is https://wordpress.com/stats/62578073?from=wp-admin but I think you won’t get there because it needs credentials for my blog.

    Thread Starter BraveThrasher

    (@bravethrasher)

    Euhm… I’m not sure… the one that is on wordpress.com ?!?
    Jetpack has a link that says “Did you know you can view enhanced stats on WordPress.com? [Show Me]”, those “enhanced stats”.

    Thread Starter BraveThrasher

    (@bravethrasher)

    Thank you, Chouby! With these pointers and a little research I was able to get the Polylang integration in the EU Cookie Law Compliance plugin to work again.

    See this topic for what I did…

    Thread Starter BraveThrasher

    (@bravethrasher)

    After research on plugins and with the help of Chouby in another topic I got it to work.

    The things I did to get it to work:

    • in file cookie-compliance.php I added the following line before the line starting with ‘require…’
      include_once(ABSPATH . 'wp-admin/includes/plugin.php');
    • in file cookie-compliance.php I changed
      add_action('init', array('Cookie_Compliance', 'initialize'));
      into

      if (is_plugin_active('polylang/polylang.php')) {
        add_action('pll_language_defined', array('Cookie_Compliance', 'initialize'));
      } else {
        add_action('init', array('Cookie_Compliance', 'initialize'));
      }

      Because of certain Polylang settings the current language is not always known at ‘init’ action but Polylang has its own action ‘pll_language_defined’ to catch it. The code above checks if PolyLang is active and if that is so EU Cookie Law Compliance hooks into the Polylang action.

    • in file classes/cookie-compliance.php in the static function initialize I replaced 2 occurences of
      $polylang->get_languages_list()
      by
      $polylang->model->get_languages_list()
    • in the same file (classes/cookie-compliance.php) in the static function initialize I replaced
      self::$language = $pll_options['default_language'];
      by
      self::$language = $pll_options['default_lang'];

    After these changes EU Cookie Law Compliance showed the translated texts like it should.

    Thread Starter BraveThrasher

    (@bravethrasher)

    What can be the reason for pll_current_language('slug') to return null?
    Do I need to do something else first?

    Thread Starter BraveThrasher

    (@bravethrasher)

    Polylang is integrated into EU Cookie Law Compliance with the following code:

    if (is_plugin_active('polylang/polylang.php') && function_exists('pll_current_language') && function_exists('pll_the_languages')) {
                if (!is_admin()) {
                    self::$language = pll_current_language('slug');
                } else {
                    global $polylang;
                    if (!(!$polylang->get_languages_list())) {
                        $pll_options    = get_option('polylang');
                        self::$language = $pll_options['default_language'];
                        if (isset($_GET['lang']) && isset($_GET['page']) && $_GET['page'] == 'cookie-compliance-settings') {
                            self::$language = $_GET['lang'];
                        }
                        foreach ($polylang->get_languages_list() as $language) {
                            $language                           = get_object_vars($language);
                            self::$languages[$language['slug']] = $language['name'];
                        }
                        self::$languagechoice = true;
                    }
                }
            }

    I have noticed that pll_current_language(‘slug’) returns null.
    What needs to be changed to make this snippet work with Polylang version 1.3.1?

Viewing 7 replies - 1 through 7 (of 7 total)