我一直在使用add\\u tab在Customizer中添加带有默认图像的选项卡。它已被弃用,不再适用于WordPress 4.1。如何创建/找到替代方案?
add_action( \'customize_register\',\'add_pattern_images\', 12, 1 );
function add_pattern_images( $wp_customize ) {
$control = $wp_customize->get_control( \'aaa[backgroundpattern]\' );
$control->add_tab( \'theme_patterns\', \'Theme Patterns\', \'pattern_images\' );
}
function pattern_images() {
$backgrounds = array(
\'/library/images/background_pattern/background_pattern_01.png\',
\'/library/images/background_pattern/background_pattern_02.png\',
\'/library/images/background_pattern/background_pattern_03.png\',
\'/library/images/background_pattern/background_pattern_04.png\',
\'/library/images/background_pattern/background_pattern_05.png\',
\'/library/images/background_pattern/background_pattern_06.png\',
\'/library/images/background_pattern/background_pattern_07.png\',
\'/library/images/background_pattern/background_pattern_08.png\',
\'/library/images/background_pattern/background_pattern_09.png\',
\'/library/images/background_pattern/background_pattern_10.png\',
);
global $wp_customize;
$control = $wp_customize->get_control( \'aaa[backgroundpattern]\' );
foreach ( (array) $backgrounds as $background )
$control->print_tab_image( esc_url_raw( get_template_directory_uri() . $background ) );
}
SO网友:Михаил Семёнов
正如我所看到的,它们完全改变了在customizer中选择的背景图像(或图像)。
根本没有图像选项卡。
但您可以做的是创建一个新类,该类将扩展WP\\u Customize\\u Image\\u Control(或WP\\u Customize\\u Upload\\u Control),并在其中添加一个选项(select或radio)以显示上载或sellect模式。
可能它可以在没有新类的情况下完成,只需添加\\u控制函数来添加字段,并添加litle js来显示隐藏上载和选择模式框。
就个人而言,我不喜欢customizer,所以我对它了解不多,但i\'v looked to code and add\\u tab is gone for shore(