• gdebrion

    (@gdebrion)


    Hello,

    With Polylang 2.2.3, everything works great. But when I update the plugin, to the current version (2.2.5), I got a blank page.

    The log display:

    [Thu Nov 09 15:03:52.835790 2017] [:error] [pid 5879] [client 86.xxx.69.xxx:48636
    ] PHP Fatal error:  Call to a member function get_current_language() on null in
    /home/xxx/dev/wp-content/plugins/yith-woocommerce-request-a-quote-premium/
    includes/class.yith-request-quote.php on line 797, referer: https://xxx.fr/wp-admin/plugins.php

    And the ligne 797 of the Yith plugin:

    if ( function_exists( 'wpml_object_id_filter' ) ) {
      global $sitepress;
      $option_value = wpml_object_id_filter( $option_value, 'post', true, $sitepress->get_current_language() );
    }

    Look likes $sitepress is not supported anymore?

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

    (@chouby)

    Hi,

    Polylang has never supported $sitepress and it will never support it. $sitepress is the global object of WPML.

    The reason why your plugin breaks now and not in 2.2.3 is because I added the support of the function wpml_object_id_filter in version 2.2.4 (to add compatibility with the plugin Yith WooCommerce compare :/). It was not there before because it’s a deprecated function. But there are loads of plugins still using WPML deprecated functions, so when I find one, I add it.

    What’s done in your plugin is wrong. It correctly tests for the existence of the function wpml_object_id_filter but not for the object $sitepress.

    The best fix would be that plugin authors stop using WPML internal functions or deprecated functions and use the current WPML API. In this case

    
    $option_value = apply_filters( 'wpml_object_id', $option_value, 'post', true );

    is the correct code for WPML and works for Polylang too. Getting the current language as the 4th parameter is useless as it is the default value. However if someone needs it, here is the correct code:

    
    $current_language = apply_filters( 'wpml_current_language', '' );

    See also: https://polylang.pro/fatal-error-call-to-a-member-function-on-a-non-object-in/

    • This reply was modified 7 years ago by Chouby.
    • This reply was modified 7 years ago by Chouby.
    Thread Starter gdebrion

    (@gdebrion)

    Thank you for the quick answer ??

    I will contact Yith and hope there will be a fix soon from their side!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Polylang breaks support of $sitepress?’ is closed to new replies.