podkot / cmb-field-select2
CMB2的Select2字段类型
2.1.1
2016-10-23 03:15 UTC
This package is not auto-updated.
Last update: 2024-09-18 19:56:47 UTC
README
描述
运行较旧版本的CMB?请查看之前的发布版。
此插件基于Select2脚本提供了两种CMB字段类型
pw_select
字段的作用类似于默认的select
字段。然而,它增加了类似自动补全的搜索功能,让您可以快速从大量列表中进行选择pw_multiselect
字段允许您通过类似自动补全的搜索选择多个值。这些值可以拖放以重新排序
安装
您可以将此字段类型安装得就像安装一个WordPress插件一样
- 下载插件
- 将插件文件夹放入您的
/wp-content/plugins/
目录 - 在插件仪表板上激活插件
或者,您可以将插件文件夹放入您的主题/插件中。在您调用CMB后
require_once 'init.php';
添加另一行以包含cmb-field-select2.php
文件。例如
require_once 'cmb-field-select2/cmb-field-select2.php';
用法
pw_select
- 带有类似自动补全搜索的选择框。示例
array(
'name' => 'Cooking time',
'id' => $prefix . 'cooking_time',
'desc' => 'Cooking time',
'type' => 'pw_select',
'options' => array(
'5' => '5 minutes',
'10' => '10 minutes',
'30' => 'Half an hour',
'60' => '1 hour',
),
),
pw_multiselect
- 带有拖放重新排序的多值选择框。示例
array(
'name' => 'Ingredients',
'id' => $prefix . 'ingredients',
'desc' => 'Select ingredients. Drag to reorder.',
'type' => 'pw_multiselect',
'options' => array(
'flour' => 'Flour',
'salt' => 'Salt',
'eggs' => 'Eggs',
'milk' => 'Milk',
'butter' => 'Butter',
),
),