• Resolved Alvin

    (@iluminancia)


    Hi there,

    I just update to version 2.3.3 and I see this message

    Fatal error: Call to undefined function is_plugin_active() in /home2/iluminan/public_html/wp-content/plugins/autoptimize/classlesses/autoptimizeExtra.php on line 38

    I purged all caches, but the issue remains.

    I couldn’t even login to WP administration page. I had to go the server and changed the folder name to deactivate AO.

    I’d appreciate your kind support to restore the use of AO.

    Regards, Alvin

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

Viewing 15 replies - 1 through 15 (of 15 total)
  • Similar problem – Got an HTTP error 500 when trying to access my site after updating the plugin.

    Was able to access wordpress dashboard and deactivate the plugin which fixed the problem. Weirdly, my other site works fine.

    Edit, same error as above:

    [29-Mar-2018 10:12:41 UTC] PHP Fatal error: Uncaught Error: Call to undefined function is_plugin_active() in /www/wp-content/plugins/autoptimize/classlesses/autoptimizeExtra.php:38
    Stack trace:
    #0 /www/wp-content/plugins/autoptimize/classlesses/autoptimizeExtra.php(9): autoptimize_extra_init()
    #1 /www/wp-content/plugins/autoptimize/autoptimize.php(330): include_once(‘/www/wp-content…’)
    #2 /www/wp-includes/class-wp-hook.php(286): includeAutoptimizeExtra(”)
    #3 /www/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
    #4 /www/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #5 /www/wp-settings.php(330): do_action(‘plugins_loaded’)
    #6 /www/wp-config.php(90): require_once(‘/www/wp-setting…’)
    #7 /www/wp-load.php(37): require_once(‘/www/wp-config….’)
    #8 /www/wp-blog-header.php(13): require_once(‘/www/wp-load.ph…’)
    #9 /www/index.php(17): require(‘/www/wp-blog-he…’)
    #10 {main}

    • This reply was modified 6 years, 6 months ago by lozula.
    Plugin Author Optimizing Matters

    (@optimizingmatters)

    @lozula; do you *know* or *suspect* this is the same problem?

    pretty weird @iluminancia, given that is_plugin_active is a WordPress core function.

    a simple fix (which I will push out if confirmed OK by you) would be to alter autoptimizeExtra.php on lines 342;

    <?php if ( is_plugin_active('async-javascript/async-javascript.php') ) {
    to become
    <?php if ( function_exists('is_plugin_active') && is_plugin_active('async-javascript/async-javascript.php') ) {

    and 360:
    <?php if ( is_plugin_active('wp-youtube-lyte/wp-youtube-lyte.php') ) {
    to become
    <?php if ( function_exists('is_plugin_active') && is_plugin_active('wp-youtube-lyte/wp-youtube-lyte.php') ) {

    looking forward to your feedback!
    frank

    @optimizingmatters – yes, sorry, I updated my comment with the php log from my server, you can see it’s the same error.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I saw @lozula, hope you can try the fix above?

    @optimizingmatters – I can try that – what about the is_plugin_active check on line 38 of that same file?

    Thread Starter Alvin

    (@iluminancia)

    Hi @optimizingmatters,

    Thank you very much for a quick reply.

    However, I changed the line of codes and reactivated AO. I could access WP administration page with AO activated, but when I try to access my blog, I see still this error message:

    Fatal error: Call to undefined function is_plugin_active() in /home2/iluminan/public_html/wp-content/plugins/autoptimize/classlesses/autoptimizeExtra.php on line 38

    Even if I deactivate AO from plugin administration panel, I still see that error.

    So far, the only way to recover my blog is to change folder name on server level in order to disable the plugin.

    Do I need to make other changes?

    Regards,

    Alvin

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    good call! πŸ™‚

    so on L38 and following change

        /* async JS */
        if ( !empty($autoptimize_extra_options['autoptimize_extra_text_field_3']) && !is_plugin_active('async-javascript/async-javascript.php') ) {

    into

        /* async JS */
        $_asyncJSactive = false;
        if ( function_exists('is_plugin_active') && is_plugin_active('async-javascript/async-javascript.php') ) {
            $_asyncJSactive = true;
        }
        if ( !empty($autoptimize_extra_options['autoptimize_extra_text_field_3']) && $_asyncJSactive === false ) {

    frank

    • This reply was modified 6 years, 6 months ago by Optimizing Matters. Reason: active not actiwe
    Thread Starter Alvin

    (@iluminancia)

    Hi again,

    I made the change on line 38. Blog is loading fine with AO activated.

    Thank you!

    Alvin

    Edited, let me try again.

    • This reply was modified 6 years, 6 months ago by lozula.
    Thread Starter Alvin

    (@iluminancia)

    By the way,

    Is this piece of code right for line 38:

    ‘is_plugin_actiwe’ ==> actiWe? Should it be active?

    Regards.

    I can confirm it works fine now with all the changes and “is_plugin_active” on line 38 instead of “is_plugin_actiwe” πŸ˜‰

    Thanks for the quick response!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Also, just an FYI there’s a spelling error in your recent comment: is_plugin_actiwe instead of is_plugin_active – just letting you know in case you copy paste it somewhere

    typo corrected πŸ™‚

    frank

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    and thanks for your great assistance @iluminancia and @lozula!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    update; the root cause is me not reading the codex page thoroughly enough; is_plugin_active is -by default- simply not available in frontend, hence the fatal error.

    the full block of code that will be in AO 2.3.4 (which will be pushed out this afternoon) reads;

    
        /* 
         * async JS
         * 
         * is_plugin_active is not available in frontend by default
         * cfr. https://codex.wordpress.org/Function_Reference/is_plugin_active
         * so we need to source in wp-admin/includes/plugin.php
        */
        include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
        $_asyncJSactive = false;
        if ( function_exists('is_plugin_active') && is_plugin_active('async-javascript/async-javascript.php') ) {
            $_asyncJSactive = true;
        }
        if ( !empty($autoptimize_extra_options['autoptimize_extra_text_field_3']) && $_asyncJSactive === false ) {
            add_filter('autoptimize_filter_js_exclude','autoptimize_extra_async_js',10,1);
        }

    Thanks for the clarification! I have just installed 2.3.4 on both my sites and it is working great again πŸ™‚

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘“Fatal error” after update to 2.3.3’ is closed to new replies.