0

当我尝试从 wp_customize 设置输出一些多个复选框选项时,我收到非法字符串偏移警告。

    $wp_customize->add_control( new Customizer_Simple_Checkbox_Control( $wp_customize, 'single_share_box_options',
array(
    'label' => __( 'Share Box Options', 'custom' ),
    'description' => esc_html__( 'Select share box options.', 'custom' ),
    'section' => 'single_post_general_section',
    'active_callback' => 'quanticthemes_share_box_condition',
    'input_attrs' => array(
        'sortable' => false,
        'fullwidth' => true,
    ),
    'choices' => array(
        'facebook' => esc_html__('Facebook', 'custom'),
        'twitter' => esc_html__('Twitter', 'custom'),
        'linkedin' => esc_html__('Linkedin', 'custom'),
        'pinterest' => esc_html__('Pinterest', 'custom'),
        'telegram' => esc_html__('Telegram', 'custom'),
        'email' => esc_html__('Email', 'custom'),
        'whatsapp' => esc_html__('WhatsApp', 'custom'),
        'link' => esc_html__('Link Box', 'custom'),
    ),
)
) );

然后我尝试像这样输出,但我收到非法字符串偏移警告:

    $social = get_theme_mod('single_share_box_options');
    <?php if( $social['facebook'] ): ?>
    <div>My content</div>
    <?php endif; ?>
    <?php if( $social['twitter'] ): ?>
    <div>My content</div>
    <?php endif; ?>
4

0 回答 0