Opened 6 years ago
Closed 6 years ago
#44875 closed enhancement (duplicate)
register_post_type won't accept menu_position as float (as string) like other admin menu functions do
Reported by: | stiofansisland | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Menus | Keywords: | has-patch dev-feedback |
Focuses: | administration | Cc: |
Description
The register_post_type function does not accept float values so its impossible to exactly position your CPTs next to each other if you have more than 5.
Most other functions to add admin menu items accept float values as a string like "55.1" but this is not the case with register_post_type due to a is_int check.
I will attach a diff file for the smallest change ever...
Attachments (1)
Change History (5)
This ticket was mentioned in Slack in #core by stiofansisland. View the logs.
6 years ago
#3
in reply to:
↑ 2
@
6 years ago
@earnjam add_menu_page() does accept decimals as a string "12.345" i have been using it this way for years, i actually thought it was in the codex as i remember reading about it years ago.
https://github.com/AyeCode/geodirectory/blob/0e5b9d066a3f4b3f034464a36a8856af4b967b80/includes/admin/class-geodir-admin-menus.php#L48
Do you want me to recreate the patch from root?
Thanks,
Stiofan
Adjusting version to 3.0. Looks like this
is_int()
check was added originally back in [14014].add_menu_page()
suggestsmenu_position
should be an int in the documentation, but doesn't require that and actually seems like you could pass a string for that value if you wanted to (though I haven't tested that). It ends up doing auksort
bystrnatcasecmp
in /wp-admin/includes/menu.php to determine the order.If we're going to allow any string (or anything other than integers) to be passed for
menu_position
, we should update the documentation foradd_menu_page
andregister_post_type
to reflect that.Also, @stiofansisland when creating patches, can you do it from the root directory? It makes it easier to apply.