Freemius / wordpress-sdk

https://freemius.com
GNU General Public License v3.0
264 stars 76 forks source link

Multisite - If menu has a parent slug, the account urls will direct to 404 #674

Open bfintal opened 10 months ago

bfintal commented 10 months ago

🐞 bug report

What is the issue? (*)

If you have the following scenario, there is no way to access the account page. Also, all links in the account page will also direct to a 404:

  1. You have this SDK setting enabled:
'menu' => array(
    'parent'     => array(
        'slug' => 'options-general.php',
    ),
),
  1. You have the plugin network activated in a multisite

Looks like the function call fs()->get_account_url() gives an invalid URL / or a 404 page

Other findings

The call fs()->get_account_url() returns this URL which is inaccessible:

http://multisite.local/wp-admin/network/options-general.php?page=stackable-account

But if you change the URL to this, it works:

http://multisite.local/wp-admin/network/admin.php?page=stackable-account

Workaround

A workaround I've devised is to detect if the user is in multisite, main site and is network activated, then change the SDK setting dynamically:

$menu_slug = 'options-general.php';
if ( is_multisite() && is_main_site() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
    $menu_slug = 'admin.php';
}

What is the expected behavior?

It should go to the accounts page and all links in it should work.