helgatheviking / kia-customizer-range-control
WordPress自定义工具栏的范围滑动控制器。
1.1.0
2023-08-08 14:09 UTC
Requires
- php: >=7.4
- composer/installers: ~2.0
Requires (Dev)
README
WordPress自定义工具栏的范围控制滑动条
安装
将以下内容添加到您的 composer.json
文件中,并运行 composer update
"repositories": [
{
"type": "git",
"url": "https://github.com/helgatheviking/kia-customizer-range-control.git"
}
],
"require": {
"helgatheviking/kia-customizer-range-control": "dev-main"
},
"extra": {
"installer-paths": {
"includes/{$name}": [
"helgatheviking/kia-customizer-range-control"
]
}
添加控制项
/** * Add range slider to Customizer. * * @param obj $wp_customize */ function kia_customizer( $wp_customize ) { // Include the class require_once dirname( __FILE__ ) . '/includes/kia-customizer-range-control/class-kia-customizer-range-control.php'; // Register the control types that we're using as JavaScript controls. $wp_customize->register_control_type( 'KIA_Customizer_Range_Control' ); $wp_customize->add_setting( 'my_setting', array( 'default' => 3, 'type' => 'option', 'capability' => 'edit_themes', 'transport' => 'postMessage', 'sanitize_callback' => 'absint', 'sanitize_js_callback' => 'absint', ) ); $wp_customize->add_control( new KIA_Customizer_Range_Control( $wp_customize, 'my_control', array( 'type' => 'kia-range', 'label' => __( 'Number of columns', 'your-textomain' ), 'description' => __( 'How many items should be shown per row?', 'your-textdomain' ), 'section' => 'my_section', 'settings' => 'my_setting', 'input_attrs' => array( 'min' => 1, 'max' => 6, 'step' => 1, ), ) ) ); } add_action( 'customize_register', 'kia_customizer' );
致谢
对Rich Tabor的登录设计器和Per Soderlind的自定义工具栏范围值控制器表示极大的敬意。