getolympus / olympus-dionysos-field-toggle
Toggle field, this component is a part of the Olympus Dionysos fields.
Installs: 232
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:Less
Type:olympus-field
pkg:composer/getolympus/olympus-dionysos-field-toggle
Requires (Dev)
- phpunit/phpunit: ~5.3
README
Dionysos Toggle Field
This component is a part of the Olympus Dionysos fields for WordPress.
composer require getolympus/olympus-dionysos-field-toggle
Table of contents
Field initialization • Variables definition • Retrive data • Release history • Contributing
Field initialization
Use the following lines to add a toggle field in your WordPress admin pages or custom post type meta fields:
return \GetOlympus\Dionysos\Field\Toggle::build('my_toggle_field_id', [ 'title' => 'Get ready to rumble!', 'default' => true, 'description' => 'Put it on to get started', ]);
Variables definition
| Variable | Type | Default value if not set | Accepted values | 
|---|---|---|---|
| title | String | 'Toggle' | empty | 
| default | Boolean | false | trueorfalse | 
| description | String | empty | empty | 
Retrive data
Retrieve your value from Database with a simple get_option('my_toggle_field_id', false) (see WordPress reference):
// Get toggle from Database $toggle = get_option('my_toggle_field_id', false); // Display toggle in HTML tag echo $toggle ? 'Let\'s go!' : 'Not ready yet.';
Release history
| Version | Note | 
|---|---|
| 0.0.16 | Use WordPress default design to display toggle box | 
| 0.0.15 | Use default getVarsZeus-Core method. No need to override it anymore | 
| 0.0.14 | New Olympus components compatibility Change repository to be a part of Dionysos fields | 
Contributing
- Fork it (https://github.com/GetOlympus/olympus-dionysos-field-toggle/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.
