我试图在自定义程序的“菜单”面板中添加一个复选框,但由于某些原因,它没有显示出来。如果我尝试将其从“nav\\u菜单”更改为“title\\u tagline”或“colors”,复选框会显示得很好。是什么阻止它显示在“菜单”面板上?
// add custom options to the Customizer
function nssra_customizer_options($wp_customize) {
// add "menu primary flex" checkbox setting
$wp_customize->add_setting("menu_primary_flex", array(
"capability" => "edit_theme_options",
"default" => "1",
"sanitize_callback" => "nssra_sanitize_checkbox",
));
// add "menu primary flex" checkbox control
$wp_customize->add_control("menu_primary_flex", array(
"label" => __("Stretch the primary menu to fill the available space.", "nssra"),
"section" => "nav_menus",
"settings" => "menu_primary_flex",
"std" => "1",
"type" => "checkbox",
"priority" => 1,
));
}
add_action("customize_register", "nssra_customizer_options");
// sanitize checkbox fields
function nssra_sanitize_checkbox($input, $setting) {
return sanitize_key($input) === "1" ? 1 : 0;
}