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
Option page as sub-page of another menu broken in 2.8.0 #1410
Comments
I'd need to test and try to confirm, but I wonder if it's coming from the changes that were a part of #1380 |
I'm also having the same issue |
@sonnysunzu can you provide your CMB2 configuration code as well, in case variations are producing different results, and so we could just verify that a change is indeed affecting both. |
as soon as i remove the 'parent_slug' the side menu will then show the link as a stand alone menu item outside of the submenu and works. so something has happened for submenu items to no longer work wp add menu settings
cmb2 setup
I hope this is what you asked for. |
yep that's the part i was looking for. thanks. |
@tw2113, @JiveDig, I found the issue. inside includes/CMB2_Options_Hookup.php line 71
if you remove so looking further into this. Too fix my issue without modifying the cmb2 direct i had to add so like this
without going to far as its 1am here and i need to be up for work in the morning. I'm going to take a guess that the hook for the submenu is running before the hook for the parent menu item. I could be wrong I'm tired |
I must not be doing something right, because my submenu items with both code samples above put me on 404 pages on the frontend. For example, I'm ending up on https://wds.test/wp-admin/some_sub_page for @JiveDig's code. I've reverted myself back to the 2.7.0 release as well, just to help. What URLs are you two getting for your submenus? |
I'm on mobile at the moment, but the exact URLs I get with my reduced code example are all in the OP. |
@tw2113 have you set the priority to low ? like i suggested as this solved the issue for me. (sorry i have two accounts one for work and a personal one. this is my personal one, and the sonnysunzu is my work) |
Great find @sonnysunzu. Adding any priority works for me. I tested first with So it looks like the change to https://github.com/CMB2/CMB2/blob/develop/includes/CMB2_Options_Hookup.php#L71 Is currently:
But should be:
|
Actually, the get_priority method has a default set like |
I strongly believe the default priority of hence when setting the priority to low corrected the order the hooks was run. meaning the hook for the parent was ran first then the hook for cmb2 This would explain why. when removing the parent id and having the menu option as standalone it worked. because it does not depend on a parent existing first |
@sonnylloyd i was trying with version 2.7.0 and no priority argument passed and still wasn't seeing successful option pages. I may try again later tonight or tomorrow with all this new information, but I was really hoping to have a |
@tw2113 Did you try my original code? With a clean install of WP and Twenty Twenty One theme active, if I put the following code in functions.php it works in 2.7.0 and doesn't work in 2.8.0.
|
That's exactly right. Priority defaults to Which is translated to a hook priority of I didn't notice/realize that by adding this priority thing in 94e80d7 that I would be breaking back-compatibility. Ugh. I'll get this updated so that the priority is |
@JiveDig i was only ever getting the second one, even though I'm pretty sure I checked out the right git tag to go back to 2.7.0. Regardless it looks like Justin is on the case as well and has a good lead on things, so I'm going to let him take over from here. |
* upstream/develop: Clean up and add props for CMB2#1413 Sanitize URLs with HTTPS Add develop suffix to init class Add am-cli-tools Update changelong and version numbers and readmes, and prepare release Set default priority to 10 for options pages. Fixes CMB2#1410 build field-cache key manually to remove unnecessary |'s Better generated array key for cached fields, fixes issue where wrong field is found. Fixes CMB2#1405 Add to list of valid image types from get_allowed_mime_types(). Fixes CMB2#1223 Move tab markup output to separate method, options_page_tab_nav_output. Fixes CMB2#1407 Add cmb2_tab_group_tabs filter for adding arbitrary menu page urls to the cmb2 tabs. See CMB2#1407 Update since tag, and add props for CMB2#1340 Limit use of italic, including removing from field descriptions. Fixes CMB2#1404 Add props for CMB2#1400 move $args in deprecated_param method for 7.4 Add develop suffix to init class Prepare release and changelog for 2.8.0 Fix tests since WP_Error signature changed move $args in deprecated_param method for 7.4 Use the already-existing get_priority method. Re CMB2#1380 and CMB2#1398 Use existing "priority" field param. Fixes CMB2#1380. Closes CMB2#1398 Add admin_menu_hook_priority box property for options boxes. Fixes CMB2#1380. Closes CMB2#1398 Make field_can first param required to address php 8 "Required parameter follows optional parameter". Fixes CMB2#1396 Update includes/types/CMB2_Type_Colorpicker.php Update includes/types/CMB2_Type_Colorpicker.php Update includes/CMB2_Utils.php Prevent array to string conversion Update includes/types/CMB2_Type_Colorpicker.php Update includes/types/CMB2_Type_Colorpicker.php Update includes/types/CMB2_Type_Colorpicker.php Update includes/types/CMB2_Type_Colorpicker.php Update includes/types/CMB2_Type_Colorpicker.php Update includes/types/CMB2_Type_Colorpicker.php Added sanitize_color() function and remove PHP warnings suppresions Fixes PHP warnings on repeatable ColorPicker with an array as default
Describe the bug
I have a plugin that uses CMB2 to register an options page as a sub-menu of another custom admin page. This works in 2.7.0 but breaks the url in 2.8.0.
Steps to reproduce (I have confirmed I can reproduce this issue on the
develop
branch):The following works with 2.7 producing an admin url with
/wp-admin/admin.php?page=some_sub_page
but breaks in 2.8 producing an admin url with
/wp-admin/some_sub_page
The text was updated successfully, but these errors were encountered: