WordPress.org

Ready to get started?Download WordPress

Forums

EU Cookie Law Compliance
[Plugin: Cookie Compliance] Polylang compatible? (19 posts)

  1. RavanH
    Member
    Posted 1 year ago #

    Hi,

    qTranslate compatible. Great, but... what about the new multi-lingual kid on the block, Polylang?

    http://wordpress.org/extend/plugins/cookie-compliance/

  2. tegotha
    Member
    Posted 1 year ago #

    or wpml? WPML has a nice plugin string discovery and translation tool, but it does not work with your Cookie Compliance

  3. zafrira
    Member
    Plugin Author

    Posted 1 year ago #

    Hi RavanH and Tegotha,

    we are working on making the plugin compatible with other language plugins as well.
    We will have a look into the Polylang and WPML plugins.

    Anyone else any suggestions? Please let us know!

  4. zafrira
    Member
    Plugin Author

    Posted 1 year ago #

    Hi RavanH,

    release 1.0.8 will be released today, it supports Polylang.
    If you experience any troubles, please let us know.

  5. RavanH
    Member
    Posted 1 year ago #

    That's great news! I'll be testing soon :)

  6. RavanH
    Member
    Posted 1 year ago #

    OK, first quick test with Polylang shows me the ability to change the texts for each configured language. Great!

    However, it also breaks my home page :(

    I use a static homepage with the Showcase template in Twenty Eleven. The Polylang options
    - "When using static front page, redirect the language page (example: http://status301.net/en/) to the front page in the right language"
    - "When the front page is visited, set the language according to the browser preference"
    - "Hide URL language information for default language"
    are checked.

    But after accepting the cookie notice, the home page returns a 404...

  7. zafrira
    Member
    Plugin Author

    Posted 1 year ago #

    Hi RavanH,

    an update was released tonight (version 1.0.10), this should fix the problem you experienced.
    Can you check and let me know?

    Thanks!

  8. RavanH
    Member
    Posted 1 year ago #

    It does not seem to change anything. I tried resaving permalink structure and both plugin settings but still the 404 on all language homepages occurs...

  9. zafrira
    Member
    Plugin Author

    Posted 1 year ago #

    ok, i will try to reproduce the error. I will let you know when we fixed it for sure :)

  10. zafrira
    Member
    Plugin Author

    Posted 1 year ago #

    Ok, i could reproduce the error pretty easy.
    Sorry i didnt see this before.

    I added version 1.0.11 but didnt release it yet, could you try it?

    It can be found here: http://downloads.wordpress.org/plugin/cookie-compliance.1.0.11.zip

  11. RavanH
    Member
    Posted 1 year ago #

    Yep, that seems to be working fine :)

    Excellent work!

  12. Chouby
    Member
    Posted 1 year ago #

    Maybe I can help a bit...

    But for this, I should understand the reason for you to instantiate a Polylang_Core object on admin side with:

    require_once(PLL_INC.'/core.php');
    $PolyLang = new Polylang_Core();
    require_once(PLL_INC.'/api.php');

    I have seen that you use it only for the function get_current_language which is available only on frontend. Are you doing this for AJAX?

    In that case, setting $_REQUEST['pll_load_front'] in your AJAX request should load the frontend side of Polylang, and then you can use the global variable $polylang. If you set $_REQUEST['lang'], Polylang will use it to set the language, otherwise it will use the preferred language (cookie or browser preference or default)

    Edit: maybe my help is not needed anymore, if everything works

  13. zafrira
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Chouby,

    for the frontend using the pll_current_language('slug') is enough, only need to know the current language.

    But in the backend we need to know the list of available languages. I use the function get_languages_list() for this.

    Indeed the problem was caused by initiating the Polylang_Core object, which was also initiated when on the frontend.

    It does work ok at the moment, but when you see anything that could be improved or simplified. All info is always welcome :)

  14. zafrira
    Member
    Plugin Author

    Posted 1 year ago #

    Hi RavanH,

    thanks for the check! I will put it in the release now.

  15. Chouby
    Member
    Posted 1 year ago #

    Well, in fact, I don't understand the lines:

    $tmplang = get_object_vars($PolyLang->get_current_language());
    self::$language = $tmplang['slug'];

    get_current_language has some meaning only on frontend but you call it when is_admin == true (that's why I thought you are doing this for AJAX).
    Normally, it is not available on backend side (you can call it because you instantiated a "frontend" object of Polylang).

    get_languages_list() is already available on both frontend and backend if you use the global object $polylang

  16. zafrira
    Member
    Plugin Author

    Posted 1 year ago #

    ok, that makes sense...

    i kinda just need to set a current or default language code in the backend when there is nothing chosen yet.
    Maybe better if i just take the first language in the list when nothing is set... that should do...
    gonna try that, it would reduce the code indeed...

  17. Chouby
    Member
    Posted 1 year ago #

    It would reduce the memory used too (the main reason for which I fully separated backend and frontend code ;-) )
    If you prefer, you can get the default language with something like:

    $pll_options = get_option('polylang');
    self::$language = $pll_options['default_language'];
  18. zafrira
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Chouby,

    just released an update and changed the code based on your suggestions.
    Thank you for the help! :)

  19. zafrira
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Tegotha,

    Support for WPML is now added to the plugin. Please upgrade to the latest version (1.1.1) to be able to use it.

    Thank you for your suggestion. And thanks to the wpml.org team for the support.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags