仅当选中复选框时,我才尝试在自定义程序中显示文本区域。我遵循了这篇帖子的指示,但我的文本区域一直隐藏着。任何帮助都将不胜感激!非常感谢。
function map_enabled(){
$tsum_options = get_theme_mod( \'tsum_options\');
if( empty( $tsum_options[\'map_code\'] ) ) {
return false;
}
return true;
}
function tsum_customize_register( $wp_customize ) {
$wp_customize->add_setting( \'tsum_options[show_map]\', array(
\'default\' => false,
\'capability\' => \'edit_theme_options\',
));
// FRONT BOX CHECK - CONTROL
$wp_customize->add_control( \'show_map\', array(
\'label\' => \'Show Goole Map?\',
\'section\' => \'tsum_contact_section\',
\'settings\' => \'tsum_options[show_map]\',
\'type\' => \'checkbox\',
//\'priority\' => 20,
));
// FRONT BOX TEXT - SETTING
$wp_customize->add_setting(\'tsum_options[map_code]\', array(
\'default\' => \'<iframe src=... \',
\'capability\' => \'edit_theme_options\',
));
// FRONT BOX TEXT - CONTROL
$wp_customize->add_control(\'map_code\', array(
\'label\' => \'lll\',
\'description\' => \'To embed a map, follow the steps below.<br>
1.) Open Google Maps. <a href="https://www.google.com/maps" target="_blank">Click here.</a><br>
2.) Search for your Location.<br>
3.) Zoom in - optional.<br>
4.) Change to Earth View - optional.<br>
5.) Click on Share<br>
6.) Click on Embed<br>
7.) Select Size => Custom Size.<br>
8.) Type in: 980 x 300<br>
9.) Copy the iframe code<br>
10.) Paste it below<br>
11.) Click on Save and Publish\',
\'section\' => \'tsum_contact_section\',
\'type\' => \'textarea\',
\'setting\' => \'tsum_options[map_code]\',
\'active_callback\' => \'map_enabled\',
));
}
add_action( \'customize_register\', \'tsum_customize_register\' );