Deprecated. Use WP Better Settings instead.
WordPress Settings Module is a standardized, organized, object-oriented foundation for building extendable WordPress Plugins.
- The Module is based on the Settings API, Options API, Coding Standards, and Documentation Standards.
- A set of hooks come out of the box. So that your plugin can be extended by other add-ons. See hooks & filters list.
- A static class for retrieving saved settings. See get options.
- (TODO) All classes, functions, and variables are documented so that you know what you need to be changed.
Check out this blog post for a more detailed installation guide.
Here is an short example of using WordPress Settings Module on a fresh WordPress Plugin Boilerplate
-
Clone the WordPress Plugin Boilerplate repo. And, follow its installation instructions but leave
Plugin_Name
unchanged.git clone https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate.git
-
Clone the WordPress Settings Module repo
git clone https://github.com/wphuman/WordPress-Settings-Module.git
-
Copy these files into the thier counterparts in
/trunk/
:
WordPress-Settings-Module/admin/partials/*
WordPress-Settings-Module/admin/settings/*
WordPress-Settings-Module/admin/class-plugin-name-admin.php
WordPress-Settings-Module/includes/class-plugin-name-option.php
WordPress-Settings-Module/includes/class-plugin-name.php
Important: Be careful when you replacing existing files. Review what is new from the WordPress Settings Module since it is not only intended for WordPress Plugin Boilerplate.
-
Here is a screenshot of the file structure. Arrows indicate files from WordPress Settings Module.
-
Open the new options page for a full list of settings avaiable.
Besides changing the file names, these lines must be changed:
-
admin/settings/class-plugin-name-settings-definition.php
$plugin_name = 'plugin-name'
-
includes/class-plugin-name-option.php
$plugin_options = get_option( 'plugin_name_settings', array() );
You can rertive saved settings by Plugin_Option::get_option( $field_key, $default )
For add-ons to extend the settings page:
plugin_name_settings_tabs
plugin_name_settings_<tab_slug>
During settings saving:
- Filter:
plugin_name_settings_sanitize_<tab_slug>
- Filter:
plugin_name_settings_sanitize_<type>
- Filter:
plugin_name_settings_sanitize
- Action:
plugin_name_settings_on_change_<tab_slug>
- Action:
plugin_name_settings_on_change_<field_key>
- Eg:
$this->loader->add_action( 'plugin_name_settings_on_change_my_tab_name', $plugin_admin, 'my_tab_name_settings_save', 10, 2 );
- Eg:
tab_slug
cannot be the same asfield_key
No.
Tom McFarlin's WordPress Plugin Boilerplate is a great skeleton to build WordPress plugins. Strongly recommanded. However, it is not required for WordPress Settings Module.
The WordPress Settings Module was started in December 2014 by Tang Rufus from WP Human.
Inspired by Pippin Williamson's How I Built the Easy Digital Downloads Settings System.
Not yet completed. If you’re interested, please let me know and we’ll see what we can do.