Arguments
Name | Type | Default | Description |
---|
id | string | | A unique ID. This ID will be used to get the value |
type | string | color | Type of the field |
title | string | | Title of the field |
default | string | | Default value from database, if the option doesn’t exist |
subtitle | string | | Subtitle to display below the title |
desc | string | | Description to display after the field |
help | string | | Text to display on right-corner (as hover/popup) of the field |
class | string | | Extra CSS classes (space separated) to append to the field |
before | string | | Content to display before the field |
after | string | | Content to dipslay after the field |
dependency | array | | Define field visibility depending on other field value |
attributes | array | | Extra HTML attributes to append to the value |
sanitize | string | | Callback function for sanitizing value |
validate | string | | Callback function for validating value |
EXTRAS | | | |
output | array|string | | CSS elements selector |
output_mode | string | | Output CSS property of an element |
output_important | bool | false | Flag to add !important rule on output css. |
Simple Color Field Example
array(
'id' => 'example-color',
'type' => 'color',
'title' => 'Example Color',
),
Color Field Example with Default Settings
array(
'id' => 'example-color',
'type' => 'color',
'title' => 'Example Color',
'default' => '#ffbc00',
),
Color Field Example with Output Settings
//output for default color
array(
'id' => 'example-color',
'type' => 'color',
'title' => 'Example Color',
'output' => '.main-element',
),
//output for background color
array(
'id' => 'example-color',
'type' => 'color',
'title' => 'Example Color',
'output' => '.background-element',
'output_mode' => 'background-color',
),
//output for multiple elements
array(
'id' => 'example-color',
'type' => 'color',
'title' => 'Example Color',
'output' => array('.main-element', '.background-element', '.footer-element'),
),
// output for multiple elements with different properties
array(
'id' => 'example-color',
'type' => 'color',
'title' => 'Example Color',
'output' => array(
'background-color' => '.main-element',
'color' => '.second-element',
'border-color' => 'third-element'
),
),
Was this article helpful to you?
Yes
No