在自定义可视化合成器项中选择类型

问题描述 投票:3回答:1

我正在尝试为我的主题制作一个自定义的视觉作曲家项目。到目前为止,我把事情做好了。但是在这里,我想为我的项目做出选择以检查它是否是第一个值显示的东西,如果是第二个值显示其他东西等等。但我不知道如何选择。这是我的映射部分中的php文件代码:

<?php
// Element Mapping
    public function vc_showcase_mapping() {
         
        // Stop all if VC is not enabled
        if ( !defined( 'WPB_VC_VERSION' ) ) {
            return;
        }
         
        // Map the block with vc_map()
        vc_map( 
            array(
                'name' => __('Showcase', 'filmview'),
                'base' => 'vc_showcase',
                'description' => __('Showcase', 'filmview'), 
                'category' => __('filmview', 'filmview'),   
                'icon' => get_template_directory_uri().'/vc-elements/img/vc-showcase.png',            
                'params' => array(   
                         
                    array(
                        'type' => 'input',
                        'holder' => '',
                        'class' => '',
                        'heading' => __( 'Showcase type', 'filmview' ),
                        'param_name' => 'showcase-type',
                        'value' => __( 'showcase-1', 'filmview' ),
                        'description' => __( 'select type', 'filmview' ),
                        'admin_label' => false,
                        'weight' => 0,
                        'group' => 'settings',
                    ),                        
                ),
            )
        );                                
        
    }
 ?>
php wordpress visual-composer
1个回答
1
投票

我得到了答案,这里有:

我只需要将'value' => __( 'showcase-1', 'filmview' ),更改为:

'value' => array(
array(
'value' => 'showcase-1',
'label' => __( 'showcase type 1', 'filmview' ),
),
array(
'value' => 'showcase-2',
'label' => __( 'showcase type 2', 'filmview' ),
),
)
© www.soinside.com 2019 - 2024. All rights reserved.