WordPress.org

Make WordPress Core

Opened 14 months ago

Closed 7 months 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:
PR Number:

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)

menu.diff (681 bytes) - added by stiofansisland 14 months ago.

Download all attachments as: .zip

Change History (5)

This ticket was mentioned in Slack in #core by stiofansisland. View the logs.


14 months ago

#2 follow-up: @earnjam
14 months ago

  • Version changed from trunk to 3.0

Adjusting version to 3.0. Looks like this is_int() check was added originally back in [14014].

add_menu_page() suggests menu_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 a uksort by strnatcasecmp 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 for add_menu_page and register_post_type to reflect that.

Also, @stiofansisland when creating patches, can you do it from the root directory? It makes it easier to apply.

#3 in reply to: ↑ 2 @stiofansisland
14 months 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

#4 @SergeyBiryukov
7 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, thanks for the report!

We're already tracking this issue in #16856.

Note: See TracTickets for help on using tickets.