Skip to content

Commit

Permalink
Merge pull request #11 from dwnload/develop
Browse files Browse the repository at this point in the history
Make sure to validate the settings are for the current plugin only. (…
  • Loading branch information
thefrosty committed Aug 12, 2022
2 parents 8ad93d1 + 4de74be commit d9fb6cf
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
use Dwnload\WpSettingsApi\Settings\FieldManager;
use Dwnload\WpSettingsApi\Settings\SectionManager;
use Dwnload\WpSettingsApi\WpSettingsApi;
use TheFrosty\WpUtilities\Plugin\WpHooksInterface;
use TheFrosty\WpUtilities\Plugin\AbstractHookProvider;

/**
* Class Settings
*
* @package Dwnload\WpEmailDownload\Admin
*/
class Settings implements WpHooksInterface {
class Settings extends AbstractHookProvider {

const SETTING_ID_S = 'email_download_%s';
const LICENSE_SETTING = 'license';
Expand All @@ -28,27 +28,23 @@ class Settings implements WpHooksInterface {
* so you have to register a priority and the parameter count.
*/
public function addHooks(): void {
add_action( WpSettingsApi::ACTION_PREFIX . 'init', [ $this, 'init' ], 10, 2 );
add_action( WpSettingsApi::ACTION_PREFIX . 'init', [ $this, 'init' ], 10, 3 );
}

/**
* Initiate our setting to the Section & Field Manager classes.
*
* SettingField requires the following settings (passes as an array or set explicitly):
* [
* SettingField::NAME
* SettingField::LABEL
* SettingField::DESC
* SettingField::TYPE
* SettingField::SECTION_ID
* ]
*
* @see SettingField for additional options for each field passed to the output
*
* @param SectionManager $section_manager
* @param FieldManager $field_manager
* @param WpSettingsApi $wp_settings_api
*/
public function init( SectionManager $section_manager, FieldManager $field_manager ) {
public function init(
SectionManager $section_manager,
FieldManager $field_manager,
WpSettingsApi $wp_settings_api
): void {
if (!$wp_settings_api->isCurrentMenuSlug($this->getPlugin()->getSlug())) {
return;
}
/**
* License Settings Section
*/
Expand Down

0 comments on commit d9fb6cf

Please sign in to comment.