threadi / wp-easy-setup
为WordPress后端提供简单的由React驱动的插件设置。
1.2.2
2024-09-13 12:57 UTC
- dev-master
- 1.2.2
- 1.2.1
- 1.2.0
- 1.0.4
- dev-fix/addOptionParameter
- dev-feature/checkForDirectory
- dev-feature/addSkipOption
- dev-fix/compatiblityWithPreWp66
- dev-feature/addVendorPathConfig
- dev-feature/addFieldsReloading
- dev-fix/missingErrorMessages
- dev-fix/betterCheckForFieldsToMark
- dev-feature/updateVendorDirDetection
- dev-feature/optimizeEmbedding
- dev-feature/optimizeHandling
This package is auto-updated.
Last update: 2024-09-13 12:58:12 UTC
README
需求
- 使用composer安装此包。
- 使用npm编译脚本。
- 使用此设置的WordPress插件
安装
composer require threadi/wp-easy-setup- 切换到
vendor/thread/wp-easy-setup - 运行
npm i安装依赖项。 - 运行
npm run build编译脚本。
用法
嵌入
将此代码添加到您想要显示设置的页面中。
$setup_obj = \wpEasySetup\Setup::get_instance();
$setup_obj->set_url( 'website-URL' );
$setup_obj->set_path( 'website-path' );
$setup_obj->set_texts( array(
'title_error' => __( 'Error', 'your-text-domain' ),
'txt_error_1' => __( 'The following error occurred:', 'your-text-domain' ),
'txt_error_2' => __( 'text after error', 'your-text-domain' ),
) );
$setup_obj->set_config( array( /* your custom setup configuration */ ) );
$setup_obj->display( 'your-setup-name' );
提示:第1到4行应在任何输出之前运行,例如通过'admin_init'钩子。
自定义配置
数组必须包含以下条目
- name => 设置的唯一名称(例如,插件短名)
- title => 设置的标题,用于其标题的语言特定版本
- steps => 步骤列表(见下文)
- back_button_label => 语言特定的后退按钮标题
- continue_button_label => 语言特定的继续按钮标题
- finish_button_label => 语言特定的完成按钮标题
步骤
步骤定义为索引为步骤编号的数组,值为字段配置。示例
1 => array( /* fields in step 1 */ ),
2 => array( /* fields in step 2 */ )
字段配置定义为以下结构的数组
1 => array(
'field_1_name' => array(
'type' => 'field-type',
'label' => __( 'the label', 'your-text-domain' ),
'help' => __( 'the help text', 'your-text-domain' ),
'placeholder' => __( 'the placeholder', 'your-text-domain' ),
'required' => true, // true if required for next step
'validation_callback' => 'example::validate', // PHP-callback to validate the entry
),
'field_2_name' => array(
'type' => 'field-type',
'label' => __( 'the label', 'your-text-domain' ),
'help' => __( 'the help text', 'your-text-domain' ),
'placeholder' => __( 'the placeholder', 'your-text-domain' ),
'required' => true, // true if required for next step
'validation_callback' => 'example::validate', // PHP-callback to validate the entry
),
字段类型
以下字段类型受支持
- CheckboxControl => 显示简单的“是/否”复选框
- ProgressBar => 显示进度条,它将通过“wp_easy_setup_process”钩子定义的处理过程
- RadioControl => 显示一组单选按钮,用户应选择要选择的内容
- TextControl => 显示单个输入文本字段
- Text => 显示您在数组键“text”中定义的文本
其他数组键
- label => 字段上方的标签
- help => 在字段下方显示html格式化的文本
- placeholder => 在支持的字段上用作占位符
- required => 如果字段是下一步必需的,则为true
- validation_callback => 用于验证输入的PHP回调