定制器中的面板描述未显示

时间:2016-11-09 作者:Sebastian Kaczmarek

如上所述,当我将面板添加到Customizer时,其描述不会显示。此外,节描述显示正确。此外,DOM中的元素存在,但它display:none; 属性继承自某些默认样式。这就是我正在做的:

$wp_customize->add_panel(\'mypanel\', array(
    \'title\'         => __(\'My awesome panel\', \'domain\'),
    \'description\'   => __("This is the description which doesn\'t want to show up :(", \'domain\'),
    \'capability\'    => \'edit_theme_options\',
    \'priority\'      => 2
));

$wp_customize->add_section(\'mysection\', array(
    \'title\'    => __(\'My even more awesome section\', \'domain\'),
    \'panel\'    => \'mypanel\',
    \'description\' => __(\'Section description which does show up\', \'domain\')
));

$wp_customize->add_setting(\'mysetting\', array(
    \'settings\'          => \'mysection\',
    \'capability\'        => \'edit_theme_options\',
    \'sanitize_callback\' => \'sanitize_text_field\'
    ));

$wp_customize->add_control(\'mycontrol\', array(
    \'label\'   => __(\'The most awesome control\', \'domain\'),
    \'section\' => \'mysection\',
    \'type\'    => \'text\'
));
就像我说的,描述<div> 实际上存在于DOM结构中,但其CSS样式阻止其显示:

HTML:
enter image description here

CSS:
enter image description here

QUESTION: 为什么会发生这种情况,我如何才能使描述可见?

1 个回复
最合适的回答,由SO网友:Dave Romsey 整理而成

我需要稍微调整一下设置和控件代码,以使它们正常工作:

$wp_customize->add_panel(\'mypanel\', array(
        \'title\'         => __(\'My awesome panel\', \'domain\'),
        \'description\'   => __("This is the description which doesn\'t want to show up :(", \'domain\'),
        \'capability\'    => \'edit_theme_options\',
        \'priority\'      => 2
));

$wp_customize->add_section(\'mysection\', array(
        \'title\'    => __(\'My even more awesome section\', \'domain\'),
        \'panel\'    => \'mypanel\',
        \'description\' => __(\'Section description which does show up\', \'domain\')
));

$wp_customize->add_setting(\'mysetting\', array(
        \'capability\'        => \'edit_theme_options\',
        \'sanitize_callback\' => \'sanitize_text_field\'
        ));

$wp_customize->add_control(\'mycontrol\', array(
        \'settings\' => \'mysetting\',
        \'label\'   => __(\'The most awesome control\', \'domain\'),
        \'section\' => \'mysection\',
        \'type\'    => \'text\'
));
这里的主要内容是,面板描述仅在? 单击图标:

Reveal Panel description

相关推荐