[wp-trac] [WordPress Trac] #63633: Post Types with numeric characters in the slug are not searchable within the nav menu

WordPress Trac noreply at wordpress.org
Fri Jun 27 18:07:54 UTC 2025


#63633: Post Types with numeric characters in the slug are not searchable within
the nav menu
--------------------------+-----------------------------
 Reporter:  kshaner       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Menus         |    Version:  6.8
 Severity:  major         |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When a post type is registered, the slug is run through sanitize_key.

 The docblock for sanitize_key:

 {{{
 Keys are used as internal identifiers. Lowercase alphanumeric characters,
 dashes, and underscores are allowed.
 }}}

 When a post type is registered with a numeric character, the function
 _wp_ajax_menu_quick_search contains a regex that tries to match the post
 type from the request payload $_POST['type'] which contains a payload
 formatted like: quick-search-posttype-post or quick-search-posttype-page.

 However when a numeric character is in the post type slug, the regex that
 validates the post type does not allow numeric characters.

 The current call is:
 {{{
 preg_match( '/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type,
 $matches ) )
 }}}

 To match the allowed formats of sanitize_key, this regex should be
 modified to:

 {{{
 preg_match( '/quick-search-(posttype|taxonomy)-([a-zA-Z0-9_-]*\b)/',
 $type, $matches ) )
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63633>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list