Support » Plugin: WP BrowserUpdate » Plugin activation hook is not firing on network activate which led to an js erro

  • Resolved Naveen

    (@naveen17797)


    since the activation hook is not fired for all the sites, there is no option wp_browserupdate_browsers saved on the table.

    the below js code is generated

    var $buoop = {required:{e:,f:,o:,s:},test:,newwindow:,style:“”,insecure:,unsupported:,mobile:,shift_page_down:,api:2019.08}

    the generated js code is not right in that case.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Marco Steinbrecher

    (@macsteini)

    I’m afraid I don’t understand. Would you please rephrase and add some more details?

    Thread Starter Naveen

    (@naveen17797)

    Hello Steini

    From the code i understand you are saving an option upon the plugin activation

    function wpbu_activation() {
    	add_option( 'wp_browserupdate_browsers', '0 0 0 0 0' );
    	add_option( 'wp_browserupdate_js', '0 false true top true true true true' );
    	add_option( 'wp_browserupdate_css_buorg', '' );
    }

    But this function wont run when the plugin is network activated

    Related stackoverflow question : https://wordpress.stackexchange.com/questions/181141/how-to-run-an-activation-function-when-plugin-is-network-activated-on-multisite

    so when this wpbu() function is called, the option doesnt exist on the db,

    $browser = 'e:' . $wpbu_vars[0] . ',f:' . $wpbu_vars[1] . ',o:' . $wpbu_vars[2] . ',s:' . $wpbu_vars[3] . ( ! isset( $wpbu_vars[4] ) ? '' : ',c:' . $wpbu_vars[4] );

    there are no isset checks here which led to generation of js script with syntax errors

    To replicate the bug, remove the option wp_browserupdate_browsers from db and open the page.

    Plugin Author Marco Steinbrecher

    (@macsteini)

    That’s a brilliant hint. To be honest, I had no idea the networking feature would affect the way a plugin works. Will implement the changes and push an update soon. Would you be able to test and provide feedback here?

    Thread Starter Naveen

    (@naveen17797)

    sure, i would love to.

    If you point me to the plugin github repo i could even send a PR with the quick fix.

    Plugin Author Marco Steinbrecher

    (@macsteini)

    There’s no repo as of yet. Feel free to pass me the changes here or send an e-mail to wordpress at steinbrecher dot co

    Thread Starter Naveen

    (@naveen17797)

    I have sent the fix via email 🙂

    Plugin Author Marco Steinbrecher

    (@macsteini)

    Received, massive thanks! Will push the update soon…

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Plugin activation hook is not firing on network activate which led to an js erro’ is closed to new replies.