Color Set

The color-set lets you add a field for selecting color.

Color Set

Parameters

Here are the parameters in adding color-set.

id
string | required

a unique slug-like string to use as an id and also as index in saving data in database.

label
string | optional

the label of the field.

description
string | optional

the description of the field and display under the label.

section
string | requiredl

the section where the field will be displayed.

default
string | required

the default value of the field.

Note: default value must exist in colors.

priority
integer | optional

determines the order of fields in section.

colors
array | required

the list array of colors to be used.

shape
string | optional | default: square

the actual shape of color radio.

Note: shape valid values are 'square' and 'circle'.

size
integer | optional

the actual size of color radio, unit size is "px".

Example


Yano::field( 'color-set', [
    'id'          => 'colorsetdb1',
    'label'       => 'Choose Color 1',
    'description' => 'Some description',
    'section'     => 'section_id',
    'default'     => '#000000',
    'priority'    => 14,
    'colors'      => [ '#000000', '#ffffff', '#eeeeee' ],
    'shape'       => 'square',
    'size'        => 20
] );

Yano provide material colors here are material color set : all, primary, a100, a200, a400, a700, red, pink, purple, deepPurple, indigo, lightBlue, cyan, teal, green, lightGreen, lime, yellow, amber, orange, deepOrange, brown, grey and blueGrey.


Yano::field( 'color-set', [
    'id'          => 'colorsetdb1',
    'label'       => 'Choose Color 1',
    'description' => 'Some description',
    'section'     => 'sectisection_idon_1',
    'default'     => '#000000',
    'priority'    => 14,
    'colors'      => Yano_Util::_get_material_colors( 'all' ),
    'shape'       => 'square',
    'size'        => 20
] );

Usage

The get_theme_mod() function is recommended to retrieve data.


// Return a string
echo get_theme_mod('colorsetdb1');