nsrosenqvist/cmb2-nav-menus

此包已被 废弃 且不再维护。未建议替代包。

安装: 38

依赖项: 0

建议者: 0

安全: 0

星标: 3

关注者: 2

分支: 0

开放问题: 1

类型:wordpress-plugin

1.0.1 2018-06-19 09:36 UTC

This package is auto-updated.

Last update: 2020-06-09 20:09:57 UTC


README

允许您在导航菜单条目中使用 CMB2。

注册菜单位置以启用 CMB2

// Add filter for locations
add_filter('cmb2_nav_menus', function($menu_slugs) {
    $menu_slugs[] = 'my_menu';

    return $menu_slugs;
}, 10, 1);

为菜单注册 CMB2 字段

// For all menus
add_filters('cmb2_nav_menu_fields, function($fields) {
    // You can set ID both as the key and in the array
    $fields['icon-class'] = [
        'name' => __( 'Icon Class', 'theme' ),
        'type' => 'fontawesome_icon',
        'help' => 'Choose a FontAwesome icon class name (eg. fa-circle)',
    ];
}, 10, 1);

// For specific menu
add_filters('cmb2_nav_menu_fields_my_menu, function($fields) {
    // You can set ID both as the key and in the array
    $fields['disabled'] = [
        'name' => __( 'Disabled', 'theme' ),
        'type' => 'checkbox',
        'style' => 'thin',
    ];
}, 10, 1);

使用包含的助手获取导航菜单项选项

cmb2_get_nav_option($menu_item_id, $key = '', $default = null);