New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sorry, you are not allowed to access this page when activating Social Meta module #1066
Comments
This started with 2.3.15 When a page is added to the submenu, the menu item refers to "admin.php?page=all-in-one-seo-pack/modules/aioseop_opengraph.php" while the working slug is "admin.php?page=aiosp_opengraph". A few other menu items refer to "/modules/%module_name%.php" while some others refer to "%module_name%.php", even though all of them are located in /all-in-one-seo-pack/modules/... |
In aioseop_module_class.php function add_menu() there are three add_submenu_page()s. The first one, on line 1971 is how most modules get added. |
@michaeltorbert I tracked this bug back to this commit - 98703b5 |
I'm not sure why that PR tagged this issue, but it's unrelated and can be ignored within the context of this issue. |
The problem is the settings being moved to a new init() function on the WP init action hook. This has the information needed to add the submenu, which needs to be available before the init function runs. |
@michaeltorbert This was moved under "init" hook because the module was being initialized before wordpress or external plugins were initialized/instantiated, this was causing an scope issue, because the module was limited to default post types and taxonomies. Custom types/taxonomies registered by other plugins were left out of the scope. Can't recall if this was related when doing the taxonomies task, but custom things registered by 3rd party plugins where not showing in the checkboxes because the menu/submenu was being genereated before wordpress initializes itself and all plugins. |
@amostajo What are your thoughts on how we should handle this?
|
@michaeltorbert The right thing to do would be option (2), imo. Because menus should be created following Wordpress initialization flow. Menus should not be created before Wordpress initializes itself and plugins. My comments to the other options:
No sure... without unit testing this is unknown... and every little change in this plugin always affect something, my past experience...
The issue reported were custom post types/taxonomies are not showing will reappear. Cuz it is initializing menus before wordpress init.
Same issue as below. The only difference is that part of the code is on a method rather than constructor. |
I agree 2 is the best solution, at least long term, but it may take quite a bit to do it. I've never liked how complicated the menu code is. It's normally pretty simple in WP plugins. We should probably first figure out why the behavior of 1 exists in the first place though before we ditch it completely. For 4, I meant that we call init() on the init action, as well as from the constructor (as a temporary solution). I'm not sure if that causes any problems. |
Will test it |
Calls init outside Wordpress initialization flow to prevent plugin menu issues.
Did some testing and appears to work fine without any errors thrown. |
PR #1082 has been tested and is good. |
Calls init outside Wordpress initialization flow to prevent plugin menu issues.
When activating the Social Meta module, the first time you click on the Social Meta menu item you get a Sorry, you are not allowed to access this page error.
This is because the menu link is http://testsite.dev/wp-admin/admin.php?page=all-in-one-seo-pack/modules/aioseop_opengraph.php when it should be http://testsite.dev/wp-admin/admin.php?page=aiosp_opengraph
Need to find when this broke.
The text was updated successfully, but these errors were encountered: