WordPressのカスタマイズ画面でのフォーム項目の出し分け active_callback
これからはFSEの時代ですがまだカスタマイザも2年くらいは現役だろうなという事で覚書。
add_action( 'customize_register', 'lightning_customize_register_basic' );
function lightning_customize_register_basic( $wp_customize ) {
$wp_customize->add_section(
'lightning_basic',
array(
'title' => __( 'Basic settings', 'lightning' ),
)
);
$wp_customize->add_setting( 'demo_radio_control', array(
'default' => 'a',
) );
$wp_customize->add_control( 'demo_radio_control', array(
'label' => 'radio_control',
'section' => 'lightning_basic',
'settings' => 'demo_radio_control',
'type' => 'radio',
'choices' => array(
'a' => 'Choice A',
'b' => 'Choice B',
),
) );
$wp_customize->add_setting( 'choice_a_text', array(
'default' => '',
) );
$wp_customize->add_control( 'choice_a_text', array(
'label' => 'Choice A: ',
'section' => 'lightning_basic',
'type' => 'text',
'active_callback' => 'choice_a_callback',
) );
function choice_a_callback( $control ) {
if ( $control->manager->get_setting('demo_radio_control')->value() == 'a' ) {
return true;
} else {
return false;
}
}
}
参照
http://ottopress.com/2015/whats-new-with-the-customizer/
Special Thanks
@Toro_Unit
Author And Source
この問題について(WordPressのカスタマイズ画面でのフォーム項目の出し分け active_callback), 我々は、より多くの情報をここで見つけました https://qiita.com/kurudrive/items/ea79f5803e94a7633a1b著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .