Skip to content

ClearcodeHQ/wordpress-settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clearcode WordPress Settings

WordPress Settings library by Clearcode.

Installation

$ composer require clearcode/wordpress-settings
require __DIR__ . '/vendor/autoload.php';

new Settings( [
    'option_name' => [
        'group' => 'option_group', // optional
        'type' => 'string', // optional
        'description' => 'setting description', // optional
        'rest' => false, // optional
        'pages' => [
            'page_slug' => [
                'title' => 'page title',
                'capability' => 'manage_options', // optional
                'menu' => [
                    'title' => 'menu title',
                    'icon' => 'dashicons-admin-plugins',
                    'position' => null,
                    'parent' => 'options-general.php'
                ],
                'tabs' => [
                    'tab_1' => [
                        'title' => 'tab title',
                        'sections' => [
                            'section_1' => [
                                'title' => 'section title',
                                'render' => [
                                    'template' => 'section', // template file path
                                    'args' => [ 
                                        'content' => 'section description'
                                    ]
                                ],
                                'fields' => [
                                    'field_1' => [
                                        'title' => 'field title',
                                        'default' => 'default value',
                                        'sanitize' => function( $value ) { return $value; }, // callback function
                                        'render' => [
                                            'template' => 'input', // supported templates: input, textarea, select
                                            'args' => [
                                                'atts' => [
                                                    'type' => 'text'
                                                ],
                                                'before' => 'before text',
                                                'after' => 'after text',
                                                'description' => 'description text'
                                            ]
                                        ]
                                    ]
                                ]
                            ]
                        ]
                    ]
                ]
            ]
        ]
    ]
] );

License

GPL3.0+ see LICENSE.txt and AUTHORS.txt

About

WordPress Settings library by Clearcode.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages