getolympus / olympus-dionysos-field-text
Text field, this component is a part of the Olympus Dionysos fields.
Installs: 217
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:olympus-field
Requires (Dev)
- phpunit/phpunit: ~5.3
README
Dionysos Text Field
This component is a part of the Olympus Dionysos fields for WordPress.
It uses the default WordPress text field to display password, range, text, datetime, tel, and more fields.
composer require getolympus/olympus-dionysos-field-text
Table of contents
Field initialization • Variables definition • Settings definition • Retrive data • Release History • Contributing
Field initialization
Use the following lines to add a text field
in your WordPress admin pages or custom post type meta fields:
return \GetOlympus\Dionysos\Field\Text::build('my_text_field_id', [ 'title' => 'What do you like?', 'default' => 'Penguins, I am sure they\'re gonna dominate the World!', 'description' => 'Put in here everything you want.', 'placeholder' => 'McDonald\'s as well', 'type' => 'text', /** * Settings definition * @see the `Settings definition` section below */ 'settings' => [], ]);
Variables definition
Accepted type
date
see Date typedatetime-local
see Datetime-local typeemail
see Email typehidden
see Hidden typemonth
see Month typenumber
see Number typepassword
see Password typerange
see Range typesearch
see Search typetel
see Tel typetext
see Text typetime
see Time typeurl
see URL typeweek
see Week type
Settings definition
The settings
variable is an array of options depending on type
value.
In all cases, here are the default settings with their explanations:
- Special case:
attrs
will let you add all additional attributes you need, such asdata-*
. Pay attention to this! after
will insert contents after the field. Innumber
andrange
cases, theafter
content will prepend themax
valuebefore
will insert contents before the field. Innumber
andrange
cases, thebefore
content will append themin
valueclass
will add CSS classes to the already-inregular-text
field class (not used inhidden
case)readonly
will avoid the field to be used when its value is set totrue
Date type
Full documentation on Mozilla Date page
Datetime-local type
Full documentation on Mozilla Datetime-local page
Email type
Full documentation on Mozilla Email page
Hidden type
Full documentation on Mozilla Hidden page
This special display
variable defines if the hidden field have to show field value or not:
- set to
false
, a sentence will show where the value is stored in Database - set to
true
, a sentence will show where the value is stored in Database and what is the current value
Month type
Full documentation on Mozilla Month page
Number type
Full documentation on Mozilla Number page
Password type
Full documentation on Mozilla Password page
Range type
Full documentation on Mozilla Range page
This range
type will display an input number
HTML tag with the field value.
Search type
Full documentation on Mozilla Search page
Tel type
Full documentation on Mozilla Tel page
Text type
Full documentation on Mozilla Text page
Time type
Full documentation on Mozilla Time page
When the step
variable is provided, browser will add the seconds input area adjacent to the minutes section.
The max
and min
variables format will automatically be forced to hh:mm:ss
.
URL type
Full documentation on Mozilla URL page
Week type
Full documentation on Mozilla Week page
Retrive data
Retrieve your value from Database with a simple get_option('my_text_field_id', '')
(see WordPress reference):
// Get text from Database $text = get_option('my_text_field_id', ''); // Display text echo $text;
Release History
Contributing
- Fork it (https://github.com/GetOlympus/olympus-dionysos-field-text/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.