wp_widgets_add_menu

函数
wp_widgets_add_menu ( No parameters )

wp_widgets_add_menu – 这个函数用来在WordPress仪表盘菜单中添加一个小工具管理界面的菜单项。

将Widgets菜单添加到主题的主菜单中。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
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 ); }
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 );
}

常见问题

FAQs
查看更多 >