Я ищу способ удалить раздел font_selection
и переместить body_font_family
управления body_font_family
прямо на панель font_panel
с помощью functions.php
Child Theme functions.php
. Ниже приведен пример CODE из 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 ) );
Предполагая, что родительская тема работает над указанным выше кодом в customize_register
priority 10, вам просто нужно добавить еще один callback-запрос 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 );
Можно ли перемещать виджеты в другой раздел?
Как sidebar_widgets хотите переместить my_section
$sidebars_widgets_control = $wp_customize->get_control( 'sidebars_widgets-foot_sidebar' ); if ( $sidebars_widgets_control ) { $sidebars_widgets_control->section = 'my_settings'; } }, 20 );