1. Home
  2. Docs
  3. WordPress Studio Framework
  4. Framework Fields
  5. Color Field

Color Field

Arguments

NameTypeDefaultDescription
idstring A unique ID. This ID will be used to get the value
typestringcolorType of the field
titlestring Title of the field
defaultstring Default value from database, if the option doesn’t exist
subtitlestring Subtitle to display below the title
descstring Description to display after the field
helpstring Text to display on right-corner (as hover/popup) of the field
classstring Extra CSS classes (space separated) to append to the field
beforestring Content to display before the field
afterstring Content to dipslay after the field
dependencyarray Define field visibility depending on other field value
attributesarray Extra HTML attributes to append to the value
sanitizestring Callback function for sanitizing value
validatestring Callback function for validating value
EXTRAS   
outputarray|string CSS elements selector
output_modestring Output CSS property of an element
output_importantboolfalseFlag 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

How can we help?