diff --git a/settings.ods b/settings.ods index 265f1a8..4a98b91 100644 Binary files a/settings.ods and b/settings.ods differ diff --git a/src/includes/settings/class-TEMP-settings-group.php b/src/includes/settings/class-TEMP-settings-group.php new file mode 100644 index 0000000..95b1379 --- /dev/null +++ b/src/includes/settings/class-TEMP-settings-group.php @@ -0,0 +1,64 @@ + 'TEMP_SETTING_KEY', + 'name' => 'TEMP_SETTING_LABEL', + 'description' => 'TEMP_SETTING_DESC', + 'default_value' => TEMP_DEFAULT_VALUE, + 'type' => 'integer', + 'input_type' => 'number', + ['input_max' => TEMP_MAX,] + ['input_min' => TEMP_MIN,] + ['enabled_by' => self::TEMP_ENABLED_BY_SETTING_NAME] + ); + + protected function add_settings(array|false $options): void { + $this->settings = array( + self::TEMP_SETTING_NAME['key'] => $this->add_setting(self::TEMP_SETTING_NAME), + ); + + $this->load_values( $options ); + } +} diff --git a/src/includes/settings/general/class-general-settings-section.php b/src/includes/settings/general/class-general-settings-section.php index 7e9158b..6efd62e 100644 --- a/src/includes/settings/general/class-general-settings-section.php +++ b/src/includes/settings/general/class-general-settings-section.php @@ -10,9 +10,12 @@ declare(strict_types=1); namespace footnotes\includes\settings\general; -require_once plugin_dir_path( __DIR__ ) . 'settings/class-settings-section.php'; +require_once plugin_dir_path( __DIR__ ) . 'class-settings-section.php'; +use footnotes\includes\settings\SettingsSection; use footnotes\includes\settings\general\ReferenceContainerSettingsGroup; +use footnotes\includes\settings\general\ScrollingSettingsGroup; +use footnotes\includes\settings\general\ShortcodeSettingsGroup; /** * Class defining general plugin settings. @@ -20,7 +23,7 @@ use footnotes\includes\settings\general\ReferenceContainerSettingsGroup; * @package footnotes * @since 2.8.0 */ -class GeneralSettingsSection extends SettingsSection { +class GeneralSettingsSection extends SettingsSection { /** * The groups of settings within this section. * @@ -29,31 +32,36 @@ class GeneralSettingsSection extends SettingsSection { * @since 2.8.0 */ protected array $settings_groups; - + public function __construct( $options_group_slug, $section_slug, $title ) { $this->options_group_slug = $options_group_slug; - $this->section_slug = $section_slug; - $this->title = $title; - + $this->section_slug = $section_slug; + $this->title = $title; + $this->load_dependencies(); - - $this->add_settings_groups(get_option( $this->options_group_slug )); + + $this->add_settings_groups( get_option( $this->options_group_slug ) ); $this->load_options_group(); } - + protected function load_dependencies(): void { - require_once plugin_dir_path( __DIR__ ) . 'settings/class-setting.php'; - require_once plugin_dir_path( __DIR__ ) . 'settings/general/class-reference-container-settings-group.php'; + parent::load_dependencies(); + + require_once plugin_dir_path( __DIR__ ) . 'general/class-reference-container-settings-group.php'; + require_once plugin_dir_path( __DIR__ ) . 'general/class-scrolling-settings-group.php'; + require_once plugin_dir_path( __DIR__ ) . 'general/class-shortcode-settings-group.php'; } - + protected function add_settings_groups(): void { - $this->settings_groups = array ( - ReferenceContainerSettingsGroup::GROUP_ID => new ReferenceContainerSettingsGroup($this->options_group_slug, $this->section_slug), + $this->settings_groups = array( + ReferenceContainerSettingsGroup::GROUP_ID => new ReferenceContainerSettingsGroup( $this->options_group_slug, $this->section_slug ), + ScrollingSettingsGroup::GROUP_ID => new ScrollingSettingsGroup( $this->options_group_slug, $this->section_slug ), + ShortcodeSettingsGroup::GROUP_ID => new ShortcodeSettingsGroup( $this->options_group_slug, $this->section_slug ), ); } } 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 3c96770..7962164 100644 --- a/src/includes/settings/general/class-reference-container-settings-group.php +++ b/src/includes/settings/general/class-reference-container-settings-group.php @@ -22,7 +22,7 @@ use footnotes\includes\settings\SettingsGroup; * @package footnotes * @since 2.8.0 */ -class ReferenceContainerSettingsGroup extends SettingsGroup { +class ReferenceContainerSettingsGroup extends SettingsGroup { /** * Setting group ID. * @@ -31,7 +31,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * @since 2.8.0 */ const GROUP_ID = 'reference-container'; - + /** * Settings container key for combining identical footnotes. * @@ -43,13 +43,13 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const COMBINE_IDENTICAL_FOOTNOTES = array( - 'key' => 'footnote_inputfield_combine_identical', - 'name' => 'Combine Identical Footnotes', + 'key' => 'footnote_inputfield_combine_identical', + 'name' => 'Combine Identical Footnotes', 'default_value' => true, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); - + /** * Settings container key for the label of the reference container. * @@ -60,13 +60,13 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const REFERENCE_CONTAINER_NAME = array( - 'key' => 'footnote_inputfield_references_label', - 'name' => 'Reference Container Title', + 'key' => 'footnote_inputfield_references_label', + 'name' => 'Reference Container Title', 'default_value' => 'References', - 'type' => 'string', - 'input_type' => 'text' + 'type' => 'string', + 'input_type' => 'text', ); - + /** * Settings container key for the reference container label element. * @@ -76,12 +76,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`. * Convert from `string` to `array`. */ - const REFERENCE_CONTAINER_LABEL_ELEMENT =array( - 'key' => 'footnote_inputfield_references_label', - 'name' => 'Heading\'s HTML Element', + const REFERENCE_CONTAINER_LABEL_ELEMENT = array( + 'key' => 'footnote_inputfield_references_label', + 'name' => 'Heading\'s HTML Element', 'default_value' => 'p', - 'type' => 'string', - 'input_type' => 'select', + 'type' => 'string', + 'input_type' => 'select', 'input_options' => array( 'p' => 'paragraph', 'h2' => 'heading 2', @@ -89,9 +89,9 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { 'h4' => 'heading 4', 'h5' => 'heading 5', 'h6' => 'heading 6', - ) + ), ); - + /** * Settings container key to enable the reference container label bottom border. * @@ -103,13 +103,13 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER = array( - 'key' => 'footnotes_inputfield_reference_container_label_bottom_border', - 'name' => 'Border Under the Heading', + 'key' => 'footnotes_inputfield_reference_container_label_bottom_border', + 'name' => 'Border Under the Heading', 'default_value' => true, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); - + /** * Settings container key to collapse the reference container by default. * @@ -121,13 +121,13 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const REFERENCE_CONTAINER_COLLAPSE = array( - 'key' => 'footnote_inputfield_collapse_references', - 'name' => 'Collapse by Default', + 'key' => 'footnote_inputfield_collapse_references', + 'name' => 'Collapse by Default', 'default_value' => false, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); - + /** * Settings container key to select the script mode for the reference container. * @@ -138,16 +138,16 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE = array( - 'key' => 'footnotes_inputfield_reference_container_script_mode', - 'name' => 'Script Mode', - 'description' => 'The plain JavaScript mode will enable hard links with configurable scroll offset.', + 'key' => 'footnotes_inputfield_reference_container_script_mode', + 'name' => 'Script Mode', + 'description' => 'The plain JavaScript mode will enable hard links with configurable scroll offset.', 'default_value' => 'jquery', - 'type' => 'string', - 'input_type' => 'select', + 'type' => 'string', + 'input_type' => 'select', 'input_options' => array( 'jquery' => 'jQuery', - 'js' => 'plain JavaScript' - ) + 'js' => 'plain JavaScript', + ), ); /** @@ -160,17 +160,17 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const REFERENCE_CONTAINER_POSITION = array( - 'key' => 'footnote_inputfield_reference_container_place', - 'name' => 'Container Position', - 'description' => 'Where the container should be placed on the page. To use the position or section shortcode, please set the position to: at the end of the post', + 'key' => 'footnote_inputfield_reference_container_place', + 'name' => 'Container Position', + 'description' => 'Where the container should be placed on the page. To use the position or section shortcode, please set the position to: at the end of the post', 'default_value' => 'post_end', - 'type' => 'string', - 'input_type' => 'select', + 'type' => 'string', + 'input_type' => 'select', 'input_options' => array( 'post_end' => 'at the end of the post', 'widget' => 'in the widget area', 'footer' => 'in the footer', - ) + ), ); /** @@ -183,14 +183,14 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const REFERENCE_CONTAINER_POSITION_SHORTCODE = array( - 'key' => 'footnote_inputfield_reference_container_position_shortcode', - 'name' => 'Position Shortcode', - 'description' => 'If present in the content, any shortcode in this text box will be replaced with the reference container.', + 'key' => 'footnote_inputfield_reference_container_position_shortcode', + 'name' => 'Position Shortcode', + 'description' => 'If present in the content, any shortcode in this text box will be replaced with the reference container.', 'default_value' => '[[references]]', - 'type' => 'string', - 'input_type' => 'text' + 'type' => 'string', + 'input_type' => 'text', ); - + /** * Settings container key for the footnote section shortcode. * @@ -201,12 +201,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const FOOTNOTE_SECTION_SHORTCODE = array( - 'key' => 'footnotes_inputfield_section_shortcode', - 'name' => 'Footnote Section Shortcode', - 'description' => 'If present in the content, any shortcode in this text box will delimit a section terminated by a reference container.', + 'key' => 'footnotes_inputfield_section_shortcode', + 'name' => 'Footnote Section Shortcode', + 'description' => 'If present in the content, any shortcode in this text box will delimit a section terminated by a reference container.', 'default_value' => '[[/footnotesection]]', - 'type' => 'string', - 'input_type' => 'text' + 'type' => 'string', + 'input_type' => 'text', ); /** @@ -220,11 +220,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const REFERENCE_CONTAINER_START_PAGE_ENABLE = array( - 'key' => 'footnotes_inputfield_reference_container_start_page_enable', - 'name' => 'Display on Start Page Too', + 'key' => 'footnotes_inputfield_reference_container_start_page_enable', + 'name' => 'Display on Start Page Too', 'default_value' => true, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); /** @@ -237,16 +237,16 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `int` to `array`. */ const REFERENCE_CONTAINER_TOP_MARGIN = array( - 'key' => 'footnotes_inputfield_reference_container_top_margin', - 'name' => 'Top Margin', - 'description' => 'pixels; may be negative', + 'key' => 'footnotes_inputfield_reference_container_top_margin', + 'name' => 'Top Margin', + 'description' => 'pixels; may be negative', 'default_value' => 24, - 'type' => 'integer', - 'input_type' => 'number', - 'input_max' => 500, - 'input_min' => -500 + 'type' => 'integer', + 'input_type' => 'number', + 'input_max' => 500, + 'input_min' => -500, ); - + /** * Settings container key for reference container bottom margin. * @@ -257,14 +257,14 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `int` to `array`. */ const REFERENCE_CONTAINER_BOTTOM_MARGIN = array( - 'key' => 'footnotes_inputfield_reference_container_bottom_margin', - 'name' => 'Bottom Margin', - 'description' => 'pixels; may be negative', + 'key' => 'footnotes_inputfield_reference_container_bottom_margin', + 'name' => 'Bottom Margin', + 'description' => 'pixels; may be negative', 'default_value' => 0, - 'type' => 'integer', - 'input_type' => 'number', - 'input_max' => 500, - 'input_min' => -500 + 'type' => 'integer', + 'input_type' => 'number', + 'input_max' => 500, + 'input_min' => -500, ); /** @@ -279,18 +279,18 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const FOOTNOTES_PAGE_LAYOUT_SUPPORT = array( - 'key' => 'footnotes_inputfield_page_layout_support', - 'name' => 'Apply Basic Responsive Page Layout', - 'description' => 'Most themes don\'t need this fix.', + 'key' => 'footnotes_inputfield_page_layout_support', + 'name' => 'Apply Basic Responsive Page Layout', + 'description' => 'Most themes don\'t need this fix.', 'default_value' => 'none', - 'type' => 'string', - 'input_type' => 'select', + 'type' => 'string', + 'input_type' => 'select', 'input_options' => array( 'none' => 'No', 'reference-container' => 'to the reference container exclusively', 'entry-content' => 'to the div element starting below the post title', 'main-content' => 'to the main element including the post title', - ) + ), ); /** @@ -307,12 +307,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const FOOTNOTE_URL_WRAP_ENABLED = array( - 'key' => 'footnote_inputfield_url_wrap_enabled', - 'name' => 'Allow URLs to Line-Wrap Anywhere', - 'description' => 'Unicode-conformant browsers don\'t need this fix.', + 'key' => 'footnote_inputfield_url_wrap_enabled', + 'name' => 'Allow URLs to Line-Wrap Anywhere', + 'description' => 'Unicode-conformant browsers don\'t need this fix.', 'default_value' => true, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); /** @@ -326,12 +326,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE = array( - 'key' => 'footnotes_inputfield_reference_container_backlink_symbol_enable', - 'name' => 'Display a Backlink Symbol', - 'description' => 'Please choose or input the symbol at the top of the next dashboard tab.', + 'key' => 'footnotes_inputfield_reference_container_backlink_symbol_enable', + 'name' => 'Display a Backlink Symbol', + 'description' => 'Please choose or input the symbol at the top of the next dashboard tab.', 'default_value' => true, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); /** @@ -345,11 +345,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH = array( - 'key' => 'footnotes_inputfield_reference_container_backlink_symbol_switch', - 'name' => 'Append Instead of Prepend Symbol', + 'key' => 'footnotes_inputfield_reference_container_backlink_symbol_switch', + 'name' => 'Append Instead of Prepend Symbol', 'default_value' => false, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); /** @@ -363,12 +363,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE = array( - 'key' => 'footnotes_inputfield_reference_container_3column_layout_enable', - 'name' => 'Backlink Symbol in an Extra Column', - 'description' => 'This legacy layout is available if identical footnotes are not combined.', + 'key' => 'footnotes_inputfield_reference_container_3column_layout_enable', + 'name' => 'Backlink Symbol in an Extra Column', + 'description' => 'This legacy layout is available if identical footnotes are not combined.', 'default_value' => false, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); /** @@ -382,11 +382,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const REFERENCE_CONTAINER_ROW_BORDERS_ENABLE = array( - 'key' => 'footnotes_inputfield_reference_container_row_borders_enable', - 'name' => 'Borders Around the Table Rows', + 'key' => 'footnotes_inputfield_reference_container_row_borders_enable', + 'name' => 'Borders Around the Table Rows', 'default_value' => false, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); /** @@ -406,11 +406,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const BACKLINKS_SEPARATOR_ENABLED = array( - 'key' => 'footnotes_inputfield_backlinks_separator_enabled', - 'name' => 'Add a Separator When Enumerating Backlinks', + 'key' => 'footnotes_inputfield_backlinks_separator_enabled', + 'name' => 'Add a Separator When Enumerating Backlinks', 'default_value' => true, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); /** @@ -426,19 +426,19 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const BACKLINKS_SEPARATOR_OPTION = array( - 'key' => 'footnotes_inputfield_backlinks_separator_option', - 'name' => 'Backlink Separator Symbol', + 'key' => 'footnotes_inputfield_backlinks_separator_option', + 'name' => 'Backlink Separator Symbol', 'default_value' => 'comma', - 'type' => 'string', - 'input_type' => 'select', + 'type' => 'string', + 'input_type' => 'select', 'input_options' => array( // Unicode character names are conventionally uppercase. 'comma' => ',', 'semicolon' => ';', 'en_dash' => '–', ), - 'enabled_by' => self::BACKLINKS_SEPARATOR_ENABLED, - 'overridden_by' => self::BACKLINKS_SEPARATOR_CUSTOM + 'enabled_by' => self::BACKLINKS_SEPARATOR_ENABLED, + 'overridden_by' => self::BACKLINKS_SEPARATOR_CUSTOM, ); /** @@ -454,15 +454,14 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const BACKLINKS_SEPARATOR_CUSTOM = array( - 'key' => 'footnotes_inputfield_backlinks_separator_custom', - 'name' => 'Custom Backlink Separator Symbol', + 'key' => 'footnotes_inputfield_backlinks_separator_custom', + 'name' => 'Custom Backlink Separator Symbol', 'description' => 'Your input overrides the selection.', - 'default_value' => null, - 'type' => 'string', - 'input_type' => 'text', - 'enabled_by' => self::BACKLINKS_SEPARATOR_ENABLED + 'type' => 'string', + 'input_type' => 'text', + 'enabled_by' => self::BACKLINKS_SEPARATOR_ENABLED, ); - + /** * Settings container key to enable the presence of a backlink terminator. * @@ -477,11 +476,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const BACKLINKS_TERMINATOR_ENABLED = array( - 'key' => 'footnotes_inputfield_backlinks_terminator_enabled', - 'name' => 'Add a Terminal Punctuation to Backlinks', + 'key' => 'footnotes_inputfield_backlinks_terminator_enabled', + 'name' => 'Add a Terminal Punctuation to Backlinks', 'default_value' => false, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); /** @@ -497,19 +496,19 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const BACKLINKS_TERMINATOR_OPTION = array( - 'key' => 'footnotes_inputfield_backlinks_terminator_option', - 'name' => 'Backlink Terminator Symbol', + 'key' => 'footnotes_inputfield_backlinks_terminator_option', + 'name' => 'Backlink Terminator Symbol', 'default_value' => 'period', - 'type' => 'string', - 'input_type' => 'select', + 'type' => 'string', + 'input_type' => 'select', 'input_options' => array( 'period' => '.', // Unicode 1.0 name of RIGHT PARENTHESIS (represented as a left parenthesis in right-to-left scripts). 'parenthesis' => ')', 'colon' => ':', ), - 'enabled_by' => self::BACKLINKS_TERMINATOR_ENABLED, - 'overridden_by' => self::BACKLINKS_TERMINATOR_CUSTOM + 'enabled_by' => self::BACKLINKS_TERMINATOR_ENABLED, + 'overridden_by' => self::BACKLINKS_TERMINATOR_CUSTOM, ); /** @@ -525,15 +524,14 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const BACKLINKS_TERMINATOR_CUSTOM = array( - 'key' => 'footnotes_inputfield_backlinks_terminator_custom', - 'name' => 'Custom Backlink Terminator Symbol', + 'key' => 'footnotes_inputfield_backlinks_terminator_custom', + 'name' => 'Custom Backlink Terminator Symbol', 'description' => 'Your input overrides the selection.', - 'default_value' => null, - 'type' => 'string', - 'input_type' => 'text', - 'enabled_by' => self::BACKLINKS_TERMINATOR_ENABLED + 'type' => 'string', + 'input_type' => 'text', + 'enabled_by' => self::BACKLINKS_TERMINATOR_ENABLED, ); - + /** * Settings container key to enable the backlinks column width. * @@ -548,11 +546,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const BACKLINKS_COLUMN_WIDTH_ENABLED = array( - 'key' => 'footnotes_inputfield_backlinks_column_width_enabled', - 'name' => 'Set Backlinks Column Width', + 'key' => 'footnotes_inputfield_backlinks_column_width_enabled', + 'name' => 'Set Backlinks Column Width', 'default_value' => false, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); /** @@ -568,14 +566,14 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const BACKLINKS_COLUMN_WIDTH_SCALAR = array( - 'key' => 'footnotes_inputfield_backlinks_column_width_scalar', - 'name' => 'Backlinks Column Width', + 'key' => 'footnotes_inputfield_backlinks_column_width_scalar', + 'name' => 'Backlinks Column Width', 'default_value' => 50, - 'type' => 'number', - 'input_type' => 'number', - 'input_max' => 500, - 'input_min' => 0, - 'enabled_by' => self::BACKLINKS_COLUMN_WIDTH_ENABLED + 'type' => 'number', + 'input_type' => 'number', + 'input_max' => 500, + 'input_min' => 0, + 'enabled_by' => self::BACKLINKS_COLUMN_WIDTH_ENABLED, ); /** @@ -591,16 +589,16 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const BACKLINKS_COLUMN_WIDTH_UNIT = array( - 'key' => 'footnotes_inputfield_backlinks_column_width_unit', - 'name' => 'Backlinks Column Width Unit', - 'description' => 'Absolute width in pixels doesn\'t need to be accurate to the tenth, but relative width in `rem` or `em` may.', + 'key' => 'footnotes_inputfield_backlinks_column_width_unit', + 'name' => 'Backlinks Column Width Unit', + 'description' => 'Absolute width in pixels doesn\'t need to be accurate to the tenth, but relative width in `rem` or `em` may.', 'default_value' => 'px', - 'type' => 'string', - 'input_type' => 'select', + 'type' => 'string', + 'input_type' => 'select', 'input_options' => Settings::WIDTH_UNIT_OPTIONS, - 'enabled_by' => self::BACKLINKS_COLUMN_WIDTH_ENABLED + 'enabled_by' => self::BACKLINKS_COLUMN_WIDTH_ENABLED, ); - + /** * Settings container key to enable a max width for the backlinks column. * @@ -615,11 +613,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const BACKLINKS_COLUMN_MAX_WIDTH_ENABLED = array( - 'key' => 'footnotes_inputfield_backlinks_column_max_width_enabled', - 'name' => 'Set Backlinks Column Max. Width', + 'key' => 'footnotes_inputfield_backlinks_column_max_width_enabled', + 'name' => 'Set Backlinks Column Max. Width', 'default_value' => false, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); /** @@ -635,14 +633,14 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const BACKLINKS_COLUMN_MAX_WIDTH_SCALAR = array( - 'key' => 'footnotes_inputfield_backlinks_column_max_width_scalar', - 'name' => 'Backlinks Column Width', + 'key' => 'footnotes_inputfield_backlinks_column_max_width_scalar', + 'name' => 'Backlinks Column Width', 'default_value' => 140, - 'type' => 'number', - 'input_type' => 'number', - 'input_max' => 500, - 'input_min' => 0, - 'enabled_by' => self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED + 'type' => 'number', + 'input_type' => 'number', + 'input_max' => 500, + 'input_min' => 0, + 'enabled_by' => self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED, ); /** @@ -658,16 +656,16 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert from `string` to `array`. */ const BACKLINKS_COLUMN_MAX_WIDTH_UNIT = array( - 'key' => 'footnotes_inputfield_backlinks_column_max_width_unit', - 'name' => 'Backlinks Column Width Unit', - 'description' => 'Absolute width in pixels doesn\'t need to be accurate to the tenth, but relative width in `rem` or `em` may.', + 'key' => 'footnotes_inputfield_backlinks_column_max_width_unit', + 'name' => 'Backlinks Column Width Unit', + 'description' => 'Absolute width in pixels doesn\'t need to be accurate to the tenth, but relative width in `rem` or `em` may.', 'default_value' => 'px', - 'type' => 'string', - 'input_type' => 'select', + 'type' => 'string', + 'input_type' => 'select', 'input_options' => Settings::WIDTH_UNIT_OPTIONS, - 'enabled_by' => self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED + 'enabled_by' => self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED, ); - + /** * Settings container key to enable line breaks between backlinks. * @@ -681,14 +679,14 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const BACKLINKS_LINE_BREAKS_ENABLED = array( - 'key' => 'footnotes_inputfield_backlinks_line_breaks_enabled', - 'name' => 'Stack Backlinks When Enumerating', - 'description' => 'This option adds a line break before each added backlink when identical footnotes are combined.', + 'key' => 'footnotes_inputfield_backlinks_line_breaks_enabled', + 'name' => 'Stack Backlinks When Enumerating', + 'description' => 'This option adds a line break before each added backlink when identical footnotes are combined.', 'default_value' => false, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); - + /** * Settings container key for the link element option. * @@ -700,12 +698,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * Convert setting data type from `string` to `boolean`. */ const LINK_ELEMENT_ENABLED = array( - 'key' => 'footnote_inputfield_link_element_enabled', - 'name' => 'Use the Link Element for Referrers and Backlinks', - 'description' => 'The link element is needed to apply the theme\'s link color. If the link element is not desired for styling, a simple span is used instead when the above is unchecked.', + 'key' => 'footnote_inputfield_link_element_enabled', + 'name' => 'Use the Link Element for Referrers and Backlinks', + 'description' => 'The link element is needed to apply the theme\'s link color. If the link element is not desired for styling, a simple span is used instead when the above is unchecked.', 'default_value' => true, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); /** @@ -722,121 +720,52 @@ class ReferenceContainerSettingsGroup extends SettingsGroup { * @todo Un-deprecate or delete. */ const FOOTNOTES_EXPERT_MODE = array( - 'key' => 'footnote_inputfield_enable_expert_mode', - 'name' => 'Expert Mode', - 'description' => 'DEPRECATED', + 'key' => 'footnote_inputfield_enable_expert_mode', + 'name' => 'Expert Mode', + 'description' => 'DEPRECATED', 'default_value' => true, - 'type' => 'boolean', - 'input_type' => 'checkbox' + 'type' => 'boolean', + 'input_type' => 'checkbox', ); - - /** - * The general settings. - * - * @var Setting[] - * - * @since 2.8.0 - */ - protected array $settings; - - public function __construct( - /** - * Setting options group slug. - * - * @var string - * - * @since 2.8.0 - */ - protected string $options_group_slug, - - /** - * Setting section slug. - * - * @var string - * - * @since 2.8.0 - */ - protected string $section_slug - ) { - $this->load_dependencies(); - - $this->add_settings(get_option( $this->options_group_slug )); - } - - protected function load_dependencies(): void { - require_once plugin_dir_path( __DIR__ ) . 'class-setting.php'; - } - - protected function add_settings(array $options): void { + + protected function add_settings( array|false $options ): void { $this->settings = array( - self::REFERENCE_CONTAINER_NAME['key'] => $this->add_setting(self::REFERENCE_CONTAINER_NAME), - self::COMBINE_IDENTICAL_FOOTNOTES['key'] => $this->add_setting(self::COMBINE_IDENTICAL_FOOTNOTES), - self::REFERENCE_CONTAINER_NAME['key'] => $this->add_setting(self::REFERENCE_CONTAINER_NAME), - self::REFERENCE_CONTAINER_LABEL_ELEMENT['key'] => $this->add_setting(self::REFERENCE_CONTAINER_LABEL_ELEMENT), - self::REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER['key'] => $this->add_setting(self::REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER), - self::REFERENCE_CONTAINER_COLLAPSE['key'] => $this->add_setting(self::REFERENCE_CONTAINER_COLLAPSE), - self::FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE['key'] => $this->add_setting(self::FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE), - self::REFERENCE_CONTAINER_POSITION['key'] => $this->add_setting(self::REFERENCE_CONTAINER_POSITION), - self::REFERENCE_CONTAINER_POSITION_SHORTCODE['key'] => $this->add_setting(self::REFERENCE_CONTAINER_POSITION_SHORTCODE), - self::FOOTNOTE_SECTION_SHORTCODE['key'] => $this->add_setting(self::FOOTNOTE_SECTION_SHORTCODE), - self::REFERENCE_CONTAINER_START_PAGE_ENABLE['key'] => $this->add_setting(self::REFERENCE_CONTAINER_START_PAGE_ENABLE), - self::REFERENCE_CONTAINER_TOP_MARGIN['key'] => $this->add_setting(self::REFERENCE_CONTAINER_TOP_MARGIN), - self::REFERENCE_CONTAINER_BOTTOM_MARGIN['key'] => $this->add_setting(self::REFERENCE_CONTAINER_BOTTOM_MARGIN), - self::FOOTNOTES_PAGE_LAYOUT_SUPPORT['key'] => $this->add_setting(self::FOOTNOTES_PAGE_LAYOUT_SUPPORT), - self::FOOTNOTE_URL_WRAP_ENABLED['key'] => $this->add_setting(self::FOOTNOTE_URL_WRAP_ENABLED), - self::REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE['key'] => $this->add_setting(self::REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE), - self::REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH['key'] => $this->add_setting(self::REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH), - self::REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE['key'] => $this->add_setting(self::REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE), - self::REFERENCE_CONTAINER_ROW_BORDERS_ENABLE['key'] => $this->add_setting(self::REFERENCE_CONTAINER_ROW_BORDERS_ENABLE), - self::BACKLINKS_SEPARATOR_ENABLED['key'] => $this->add_setting(self::BACKLINKS_SEPARATOR_ENABLED), - self::BACKLINKS_SEPARATOR_OPTION['key'] => $this->add_setting(self::BACKLINKS_SEPARATOR_OPTION), - self::BACKLINKS_SEPARATOR_CUSTOM['key'] => $this->add_setting(self::BACKLINKS_SEPARATOR_CUSTOM), - self::BACKLINKS_TERMINATOR_ENABLED['key'] => $this->add_setting(self::BACKLINKS_TERMINATOR_ENABLED), - self::BACKLINKS_TERMINATOR_OPTION['key'] => $this->add_setting(self::BACKLINKS_TERMINATOR_OPTION), - self::BACKLINKS_TERMINATOR_CUSTOM['key'] => $this->add_setting(self::BACKLINKS_TERMINATOR_CUSTOM), - self::BACKLINKS_COLUMN_WIDTH_ENABLED['key'] => $this->add_setting(self::BACKLINKS_COLUMN_WIDTH_ENABLED), - self::BACKLINKS_COLUMN_WIDTH_SCALAR['key'] => $this->add_setting(self::BACKLINKS_COLUMN_WIDTH_SCALAR), - self::BACKLINKS_COLUMN_WIDTH_UNIT['key'] => $this->add_setting(self::BACKLINKS_COLUMN_WIDTH_UNIT), - self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED['key'] => $this->add_setting(self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED), - self::BACKLINKS_COLUMN_MAX_WIDTH_SCALAR['key'] => $this->add_setting(self::BACKLINKS_COLUMN_MAX_WIDTH_SCALAR), - self::BACKLINKS_COLUMN_MAX_WIDTH_UNIT['key'] => $this->add_setting(self::BACKLINKS_COLUMN_MAX_WIDTH_UNIT), - self::BACKLINKS_LINE_BREAKS_ENABLED['key'] => $this->add_setting(self::BACKLINKS_LINE_BREAKS_ENABLED), - self::LINK_ELEMENT_ENABLED['key'] => $this->add_setting(self::LINK_ELEMENT_ENABLED), - self::FOOTNOTES_EXPERT_MODE['key'] => $this->add_setting(self::FOOTNOTES_EXPERT_MODE) + self::REFERENCE_CONTAINER_NAME['key'] => $this->add_setting( self::REFERENCE_CONTAINER_NAME ), + self::COMBINE_IDENTICAL_FOOTNOTES['key'] => $this->add_setting( self::COMBINE_IDENTICAL_FOOTNOTES ), + self::REFERENCE_CONTAINER_NAME['key'] => $this->add_setting( self::REFERENCE_CONTAINER_NAME ), + self::REFERENCE_CONTAINER_LABEL_ELEMENT['key'] => $this->add_setting( self::REFERENCE_CONTAINER_LABEL_ELEMENT ), + self::REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER['key'] => $this->add_setting( self::REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER ), + self::REFERENCE_CONTAINER_COLLAPSE['key'] => $this->add_setting( self::REFERENCE_CONTAINER_COLLAPSE ), + self::FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE['key'] => $this->add_setting( self::FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE ), + self::REFERENCE_CONTAINER_POSITION['key'] => $this->add_setting( self::REFERENCE_CONTAINER_POSITION ), + self::REFERENCE_CONTAINER_POSITION_SHORTCODE['key'] => $this->add_setting( self::REFERENCE_CONTAINER_POSITION_SHORTCODE ), + self::FOOTNOTE_SECTION_SHORTCODE['key'] => $this->add_setting( self::FOOTNOTE_SECTION_SHORTCODE ), + self::REFERENCE_CONTAINER_START_PAGE_ENABLE['key'] => $this->add_setting( self::REFERENCE_CONTAINER_START_PAGE_ENABLE ), + self::REFERENCE_CONTAINER_TOP_MARGIN['key'] => $this->add_setting( self::REFERENCE_CONTAINER_TOP_MARGIN ), + self::REFERENCE_CONTAINER_BOTTOM_MARGIN['key'] => $this->add_setting( self::REFERENCE_CONTAINER_BOTTOM_MARGIN ), + self::FOOTNOTES_PAGE_LAYOUT_SUPPORT['key'] => $this->add_setting( self::FOOTNOTES_PAGE_LAYOUT_SUPPORT ), + self::FOOTNOTE_URL_WRAP_ENABLED['key'] => $this->add_setting( self::FOOTNOTE_URL_WRAP_ENABLED ), + self::REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE['key'] => $this->add_setting( self::REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE ), + self::REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH['key'] => $this->add_setting( self::REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH ), + self::REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE['key'] => $this->add_setting( self::REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE ), + self::REFERENCE_CONTAINER_ROW_BORDERS_ENABLE['key'] => $this->add_setting( self::REFERENCE_CONTAINER_ROW_BORDERS_ENABLE ), + self::BACKLINKS_SEPARATOR_ENABLED['key'] => $this->add_setting( self::BACKLINKS_SEPARATOR_ENABLED ), + self::BACKLINKS_SEPARATOR_OPTION['key'] => $this->add_setting( self::BACKLINKS_SEPARATOR_OPTION ), + self::BACKLINKS_SEPARATOR_CUSTOM['key'] => $this->add_setting( self::BACKLINKS_SEPARATOR_CUSTOM ), + self::BACKLINKS_TERMINATOR_ENABLED['key'] => $this->add_setting( self::BACKLINKS_TERMINATOR_ENABLED ), + self::BACKLINKS_TERMINATOR_OPTION['key'] => $this->add_setting( self::BACKLINKS_TERMINATOR_OPTION ), + self::BACKLINKS_TERMINATOR_CUSTOM['key'] => $this->add_setting( self::BACKLINKS_TERMINATOR_CUSTOM ), + self::BACKLINKS_COLUMN_WIDTH_ENABLED['key'] => $this->add_setting( self::BACKLINKS_COLUMN_WIDTH_ENABLED ), + self::BACKLINKS_COLUMN_WIDTH_SCALAR['key'] => $this->add_setting( self::BACKLINKS_COLUMN_WIDTH_SCALAR ), + self::BACKLINKS_COLUMN_WIDTH_UNIT['key'] => $this->add_setting( self::BACKLINKS_COLUMN_WIDTH_UNIT ), + self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED['key'] => $this->add_setting( self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED ), + self::BACKLINKS_COLUMN_MAX_WIDTH_SCALAR['key'] => $this->add_setting( self::BACKLINKS_COLUMN_MAX_WIDTH_SCALAR ), + self::BACKLINKS_COLUMN_MAX_WIDTH_UNIT['key'] => $this->add_setting( self::BACKLINKS_COLUMN_MAX_WIDTH_UNIT ), + self::BACKLINKS_LINE_BREAKS_ENABLED['key'] => $this->add_setting( self::BACKLINKS_LINE_BREAKS_ENABLED ), + self::LINK_ELEMENT_ENABLED['key'] => $this->add_setting( self::LINK_ELEMENT_ENABLED ), + self::FOOTNOTES_EXPERT_MODE['key'] => $this->add_setting( self::FOOTNOTES_EXPERT_MODE ), ); - } - - private function add_setting(array $setting): Setting { - extract( $setting ); - - return new Setting( - self::GROUP_ID, - $this->options_group_slug, - $this->section_slug, - $key, - $name, - $description ?? null, - $default_value, - $type, - $input_type, - $input_options ?? null, - $input_max ?? null, - $input_min ?? null, - $enabled_by['key'] ?? null, - $overridden_by['key'] ?? null - ); - } - - public function add_settings_fields($component): void { - foreach ($this->settings as $setting) { - add_settings_field( - $setting->key, - __( $setting->name, 'footnotes' ), - array ($component, 'setting_field_callback'), - 'footnotes', - $setting->get_section_slug(), - $setting->get_setting_field_args() - ); - } + + $this->load_values( $options ); } } diff --git a/src/includes/settings/general/class-scrolling-settings-group.php b/src/includes/settings/general/class-scrolling-settings-group.php new file mode 100644 index 0000000..04dd4c3 --- /dev/null +++ b/src/includes/settings/general/class-scrolling-settings-group.php @@ -0,0 +1,189 @@ + 'footnotes_inputfield_css_smooth_scrolling', + 'name' => 'CSS-based Smooth Scrolling', + 'description' => 'May slightly disturb jQuery scrolling and is therefore disabled by default. Works in recent browsers.', + 'default_value' => false, + 'type' => 'boolean', + 'input_type' => 'checkbox', + ); + + /** + * Settings container key for scroll-up delay. + * + * @var array + * + * @since 2.5.11 + * @since 2.8.0 Move from `Settings` to `ScrollingSettingsGroup`. + * Convert from `int` to `array`. + */ + const FOOTNOTES_SCROLL_UP_DELAY = array( + 'key' => 'footnotes_inputfield_scroll_up_delay', + 'name' => 'Scroll-up Delay', + 'description' => 'milliseconds. Less useful than the scroll-down delay.', + 'default_value' => 0, + 'type' => 'integer', + 'input_type' => 'number', + 'input_max' => 0, + 'input_min' => 20000, + ); + + /** + * Settings container key for scroll-down delay. + * + * @var array + * + * @since 2.5.11 + * @since 2.8.0 Move from `Settings` to `ScrollingSettingsGroup`. + * Convert from `int` to `array`. + */ + const FOOTNOTES_SCROLL_DOWN_DELAY = array( + 'key' => 'footnotes_inputfield_scroll_down_delay', + 'name' => 'Scroll-down Delay', + 'description' => 'milliseconds. Useful to see the effect on input elements when referrers without hard links are clicked in form labels.', + 'default_value' => 0, + 'type' => 'integer', + 'input_type' => 'number', + 'input_max' => 0, + 'input_min' => 20000, + ); + + /** + * Settings container key for scroll offset. + * + * @var array + * + * @since 2.1.4 + * @since 2.8.0 Move from `Settings` to `ScrollingSettingsGroup`. + * Convert from `int` to `array`. + */ + const FOOTNOTES_SCROLL_OFFSET = array( + 'key' => 'footnotes_inputfield_scroll_offset', + 'name' => 'Scroll Offset', + 'description' => 'per cent viewport height from the upper edge', + 'default_value' => 20, + 'type' => 'integer', + 'input_type' => 'number', + 'input_max' => 0, + 'input_min' => 100, + ); + + /** + * Settings container key for scroll duration. + * + * @var array + * + * @since 2.1.4 + * @since 2.8.0 Move from `Settings` to `ScrollingSettingsGroup`. + * Convert from `int` to `array`. + */ + const FOOTNOTES_SCROLL_DURATION = array( + 'key' => 'footnotes_inputfield_scroll_duration', + 'name' => 'Scroll Duration', + 'description' => 'milliseconds. If asymmetric scroll durations are enabled, this is the scroll-up duration.', + 'default_value' => 380, + 'type' => 'integer', + 'input_type' => 'number', + 'input_max' => 0, + 'input_min' => 20000, + ); + + /** + * Settings container key for scroll duration asymmetricity + * + * @var array + * + * @since 2.5.11 + * @since 2.8.0 Move from `Settings` to `ScrollingSettingsGroup`. + * Convert from `int` to `array`. + * Convert setting data type from `string` to `boolean`. + */ + const FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY = array( + 'key' => 'footnotes_inputfield_scroll_duration_asymmetricity', + 'name' => 'Enable Asymmetric Scroll Durations', + 'description' => 'With this option enabled, scrolling up may take longer than down, or conversely.', + 'default_value' => false, + 'type' => 'boolean', + 'input_type' => 'checkbox', + ); + + /** + * Settings container key for scroll duration. + * + * @var array + * + * @since 2.1.11 + * @since 2.8.0 Move from `Settings` to `ScrollingSettingsGroup`. + * Convert from `int` to `array`. + */ + const FOOTNOTES_SCROLL_DOWN_DURATION = array( + 'key' => 'footnotes_inputfield_scroll_down_duration', + 'name' => 'Scroll-down Duration', + 'description' => 'milliseconds', + 'default_value' => 150, + 'type' => 'integer', + 'input_type' => 'number', + 'input_max' => 0, + 'input_min' => 20000, + 'enabled_by' => self::FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY, + ); + + 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 ), + self::FOOTNOTES_SCROLL_UP_DELAY['key'] => $this->add_setting( self::FOOTNOTES_SCROLL_UP_DELAY ), + self::FOOTNOTES_SCROLL_DOWN_DELAY['key'] => $this->add_setting( self::FOOTNOTES_SCROLL_DOWN_DELAY ), + self::FOOTNOTES_SCROLL_OFFSET['key'] => $this->add_setting( self::FOOTNOTES_SCROLL_OFFSET ), + self::FOOTNOTES_SCROLL_DURATION['key'] => $this->add_setting( self::FOOTNOTES_SCROLL_DURATION ), + self::FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY['key'] => $this->add_setting( self::FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY ), + self::FOOTNOTES_SCROLL_DOWN_DURATION['key'] => $this->add_setting( self::FOOTNOTES_SCROLL_DOWN_DURATION ), + ); + + $this->load_values( $options ); + } +} diff --git a/src/includes/settings/general/class-shortcode-settings-group.php b/src/includes/settings/general/class-shortcode-settings-group.php new file mode 100644 index 0000000..345a998 --- /dev/null +++ b/src/includes/settings/general/class-shortcode-settings-group.php @@ -0,0 +1,156 @@ + 'footnotes_inputfield_shortcode_syntax_validation_enable', + 'name' => 'Check for Balanced Shortcodes', + 'description' => 'In the presence of a lone start tag shortcode, a warning displays below the post title. If the start tag short code is (( or (((, it will not be reported as unbalanced if the following string contains braces hinting that it is a script.', + 'default_value' => true, + 'type' => 'boolean', + 'input_type' => 'checkbox', + ); + + /** + * Settings container key for the short code of the footnote's start. + * + * @var array + * + * @since 1.5.0 + * @since 2.8.0 Move from `Settings` to `ShortcodeSettingsGroup`. + * Convert from `string` to `array`. + */ + const FOOTNOTES_SHORT_CODE_START = array( + 'key' => 'footnote_inputfield_placeholder_start', + 'name' => 'Footnote Start Tag Short Code', + 'description' => 'When delimiters with pointy brackets are used, the diverging escapement schemas will be unified before footnotes are processed. WARNING: Although widespread industry standard, the double parentheses are problematic because they may occur in scripts embedded in the content and be mistaken as a short code.', + 'default_value' => '((', + 'type' => 'string', + 'input_type' => 'select', + 'input_options' => array( + '((' => '((', + '(((' => '(((', + '{{' => '{{', + '{{{' => '{{{', + '[n]' => '[n]', + '[fn]' => '[fn]', + '' => '<fn>', + '' => '<ref>', + 'userdefined' => 'custom short code', + ), + ); + + /** + * Settings container key for the user-defined short code of the footnotes start. + * + * @var array + * + * @since 1.5.0 + * @since 2.8.0 Move from `Settings` to `ShortcodeSettingsGroup`. + * Convert from `string` to `array`. + */ + const FOOTNOTES_SHORT_CODE_START_USER_DEFINED = array( + 'key' => 'footnote_inputfield_placeholder_start_user_defined', + 'name' => 'User-defined Start Shortcode', + 'type' => 'string', + 'input_type' => 'text', + 'enabled_by' => self::FOOTNOTES_SHORT_CODE_START, + ); + + /** + * Settings container key for the short code of the footnote's end. + * + * @var array + * + * @since 1.5.0 + * @since 2.8.0 Move from `Settings` to `ShortcodeSettingsGroup`. + * Convert from `string` to `array`. + */ + const FOOTNOTES_SHORT_CODE_END = array( + 'key' => 'footnote_inputfield_placeholder_end', + 'name' => 'Footnote End Tag Short Code', + 'default_value' => '))', + 'type' => 'string', + 'input_type' => 'select', + 'input_options' => array( + '))' => '))', + ')))' => ')))', + '}}' => '}}', + '}}}' => '}}}', + '[/n]' => '[/n]', + '[/fn]' => '[/fn]', + '' => '</fn>', + '' => '</ref>', + 'userdefined' => 'custom short code', + ), + ); + + /** + * Settings container key for the user-defined short code of the footnotes end. + * + * @var array + * + * @since 1.5.0 + * @since 2.8.0 Move from `Settings` to `ShortcodeSettingsGroup`. + * Convert from `string` to `array`. + */ + const FOOTNOTES_SHORT_CODE_END_USER_DEFINED = array( + 'key' => 'footnote_inputfield_placeholder_end_user_defined', + 'name' => 'User-defined End Shortcode', + 'type' => 'string', + 'input_type' => 'text', + 'enabled_by' => self::FOOTNOTES_SHORT_CODE_END, + ); + + 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 ), + self::FOOTNOTES_SHORT_CODE_START['key'] => $this->add_setting( self::FOOTNOTES_SHORT_CODE_START ), + self::FOOTNOTES_SHORT_CODE_START_USER_DEFINED['key'] => $this->add_setting( self::FOOTNOTES_SHORT_CODE_START_USER_DEFINED ), + self::FOOTNOTES_SHORT_CODE_END['key'] => $this->add_setting( self::FOOTNOTES_SHORT_CODE_END ), + self::FOOTNOTES_SHORT_CODE_END_USER_DEFINED['key'] => $this->add_setting( self::FOOTNOTES_SHORT_CODE_END_USER_DEFINED ), + ); + + $this->load_values( $options ); + } +}