Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure to validate the settings are for the current plugin only. (… #11

Merged
merged 1 commit into from
Aug 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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