Download the PHP package yivi/wp_optional without Composer
On this page you can find all versions of the php package yivi/wp_optional. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yivi/wp_optional
More information about yivi/wp_optional
Files in yivi/wp_optional
Package wp_optional
Short Description A helping hand to create option pages and option fields
License GPL-3.0-or-later
Informations about the package wp_optional
WP Optional
Library to help in generating option pages for plugins and themes.
Work in progress, but the basic usage is as follows:
PageSettings object
Subpages
When settings are long enough or complex enough, you may want to separate them in different "subpages" (or tabs) to make access easier. You always need at least one subpage
Sections
Each page should have 1 or more "sections" to group settings
Fields
Fields are added to each of the sections, directly.
Field Types
- TextField
- PasswordField
- TextareaField
- SelectField
- SelectMultipleField
- CheckboxField
Field Configuration
Description
Sets the optional value for a field description. If provided, will be rendered close to the field
$field->setDescription('This field rocks and rolls');
Default
Default value for the field, if the user doesn't provide one
$field->setDefault('1');
Class
If provided, this string will be rendered in the class attribute of the field
$field->setClass('mucho-clase very-nav');
Extra Attributes
This should be a associative array. Each key => value combination will be rendered as an additional attribute for the field
$field->setAttributes(['rows' => '30', 'data-value' => $whatever ]);
Choices
This is a list of values and labels, generally used for <select>
or <radio>
$field->setChoices('WS' => 'Washington', 'NY', 'New York', 'MAD' => 'Madrid');
Example
Since these calls are chainable, you could do: