_wp_menus_changed

函式
_wp_menus_changed ( No parameters )

_wp_menus_changed: 這個函式在選單被改變時被呼叫,可以是新增、編輯或刪除選單。

在主題改變後處理選單配置。

function _wp_menus_changed() {
	$old_nav_menu_locations    = get_option( 'theme_switch_menu_locations', array() );
	$new_nav_menu_locations    = get_nav_menu_locations();
	$mapped_nav_menu_locations = wp_map_nav_menu_locations( $new_nav_menu_locations, $old_nav_menu_locations );

	set_theme_mod( 'nav_menu_locations', $mapped_nav_menu_locations );
	delete_option( 'theme_switch_menu_locations' );
}

常見問題

FAQs
檢視更多 >