Wordpress定制器中的菜单面板

时间:2015-09-01 06:21:32

标签: wordpress

我正在尝试使用以下代码删除wordpress自定义程序中的菜单面板,但它无法正常工作。有人请指导我。谢谢

$wp_customize->remove_panel( 'nav_menus' );

2 个答案:

答案 0 :(得分:5)

有2张Trac门票可以解决这个问题。完整的解决方案是

add_action( 'customize_register', function( $wp_customize ) {
        /** @var WP_Customize_Manager $wp_customize */
        remove_action( 'customize_controls_enqueue_scripts', array( $wp_customize->nav_menus, 'enqueue_scripts' ) );
        remove_action( 'customize_register', array( $wp_customize->nav_menus, 'customize_register' ), 11 );
        remove_filter( 'customize_dynamic_setting_args', array( $wp_customize->nav_menus, 'filter_dynamic_setting_args' ) );
        remove_filter( 'customize_dynamic_setting_class', array( $wp_customize->nav_menus, 'filter_dynamic_setting_class' ) );
        remove_action( 'customize_controls_print_footer_scripts', array( $wp_customize->nav_menus, 'print_templates' ) );
        remove_action( 'customize_controls_print_footer_scripts', array( $wp_customize->nav_menus, 'available_items_template' ) );
        remove_action( 'customize_preview_init', array( $wp_customize->nav_menus, 'customize_preview_init' ) );
}, 10 );

更多详情:

https://core.trac.wordpress.org/ticket/33552

https://core.trac.wordpress.org/ticket/33411

在旧版本的wordpress(< 4.3)中,这有效,但不是现在:

function your_customizer( $wp_customize ) {
$wp_customize->remove_panel( 'widgets' );
}
add_action( 'customize_register', 'your_customizer' );

答案 1 :(得分:1)

谢谢dingo_d,这对我也有用。 顺便说一下,$wp_customize->remove_panel('widgets);仍适用于Wordpress v.4.5.1