monkeyscode / customizer
Create theme option in Wordpress
This package's canonical repository appears to be gone and the package has been frozen as a result.
1.2.0
2018-01-09 15:18 UTC
Requires
- php: >5.4
This package is not auto-updated.
Last update: 2019-06-11 08:46:04 UTC
README
Create theme options
Installation
composer require monkeyscode/customizer
Usage
You have to run under customize_register
action.
- The Data passed through an instance is array. Each element of this array must have
data:info
anddata:fields
. Each element of data must haveinfo:name
as required. Other section options are optional. Everydata:field
must havefield:name
andfield:type
. Other field options are optional.
For example:
$data = [ [ 'info' => [ 'name' => 'duy_customize_section', 'label' => 'Duy Section', 'description' => '', 'priority' => 0, ], 'fields' => [ [ 'name' => 'my_text', 'type' => 'text', 'default' => 'hole', 'label' => 'Text Field' ] ] ], [ 'info' => [ 'name' => 'duy_customize_section_2', 'label' => 'Duy Section 2', 'description' => '', 'priority' => 0, ], 'fields' => [ [ 'name' => 'my_text_2', 'type' => 'text', 'default' => 'hole 2', 'label' => 'Text Field 2' ] ] ], ]; $customizer = new Customizer($data); $customizer->create();
List of Fields
- Text Field
[ 'name' => 'my_field', 'type' => 'text', 'default' => 'hole', 'label' => 'Text Field' ]
- Textarea Field
[ 'name' => 'my_field', 'type' => 'textarea', 'default' => 'hole', 'label' => 'Textarea Field' ]
- Radio Field
[ 'name' => 'my_field', 'type' => 'radio', 'default' => 'hole', 'label' => 'Radio Field', 'choices' => [ 1 => 1, 2 => 2 ] ]
- Checkbox Field
[ 'name' => 'my_field', 'type' => 'checkbox', 'default' => 'hole', 'label' => 'Checkbox Field', ]
- Select Field
[ 'name' => 'my_field', 'type' => 'select', 'default' => 'hole', 'label' => 'Select Field', 'choices' => [ 1 => 1, 2 => 2 ] ]
- Upload Field
[ 'name' => 'my_field', 'type' => 'upload', 'default' => 'hole', 'label' => 'Upload Field', ]
- Color Field
[ 'name' => 'my_field', 'type' => 'color', 'default' => 'hole', 'label' => 'Color Field', ]
Use in template file
get_option('<section_name>_<field_name>');