Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Plugins Options Module

This module allows WBF plugins to have their own standardized settings page. If any WBF plugins register it's settings to the module, a link to a general options page will be created under WBF menu.

Create an option tab

Create a new class by extending \WBF\modules\plugins_options\OptionsTab.

namespace MyPlugin\options;

class OptionsTab extends \WBF\modules\plugins_options\OptionsTab{
	public function render() {
		echo 'Hello World!';

You can put the tab output (input fields and such) into the render() method.

Register a setting tab

Use the filter called: wbf/modules/plugins_options/tabs and add a new tab.

	 * @param $tabs
	 * @hooked 'wbf/modules/plugins_options/tabs'
	 * @return array
	public function add_plugin_options($tabs){
		$tab = new MyPlugin\options\OptionsTab($this,'My Plugin'); //$this is the WBF\components\pluginsframework\BasePlugin instance
		$tabs[] = $tab;
		return $tabs;

Now you have a fully functional settings page ready.

Use the settings page

The module does not dictate on how you have to save or render the settings. It wraps your render() output in a form like this:

<form method="post" action=";tab=my-plugin">
    <!-- You render() output -->
	<button style="display: block; margin-top: 10px;" class="button button-primary" type="submit">Save settings</button>
    <input type="hidden" name="save-wbf-plugins-settings" value="my-plugin">
    <!-- NONCE Example: The nonce action is: save-wbf-plugins-settings -->
    <input type="hidden" id="_wpnonce" name="_wpnonce" value="0bd9dd176c"><input type="hidden" name="_wp_http_referer" value="/wp-admin/admin.php?page=wbf-plugins-options">

So you can intercept the POST event and save the settings as you prefer.

Please note that WBF\components\pluginsframework\BasePlugin provides a nice API to manage plugin settings.