Support » Plugin: Polylang » Polylang and issue with Simple Google Connect authorization

  • Hi Chouby,

    Just to let everybody know: When using the plugin Simple Google Connect and Polylang together, it is IMPOSSIBLE to authorize the connection between Google and WordPress when you have NOT checked the option “Hide URL language information for default language” in the Polylang settings.

    I would guess the homepage redirection that Polylang does, interferes with the authorization steps (via /oauth2callback) which results in the home page (with language info like /en/ in the URL) to appear in the popup window instead of redirecting back to the user Profile page.

    The solution is simply to check the option “Hide URL language information for default language” but in my case that would mess with the pagerank of the default language homepage since checking that option will render the old default language URL /en/ with a 404 page… 🙁

    Would it be possible to have Polylang redirect the default language URL (with language info) with a 301 to back to the root URL when that option is checked?

    http://wordpress.org/extend/plugins/polylang/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Chouby

    (@chouby)

    Hi!

    Did you try the plugin redirection?

    We can try to find and solve the conflict. One possibility could be to remove the Polylang home_url filter by putting define('PLL_FILTER_HOME_URL', false); in wp-config.php at least to check that the conflict is coming from here. However, all your ‘home’ links in your theme will point to your homepage *without* language.

    I tried all kinds of variations in the Polylang settings on Settings > Languages > Settings but as far as I could tell only the option ‘Hide URL language information for default language’ makes any difference.

    And although with define('PLL_FILTER_HOME_URL', false); in wp-config.php I did not test all the options again, it appears to behave the same. In fact, that global does not seem to change anything. The homepages remain pointed at either their language URL or their proper slug URL depending on the redirect option. Is that normal or is there something going wrong here?

    Plugin Author Chouby

    (@chouby)

    I checked define('PLL_FILTER_HOME_URL', false); in wp-config.php with Twenty ten and it works as expected, ie home_url( '/' ) does output the home url without the language information.

    When the option is true (default), Polylang filters home_url( '/' ), home_url(), bloginfo('url'), get_bloginfo('url'). to output the home url with the language option. This is nice to avoid themes modifications but causes conflict with some plugins.

    Did you write the define above /* That's all, stop editing! Happy blogging. */ ? I did not pay attention to this the first times I edited the file and it caused me a lot of troubles.

    Otherwise, it means the conflict comes from somewhere else and it will be harder to find.

    Did you try ‘redirection’ ?

    Yes, I tried the redirection option. It does not change the login behaviour of Google Connect.

    So examining define(‘PLL_FILTER_HOME_URL’, false); closer on my Twenty Eleven run iste, I notice the header image linking back to / all the time while when set to true, that URL becomes the current language home URL. So I guess it does indeed work correctly.

    However, on the login with Google Connect it does not have any influence. Only the option ‘Hide URL language info’ does.

    Plugin Author Chouby

    (@chouby)

    Have you a link for me to see the plugin in action ?

    Can you give it a try to this ?
    Edit the filer polylang/include/core.php at line 248, just after:
    function pre_get_posts($query) {
    and add:

    if ( get_query_var('oauth2callback') == 1 )
      return;

    Yes! That does the trick!

    If you want, I can set up a test site with account for you to do some further experimenting but I think you’ve nailed it already 🙂

    Plugin Author Chouby

    (@chouby)

    No I am fine with this solution !

    I know you probably arrange this yourself, but for people who may have the same issue, a better solution (although I did not test it) should be to create a personal plugin with the following code inside:

    add_filter('pre_get_posts', array(&$this, 'remove_conflict'), 1);
    
    function remove_conflict() {
    global $polylang;
    if (isset($polylang) && get_query_var('oauth2callback') == 1 )
      remove_filter('pre_get_posts', array(&$polylang, 'pre_get_posts'));
    }

    Thus no need to edit the Polylang code at each updtate.

    Plugin Author Chouby

    (@chouby)

    Fantastic !

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Polylang and issue with Simple Google Connect authorization’ is closed to new replies.