Download the PHP package solutionbox/wordpress-settings-framework without Composer
On this page you can find all versions of the php package solutionbox/wordpress-settings-framework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package wordpress-settings-framework
WordPress Settings Framework
The WordPress Settings Framework aims to take the pain out of creating settings pages for your WordPress plugins by effectively creating a wrapper around the WordPress settings API and making it super simple to create and maintain settings pages.
This repo is actually a working plugin which demonstrates how to implement SBSA in your plugins. See src/sbsa-test.php
for details.
You can use this framework with composer if you are using auto loading in your plugin.
Installation
Setting Up Your Plugin
- Install the package via composer.
- Create a "settings" folder in your plugin root.
- Create a settings file in your new "settings" folder (e.g.
settings-general.php
)
Now you can set up your plugin like:
Your settings values can be accessed like so:
This will get either the saved setting values, or the default values that you set in your settings file.
Or by getting individual settings:
The Settings Files
The settings files work by filling the global $sbsa_settings
array with data in the following format:
Valid fields
values are:
id
- Field IDtitle
- Field titledesc
- Field descriptionplaceholder
- Field placeholdertype
- Field type (text/password/textarea/select/radio/checkbox/checkboxes/color/file/editor/code_editor)default
- Default value (or selected option)choices
- Array of options (for select/radio/checkboxes)mimetype
- Any valid mime type accepted by Code Mirror for syntax highlighting (for code_editor)
See settings/example-settings.php
for an example of possible values.
API Details
new Solution_Box_Settings\SettingsAPI( string $settings_file [, string $option_group = ''] )
Creates a new settings option_group based on a settings file.
$settings_file
- path to the settings file$option_group
- optional "option_group" override (by default this will be set to the basename of the settings file)
Solution_Box_Settings\SettingsAPI::get_setting( $option_group, $section_id, $field_id )
Get a setting from an option group
$option_group
- option group id.$section_id
- section id (change to[{$tab_id}_{$section_id}]
when using tabs.$field_id
- field id.
Solution_Box_Settings\SettingsAPI::delete_settings( $option_group )
Delete all the saved settings from a option group
$option_group
- option group id
Actions & Filters
Filters
sbsa_register_settings_[option_group]
- The filter used to register your settings. Seesettings/example-settings.php
for an example.[option_group]_settings_validate
- Basically the$sanitize_callback
from register_setting. Use$sbsa->get_option_group()
to get the option group id.sbsa_defaults_[option_group]
- Default args for a settings field
Actions
sbsa_before_settings_page_[option_group]
- Before setting page HTML is outputsbsa_after_settings_page_[option_group]
- After setting page HTML is outputsbsa_before_settings_page_header_[option_group]
- Before setting page header HTML is outputsbsa_after_settings_page_header_[option_group]
- After setting page header HTML is outputsbsa_settings_sections_args_[option_group]
- Section extra args for to wrap the section with HTML and extra class Moresbsa_before_field_[option_group]
- Before a field HTML is outputsbsa_before_field_[option_group]_[field_id]
- Before a field HTML is outputsbsa_after_field_[option_group]
- After a field HTML is outputsbsa_after_field_[option_group]_[field_id]
- After a field HTML is outputsbsa_before_settings_[option_group]
- Before settings form HTML is outputsbsa_after_settings_[option_group]
- After settings form HTML is outputsbsa_before_tabless_settings_[option_group]
- Before settings section HTML is outputsbsa_after_tabless_settings_[option_group]
- After settings section HTML is outputsbsa_before_settings_fields_[option_group]
- Before settings form fields HTML is output (inside the<form>
)sbsa_do_settings_sections_[option_group]
- Settings form fields HTMLoutput (inside the<form>
)sbsa_before_tab_links_[option_group]
- Before tabs HTML is outputsbsa_after_tab_links_[option_group]
- After tabs HTML is output
Examples
Example 1 Tabless settings

Example 2 Tabbed settings

Credits
The WordPress Settings Framework was Cloned from iconicwp then converted into php package with more features.
Please contribute by reporting bugs and submitting pull requests.
Want to say thanks? Consider tipping me.