kirki-framework / control-slider
Kirki自定义框架的范围滑块控件
此包的官方仓库似乎已不存在,因此该包已被冻结。
v1.0.5
2022-01-18 06:31 UTC
Requires
- php: >=7.0
- kirki-framework/control-base: *
README
Kirki自定义框架的滑块控件包。
目录
安装
首先,使用composer安装此包
composer require kirki-framework/control-slider
然后确保您已包含自动加载器
require_once "your/path/to/vendor/autoload.php";
使用方法
可以使用Kirki API或WordPress自定义API使用此控件。
使用简化API
new \Kirki\Field\Slider( [ 'settings' => 'your_control_setting_id', 'label' => esc_html__( 'Your Control Label', 'your-text-domain' ), 'description' => esc_html__( 'Your control description.', 'your-text-domain' ), 'section' => 'your_section_id', 'default' => 5, 'choices' => [ 'min' => 0, 'max' => 100, 'step' => 1, ], ] );
使用自定义API
/** * Register customizer settings and controls. * * @param \WP_Customize_Manager $wp_customize The Customizer object. */ function your_customize_register_function( $wp_customize ) { // Add setting. $wp_customize->add_setting( 'your_control_setting_id', [ 'type' => 'theme_mod', // Or 'option'. 'capability' => 'edit_theme_options', 'default' => 5, 'transport' => 'postMessage', // Or 'refresh'. 'sanitize' => 'intval', // Or 'absint' or other int sanitization. ] ); // Add control. $wp_customize->add_control( new \Kirki\Control\Slider( $wp_customize, 'your_control_setting_id', [ 'label' => esc_html__( 'Your Control Label', 'your-text-domain' ), 'description' => esc_html__( 'Your control description.', 'your-text-domain' ), 'section' => 'your_section_id', 'choices' => [ 'min' => 0, 'max' => 100, 'step' => 1, ], ] ) ); // Add more settings... // Add more controls... } add_action( 'customize_register', 'your_customize_register_function' );
开发
如果您想修改此控件,可以编辑位于src
文件夹中的JS文件。
- 如果您尚未安装包,请运行
npm install
- 编辑完成后,运行
npm run build