diazoxide/wp-lib-option 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

diazoxide/wp-lib-option

Composer 安装命令:

composer require diazoxide/wp-lib-option

包简介

WordPress Option

README 文档

README

Create dynamic admin settings page with flexible configurations.

Methods

  • Single
  • Multiple

Types

  • Boolean
  • Text
  • Object
  • Group

Markup

  • Text
  • Checkbox
  • Select
  • Number
  • Textarea

Screenshot_1

How to install

Install with composer

On your custom plugin directory run this composer command

composer require diazoxide/wp-lib-option:dev-master

Or add in your composer.json require field

{
 "require": {
    "diazoxide/wp-lib-option": "dev-master"
  }
}

How to use

For example we have multidimensional array $config that have one static value name, two dynamic values country and other->is_solder.

country field should be set by user from admin side

use diazoxide\wp\lib\option\v2\Option;

$config = [
    'name'=>'Arthur',
    'country' => new Option(
        [
            'default'     => 'uk',
            'type'        => Option::TYPE_TEXT,
            'method'      => Option::METHOD_SINGLE,
            'values'      => [
                'fr'=>"France",
                'uk'=>"United Kingdom",
                'it'=>"Italy"
            ],
            'label'       => 'Country',
            'description' => 'Select country.'
        ]
    ),
    'other'=>[
        'is_solder'=>new Option(
             [
                 'default'     => false,
                 'type'        => Option::TYPE_BOOL,
                 'label'       => 'Solder or not'
             ]
         )
    ]
];

Print this config form

Option::printForm(
    'custom_index_key_for_config',
    $config,
    [
        'title' => 'Arthur Configuration'
    ]
);

If change values from printed form and click save, then all changes will be stored on wp_options table with custom custom_index_key_for_config prefix.

Getting final values of this options

$options = Option::expandOptions(
    $config,
    'custom_index_key_for_config'
);

So we have already expanded options with dynamic and static values. You can use it simply.

For example

echo $options['name']; // Output: Arthur

echo $options['country']; // Output is dynamic. Default value is `fr`

var_dump($options['other']['is_solder']); // Output is dynamic. Default value is `false`

统计信息

  • 总下载量: 481
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2020-01-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固