__( '导航菜单', 'Bing' ), 'footer_menu' => __( '页脚菜单', 'Bing' ) ) ); } add_action( 'after_setup_theme', 'Bing_register_nav_menus', 6 ); /** * 获取菜单名称 * * @see get_registered_nav_menus() * @see wp_get_nav_menu_object() */ function Bing_menu_name( $menu ){ $locations = get_registered_nav_menus(); $menu_locations = get_nav_menu_locations(); if( empty( $menu_locations[$menu] ) ) return $locations[$menu]; $menu_object = wp_get_nav_menu_object( $menu_locations[$menu] ); if( empty( $menu_object ) || is_wp_error( $menu_object ) ) return $locations[$menu]; return $menu_object->name; } /** * 导航菜单未设置回调函数 * * @see wp_nav_menu() */ function Bing_not_set_menu_fallback( $args ){ $menus = array( array( 'url' => home_url(), 'name' => __( '首页', 'Bing' ), 'current' => is_home() ), array( 'url' => admin_url( 'nav-menus.php?action=locations' ), 'name' => __( '⊕添加菜单', 'Bing' ) ) ); $code = '