Make WordPress Core

Opened 6 years ago

Closed 5 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's profile stiofansisland Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Menus Keywords: has-patch dev-feedback
Focuses: administration Cc:


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 6 years ago.

Download all attachments as: .zip

Change History (5)

6 years ago

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

6 years ago

#2 follow-up: @earnjam
6 years 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
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.

Do you want me to recreate the patch from root?



#4 @SergeyBiryukov
5 years 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.