Skip to content
Color field, this component is a part of the Olympus Zeus Core framework.
PHP HTML
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
languages
src
.gitignore
LICENSE
README.md
composer.json

README.md

Color Field

This component is a part of the Olympus Zeus Core WordPress framework.
It uses the default WordPress color field.

Olympus Component CodeFactor Grade Packagist Version

Installation

Using composer in your PHP project:

composer require getolympus/olympus-color-field

Field initialization

Use the following lines to add a color field in your WordPress admin pages or custom post type meta fields:

return \GetOlympus\Field\Color::build('my_color_field_id', [
    'title'       => 'What is your favorite Coke?',
    'default'     => '#f40000',
    'description' => 'Zero and Light are not available colors!',

    /**
     * Color picker settings
     * @see https://core.trac.wordpress.org/browser/trunk/src/js/_enqueues/lib/color-picker.js
     */
    'settings' => [
        'defaultColor' => false,
        'hide'         => true,
        'palettes'     => true,
        'width'        => 255,
        'mode'         => 'hsv',
        'type'         => 'full',
        'slider'       => 'horizontal',
    ],
]);

Variables definitions

Variable Type Default value if not set Accepted values
title String 'Color' empty
default String empty Hex color code
description String empty empty
settings Array see Field initialization see WordPress reference

Retrive data

Retrieve your value from Database with a simple get_option('my_color_field_id', '') (see WordPress reference).

// Get color from Database
$color = get_option('my_color_field_id', '#f40000');

// Display Coca-Cola baseline in color
echo 'Always <b style="color:'.$color.'">Coca-Cola</b>';

Release History

  • 0.0.11
  • FIX: json encoder in twig source file
  • 0.0.10
  • FIX: remove twig dependency from composer
  • 0.0.9
  • FIX: remove zeus-core dependency from composer
  • 0.0.8
  • ADD: new version compatible with Zeus-Core latest version

Authors and Copyright

Achraf Chouk
@crewstyle

Please, read LICENSE for more information.
MIT

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

Contributing

  1. Fork it (https://github.com/GetOlympus/olympus-color-field/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Built with ♥ by Achraf Chouk ~ (c) since a long time.

You can’t perform that action at this time.