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§ion=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§ion=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.