getolympus / olympus-dionysos-field-font
Font field, this component is a part of the Olympus Dionysos fields.
Installs: 152
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:olympus-field
Requires (Dev)
- phpunit/phpunit: ~5.3
This package is auto-updated.
Last update: 2024-11-05 07:06:06 UTC
README
This component is a part of the Olympus Dionysos fields for WordPress.
composer require getolympus/olympus-dionysos-field-font
Field initialization
Use the following lines to add an font field
in your WordPress admin pages or custom post type meta fields:
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
Retrive data
Retrieve your value from Database with a simple get_option('my_font_field_id', [])
(see WordPress reference).
Below, a json_encode()
example to understand how data are stored in Database:
{ "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
:
// Get font from Database $font = get_option('my_font_field_id', []); // Check if font is empty and display it if (!empty($font)) { echo '<h1 style="font-family:'.$font['family'].';font-size:'.$font['size'].'">My custom title</h1>'; }
Release History
0.0.2
- Add ajax call
- Add display
- Add Google fonts
0.0.1
- Initial commit
Contributing
- Fork it (https://github.com/GetOlympus/olympus-dionysos-field-font/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
Built with ♥ by Achraf Chouk ~ (c) since a long time.