_add_post_type_submenus

The timeline below displays how wordpress function _add_post_type_submenus has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Adds submenus for post types.
 *
 * @access private
 * @since 3.1.0
 */
function _add_post_type_submenus()
{
    foreach (get_post_types(array('show_ui' => true)) as $ptype) {
        $ptype_obj = get_post_type_object($ptype);
        // Sub-menus only.
        if (!$ptype_obj->show_in_menu || true === $ptype_obj->show_in_menu) {
            continue;
        }
        add_submenu_page($ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type={$ptype}");
    }
}

WordPress Version: 5.4

/**
 * Add submenus for post types.
 *
 * @access private
 * @since 3.1.0
 */
function _add_post_type_submenus()
{
    foreach (get_post_types(array('show_ui' => true)) as $ptype) {
        $ptype_obj = get_post_type_object($ptype);
        // Sub-menus only.
        if (!$ptype_obj->show_in_menu || true === $ptype_obj->show_in_menu) {
            continue;
        }
        add_submenu_page($ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type={$ptype}");
    }
}

WordPress Version: 4.0

/**
 * Add submenus for post types.
 *
 * @access private
 * @since 3.1.0
 */
function _add_post_type_submenus()
{
    foreach (get_post_types(array('show_ui' => true)) as $ptype) {
        $ptype_obj = get_post_type_object($ptype);
        // Sub-menus only.
        if (!$ptype_obj->show_in_menu || $ptype_obj->show_in_menu === true) {
            continue;
        }
        add_submenu_page($ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type={$ptype}");
    }
}

WordPress Version: 3.7

/**
 * Adds submenus for post types.
 *
 * @access private
 * @since 3.1.0
 */
function _add_post_type_submenus()
{
    foreach (get_post_types(array('show_ui' => true)) as $ptype) {
        $ptype_obj = get_post_type_object($ptype);
        // Submenus only.
        if (!$ptype_obj->show_in_menu || $ptype_obj->show_in_menu === true) {
            continue;
        }
        add_submenu_page($ptype_obj->show_in_menu, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, "edit.php?post_type={$ptype}");
    }
}