https://github.com/getolympus/olympus-dionysos-field-font
Διώνυσος — Font field, this component is a part of the Olympus Dionysos fields for WordPress.
https://github.com/getolympus/olympus-dionysos-field-font
Last synced: 24 days ago
JSON representation
Διώνυσος — Font field, this component is a part of the Olympus Dionysos fields for WordPress.
- Host: GitHub
- URL: https://github.com/getolympus/olympus-dionysos-field-font
- Owner: GetOlympus
- License: mit
- Created: 2020-03-30T00:31:45.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-04T21:11:00.000Z (about 5 years ago)
- Last Synced: 2024-04-26T18:47:22.041Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dionysos Font Field
> This component is a part of the **Olympus Dionysos fields** for **WordPress**.```sh
composer require getolympus/olympus-dionysos-field-font
```---
[![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 an `font field` in your **WordPress** admin pages or custom post type meta fields:
```php
return \GetOlympus\Dionysos\Field\Font::build('my_font_field_id', [
'title' => 'Select your character!',
'default' => [
'family' => 'Open Sans',
'backup' => 'Arial, Helvetica, sans-serif',
'subset' => 'latin',
'variant' => 'regular',
'size' => '16px',
'lineheight' => '1.8',
'letterspacing' => '0',
'color' => '#000000',
],
'description' => 'Select your fighting stage!',
]);
```## Variables definition
| Variable | Type | Default value if not set | Accepted values |
| ------------- | ------- | ------------------------ | --------------- |
| `title` | String | `'Font'` | *empty* |
| `default` | Array | *empty* | *empty* |
| `description` | String | *empty* | *empty* |## Retrive data
Retrieve your value from Database with a simple `get_option('my_font_field_id', [])` (see [WordPress reference][getoption-url]).
Below, a `json_encode()` example to understand how data are stored in Database:```json
{
"family": "Open Sans",
"backup": "Arial, Helvetica, sans-serif",
"subset": "latin",
"variant": "regular",
"size": "16px",
"lineheight": "1.8",
"letterspacing": "0",
"color": "#000000"
}
```And below, a simple example to show how to iterate on the data array in `PHP`:
```php
// Get font from Database
$font = get_option('my_font_field_id', []);// Check if font is empty and display it
if (!empty($font)) {
echo 'My custom title
';
}
```## Release History
0.0.2
- Add ajax call
- Add display
- Add Google fonts0.0.1
- Initial commit## 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-font/badge?style=flat-square
[codefactor-url]: https://www.codefactor.io/repository/github/getolympus/olympus-dionysos-field-font
[getoption-url]: https://developer.wordpress.org/reference/functions/get_option/
[license-blob]: https://github.com/GetOlympus/olympus-dionysos-field-font/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-font.svg?style=flat-square
[packagist-url]: https://packagist.org/packages/getolympus/olympus-dionysos-field-font