This repository has been archived on 2023-08-16. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
footnotes/src/includes/settings/general/class-generalsettingssection.php

122 lines
4.4 KiB
PHP
Raw Normal View History

2021-05-17 12:56:22 +01:00
<?php
/**
* File providing the `GeneralSettingsSection` class.
*
* @package footnotes
* @since 2.8.0
*/
declare(strict_types=1);
2021-05-30 07:40:40 +01:00
namespace footnotes\includes\settings\general;
2021-05-17 12:56:22 +01:00
use footnotes\includes\Settings;
use footnotes\includes\settings\SettingsSection;
2021-05-17 12:56:22 +01:00
use footnotes\includes\settings\general\ReferenceContainerSettingsGroup;
use footnotes\includes\settings\general\ScrollingSettingsGroup;
use footnotes\includes\settings\general\ShortcodeSettingsGroup;
use footnotes\includes\settings\general\NumberingSettingsGroup;
use footnotes\includes\settings\general\HardLinksSettingsGroup;
use footnotes\includes\settings\general\LoveSettingsGroup;
use footnotes\includes\settings\general\ExcerptsSettingsGroup;
use footnotes\includes\settings\general\AMPCompatSettingsGroup;
2021-05-17 12:56:22 +01:00
/**
* Class defining general plugin settings.
*
* @package footnotes
* @since 2.8.0
*/
class GeneralSettingsSection extends SettingsSection {
2021-05-17 12:56:22 +01:00
/**
* The groups of settings within this section.
*
* @var SettingsGroup[]
*
* @since 2.8.0
*/
protected array $settings_groups;
2021-08-09 11:27:13 +01:00
/**
* Constructs the settings section.
*
2021-08-09 11:48:58 +01:00
* @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.
2021-08-09 11:27:13 +01:00
*
* @since 2.8.0
*/
2021-05-17 12:56:22 +01:00
public function __construct(
$options_group_slug,
$section_slug,
$title,
2021-08-09 11:48:58 +01:00
/**
* The plugin settings object.
*
* @access private
* @since 2.8.0
*/
protected Settings $settings
2021-05-17 12:56:22 +01:00
) {
$this->options_group_slug = $options_group_slug;
$this->section_slug = $section_slug;
$this->title = $title;
2021-05-17 12:56:22 +01:00
$this->load_dependencies();
$this->add_settings_groups( get_option( $this->options_group_slug ) );
$this->load_options_group();
2021-05-17 12:56:22 +01:00
}
2021-08-09 11:27:13 +01:00
/**
* 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()
*/
2021-05-17 12:56:22 +01:00
protected function load_dependencies(): void {
parent::load_dependencies();
2021-08-09 11:48:58 +01:00
require_once plugin_dir_path( __DIR__ ) . 'general/class-referencecontainersettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-scrollingsettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-shortcodesettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-numberingsettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-hardlinkssettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-lovesettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-excerptssettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-ampcompatsettingsgroup.php';
2021-05-17 12:56:22 +01:00
}
2021-08-09 11:48:58 +01:00
2021-08-09 11:27:13 +01:00
/**
2021-08-09 11:48:58 +01:00
* Add the settings groups for this settings section.
*
2021-08-09 11:27:13 +01:00
* @see SettingsSection::add_settings_groups()
*/
2021-05-17 12:56:22 +01:00
protected function add_settings_groups(): void {
$this->settings_groups = array(
AMPCompatSettingsGroup::GROUP_ID => new AMPCompatSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
ReferenceContainerSettingsGroup::GROUP_ID => new ReferenceContainerSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
ScrollingSettingsGroup::GROUP_ID => new ScrollingSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
ShortcodeSettingsGroup::GROUP_ID => new ShortcodeSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
NumberingSettingsGroup::GROUP_ID => new NumberingSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
HardLinksSettingsGroup::GROUP_ID => new HardLinksSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
ExcerptsSettingsGroup::GROUP_ID => new ExcerptsSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
LoveSettingsGroup::GROUP_ID => new LoveSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
2021-05-17 12:56:22 +01:00
);
}
}