我正在寻找一种删除该部分的方法font_selection
并移动控件body_font_family
直接到面板font_panel
使用子主题functions.php
. 下面是父主题的示例代码customizer.php
:
//PANEL
$wp_customize->add_panel( \'font_panel\', array(
\'priority\' => 17,
\'capability\' => \'edit_theme_options\',
\'theme_supports\' => \'\',
\'title\' => __(\'Fonts\', \'theme\'),
) );
//SECTION
$wp_customize->add_section(
\'font_selection\',
array(
\'title\' => __(\'Font selection\', \'theme\'),
\'priority\' => 10,
\'panel\' => \'font_panel\',
)
)
);
//SETTING
$wp_customize->add_setting(
\'body_font_family\',
array(
\'sanitize_callback\' => \'theme_sanitize_text\',
\'default\' => $defaults[\'body_font_family\'],
)
);
//CONTROL
$wp_customize->add_control(
\'body_font_family\',
array(
\'label\' => __( \'Body font\', \'theme\' ),
\'section\' => \'font_selection\',
\'type\' => \'text\',
\'priority\' => 12
)
);
SO网友:Weston Ruter
假设父主题在以下位置运行上述代码:customize_register
优先级10,您只需再添加一个customize_register
之后运行的操作回调,如20。但是,不能将控件移动到面板。控件只能位于节的内部。要将控件移动到其他节,可以使用:
add_action( \'customize_register\', function ( WP_Customize_Manager $wp_customize ) {
$wp_customize->remove_section( \'font_selection\' );
$wp_customize->add_section( \'some_other_section\', array(
\'title\' => __( \'Some other section\', \'theme\' ),
) );
$body_font_family_control = $wp_customize->get_control( \'body_font_family\' );
if ( $body_font_family_control ) {
$body_font_family_control->section = \'some_other_section\';
}
}, 20 );