我正在使用一个商业主题,它在WordPress的外观/定制器中有主题设置。他们通过这样的函数调用设置:(这只是函数的一部分,大约有400行长)
function customizer_library_gateway_options() {
// Home
$section = \'home\';
$sections[] = array(
\'id\' => $section,
\'title\' => __( \'Home\', \'gateway\' ),
\'priority\' => \'20\',
\'description\' => __( \'Home Page Options.\', \'gateway\' ),
\'panel\' => $panel
);
$options[\'home_hero_bg\'] = array(
\'id\' => \'home_hero_bg\',
\'label\' => __( \'Home Background Image\', \'gateway\' ),
\'section\' => $section,
\'type\' => \'image\',
\'default\' => $imagepath . \'hero-bg.jpg\',
\'active_callback\' => \'is_front_page\'
);
$options[\'bg_attachement\'] = array(
\'id\' => \'bg_attachement\',
\'label\' => __( \'Select the behavior of the background image.\', \'gateway\' ),
\'section\' => $section,
\'type\' => \'select\',
\'choices\' => $bg_attachment,
\'default\' => \'fixed\',
\'active_callback\' => \'is_front_page\'
);
$options[\'home_hero_bg_color\'] = array(
\'id\' => \'home_hero_bg_color\',
\'label\' => __( \'Home Hero background color if no image is being used.\', \'gateway\' ),
\'section\' => $section,
\'type\' => \'color\',
\'default\' => $primary_color,
\'active_callback\' => \'is_front_page\',
\'transport\' => \'postMessage\'
);
$options[\'home_posts_title\'] = array(
\'id\' => \'home_posts_title\',
\'label\' => __( \'Enter the home featured posts section title\', \'gateway\' ),
\'section\' => $section,
\'type\' => \'text\',
\'default\' => \'Featured Posts\',
\'active_callback\' => \'is_front_page\',
\'transport\' => \'postMessage\'
);
$options[\'home_posts_cat\'] = array(
\'id\' => \'home_posts_cat\',
\'label\' => __( \'Home Posts Category\', \'gateway\' ),
\'section\' => $section,
\'type\' => \'select\',
\'choices\' => $options_cats,
\'default\' => \'\',
\'active_callback\' => \'is_front_page\'
);
}
add_action( \'init\', \'customizer_library_gateway_options\' );
My question is: How can I add to this array through my child theme so I can add a logo option? I don\'t necessarily want to re-declare the whole function if I can just add my array insertion:
我在考虑添加过滤器,但我不确定。这是我在我的子主题函数中尝试的。php:
function customizer_library_gateway_home_logo() {
$options[\'home_logo\'] = array(
\'id\' => \'home_logo\',
\'label\' => __( \'Logo\', \'gateway\' ),
\'section\' => \'home\',
\'type\' => \'image\',
\'default\' => $imagepath . \'logo.png\'
);
}
add_filter( \'customizer_library_gateway_options\', \'customizer_library_gateway_home_logo\' );
但是,主题自定义程序没有更改。如果我直接在主题的原始文件中添加home\\u徽标条目,它确实会起作用。也许我应该采取不同的行动?