• Resolved Brian Henry

    (@brianhenryie)


    Without WooCommerce active, this plugin redirects to:

    /wp-admin/options-general.php?page=wpm&section=main&subsection=google-ads

    Which says:

    Sorry, you are not allowed to access this page.

    When I am debugging a site and deactivate all plugins, then attempt to bulk activate them, this plugin’s bug prevents that.

    I think the Freemius crap might be an additional problem after this bug is fixed.

    It’s pretty frustrating when working on a live site and plugins prevent other plugins from activating due to their selfishness. An admin notice is always more appropriate than a redirect.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @brianhenryie

    Thank you for reaching out.

    It seems this is common with WooCommerce Extensions. Without the WooCommerce plugin active on the site, the WooCommerce Extension is sometimes not allowed to be activated. Or, worse, it will cause some fatal errors on your site.

    This is actually not a bug. This is just how WooCommerce Extensions work.

    In our case, our plugin gives a warning before activating it without WooCommerce active on the site. I tried this on my test site and here’s what it shows instead – https://share.getcloudapp.com/ApuXlGQp.

    Could you always ensure that WooCommerce is active before activating our plugin?

    Let me know if you have any other questions or concerns.

    Regards,
    Kenneth

    Thread Starter Brian Henry

    (@brianhenryie)

    It is certainly a bug.

    Here is your code:

    if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
        return admin_url( 'admin.php?page=wpm&section=main&subsection=google-ads' );
    } else {
        return admin_url( 'options-general.php?page=wpm&section=main&subsection=google-ads' );
    }

    With WooCommerce active, the plugin directs to a different, working, page than the one I mentioned.

    Without WooCommerce active, you are intentionally redirecting to a different page. A page which cannot be accessed.

    Sorry, you are not allowed to access this page.

    Let me ask: when you are on plugins.php and select multiple plugins to activate. Do you want them all to activate? Or do you want to be redirected to a different page and half the plugins to remain inactive?

    Hi @brianhenryie,

    We totally understand your point.

    However, it’s just how we set up our plugin. If this is not set up this way, your whole site will encounter a fatal error when you activate our plugin while WooCommerce is inactive.

    When you are on plugins.php and select multiple plugins to activate. Do you want them all to activate? Or do you want to be redirected to a different page and half the plugins to remain inactive?
    Of course, we would want them all to be activated. However, for WooCommerce Extensions, they can’t run without the WooCommerce plugin active.

    The reason why you’re experiencing this is that Pixel Manager is above the WooCommerce plugin on the list of plugins. What happens is Pixel Manager is the one being activated first before WooCommerce is activated. Here’s what I mean – https://share.getcloudapp.com/OAu87pYP.

    Thus the reason why you’re being redirected to a page you can’t access.

    If you want to prevent this from happening, please make sure that the WooCommerce plugin is active before activating any other WooCommerce Extensions.

    You can try this on other WooCommerce Extensions and see how it behaves. You’ll see that our implementation is better since it’s not allowing your site to crash.

    I hope that helps.

    Let me know if you still have other concerns.

    Regards,
    Kenneth

    Thread Starter Brian Henry

    (@brianhenryie)

    Hey,

    > You can try this on other WooCommerce Extensions and see how it behaves.

    Most WooCommerce extensions do not redirect me to a page that does not exist. Certainly none of the ones I have written: https://github.com/BrianHenryIE?tab=repositories&q=bh-wc

    You are redirecting to a page that says:

    Sorry, you are not allowed to access this page.

    A better way would be to NOT redirect at all, which you can do with this code:

    if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
        return admin_url( 'admin.php?page=wpm&section=main&subsection=google-ads' );
    } else {
        return false;
    }

    Better yet, check is this happening during bulk activation and do not redirect then either:

    woocommerce-google-adwords-conversion-tracking-tag/wgact.php:96

    // If we are bulk activating plugins, do not redirect.
    global $pagenow;
    if ( 'plugins.php' === $pagenow &&
         ( ( isset( $_REQUEST['activate-multi'] ) && 'true' === $_REQUEST['activate-multi'] )
         || ( isset( $_REQUEST['action'] ) && 'activate-selected' === $_REQUEST['action'] && isset( $_REQUEST['checked'] ) && count( $_REQUEST['checked'] ) > 1 ) )
         || ( isset( $_REQUEST['plugin'] ) && 'woocommerce-google-adwords-conversion-tracking-tag/wgact.php' !== $_REQUEST['plugin'] ) ) {
        return false;
        // If WooCommerce is not active, do not redirect.
    } elseif ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
        return false;
    } else {
        return admin_url( 'admin.php?page=wpm&section=main&subsection=google-ads' );
    }

    Just return false to not redirect. Surely that’s better than a redirection to a non-existent page. See vendor/freemius/wordpress-sdk/includes/class-freemius.php:3119 to see where Freeemius designed to facilitate this.

    Hope that helps.

    Hi @brianhenryie

    Most WooCommerce extensions do not redirect me to a page that does not exist.
    Right. Because, usually, when you activate a WooCommerce Extension with WooCommerce is not active, it crashes the site.

    But I understand your point. It might be better if the plugin is not redirecting at all.

    I’ll consult this with our developer. We may consider your suggestion in our future updates. We’ll see what we can do about this.

    For now, let me know if you have other concerns.

    Regards,
    Kenneth

    • This reply was modified 2 years, 8 months ago by Kenneth.
    Plugin Author alekv

    (@alekv)

    Hi Brian

    I tried to replicate your issue today. But, when bulk activating several plugins on the plugins page, no redirect happens. Just an admin notification is shown that the Pixel Manager requires WooCommerce, which should be ok as per your input.

    I haven’t looked further into the code for the moment. Just one question. On that install where you experienced that issue, do you have the most recent version of the Pixel Manager installed?

    I did updates on the activation routine in the past months, so maybe the issue you face has already been removed in one of the more recent versions.

    Could you verify if the issues that you have is on a version 1.17.11 or later?

    Thanks
    Aleksandar

    Plugin Author alekv

    (@alekv)

    I’m closing this support thread due to inactivity. Feel free to add another reply to this thread if you want to continue the support request. We will keep monitoring it.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Bug; prevents bulk plugin activation’ is closed to new replies.