$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group.
$types =
(array) get_post_types( array
( 'show_ui' => true,
'_builtin' => false,
'show_in_menu' => true,
));
$builtin = array
( 'post', 'page'
);
foreach ( array_merge( $builtin,
$types ) as $ptype ) { $ptype_obj =
get_post_type_object( $ptype );
// Check if it should be a submenu.
if ( true !==
$ptype_obj->show_in_menu
) { continue;
} $ptype_menu_position =
is_int( $ptype_obj->menu_position
) ?
$ptype_obj->menu_position : ++
$_wp_last_object_menu; // If we're to use $_wp_last_object_menu, increment it first.
$ptype_for_id =
sanitize_html_class( $ptype );
$menu_icon = 'dashicons-admin-post';
if ( is_string( $ptype_obj->menu_icon
) ) { // Special handling for data:image/svg+xml and Dashicons.
if ( str_starts_with( $ptype_obj->menu_icon, 'data:image/svg+xml;base64,'
) ||
str_starts_with( $ptype_obj->menu_icon, 'dashicons-'
) ) {