esc_html__("Ajax Posts", '7mag'), "base" => "YT_ajaxpost",-6ren">
gpt4 book ai didi

wordpress - 如何在视觉 Composer 中添加多选类别

转载 作者:行者123 更新时间:2023-12-02 23:24:02 24 4
gpt4 key购买 nike

如何为视觉编辑器添加多重选择器?

vc_map( array(
"name" => esc_html__("Ajax Posts", '7mag'),
"base" => "YT_ajaxpost",
"icon" => "YT_vc_ico_ajaxpost",
"class" => "YT_vc_sc_ajaxpost",
"category" => esc_html__("7mag", '7mag'),
"params" => array(
array(
"type" => "dropdown",
"heading" => esc_html__("Style", '7mag'),
"param_name" => "multiple",
"value" => $categories_array,
),
) );

例如: link

最佳答案

您需要注册新的短代码属性。

// Create multi dropdown param type
vc_add_shortcode_param( 'dropdown_multi', 'dropdown_multi_settings_field' );
function dropdown_multi_settings_field( $param, $value ) {
$param_line = '';
$param_line .= '<select multiple name="'. esc_attr( $param['param_name'] ).'" class="wpb_vc_param_value wpb-input wpb-select '. esc_attr( $param['param_name'] ).' '. esc_attr($param['type']).'">';
foreach ( $param['value'] as $text_val => $val ) {
if ( is_numeric($text_val) && (is_string($val) || is_numeric($val)) ) {
$text_val = $val;
}
$text_val = __($text_val, "js_composer");
$selected = '';

if(!is_array($value)) {
$param_value_arr = explode(',',$value);
} else {
$param_value_arr = $value;
}

if ($value!=='' && in_array($val, $param_value_arr)) {
$selected = ' selected="selected"';
}
$param_line .= '<option class="'.$val.'" value="'.$val.'"'.$selected.'>'.$text_val.'</option>';
}
$param_line .= '</select>';

return $param_line;
}

然后使用它:

array(
"type" => "dropdown_multi",
"heading" => esc_html__("Style", '7mag'),
"param_name" => "multiple",
"value" => $categories_array,
),

关于wordpress - 如何在视觉 Composer 中添加多选类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47379145/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com