Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/getolympus/olympus-dionysos-field-color

Διώνυσος — Color field, this component is a part of the Olympus Dionysos fields for WordPress.
https://github.com/getolympus/olympus-dionysos-field-color

color custom field framework olympus-zeus php twig wordpress

Last synced: about 2 months ago
JSON representation

Διώνυσος — Color field, this component is a part of the Olympus Dionysos fields for WordPress.

Awesome Lists containing this project

README

        

# Dionysos Color Field
> This component is a part of the **Olympus Dionysos fields** for **WordPress**.
> It uses the default WordPress color field.

```sh
composer require getolympus/olympus-dionysos-field-color
```

---

[![Olympus Component][olympus-image]][olympus-url]
[![CodeFactor Grade][codefactor-image]][codefactor-url]
[![Packagist Version][packagist-image]][packagist-url]
[![MIT][license-image]][license-blob]

---



---

## Field initialization

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

```php
return \GetOlympus\Dionysos\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](#field-initialization) | see [WordPress reference](https://core.trac.wordpress.org/browser/trunk/src/js/_enqueues/lib/color-picker.js) |

## Retrive data

Retrieve your value from Database with a simple `get_option('my_color_field_id', '')` (see [WordPress reference][getoption-url]).

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

// Display Coca-Cola baseline in color
echo 'Always Coca-Cola';
```

## Release History

0.0.13
- Use default `getVars` Zeus-Core method. No need to override it anymore

0.0.12
- New Olympus components compatibility
- Change repository to be a part of Dionysos fields

0.0.11
- FIX: json encoder in twig source file

## Contributing

1. Fork it ()
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](https://github.com/crewstyle "Achraf Chouk") ~ (c) since a long time.**

[olympus-image]: https://img.shields.io/badge/for-Olympus-44cc11.svg?style=flat-square
[olympus-url]: https://github.com/GetOlympus
[codefactor-image]: https://www.codefactor.io/repository/github/GetOlympus/olympus-dionysos-field-color/badge?style=flat-square
[codefactor-url]: https://www.codefactor.io/repository/github/getolympus/olympus-dionysos-field-color
[getoption-url]: https://developer.wordpress.org/reference/functions/get_option/
[license-blob]: https://github.com/GetOlympus/olympus-dionysos-field-color/blob/master/LICENSE
[license-image]: https://img.shields.io/badge/license-MIT_License-blue.svg?style=flat-square
[packagist-image]: https://img.shields.io/packagist/v/getolympus/olympus-dionysos-field-color.svg?style=flat-square
[packagist-url]: https://packagist.org/packages/getolympus/olympus-dionysos-field-color