wp_widgets_add_menu()WP 2.2.0

Appends the Widgets menu to the themes main menu.

Хуков нет.

Возвращает

null. Ничего (null).

Использование

wp_widgets_add_menu();

Заметки

  • Global. Массив. $submenu

Список изменений

С версии 2.2.0 Введена.
С версии 5.9.3 Don't specify menu order when the active theme is a block theme.

Код wp_widgets_add_menu() WP 6.4.3

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 );
}