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

    (@chouby)

    It’s curious because this line should never be called on the admin side. It is in the function which displays the widget on the frontend of the site.

    Have you other plugins installed ? I suspect a conflict. I wonder… Have you something which could display widgets previews ?

    Thread Starter Craftsmann

    (@craftsmann)

    Thanks for the quick answer! No, I don’t have any preview plugins. But I have to say I have a lot of plugins on my test environment ? which one is bad is difficult to say.
    After brief view of plugin code I suppose that it happened because when I click Save hook named widgets_init begins to run but global $polylang was not declared as object at this moment. (also after unsuccessful save all my widget page in admn area crashed with this error ). I’ve changed piece of code in Polylang’s constructor in that way and now everything is ok in my case. But I’m note sure that this is the right solution so far ??

    if (is_admin()) {
            require_once(PLL_INC.'/admin.php');
    	new Polylang_Admin();
            require_once(PLL_INC.'/core.php');
            $polylang = new Polylang_Core();
    }
    Plugin Author Chouby

    (@chouby)

    Yes it’s a workaround which not surprisingly works. Unfortunately it does not explain why the widget function – which is normally called only on frontend – is in your case called from admin. So it means that you would have to modify the code after every update which is not very convenient.

    The widgets_init hook is only used to register the widget (which is of course needed for both frontend and admin).

    The reason why I separate admin and frontend is of course performance: more speed, less memory…

    Plugin Author Chouby

    (@chouby)

    Although I do not understand why the function is called from admin, I want to increase the robustness of the plugin so that such thing does not happen again (and so that you don’t need to edit the code again and again after each update !) But I want to keep the separation between and admin and frontend. Could you try the following modification ?

    Keep polylang.php as it was before the modification you described above.

    Modify include/widget.php by adding this line just after the line 11:
    if (!isset($polylang)) return;

    Thread Starter Craftsmann

    (@craftsmann)

    This line works! In addition I found out the cause of error – this is conflict with Tabbed Widgets plugin.
    So many thanks for your help!

    Plugin Author Chouby

    (@chouby)

    Thank you for the information. I will be able to see what causes the conflict with this plugin.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Polylang] Call to a member function the_languages()’ is closed to new replies.