wp_widgets_add_menu

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

WordPress Version: 6.5

/**
 * Appends the Widgets menu to the themes main menu.
 *
 * @since 2.2.0
 * @since 5.9.3 Don't specify menu order when the active theme is a block theme.
 *
 * @global array $submenu
 */
function wp_widgets_add_menu()
{
    global $submenu;
    if (!current_theme_supports('widgets')) {
        return;
    }
    $menu_name = __('Widgets');
    if (wp_is_block_theme() || current_theme_supports('block-template-parts')) {
        $submenu['themes.php'][] = array($menu_name, 'edit_theme_options', 'widgets.php');
    } else {
        $submenu['themes.php'][8] = array($menu_name, 'edit_theme_options', 'widgets.php');
    }
    ksort($submenu['themes.php'], SORT_NUMERIC);
}

WordPress Version: 6.1

/**
 * Appends the Widgets menu to the themes main menu.
 *
 * @since 2.2.0
 * @since 5.9.3 Don't specify menu order when the active theme is a block theme.
 *
 * @global array $submenu
 */
function wp_widgets_add_menu()
{
    global $submenu;
    if (!current_theme_supports('widgets')) {
        return;
    }
    $menu_name = __('Widgets');
    if (wp_is_block_theme() || current_theme_supports('block-template-parts')) {
        $submenu['themes.php'][] = array($menu_name, 'edit_theme_options', 'widgets.php');
    } else {
        $submenu['themes.php'][7] = array($menu_name, 'edit_theme_options', 'widgets.php');
    }
    ksort($submenu['themes.php'], SORT_NUMERIC);
}

WordPress Version: 9.3

/**
 * Append the Widgets menu to the themes main menu.
 *
 * @since 2.2.0
 * @since 5.9.3 Don't specify menu order when the active theme is a block theme.
 *
 * @global array $submenu
 */
function wp_widgets_add_menu()
{
    global $submenu;
    if (!current_theme_supports('widgets')) {
        return;
    }
    $menu_name = __('Widgets');
    if (wp_is_block_theme()) {
        $submenu['themes.php'][] = array($menu_name, 'edit_theme_options', 'widgets.php');
    } else {
        $submenu['themes.php'][7] = array($menu_name, 'edit_theme_options', 'widgets.php');
    }
    ksort($submenu['themes.php'], SORT_NUMERIC);
}

WordPress Version: 4.3

/**
 * Append the Widgets menu to the themes main menu.
 *
 * @since 2.2.0
 *
 * @global array $submenu
 */
function wp_widgets_add_menu()
{
    global $submenu;
    if (!current_theme_supports('widgets')) {
        return;
    }
    $submenu['themes.php'][7] = array(__('Widgets'), 'edit_theme_options', 'widgets.php');
    ksort($submenu['themes.php'], SORT_NUMERIC);
}

WordPress Version: 4.1

/**
 * Append the Widgets menu to the themes main menu.
 *
 * @since 2.2.0
 */
function wp_widgets_add_menu()
{
    global $submenu;
    if (!current_theme_supports('widgets')) {
        return;
    }
    $submenu['themes.php'][7] = array(__('Widgets'), 'edit_theme_options', 'widgets.php');
    ksort($submenu['themes.php'], SORT_NUMERIC);
}

WordPress Version: 4.0

/**
 * Append the Widgets menu to the themes main menu.
 *
 * @since 2.2.0
 *
 * @uses $submenu The administration submenu list.
 */
function wp_widgets_add_menu()
{
    global $submenu;
    if (!current_theme_supports('widgets')) {
        return;
    }
    $submenu['themes.php'][7] = array(__('Widgets'), 'edit_theme_options', 'widgets.php');
    ksort($submenu['themes.php'], SORT_NUMERIC);
}

WordPress Version: 3.7

/**
 * Append the Widgets menu to the themes main menu.
 *
 * @since 2.2.0
 * @uses $submenu The administration submenu list.
 */
function wp_widgets_add_menu()
{
    global $submenu;
    if (!current_theme_supports('widgets')) {
        return;
    }
    $submenu['themes.php'][7] = array(__('Widgets'), 'edit_theme_options', 'widgets.php');
    ksort($submenu['themes.php'], SORT_NUMERIC);
}