getolympus/olympus-imageselect-control

带有图片的Radio/Checkbox控件,该组件是Olympus Zeus Core框架的一部分。

v0.0.2 2019-08-19 19:40 UTC

This package is auto-updated.

Last update: 2024-09-20 07:20:23 UTC


README

图像选择控件

此组件是Olympus Zeus Core WordPress框架的一部分。

Olympus Component CodeFactor Grade Packagist Version

安装

在PHP项目中使用composer

composer require getolympus/olympus-imageselect-control

控件初始化

使用以下代码在你的WordPress自定义器中添加图像选择控件

$wp_customize->add_setting('my_imageselect_control_id',[
    'default'           => 'dave',
    'transport'         => 'refresh',
    'sanitize_callback' => 'custom_text_sanitization'
]);

$wp_customize->add_control(new ImageSelect($wp_customize, 'my_imageselect_control_id', [
    'label'       => 'Select a Minion that you may know',
    'description' => 'A very important question! Pay attention to it ;)',
    'column'      => 2,
    'multiple'    => false,
    'section'     => 'my_custom_controls_section',
    'choices'     => [
        'kevin' => [
            'label' => 'Kevin',
            'image' => 'https://vignette.wikia.nocookie.net/despicableme/images/1/1d/Kevin_minions.png/revision/latest/scale-to-width-down/350?cb=20170703052012',
        ],
        'mel'   => [
            'label' => 'Mel',
            'image' => 'https://vignette.wikia.nocookie.net/despicableme/images/2/2e/Mel_Minion_01.png/revision/latest/scale-to-width-down/350?cb=20160717135212',
        ],
        'dave'  => [
            'label' => 'Dave',
            'image' => 'https://vignette.wikia.nocookie.net/despicableme/images/7/71/Daveholdingcupcake.png/revision/latest/scale-to-width-down/350?cb=20130717145735',
        ],
        'bob'   => [
            'label' => 'Bob',
            'image' => 'https://vignette.wikia.nocookie.net/despicableme/images/c/ca/Bob-from-the-minions-movie.jpg/revision/latest/scale-to-width-down/350?cb=20151224154354',
        ],
    ],
]));

如何使用

变量定义

变量定义取决于multiple

  • 设置为false,将存储在数据库中唯一的字符串值
  • 设置为true,将存储在数据库中的键值数组

用法

add_control($id, $args);

参数

$args参数

choices参数是一个包含键列表的关联数组。
每个键都与一个数组相关联,由以下组成

  • label (必需)。选项名称
  • image (必需)。图片URL

发布历史

  • 0.0.2
  • 新增:新列和多个属性
  • 0.0.1
  • 初始发布

作者和版权

Achraf Chouk
@crewstyle

请阅读LICENSE以获取更多信息。
MIT

https://github.com/crewstyle
https://fr.linkedin.com/in/achrafchouk

贡献

  1. 复制它(https://github.com/GetOlympus/olympus-imageselect-control/fork
  2. 创建你的功能分支(git checkout -b feature/fooBar
  3. 提交你的更改(git commit -am 'Add some fooBar'
  4. 推送到分支(git push origin feature/fooBar
  5. 创建新的Pull Request

Achraf Chouk用♥构建 ~ 自从很久以前(c)。