thoughtful-web / settings-page-wp
WordPress Settings page generator and validator released as free open source software under GNU GPL-2.0+ License
Requires
- php: >=7.3.5
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-15 17:55:55 UTC
README
This PHP library provides a quick, easy way to add a settings page to your plugin or theme. One configuration file defines both your settings and the page that manages them.
Table of Contents
Features
- Settings page generation from a configuration file (*.php or *.json).
- Validation on the server by default.
- No external libraries beyond WordPress's Iris library for color fields.
- Supports these form field types:
- Checkboxes
- Color
- Number
- Phone
- Radio
- Select
- Text
- Textarea
- URL
- WP Editor
Requirements
System Requirements
- WordPress 5.4 and above.
- PHP 7.3.5 and above.
Installation Requirements
If you are familiar with the command line, you may install it using Composer or Git. Otherwise, you may download a release from Github.
In any case, this library must exist two directory levels below the plugin or theme's root directory. Example: ./vendor/thoughtful-web/settings-page-wp/.
Quick Start
Note: For full specification details on the configuration file values and other possible locations for a configuration file, see here: docs/config-file.md
Step 1
Download the composer module.
$ composer require thoughtful-web/settings-page-wp
Step 2
Include the library in your plugin or theme using the Composer autoloader:
require __DIR__ . '/vendor/autoload.php; new \ThoughtfulWeb\SettingsPageWP\Page();
Step 3
Copy the example configuration file to your plugin or theme's directory at ./config/thoughtful-web/settings.php
.
Step 4
Visit your new settings page at https://your-domain.com/wp-admin/admin.php?page=thoughtful-settings and fill it in as you wish.
Step 5
Retrieve an option from the database using WordPress's get_option()
function:
$the_option = get_option( 'unique_text_field' );
Documentation
- Configuration File Reference
- Field Configuration Reference
- Action and Filter Reference
- Roadmap
- WordPress Developer Reference: Options API
Contributing
I welcome questions and discussion and have opened up Github's features to create a space for this: https://github.com/thoughtful-web/settings-page-wp/discussions. If you find an issue, please report it here: https://github.com/thoughtful-web/settings-page-wp/issues. I am currently only accepting pull requests for security improvements. Please see the contribution guidelines for details.
Free open source software under the GNU GPL-2.0+ License.
Copyright Zachary Kendall Watkins 2021-2022.