• Resolved jonwarmington

    (@jonwarmington)


    Hello, we keep getting critical errors while editing products in woocommerce admin. The critical error shows in the admin when selecting the side tab in Product Data, and selecting any of thee below:

    Advanced Production Options, Swatches,, WooThumbs, and Get more options.

    The error is actually generated on load of the admin page, you just only see the error in the UI when you select one of those options.

    After this, we receive the email notification of an error that was experienced. The error is always within the integration of your plugin, working with the PolyLangTranslator. And you can also see these errors within the error log.

    An error of type E_ERROR was caused in line 44 of the file /sitePath/wp-content/plugins/additional-product-fields-for-woocommerce/Integration/Translations/PolylangTranslator.php. Error message: Uncaught Error: Call to undefined function rednaowooextraproduct\Integration\Translations\icl_get_default_language() in /sitePath/wp-content/plugins/additional-product-fields-for-woocommerce/Integration/Translations/PolylangTranslator.php:44
    Stack trace:
    #0 /sitePath/wp-content/plugins/additional-product-fields-for-woocommerce/panel/ProductBuilderPanel.php(131): rednaowooextraproduct\Integration\Translations\PolylangTranslator->GetDefaultLanguage()
    #1 /sitePath/wp-content/plugins/additional-product-fields-for-woocommerce/core/Loader.php(529): rednaowooextraproduct\panel\ProductBuilderPanel->Execute()
    #2 /sitePath/wp-includes/class-wp-hook.php(324): rednaowooextraproduct\core\Loader->AddProductPanel()
    #3 /sitePath/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #4 /sitePath/wp-includes/plugin.php(517): WP_Hook->do_action()
    #5 /sitePath/wp-content/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-data-panel.php(54): do_action()
    #6 /sitePath/wp-content/plugins/woocommerce/includes/admin/meta-boxes/class-wc-meta-box-product-data.php(33): include('...')
    #7 /sitePath/wp-admin/includes/template.php(1456): WC_Meta_Box_Product_Data::output()
    #8 /sitePath/wp-admin/edit-form-advanced.php(723): do_meta_boxes()
    #9 /sitePath/wp-admin/post.php(206): require('...')
    #10 {main}
    thrown

    I could replicate this on V 1.2.129 and 1.2.130. I did not test others. We are currently running on latest WP v6.6. All plugins are kept up to date each week. We have the latest Polylang plugin installed, v3.6.3

    It looks like there is an error within your integration of polylang.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jonwarmington

    (@jonwarmington)

    Does anyone actually work at Rednao?? Who is Edgar from PHP Storm?? And has this really been like this since 2017?? This bug still exists.. and its an amateur bug.. When your team created the Translation integration for PolyLang, the developer copied the Integration for WPML, and then updated the file.. but not entirely.. they left integration code to get the default language from WPML. So if anyone has Polylang translator, it crashes the admin so you cannot edit products unless you disable the plugin.

    Here is the code of the integration class. Take a look at GetDefaultLanguage() method… its calling the built in function for WMPL get default language icl_get_default_language()

    <?php
    /**
    * Created by PhpStorm.
    * User: Edgar
    * Date: 12/12/2017
    * Time: 7:09 PM
    */

    namespace rednaowooextraproduct\Integration\Translations;

    class PolylangTranslator extends TranslationBase {





    public function GetLanguages()
    {
    $languages=array();
    if(function_exists('icl_get_languages'))
    {

    $tempLanguajes=icl_get_languages();
    foreach($tempLanguajes as $language)
    {
    $languages[]=array(
    'code'=>$language['language_code'],
    'id'=>$language['id'],
    'active'=>$language['active']=="1",
    'translated_name'=>$language['translated_name'],
    'country_flag_url'=>$language['country_flag_url']

    );
    }


    }

    return $languages;
    }

    public function GetDefaultLanguage()
    {
    return icl_get_default_language();
    }


    public function GetCurrentLanguage()
    {
    return pll_current_language( );

    }
    }

    a simple fix… put the PolyLang default language method in!!!

    pll_default_language()

    Here is the updated version of the class…

    <?php

    /**

    ?* Created by PhpStorm.

    ?* User: Edgar

    ?* Date: 12/12/2017

    ?* Time: 7:09 PM

    ?*/

    namespace rednaowooextraproduct\Integration\Translations;

    class PolylangTranslator extends TranslationBase {

    ? ? public function GetLanguages()

    ? ? {

    ? ? ? ? $languages=array();

    ? ? ? ? if(function_exists('icl_get_languages'))

    ? ? ? ? {

    ? ? ? ? ? ? $tempLanguajes=icl_get_languages();

    ? ? ? ? ? ? foreach($tempLanguajes as $language)

    ? ? ? ? ? ? {

    ? ? ? ? ? ? ? ? $languages[]=array(

    ? ? ? ? ? ? ? ? ? ? 'code'=>$language['language_code'],

    ? ? ? ? ? ? ? ? ? ? 'id'=>$language['id'],

    ? ? ? ? ? ? ? ? ? ? 'active'=>$language['active']=="1",

    ? ? ? ? ? ? ? ? ? ? 'translated_name'=>$language['translated_name'],

    ? ? ? ? ? ? ? ? ? ? 'country_flag_url'=>$language['country_flag_url']

    ? ? ? ? ? ? ? ? );

    ? ? ? ? ? ? }

    ? ? ? ? }

    ? ? ? ? return $languages;

    ? ? }

    ? ? public function GetDefaultLanguage()

    ? ? {

    ? ? ? ? return pll_default_language();

    ? ? }

    ? ? public function GetCurrentLanguage()

    ? ? {

    ? ? ? ? return pll_current_language( );

    ? ? }

    }

    Please fix this!

    Plugin Author EDGARROJAS

    (@edgarrojas)

    Oh sorry i missed your original thread, you honestly could have just remind me about this instead of be this aggresive though but ok. The reason this hasn’t been fixed is because no one other that this thread has brough up that issue.

    It will be fixed in the next release.

    Thread Starter jonwarmington

    (@jonwarmington)

    Thank you for fast response and for fixing it for the next release. Please confirm when next release is out and fix is applied as I had to manually update the plugin file for the client and will loose my change if the client updates the plugin and the next update does not have the fix.

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.