-
Hello! Thanks so much for creating this package. I'm working on including it into a plugin, where I'd like to allow my Settings page to be further extended by other plugins or themes, ideally using the same simple format. Is it possible to use hooks or apply a filter for my settings page to have new tabs, sections, or fields added to? Thanks in advance for any thoughts or help with this question. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi! I think you could provide your own hook for that when registrering your settings. Say you would register your default settings like this: $settings = new WPSettings(__('My Plugin Settings'));
$tab = $settings->add_tab(__( 'General', 'textdomain'));
$section = $tab->add_section('Example');
$section->add_option('text', [
'name' => 'example_option',
'label' => __('Example option', 'textdomain')
]);
apply_filters('your_custom_plugin_settings', $settings);
$settings->make(); You could then allow plugins or themes to hook into your settings through the filter. add_filter('your_custom_plugin_settings', function($settings) {
// Add additional options here...
}); |
Beta Was this translation helpful? Give feedback.
Hi! I think you could provide your own hook for that when registrering your settings.
Say you would register your default settings like this:
You could then allow plugins or themes to hook into your settings through the filter.