diff --git a/src/admin/layout/class-settings-page.php b/src/admin/layout/class-settings-page.php index 7d9fec1..c3db793 100644 --- a/src/admin/layout/class-settings-page.php +++ b/src/admin/layout/class-settings-page.php @@ -21,7 +21,6 @@ require_once plugin_dir_path( dirname( __FILE__, 2 ) ) . 'includes/class-setting use footnotes\includes\{Template, Settings, Parser, Config, Convert}; use footnotes\general\General; -use const footnotes\settings\general\ReferenceContainerSettingsGroup\{COMBINE_IDENTICAL_FOOTNOTES}; /** * Provides the abstract class to be extended for page layouts. diff --git a/src/includes/class-settings.php b/src/includes/class-settings.php index 7c7b1ea..a4ec9f7 100644 --- a/src/includes/class-settings.php +++ b/src/includes/class-settings.php @@ -15,13 +15,6 @@ namespace footnotes\includes; use footnotes\includes\Settings; use footnotes\includes\settings\Setting; -/** - * Provides data conversion methods. - * - * @todo Move to {@see Loader}. - */ -require_once plugin_dir_path( __DIR__ ) . 'includes/class-convert.php'; - use footnotes\includes\settings\general\GeneralSettingsSection; use footnotes\includes\settings\referrersandtooltips\ReferrersAndTooltipsSettingsSection; use footnotes\includes\settings\scopeandpriority\ScopeAndPrioritySettingsSection; @@ -62,10 +55,6 @@ class Settings { * @since 2.8.0 */ public $settings_sections = array(); - - /********************************************************************** - * SETTINGS STORAGE. - **********************************************************************/ /** * Loads all Settings from each WordPress Settings Container. @@ -88,6 +77,9 @@ class Settings { * * Includes the following files that make up the plugin: * + * - {@see SettingsSection}: defines a section of settings groups; + * - {@see SettingsGroup}: defines a group of settings; + * - {@see Setting}: defines a single setting; * - {@see GeneralSettingsSection}: provides general plugin settings; * - {@see ReferrersAndTooltipsSettingsSection}: provides settings for * customising the plugin's created referrers and tooltips; @@ -100,6 +92,10 @@ class Settings { * @return void */ protected function load_dependencies(): void { + require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-settings-section.php'; + require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-settings-group.php'; + require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-setting.php'; + require_once plugin_dir_path( __DIR__ ) . 'includes/settings/general/class-general-settings-section.php'; require_once plugin_dir_path( __DIR__ ) . 'includes/settings/referrers-and-tooltips/class-referrers-and-tooltips-settings-section.php'; require_once plugin_dir_path( __DIR__ ) . 'includes/settings/scope-and-priority/class-scope-and-priority-settings-section.php'; @@ -148,7 +144,7 @@ class Settings { } /** - * Retrieve a setting's defaultvalue by its key. + * Retrieve a setting's default value by its key. * * @param string $setting_key The key of the setting to search for. * @return mixed Either the setting's default value, or `null` if the setting does not exist. @@ -167,6 +163,28 @@ class Settings { return null; } + + /** + * Set a setting's value by its key. + * + * @param string $setting_key The key of the setting to search for. + * @param mixed $setting_value The new value to set. + * @return mixed 'True' if the value was successfully set. 'False' otherwise. + * + * @since 2.8.0 + * + * @todo This is an _O(n)_ linear search. Explore more scaleable alternatives. + * @todo How to handle settings with a value of `null`? + */ + public function set_setting_value( string $setting_key, mixed $setting_value ): ?bool { + foreach ($this->settings_sections as $settings_section) { + $setting = $settings_section->get_setting($setting_key); + + if ($setting) return $setting->set_value( $setting_value ); + } + + return false; + } /** * Returns the name of a specified Settings Container. diff --git a/src/includes/settings/class-setting.php b/src/includes/settings/class-setting.php index 6781275..0fa08a6 100644 --- a/src/includes/settings/class-setting.php +++ b/src/includes/settings/class-setting.php @@ -76,6 +76,11 @@ class Setting { */ protected mixed $value; + /** + * Constructs the setting. + * + * @since 2.8.0 + */ public function __construct( /** * Setting group ID. @@ -204,7 +209,8 @@ class Setting { /** * The plugin settings object. * - * @access private + * @var Settings + * * @since 2.8.0 */ private Settings $settings @@ -214,6 +220,15 @@ class Setting { register_setting( $this->options_group_slug, $this->key, $this->get_setting_args()); } + /** + * Get the args for registering the settings with WordPress. + * + * @see register_setting() + * + * @return array The setting field args. + * + * @since 2.8.0 + */ public function get_setting_args(): array { return array ( 'type' => $this->type, @@ -223,7 +238,13 @@ class Setting { } /** + * Get the args for rendering setting fields on the admin. dashboard. * + * @see add_settings_field() + * + * @return array The setting field args. + * + * @since 2.8.0 */ public function get_setting_field_args(): array { return array ( @@ -239,6 +260,15 @@ class Setting { ); } + /** + * Check whether a setting is enabled and/or overridden. + * + * @return ?bool 'True' if the setting is disabled or overridden. + * 'False' if it could be, but isn't currently. + * 'None' if the setting is not enabled/overridden by another. + * + * @since 2.8.0 + */ private function is_disabled_or_overridden(): ?bool { if (isset($this->enabled_by)) { $enabled_by_value = $this->settings->get_setting_value($this->enabled_by); @@ -261,36 +291,68 @@ class Setting { } else return null; } + /** + * Gets the slug of the setting's options group. + * + * @return string The options group slug. + * + * @since 2.8.0 + */ public function get_options_group_slug(): string { return $this->options_group_slug; } + /** + * Gets the slug of the setting's section. + * + * @return string The section slug. + * + * @since 2.8.0 + */ public function get_section_slug(): string { return $this->section_slug; } /** - * + * Gets the value of the setting. + * + * @return mixed The value of the setting, or the default value if none is set. 'None' if neither are set. + * + * @since 2.8.0 */ public function get_value(): mixed { return $this->value ?? $this->default_value ?? null; } /** - * + * Gets the default value of the setting. + * + * @return mixed The default value of the setting. 'None' if one is not set. + * + * @since 2.8.0 */ public function get_default_value(): mixed { return $this->default_value ?? null; } /** - * + * Gets the input options of the setting. + * + * @return ?array The possible options of the setting. 'None' if no options are set. + * + * @since 2.8.0 */ public function get_input_options(): ?array { return $this->input_options ?? null; } /** + * Sets the value of the setting. + * + * @param mixed $value The new value to set. + * @return bool 'True' if the value was successfully set. 'False' otherwise. + * + * @since 2.8.0 */ public function set_value(mixed $value): bool { $this->value = $value; diff --git a/src/includes/settings/class-settings-group.php b/src/includes/settings/class-settings-group.php index b5c9a97..1d50b67 100644 --- a/src/includes/settings/class-settings-group.php +++ b/src/includes/settings/class-settings-group.php @@ -11,7 +11,7 @@ declare(strict_types=1); namespace footnotes\includes\settings; use footnotes\includes\Settings; -use footnotes\admin\layout as Layout; +use footnotes\admin\layout\SettingsPage; /** * Class defining a group of plugin settings within a section. @@ -56,6 +56,11 @@ abstract class SettingsGroup { */ protected array $settings; + /** + * Constructs the settings section. + * + * @since 2.8.0 + */ public function __construct( /** * Setting options group slug. @@ -88,12 +93,38 @@ abstract class SettingsGroup { $this->add_settings( get_option( $this->options_group_slug ) ); } + /** + * Load the required dependencies. + * + * Include the following files that provide the settings for this plugin: + * + * - {@see Setting}: defines individual settings. + * + * @since 2.8.0 + */ protected function load_dependencies(): void { require_once plugin_dir_path( __DIR__ ) . 'settings/class-setting.php'; } + /** + * Add the settings for this settings group. + * + * @abstract + * @param array|false $options Saved values for the settings in this group. 'False' if none exist. + * @return void + * + * @since 2.8.0 + */ protected abstract function add_settings(array|false $options): void; + /** + * Constructs settings from the provided details. + * + * @param array $setting The setting details. + * @return Setting The constructed setting object. + * + * @since 2.8.0 + */ protected function add_setting(array $setting): Setting { extract( $setting ); @@ -116,17 +147,33 @@ abstract class SettingsGroup { ); } + /** + * Load the values for this settings group. + * + * @param array|false $options Saved values for the settings in this group. 'False' if none exist. + * @return void + * + * @since 2.8.0 + * @todo Remove settings from options group when not found. + */ protected function load_values(array|false $options): void { if ( ! $options ) return; - // TODO remove unfound settings from option foreach ( $options as $setting_key => $setting_value ) { if ( array_key_exists( $setting_key, $this->settings ) ) $this->settings[$setting_key]->set_value( $setting_value ); } } - public function add_settings_fields(Layout\SettingsPage $component): void { + /** + * Adds all the settings fields for this group to the admin. dashboard. + * + * @param SettingsPage $component The admin. dashboard settings page. + * @return void + * + * @since 2.8.0 + */ + public function add_settings_fields(SettingsPage $component): void { foreach ($this->settings as $setting) { add_settings_field( $setting->key, @@ -139,6 +186,9 @@ abstract class SettingsGroup { } } + /** + * @see Settings::get_setting() + */ public function get_setting(string $setting_key): ?Setting { foreach ($this->settings as $setting) { if ($setting->key === $setting_key) return $setting; @@ -146,7 +196,10 @@ abstract class SettingsGroup { return null; } - + + /** + * @see SettingsSection::get_options() + */ public function get_options(): array { $options = array(); @@ -157,6 +210,9 @@ abstract class SettingsGroup { return $options; } + /** + * @see Settings::get_setting_value() + */ public function get_setting_value(string $setting_key) { $setting = $this->get_setting($setting_key); @@ -164,6 +220,9 @@ abstract class SettingsGroup { else return $setting->value ?? $setting->default_value; } + /** + * @see Settings::set_setting_value() + */ public function set_setting_value(string $setting_key, $value): bool { return $this->get_setting($setting_key)->set_value($value); } diff --git a/src/includes/settings/class-settings-section.php b/src/includes/settings/class-settings-section.php index ca19228..03be3a4 100644 --- a/src/includes/settings/class-settings-section.php +++ b/src/includes/settings/class-settings-section.php @@ -1,6 +1,6 @@ "; } + /** + * Add the settings groups for this settings section. + * + * @abstract + * @return void + * + * @since 2.8.0 + */ protected abstract function add_settings_groups(): void; public function get_options_group_slug(): string { return $this->options_group_slug; } + /** + * Gets the settings section slug. + * + * @return string The section slug. + * + * @since 2.8.0 + */ public function get_section_slug(): string { return $this->section_slug; } + /** + * Gets the settings section title. + * + * @return string The section title. + * + * @since 2.8.0 + */ public function get_title(): string { return $this->title; } - public function get_settings_group(string $group_id) { - return $this->settings_groups[$group_id]; + /** + * Gets a settings groups from this section by its ID. + * + * @param string group_id The ID of the settings group. + * @return ?SettingsGroup The section group. 'None' if none found. + * + * @since 2.8.0 + */ + public function get_settings_group(string $group_id): ?SettingsGroup { + return $this->settings_groups[$group_id] ?? null; } + /** + * @see Settings::get_setting() + */ public function get_setting(string $setting_key): ?Setting { foreach ($this->settings_groups as $settings_group) { $setting = $settings_group->get_setting($setting_key); @@ -116,6 +161,13 @@ abstract class SettingsSection { return null; } + /** + * Creates an options group from the values of the settings in this section. + * + * @return array The options group. + * + * @since 2.8.0 + */ public function get_options(): array { $options = array(); @@ -126,6 +178,9 @@ abstract class SettingsSection { return $options; } + /** + * @see Settings::get_setting_value() + */ public function get_setting_value(string $setting_key) { $setting = $this->get_setting($setting_key); @@ -133,6 +188,9 @@ abstract class SettingsSection { else return $setting->value ?? $setting->default_value ?? trigger_error("No default value found for ".$setting_key.".", E_USER_ERROR); } + /** + * @see Settings::set_setting_value() + */ public function set_setting_value(string $setting_key, $value): ?bool { $setting = $this->get_setting($setting_key); diff --git a/src/includes/settings/custom-css/class-custom-css-settings-group.php b/src/includes/settings/custom-css/class-custom-css-settings-group.php index 06e9b4b..db44342 100644 --- a/src/includes/settings/custom-css/class-custom-css-settings-group.php +++ b/src/includes/settings/custom-css/class-custom-css-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\customcss; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -30,7 +28,16 @@ class CustomCSSSettingsGroup extends SettingsGroup { * * @since 2.8.0 */ - const GROUP_ID = 'custom-css'; + public const GROUP_ID = 'custom-css'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Custom CSS'; /** * Settings container key for the Custom CSS. @@ -41,13 +48,31 @@ class CustomCSSSettingsGroup extends SettingsGroup { * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`. * Convert from `string` to `array`. */ - const CUSTOM_CSS = array( + public const CUSTOM_CSS = array( 'key' => 'footnote_inputfield_custom_css_new', 'name' => 'Your Existing Custom CSS Code', 'type' => 'string', 'input_type' => 'textarea', ); - + + /** + * Load the required dependencies. + * + * Include the following files that provide the settings for this plugin: + * + * - {@see SettingsGroup}: defines a group of settings. + * + * @see SettingsGroup::load_dependencies() + */ + protected function load_dependencies(): void { + parent::load_dependencies(); + + require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; + } + + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::CUSTOM_CSS['key'] => $this->add_setting( self::CUSTOM_CSS ), diff --git a/src/includes/settings/custom-css/class-custom-css-settings-section.php b/src/includes/settings/custom-css/class-custom-css-settings-section.php index 6325798..347a023 100644 --- a/src/includes/settings/custom-css/class-custom-css-settings-section.php +++ b/src/includes/settings/custom-css/class-custom-css-settings-section.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\customcss; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-section.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\SettingsSection; @@ -34,6 +32,15 @@ class CustomCSSSettingsSection extends SettingsSection { */ protected array $settings_groups; + /** + * Constructs the settings section. + * + * @param string options_group_slug The slug of the settings section's options group. + * @param string section_slug The slug of the settings section. + * @param string title The name of the settings section. + * + * @since 2.8.0 + */ public function __construct( $options_group_slug, $section_slug, @@ -57,13 +64,28 @@ class CustomCSSSettingsSection extends SettingsSection { $this->load_options_group(); } - + + /** + * Load the required dependencies. + * + * Include the following files that provide the settings for this section: + * + * - {@see SettingsSection}: defines a settings section; and + * - {@see CustomCSSSettingsGroup}. + * + * @see SettingsSection::load_dependencies() + */ protected function load_dependencies(): void { parent::load_dependencies(); + + require_once plugin_dir_path( __DIR__ ) . 'class-settings-section.php'; require_once plugin_dir_path( __DIR__ ) . 'custom-css/class-custom-css-settings-group.php'; } + /** + * @see SettingsSection::add_settings_groups() + */ protected function add_settings_groups(): void { $this->settings_groups = array ( CustomCSSSettingsGroup::GROUP_ID => new CustomCSSSettingsGroup($this->options_group_slug, $this->section_slug, $this->settings ), diff --git a/src/includes/settings/general/class-amp-compat-settings-group.php b/src/includes/settings/general/class-amp-compat-settings-group.php index 766e8c5..142ffde 100644 --- a/src/includes/settings/general/class-amp-compat-settings-group.php +++ b/src/includes/settings/general/class-amp-compat-settings-group.php @@ -11,8 +11,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\general; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Footnotes; use footnotes\includes\Settings; use footnotes\includes\settings\Setting; @@ -42,7 +40,7 @@ class AMPCompatSettingsGroup extends SettingsGroup { * * @since 2.8.0 */ - const GROUP_NAME = 'AMP Compatiblility (unsupported)'; + const GROUP_NAME = 'AMP Compatiblility (deprecated)'; /** * Settings container key to enable AMP compatibility mode. @@ -63,6 +61,9 @@ class AMPCompatSettingsGroup extends SettingsGroup { 'input_type' => 'checkbox', ); + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::FOOTNOTES_AMP_COMPATIBILITY_ENABLE['key'] => $this->add_setting( self::FOOTNOTES_AMP_COMPATIBILITY_ENABLE ), diff --git a/src/includes/settings/general/class-excerpts-settings-group.php b/src/includes/settings/general/class-excerpts-settings-group.php index 62668d5..a908d64 100644 --- a/src/includes/settings/general/class-excerpts-settings-group.php +++ b/src/includes/settings/general/class-excerpts-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\general; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Footnotes; use footnotes\includes\Settings; use footnotes\includes\settings\Setting; @@ -64,7 +62,10 @@ class ExcerptsSettingsGroup extends SettingsGroup { 'manual' => 'Yes but run the process only to display tooltips in manual excerpts with footnote short codes' ), ); - + + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::FOOTNOTES_IN_EXCERPT['key'] => $this->add_setting( self::FOOTNOTES_IN_EXCERPT ), diff --git a/src/includes/settings/general/class-general-settings-section.php b/src/includes/settings/general/class-general-settings-section.php index 12775c5..6a6f346 100644 --- a/src/includes/settings/general/class-general-settings-section.php +++ b/src/includes/settings/general/class-general-settings-section.php @@ -10,10 +10,7 @@ declare(strict_types=1); namespace footnotes\includes\settings\general; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-section.php'; - use footnotes\includes\Settings; - use footnotes\includes\settings\SettingsSection; use footnotes\includes\settings\general\ReferenceContainerSettingsGroup; @@ -41,6 +38,15 @@ class GeneralSettingsSection extends SettingsSection { */ protected array $settings_groups; + /** + * Constructs the settings section. + * + * @param string options_group_slug The slug of the settings section's options group. + * @param string section_slug The slug of the settings section. + * @param string title The name of the settings section. + * + * @since 2.8.0 + */ public function __construct( $options_group_slug, $section_slug, @@ -65,6 +71,23 @@ class GeneralSettingsSection extends SettingsSection { $this->load_options_group(); } + /** + * Load the required dependencies. + * + * Include the following files that provide the settings for this section: + * + * - {@see SettingsSection}: defines a settings section; + * - {@see AMPCompatSettingsGroup}; + * - {@see ReferenceContainerSettingsGroup}; + * - {@see ScrollingSettingsGroup}; + * - {@see ShortcodeSettingsGroup}; + * - {@see NumberingSettingsGroup}; + * - {@see HardLinksSettingsGroup}; + * - {@see ExcerptsSettingsGroup}; and + * - {@see LoveSettingsGroup}. + * + * @see SettingsSection::load_dependencies() + */ protected function load_dependencies(): void { parent::load_dependencies(); @@ -77,7 +100,10 @@ class GeneralSettingsSection extends SettingsSection { require_once plugin_dir_path( __DIR__ ) . 'general/class-excerpts-settings-group.php'; require_once plugin_dir_path( __DIR__ ) . 'general/class-amp-compat-settings-group.php'; } - + + /** + * @see SettingsSection::add_settings_groups() + */ protected function add_settings_groups(): void { $this->settings_groups = array( AMPCompatSettingsGroup::GROUP_ID => new AMPCompatSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ), diff --git a/src/includes/settings/general/class-hard-links-settings-group.php b/src/includes/settings/general/class-hard-links-settings-group.php index a62f3e2..de20c77 100644 --- a/src/includes/settings/general/class-hard-links-settings-group.php +++ b/src/includes/settings/general/class-hard-links-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\general; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class HardLinksSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'hard-links'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'URL Fragment ID Configuration'; /** * Settings container key to enable hard links. @@ -150,7 +157,10 @@ class HardLinksSettingsGroup extends SettingsGroup { 'type' => 'string', 'input_type' => 'text', ); - + + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::FOOTNOTES_HARD_LINKS_ENABLE['key'] => $this->add_setting( self::FOOTNOTES_HARD_LINKS_ENABLE ), diff --git a/src/includes/settings/general/class-love-settings-group.php b/src/includes/settings/general/class-love-settings-group.php index 9a1a067..9aee495 100644 --- a/src/includes/settings/general/class-love-settings-group.php +++ b/src/includes/settings/general/class-love-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\general; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Footnotes; use footnotes\includes\Settings; use footnotes\includes\settings\Setting; @@ -24,7 +22,22 @@ use footnotes\includes\settings\SettingsGroup; * @since 2.8.0 */ class LoveSettingsGroup extends SettingsGroup { + /** + * The HTML 'love' symbol. + * + * @var string + * + * @since 2.8.0 + */ const LOVE_SYMBOL = ''; + + /** + * The HTML Plugin logogram. + * + * @var string + * + * @since 2.8.0 + */ const PLUGIN_SYMBOL = ''; /** @@ -43,7 +56,7 @@ class LoveSettingsGroup extends SettingsGroup { * * @since 2.8.0 */ - const GROUP_NAME = self::LOVE_SYMBOL . ' Love'; + const GROUP_NAME = self::PLUGIN_SYMBOL . ' ' . self::LOVE_SYMBOL; /** * Settings container key for the ‘I love footnotes’ text. @@ -99,7 +112,10 @@ class LoveSettingsGroup extends SettingsGroup { 'type' => 'string', 'input_type' => 'text', ); - + + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::FOOTNOTES_LOVE['key'] => $this->add_setting( self::FOOTNOTES_LOVE ), diff --git a/src/includes/settings/general/class-numbering-settings-group.php b/src/includes/settings/general/class-numbering-settings-group.php index 4c43922..714ac63 100644 --- a/src/includes/settings/general/class-numbering-settings-group.php +++ b/src/includes/settings/general/class-numbering-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\general; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class NumberingSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'numbering'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Footnotes Numbering'; /** * Settings container key for combining identical footnotes. @@ -78,7 +85,10 @@ class NumberingSettingsGroup extends SettingsGroup { 'roman_low' => 'lowercase Roman numerals (i, ii, iii, iv, v, …)', ), ); - + + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::COMBINE_IDENTICAL_FOOTNOTES['key'] => $this->add_setting( self::COMBINE_IDENTICAL_FOOTNOTES ), diff --git a/src/includes/settings/general/class-reference-container-settings-group.php b/src/includes/settings/general/class-reference-container-settings-group.php index 0c8b827..0ee04c4 100644 --- a/src/includes/settings/general/class-reference-container-settings-group.php +++ b/src/includes/settings/general/class-reference-container-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\general; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'reference-container'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Reference Container'; /** * Settings container key for the label of the reference container. @@ -680,7 +687,10 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { 'type' => 'boolean', 'input_type' => 'checkbox', ); - + + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::REFERENCE_CONTAINER_NAME['key'] => $this->add_setting( self::REFERENCE_CONTAINER_NAME ), diff --git a/src/includes/settings/general/class-scrolling-settings-group.php b/src/includes/settings/general/class-scrolling-settings-group.php index 87a0fa9..b39d2c0 100644 --- a/src/includes/settings/general/class-scrolling-settings-group.php +++ b/src/includes/settings/general/class-scrolling-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\general; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class ScrollingSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'scrolling'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Scrolling Behavior'; /** * Settings container key to enable CSS smooth scrolling. @@ -172,7 +179,10 @@ class ScrollingSettingsGroup extends SettingsGroup { 'input_min' => 0, 'enabled_by' => self::FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY, ); - + + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::FOOTNOTES_CSS_SMOOTH_SCROLLING['key'] => $this->add_setting( self::FOOTNOTES_CSS_SMOOTH_SCROLLING ), diff --git a/src/includes/settings/general/class-shortcode-settings-group.php b/src/includes/settings/general/class-shortcode-settings-group.php index 345a998..111d157 100644 --- a/src/includes/settings/general/class-shortcode-settings-group.php +++ b/src/includes/settings/general/class-shortcode-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\general; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class ShortcodeSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'shortcode'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Footnote Start and End Short Codes'; /** * Settings container key to enable shortcode syntax validation. @@ -141,7 +148,10 @@ class ShortcodeSettingsGroup extends SettingsGroup { 'input_type' => 'text', 'enabled_by' => self::FOOTNOTES_SHORT_CODE_END, ); - + + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE['key'] => $this->add_setting( self::FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE ), diff --git a/src/includes/settings/referrers-and-tooltips/class-backlink-symbol-settings-group.php b/src/includes/settings/referrers-and-tooltips/class-backlink-symbol-settings-group.php index 78393b2..46e6624 100644 --- a/src/includes/settings/referrers-and-tooltips/class-backlink-symbol-settings-group.php +++ b/src/includes/settings/referrers-and-tooltips/class-backlink-symbol-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\referrersandtooltips; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class BacklinkSymbolSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'backlink-symbol'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Backlink Symbol'; /** * Settings container key for the backlink symbol selection. @@ -80,7 +87,10 @@ class BacklinkSymbolSettingsGroup extends SettingsGroup { 'type' => 'string', 'input_type' => 'text', ); - + + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::HYPERLINK_ARROW['key'] => $this->add_setting( self::HYPERLINK_ARROW ), diff --git a/src/includes/settings/referrers-and-tooltips/class-referrers-and-tooltips-settings-section.php b/src/includes/settings/referrers-and-tooltips/class-referrers-and-tooltips-settings-section.php index 398ef29..894687d 100644 --- a/src/includes/settings/referrers-and-tooltips/class-referrers-and-tooltips-settings-section.php +++ b/src/includes/settings/referrers-and-tooltips/class-referrers-and-tooltips-settings-section.php @@ -10,10 +10,7 @@ declare(strict_types=1); namespace footnotes\includes\settings\referrersandtooltips; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-section.php'; - use footnotes\includes\Settings; - use footnotes\includes\settings\SettingsSection; /** @@ -32,6 +29,15 @@ class ReferrersAndTooltipsSettingsSection extends SettingsSection { */ protected array $settings_groups; + /** + * Constructs the settings section. + * + * @param string options_group_slug The slug of the settings section's options group. + * @param string section_slug The slug of the settings section. + * @param string title The name of the settings section. + * + * @since 2.8.0 + */ public function __construct( $options_group_slug, $section_slug, @@ -56,6 +62,25 @@ class ReferrersAndTooltipsSettingsSection extends SettingsSection { $this->load_options_group(); } + /** + * Load the required dependencies. + * + * Include the following files that provide the settings for this section: + * + * - {@see SettingsSection}: defines a section of settings; + * - {@see BacklinkSymbolSettingsGroup}; + * - {@see ReferrersSettingsGroup}; + * - {@see ReferrersInLabelsSettingsGroup}; + * - {@see TooltipsSettingsGroup}; + * - {@see TooltipAppearanceSettingsGroup}; + * - {@see TooltipDimensionsSettingsGroup}; + * - {@see TooltipPositionSettingsGroup}; + * - {@see TooltipTextSettingsGroup}; + * - {@see TooltipTimingSettingsGroup}; and + * - {@see TooltipTruncationSettingsGroup}. + * + * @see SettingsSection::load_dependencies() + */ protected function load_dependencies(): void { parent::load_dependencies(); @@ -71,6 +96,9 @@ class ReferrersAndTooltipsSettingsSection extends SettingsSection { require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltip-truncation-settings-group.php'; } + /** + * @see SettingsSection::add_settings_groups() + */ protected function add_settings_groups(): void { $this->settings_groups = array ( BacklinkSymbolSettingsGroup::GROUP_ID => new BacklinkSymbolSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ), diff --git a/src/includes/settings/referrers-and-tooltips/class-referrers-in-labels-settings-group.php b/src/includes/settings/referrers-and-tooltips/class-referrers-in-labels-settings-group.php index 2263ec1..35fc504 100644 --- a/src/includes/settings/referrers-and-tooltips/class-referrers-in-labels-settings-group.php +++ b/src/includes/settings/referrers-and-tooltips/class-referrers-in-labels-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\referrersandtooltips; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class ReferrersInLabelsSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'referrers-in-label'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Referrers in Labels'; /** * Settings container key to set the solution of the input element label issue. @@ -62,7 +69,10 @@ class ReferrersInLabelsSettingsGroup extends SettingsGroup { 'disconnect' => 'B. Labels with footnotes are disconnected from input element (discouraged)' ), ); - + + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::FOOTNOTES_LABEL_ISSUE_SOLUTION['key'] => $this->add_setting( self::FOOTNOTES_LABEL_ISSUE_SOLUTION ), diff --git a/src/includes/settings/referrers-and-tooltips/class-referrers-settings-group.php b/src/includes/settings/referrers-and-tooltips/class-referrers-settings-group.php index 3db9c2a..cc09780 100644 --- a/src/includes/settings/referrers-and-tooltips/class-referrers-settings-group.php +++ b/src/includes/settings/referrers-and-tooltips/class-referrers-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\referrersandtooltips; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class ReferrersSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'referrers'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Referrers'; /** * Settings container key for the referrer element. @@ -131,6 +138,9 @@ class ReferrersSettingsGroup extends SettingsGroup { 'input_type' => 'checkbox', ); + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS['key'] => $this->add_setting( self::FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS ), diff --git a/src/includes/settings/referrers-and-tooltips/class-tooltip-appearance-settings-group.php b/src/includes/settings/referrers-and-tooltips/class-tooltip-appearance-settings-group.php index 67ddbf8..a39ef01 100644 --- a/src/includes/settings/referrers-and-tooltips/class-tooltip-appearance-settings-group.php +++ b/src/includes/settings/referrers-and-tooltips/class-tooltip-appearance-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\referrersandtooltips; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'tooltip-appearance'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Tooltip Appearance'; /** * Settings container key to enable setting the tooltip font size. @@ -209,7 +216,10 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup { 'type' => 'string', 'input_type' => 'color', ); - + + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::MOUSE_OVER_BOX_FONT_SIZE_ENABLED['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FONT_SIZE_ENABLED ), diff --git a/src/includes/settings/referrers-and-tooltips/class-tooltip-dimensions-settings-group.php b/src/includes/settings/referrers-and-tooltips/class-tooltip-dimensions-settings-group.php index f3c9101..130f257 100644 --- a/src/includes/settings/referrers-and-tooltips/class-tooltip-dimensions-settings-group.php +++ b/src/includes/settings/referrers-and-tooltips/class-tooltip-dimensions-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\referrersandtooltips; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class TooltipDimensionsSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'tooltip-dimensions'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Tooltip Dimensions'; /** * Settings container key for the mouse-over box to define the max. width. @@ -70,6 +77,9 @@ class TooltipDimensionsSettingsGroup extends SettingsGroup { 'input_type' => 'number', ); + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH['key'] => $this->add_setting( self::FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH ), diff --git a/src/includes/settings/referrers-and-tooltips/class-tooltip-position-settings-group.php b/src/includes/settings/referrers-and-tooltips/class-tooltip-position-settings-group.php index 69aca0c..2d9b72c 100644 --- a/src/includes/settings/referrers-and-tooltips/class-tooltip-position-settings-group.php +++ b/src/includes/settings/referrers-and-tooltips/class-tooltip-position-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\referrersandtooltips; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class TooltipPositionSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'tooltip-position'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Tooltip Position'; /** * Settings container key for the mouse-over box to define the position. @@ -164,6 +171,9 @@ class TooltipPositionSettingsGroup extends SettingsGroup { 'input_type' => 'number', ); + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::FOOTNOTES_MOUSE_OVER_BOX_POSITION['key'] => $this->add_setting( self::FOOTNOTES_MOUSE_OVER_BOX_POSITION ), diff --git a/src/includes/settings/referrers-and-tooltips/class-tooltip-text-settings-group.php b/src/includes/settings/referrers-and-tooltips/class-tooltip-text-settings-group.php index 6401bb6..788a19a 100644 --- a/src/includes/settings/referrers-and-tooltips/class-tooltip-text-settings-group.php +++ b/src/includes/settings/referrers-and-tooltips/class-tooltip-text-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\referrersandtooltips; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class TooltipTextSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'tooltip-text'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Tooltip Text'; /** * Settings container key to configure the tooltip excerpt delimiter. @@ -103,6 +110,9 @@ class TooltipTextSettingsGroup extends SettingsGroup { 'input_type' => 'text', ); + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER['key'] => $this->add_setting( self::FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER ), diff --git a/src/includes/settings/referrers-and-tooltips/class-tooltip-timing-settings-group.php b/src/includes/settings/referrers-and-tooltips/class-tooltip-timing-settings-group.php index 6e7de20..e7709fe 100644 --- a/src/includes/settings/referrers-and-tooltips/class-tooltip-timing-settings-group.php +++ b/src/includes/settings/referrers-and-tooltips/class-tooltip-timing-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\referrersandtooltips; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class TooltipTimingSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'tooltip-timing'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Tooltip Timing'; /** * Settings container key for tooltip display fade-in delay. @@ -112,6 +119,9 @@ class TooltipTimingSettingsGroup extends SettingsGroup { 'input_min' => 0, ); + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::MOUSE_OVER_BOX_FADE_IN_DELAY['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FADE_IN_DELAY ), diff --git a/src/includes/settings/referrers-and-tooltips/class-tooltip-truncation-settings-group.php b/src/includes/settings/referrers-and-tooltips/class-tooltip-truncation-settings-group.php index 442fa34..bd59873 100644 --- a/src/includes/settings/referrers-and-tooltips/class-tooltip-truncation-settings-group.php +++ b/src/includes/settings/referrers-and-tooltips/class-tooltip-truncation-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\referrersandtooltips; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class TooltipTruncationSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'tooltip-truncation'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Tooltip Truncation'; /** * Settings container key to enable tooltip truncation. @@ -93,6 +100,9 @@ class TooltipTruncationSettingsGroup extends SettingsGroup { 'input_type' => 'text', ); + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED['key'] => $this->add_setting( self::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED ), diff --git a/src/includes/settings/referrers-and-tooltips/class-tooltips-settings-group.php b/src/includes/settings/referrers-and-tooltips/class-tooltips-settings-group.php index c58b20b..0dac43c 100644 --- a/src/includes/settings/referrers-and-tooltips/class-tooltips-settings-group.php +++ b/src/includes/settings/referrers-and-tooltips/class-tooltips-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\referrersandtooltips; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -31,6 +29,15 @@ class TooltipsSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'tooltips'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'Tooltips'; /** * Settings container key to enable the mouse-over box. @@ -75,6 +82,9 @@ class TooltipsSettingsGroup extends SettingsGroup { 'input_type' => 'checkbox', ); + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::FOOTNOTES_MOUSE_OVER_BOX_ENABLED['key'] => $this->add_setting( self::FOOTNOTES_MOUSE_OVER_BOX_ENABLED ), diff --git a/src/includes/settings/scope-and-priority/class-scope-and-priority-settings-section.php b/src/includes/settings/scope-and-priority/class-scope-and-priority-settings-section.php index 788dd03..bb08222 100644 --- a/src/includes/settings/scope-and-priority/class-scope-and-priority-settings-section.php +++ b/src/includes/settings/scope-and-priority/class-scope-and-priority-settings-section.php @@ -10,10 +10,7 @@ declare(strict_types=1); namespace footnotes\includes\settings\scopeandpriority; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-section.php'; - use footnotes\includes\Settings; - use footnotes\includes\settings\SettingsSection; use footnotes\includes\settings\scopeandpriority\WordPressHooksSettingsGroup; @@ -34,6 +31,15 @@ class ScopeAndPrioritySettingsSection extends SettingsSection { */ protected array $settings_groups; + /** + * Constructs the settings section. + * + * @param string options_group_slug The slug of the settings section's options group. + * @param string section_slug The slug of the settings section. + * @param string title The name of the settings section. + * + * @since 2.8.0 + */ public function __construct( $options_group_slug, $section_slug, @@ -58,12 +64,25 @@ class ScopeAndPrioritySettingsSection extends SettingsSection { $this->load_options_group(); } + /** + * Load the required dependencies. + * + * Include the following files that provide the settings for this section: + * + * - {@see SettingsSection}: defines a settings section; and + * - {@see WordPressHooksSettingsGroup}. + * + * @see SettingsSection::load_dependencies() + */ protected function load_dependencies(): void { parent::load_dependencies(); - + require_once plugin_dir_path( __DIR__ ) . 'scope-and-priority/class-wordpress-hooks-settings-group.php'; } + /** + * @see SettingsSection::add_settings_groups() + */ protected function add_settings_groups(): void { $this->settings_groups = array ( WordPressHooksSettingsGroup::GROUP_ID => new WordPressHooksSettingsGroup($this->options_group_slug, $this->section_slug, $this->settings ), diff --git a/src/includes/settings/scope-and-priority/class-wordpress-hooks-settings-group.php b/src/includes/settings/scope-and-priority/class-wordpress-hooks-settings-group.php index 51360a7..76b09f7 100644 --- a/src/includes/settings/scope-and-priority/class-wordpress-hooks-settings-group.php +++ b/src/includes/settings/scope-and-priority/class-wordpress-hooks-settings-group.php @@ -10,8 +10,6 @@ declare(strict_types=1); namespace footnotes\includes\settings\scopeandpriority; -require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php'; - use footnotes\includes\Settings; use footnotes\includes\settings\Setting; use footnotes\includes\settings\SettingsGroup; @@ -30,7 +28,16 @@ class WordPressHooksSettingsGroup extends SettingsGroup { * * @since 2.8.0 */ - const GROUP_ID = 'wordpress-hooks'; + public const GROUP_ID = 'wordpress-hooks'; + + /** + * Setting group name. + * + * @var string + * + * @since 2.8.0 + */ + const GROUP_NAME = 'WordPress Hooks with Priority Level'; /** * Settings container key to enable the `the_title` hook. @@ -53,7 +60,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup { * title string in menus and in the title element, but Footnotes doesn't * delete footnotes in them. */ - const EXPERT_LOOKUP_THE_TITLE = array( + public const EXPERT_LOOKUP_THE_TITLE = array( 'key' => 'footnote_inputfield_expert_lookup_the_title', 'name' => 'the_title()', 'description' => 'https://developer.wordpress.org/reference/hooks/the_title/', @@ -71,7 +78,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup { * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`. * Convert from `int` to `array`. */ - const EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL = array( + public const EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL = array( 'key' => 'footnote_inputfield_expert_lookup_the_title_priority_level', 'name' => 'the_title() Priority Level', 'description' => 'The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features. 9223372036854775807 is lowest priority, 0 is highest. To set priority level to lowest, set it to -1, interpreted as 9223372036854775807, the constant PHP_INT_MAX.', @@ -92,7 +99,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. * Convert setting data type from `string` to `boolean`. */ - const EXPERT_LOOKUP_THE_CONTENT = array( + public const EXPERT_LOOKUP_THE_CONTENT = array( 'key' => 'footnote_inputfield_expert_lookup_the_content', 'name' => 'the_content()', 'description' => 'https://developer.wordpress.org/reference/hooks/the_content/', @@ -126,7 +133,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup { * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`. * Convert from `int` to `array`. */ - const EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL = array( + public const EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL = array( 'key' => 'footnote_inputfield_expert_lookup_the_content_priority_level', 'name' => 'the_content() Priority Level', 'description' => 'The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features. 9223372036854775807 is lowest priority, 0 is highest. To set priority level to lowest, set it to -1, interpreted as 9223372036854775807, the constant PHP_INT_MAX. For the_content, this figure must be lower than 99 so that certain strings added by a plugin running at 99 may not be mistaken as a footnote. This makes also sure that the reference container displays above a feature inserted by a plugin running at 1200.', @@ -148,7 +155,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. * Convert setting data type from `string` to `boolean`. */ - const EXPERT_LOOKUP_THE_EXCERPT = array( + public const EXPERT_LOOKUP_THE_EXCERPT = array( 'key' => 'footnote_inputfield_expert_lookup_the_excerpt', 'name' => 'the_excerpt()', 'description' => 'https://developer.wordpress.org/reference/hooks/the_excerpt/', @@ -166,7 +173,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup { * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`. * Convert from `int` to `array`. */ - const EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL = array( + public const EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL = array( 'key' => 'footnote_inputfield_expert_lookup_the_excerpt_priority_level', 'name' => 'the_excerpt() Priority Level', 'description' => 'The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features. 9223372036854775807 is lowest priority, 0 is highest. To set priority level to lowest, set it to -1, interpreted as 9223372036854775807, the constant PHP_INT_MAX.', @@ -187,7 +194,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. * Convert setting data type from `string` to `boolean`. */ - const EXPERT_LOOKUP_WIDGET_TITLE = array( + public const EXPERT_LOOKUP_WIDGET_TITLE = array( 'key' => 'footnote_inputfield_expert_lookup_widget_title', 'name' => 'widget_title()', 'description' => 'https://codex.wordpress.org/Plugin_API/Filter_Reference/widget_title', @@ -205,7 +212,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup { * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`. * Convert from `int` to `array`. */ - const EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL = array( + public const EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL = array( 'key' => 'footnote_inputfield_expert_lookup_widget_title_priority_level', 'name' => 'widget_title() Priority Level', 'description' => 'The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features. 9223372036854775807 is lowest priority, 0 is highest. To set priority level to lowest, set it to -1, interpreted as 9223372036854775807, the constant PHP_INT_MAX.', @@ -231,7 +238,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. * Convert setting data type from `string` to `boolean`. */ - const EXPERT_LOOKUP_WIDGET_TEXT = array( + public const EXPERT_LOOKUP_WIDGET_TEXT = array( 'key' => 'footnote_inputfield_expert_lookup_widget_text', 'name' => 'widget_text()', 'description' => 'https://codex.wordpress.org/Plugin_API/Filter_Reference/widget_text. The widget_text() hook must be enabled either when footnotes are present in theme text widgets, or when Elementor accordions or toggles shall have a reference container per section. If they should not, this hook must be disabled.', @@ -249,7 +256,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup { * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`. * Convert from `int` to `array`. */ - const EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL = array( + public const EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL = array( 'key' => 'footnote_inputfield_expert_lookup_widget_text_priority_level', 'name' => 'widget_text() Priority Level', 'description' => 'The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features. 9223372036854775807 is lowest priority, 0 is highest. To set priority level to lowest, set it to -1, interpreted as 9223372036854775807, the constant PHP_INT_MAX.', @@ -260,6 +267,9 @@ class WordPressHooksSettingsGroup extends SettingsGroup { 'input_min' => -1, ); + /** + * @see SettingsGroup::add_settings() + */ protected function add_settings( array|false $options ): void { $this->settings = array( self::EXPERT_LOOKUP_THE_TITLE['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_TITLE ), diff --git a/src/public/class-general.php b/src/public/class-general.php index 186188a..a01943d 100644 --- a/src/public/class-general.php +++ b/src/public/class-general.php @@ -9,9 +9,6 @@ declare(strict_types=1); namespace footnotes\general; - -require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/settings/general/class-reference-container-settings-group.php'; -require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/settings/general/class-scrolling-settings-group.php'; use footnotes\includes\{Footnotes, Convert, Settings};