refactor: add scrolling and shortcode settings groups

This commit is contained in:
Ben Goldsworthy 2021-08-05 15:58:18 +01:00
parent c0628bc7e3
commit 751fa9d614
6 changed files with 654 additions and 308 deletions

Binary file not shown.

View file

@ -0,0 +1,64 @@
<?php
/**
* File providing the `GROUPNAMESettingsGroup` class.
*
* @package footnotes
* @since 2.8.0
*/
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;
/**
* Class defining the TEMP_SETTINGS settings.
*
* @package footnotes
* @since 2.8.0
*/
class TEMP_GROUP_NAMESettingsGroup extends SettingsGroup {
/**
* Setting group ID.
*
* @var string
*
* @since 2.8.0
*/
const GROUP_ID = 'TEMP_GROUP_ID';
/**
* TEMP_SETTING_DOCBLOCK (from `includes/class-settings.php`)
*
* @var array
*
* @since TEMP_ORIGINAL_SINCE (from `includes/class-settings.php`)
* @since 2.8.0 Move from `Settings` to `TEMP_GROUP_NAMESettingsGroup`.
* Convert from `TEMP_ORIG_DATATYPE` to `array`.
* [Convert setting data type from `string` to `boolean`.]
*/
const TEMP_SETTING_NAME = array(
'key' => '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 );
}
}

View file

@ -10,9 +10,12 @@ declare(strict_types=1);
namespace footnotes\includes\settings\general; 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\ReferenceContainerSettingsGroup;
use footnotes\includes\settings\general\ScrollingSettingsGroup;
use footnotes\includes\settings\general\ShortcodeSettingsGroup;
/** /**
* Class defining general plugin settings. * Class defining general plugin settings.
@ -36,24 +39,29 @@ class GeneralSettingsSection extends SettingsSection {
$title $title
) { ) {
$this->options_group_slug = $options_group_slug; $this->options_group_slug = $options_group_slug;
$this->section_slug = $section_slug; $this->section_slug = $section_slug;
$this->title = $title; $this->title = $title;
$this->load_dependencies(); $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(); $this->load_options_group();
} }
protected function load_dependencies(): void { protected function load_dependencies(): void {
require_once plugin_dir_path( __DIR__ ) . 'settings/class-setting.php'; parent::load_dependencies();
require_once plugin_dir_path( __DIR__ ) . 'settings/general/class-reference-container-settings-group.php';
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 { protected function add_settings_groups(): void {
$this->settings_groups = array ( $this->settings_groups = array(
ReferenceContainerSettingsGroup::GROUP_ID => new ReferenceContainerSettingsGroup($this->options_group_slug, $this->section_slug), 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 ),
); );
} }
} }

View file

@ -43,11 +43,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const COMBINE_IDENTICAL_FOOTNOTES = array( const COMBINE_IDENTICAL_FOOTNOTES = array(
'key' => 'footnote_inputfield_combine_identical', 'key' => 'footnote_inputfield_combine_identical',
'name' => 'Combine Identical Footnotes', 'name' => 'Combine Identical Footnotes',
'default_value' => true, 'default_value' => true,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -60,11 +60,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const REFERENCE_CONTAINER_NAME = array( const REFERENCE_CONTAINER_NAME = array(
'key' => 'footnote_inputfield_references_label', 'key' => 'footnote_inputfield_references_label',
'name' => 'Reference Container Title', 'name' => 'Reference Container Title',
'default_value' => 'References', 'default_value' => 'References',
'type' => 'string', 'type' => 'string',
'input_type' => 'text' 'input_type' => 'text',
); );
/** /**
@ -76,12 +76,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`. * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const REFERENCE_CONTAINER_LABEL_ELEMENT =array( const REFERENCE_CONTAINER_LABEL_ELEMENT = array(
'key' => 'footnote_inputfield_references_label', 'key' => 'footnote_inputfield_references_label',
'name' => 'Heading\'s HTML Element', 'name' => 'Heading\'s HTML Element',
'default_value' => 'p', 'default_value' => 'p',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => array( 'input_options' => array(
'p' => 'paragraph', 'p' => 'paragraph',
'h2' => 'heading 2', 'h2' => 'heading 2',
@ -89,7 +89,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'h4' => 'heading 4', 'h4' => 'heading 4',
'h5' => 'heading 5', 'h5' => 'heading 5',
'h6' => 'heading 6', 'h6' => 'heading 6',
) ),
); );
/** /**
@ -103,11 +103,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER = array( const REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER = array(
'key' => 'footnotes_inputfield_reference_container_label_bottom_border', 'key' => 'footnotes_inputfield_reference_container_label_bottom_border',
'name' => 'Border Under the Heading', 'name' => 'Border Under the Heading',
'default_value' => true, 'default_value' => true,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -121,11 +121,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const REFERENCE_CONTAINER_COLLAPSE = array( const REFERENCE_CONTAINER_COLLAPSE = array(
'key' => 'footnote_inputfield_collapse_references', 'key' => 'footnote_inputfield_collapse_references',
'name' => 'Collapse by Default', 'name' => 'Collapse by Default',
'default_value' => false, 'default_value' => false,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -138,16 +138,16 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE = array( const FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE = array(
'key' => 'footnotes_inputfield_reference_container_script_mode', 'key' => 'footnotes_inputfield_reference_container_script_mode',
'name' => 'Script Mode', 'name' => 'Script Mode',
'description' => 'The plain JavaScript mode will enable hard links with configurable scroll offset.', 'description' => 'The plain JavaScript mode will enable hard links with configurable scroll offset.',
'default_value' => 'jquery', 'default_value' => 'jquery',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => array( 'input_options' => array(
'jquery' => 'jQuery', 'jquery' => 'jQuery',
'js' => 'plain JavaScript' 'js' => 'plain JavaScript',
) ),
); );
/** /**
@ -160,17 +160,17 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const REFERENCE_CONTAINER_POSITION = array( const REFERENCE_CONTAINER_POSITION = array(
'key' => 'footnote_inputfield_reference_container_place', 'key' => 'footnote_inputfield_reference_container_place',
'name' => 'Container Position', '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', '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', 'default_value' => 'post_end',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => array( 'input_options' => array(
'post_end' => 'at the end of the post', 'post_end' => 'at the end of the post',
'widget' => 'in the widget area', 'widget' => 'in the widget area',
'footer' => 'in the footer', 'footer' => 'in the footer',
) ),
); );
/** /**
@ -183,12 +183,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const REFERENCE_CONTAINER_POSITION_SHORTCODE = array( const REFERENCE_CONTAINER_POSITION_SHORTCODE = array(
'key' => 'footnote_inputfield_reference_container_position_shortcode', 'key' => 'footnote_inputfield_reference_container_position_shortcode',
'name' => 'Position Shortcode', 'name' => 'Position Shortcode',
'description' => 'If present in the content, any shortcode in this text box will be replaced with the reference container.', 'description' => 'If present in the content, any shortcode in this text box will be replaced with the reference container.',
'default_value' => '[[references]]', 'default_value' => '[[references]]',
'type' => 'string', 'type' => 'string',
'input_type' => 'text' 'input_type' => 'text',
); );
/** /**
@ -201,12 +201,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const FOOTNOTE_SECTION_SHORTCODE = array( const FOOTNOTE_SECTION_SHORTCODE = array(
'key' => 'footnotes_inputfield_section_shortcode', 'key' => 'footnotes_inputfield_section_shortcode',
'name' => 'Footnote 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.', 'description' => 'If present in the content, any shortcode in this text box will delimit a section terminated by a reference container.',
'default_value' => '[[/footnotesection]]', 'default_value' => '[[/footnotesection]]',
'type' => 'string', 'type' => 'string',
'input_type' => 'text' 'input_type' => 'text',
); );
/** /**
@ -220,11 +220,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const REFERENCE_CONTAINER_START_PAGE_ENABLE = array( const REFERENCE_CONTAINER_START_PAGE_ENABLE = array(
'key' => 'footnotes_inputfield_reference_container_start_page_enable', 'key' => 'footnotes_inputfield_reference_container_start_page_enable',
'name' => 'Display on Start Page Too', 'name' => 'Display on Start Page Too',
'default_value' => true, 'default_value' => true,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -237,14 +237,14 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `int` to `array`. * Convert from `int` to `array`.
*/ */
const REFERENCE_CONTAINER_TOP_MARGIN = array( const REFERENCE_CONTAINER_TOP_MARGIN = array(
'key' => 'footnotes_inputfield_reference_container_top_margin', 'key' => 'footnotes_inputfield_reference_container_top_margin',
'name' => 'Top Margin', 'name' => 'Top Margin',
'description' => 'pixels; may be negative', 'description' => 'pixels; may be negative',
'default_value' => 24, 'default_value' => 24,
'type' => 'integer', 'type' => 'integer',
'input_type' => 'number', 'input_type' => 'number',
'input_max' => 500, 'input_max' => 500,
'input_min' => -500 'input_min' => -500,
); );
/** /**
@ -257,14 +257,14 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `int` to `array`. * Convert from `int` to `array`.
*/ */
const REFERENCE_CONTAINER_BOTTOM_MARGIN = array( const REFERENCE_CONTAINER_BOTTOM_MARGIN = array(
'key' => 'footnotes_inputfield_reference_container_bottom_margin', 'key' => 'footnotes_inputfield_reference_container_bottom_margin',
'name' => 'Bottom Margin', 'name' => 'Bottom Margin',
'description' => 'pixels; may be negative', 'description' => 'pixels; may be negative',
'default_value' => 0, 'default_value' => 0,
'type' => 'integer', 'type' => 'integer',
'input_type' => 'number', 'input_type' => 'number',
'input_max' => 500, 'input_max' => 500,
'input_min' => -500 'input_min' => -500,
); );
/** /**
@ -279,18 +279,18 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const FOOTNOTES_PAGE_LAYOUT_SUPPORT = array( const FOOTNOTES_PAGE_LAYOUT_SUPPORT = array(
'key' => 'footnotes_inputfield_page_layout_support', 'key' => 'footnotes_inputfield_page_layout_support',
'name' => 'Apply Basic Responsive Page Layout', 'name' => 'Apply Basic Responsive Page Layout',
'description' => 'Most themes don\'t need this fix.', 'description' => 'Most themes don\'t need this fix.',
'default_value' => 'none', 'default_value' => 'none',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => array( 'input_options' => array(
'none' => 'No', 'none' => 'No',
'reference-container' => 'to the reference container exclusively', 'reference-container' => 'to the reference container exclusively',
'entry-content' => 'to the div element starting below the post title', 'entry-content' => 'to the div element starting below the post title',
'main-content' => 'to the main element including 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`. * Convert setting data type from `string` to `boolean`.
*/ */
const FOOTNOTE_URL_WRAP_ENABLED = array( const FOOTNOTE_URL_WRAP_ENABLED = array(
'key' => 'footnote_inputfield_url_wrap_enabled', 'key' => 'footnote_inputfield_url_wrap_enabled',
'name' => 'Allow URLs to Line-Wrap Anywhere', 'name' => 'Allow URLs to Line-Wrap Anywhere',
'description' => 'Unicode-conformant browsers don\'t need this fix.', 'description' => 'Unicode-conformant browsers don\'t need this fix.',
'default_value' => true, 'default_value' => true,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -326,12 +326,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE = array( const REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE = array(
'key' => 'footnotes_inputfield_reference_container_backlink_symbol_enable', 'key' => 'footnotes_inputfield_reference_container_backlink_symbol_enable',
'name' => 'Display a Backlink Symbol', 'name' => 'Display a Backlink Symbol',
'description' => 'Please choose or input the symbol at the top of the next dashboard tab.', 'description' => 'Please choose or input the symbol at the top of the next dashboard tab.',
'default_value' => true, 'default_value' => true,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -345,11 +345,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH = array( const REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH = array(
'key' => 'footnotes_inputfield_reference_container_backlink_symbol_switch', 'key' => 'footnotes_inputfield_reference_container_backlink_symbol_switch',
'name' => 'Append Instead of Prepend Symbol', 'name' => 'Append Instead of Prepend Symbol',
'default_value' => false, 'default_value' => false,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -363,12 +363,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE = array( const REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE = array(
'key' => 'footnotes_inputfield_reference_container_3column_layout_enable', 'key' => 'footnotes_inputfield_reference_container_3column_layout_enable',
'name' => 'Backlink Symbol in an Extra Column', 'name' => 'Backlink Symbol in an Extra Column',
'description' => 'This legacy layout is available if identical footnotes are not combined.', 'description' => 'This legacy layout is available if identical footnotes are not combined.',
'default_value' => false, 'default_value' => false,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -382,11 +382,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const REFERENCE_CONTAINER_ROW_BORDERS_ENABLE = array( const REFERENCE_CONTAINER_ROW_BORDERS_ENABLE = array(
'key' => 'footnotes_inputfield_reference_container_row_borders_enable', 'key' => 'footnotes_inputfield_reference_container_row_borders_enable',
'name' => 'Borders Around the Table Rows', 'name' => 'Borders Around the Table Rows',
'default_value' => false, 'default_value' => false,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -406,11 +406,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const BACKLINKS_SEPARATOR_ENABLED = array( const BACKLINKS_SEPARATOR_ENABLED = array(
'key' => 'footnotes_inputfield_backlinks_separator_enabled', 'key' => 'footnotes_inputfield_backlinks_separator_enabled',
'name' => 'Add a Separator When Enumerating Backlinks', 'name' => 'Add a Separator When Enumerating Backlinks',
'default_value' => true, 'default_value' => true,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -426,19 +426,19 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const BACKLINKS_SEPARATOR_OPTION = array( const BACKLINKS_SEPARATOR_OPTION = array(
'key' => 'footnotes_inputfield_backlinks_separator_option', 'key' => 'footnotes_inputfield_backlinks_separator_option',
'name' => 'Backlink Separator Symbol', 'name' => 'Backlink Separator Symbol',
'default_value' => 'comma', 'default_value' => 'comma',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => array( 'input_options' => array(
// Unicode character names are conventionally uppercase. // Unicode character names are conventionally uppercase.
'comma' => ',', 'comma' => ',',
'semicolon' => ';', 'semicolon' => ';',
'en_dash' => '', 'en_dash' => '',
), ),
'enabled_by' => self::BACKLINKS_SEPARATOR_ENABLED, 'enabled_by' => self::BACKLINKS_SEPARATOR_ENABLED,
'overridden_by' => self::BACKLINKS_SEPARATOR_CUSTOM 'overridden_by' => self::BACKLINKS_SEPARATOR_CUSTOM,
); );
/** /**
@ -454,13 +454,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const BACKLINKS_SEPARATOR_CUSTOM = array( const BACKLINKS_SEPARATOR_CUSTOM = array(
'key' => 'footnotes_inputfield_backlinks_separator_custom', 'key' => 'footnotes_inputfield_backlinks_separator_custom',
'name' => 'Custom Backlink Separator Symbol', 'name' => 'Custom Backlink Separator Symbol',
'description' => 'Your input overrides the selection.', 'description' => 'Your input overrides the selection.',
'default_value' => null, 'type' => 'string',
'type' => 'string', 'input_type' => 'text',
'input_type' => 'text', 'enabled_by' => self::BACKLINKS_SEPARATOR_ENABLED,
'enabled_by' => self::BACKLINKS_SEPARATOR_ENABLED
); );
/** /**
@ -477,11 +476,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const BACKLINKS_TERMINATOR_ENABLED = array( const BACKLINKS_TERMINATOR_ENABLED = array(
'key' => 'footnotes_inputfield_backlinks_terminator_enabled', 'key' => 'footnotes_inputfield_backlinks_terminator_enabled',
'name' => 'Add a Terminal Punctuation to Backlinks', 'name' => 'Add a Terminal Punctuation to Backlinks',
'default_value' => false, 'default_value' => false,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -497,19 +496,19 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const BACKLINKS_TERMINATOR_OPTION = array( const BACKLINKS_TERMINATOR_OPTION = array(
'key' => 'footnotes_inputfield_backlinks_terminator_option', 'key' => 'footnotes_inputfield_backlinks_terminator_option',
'name' => 'Backlink Terminator Symbol', 'name' => 'Backlink Terminator Symbol',
'default_value' => 'period', 'default_value' => 'period',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => array( 'input_options' => array(
'period' => '.', 'period' => '.',
// Unicode 1.0 name of RIGHT PARENTHESIS (represented as a left parenthesis in right-to-left scripts). // Unicode 1.0 name of RIGHT PARENTHESIS (represented as a left parenthesis in right-to-left scripts).
'parenthesis' => ')', 'parenthesis' => ')',
'colon' => ':', 'colon' => ':',
), ),
'enabled_by' => self::BACKLINKS_TERMINATOR_ENABLED, 'enabled_by' => self::BACKLINKS_TERMINATOR_ENABLED,
'overridden_by' => self::BACKLINKS_TERMINATOR_CUSTOM 'overridden_by' => self::BACKLINKS_TERMINATOR_CUSTOM,
); );
/** /**
@ -525,13 +524,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const BACKLINKS_TERMINATOR_CUSTOM = array( const BACKLINKS_TERMINATOR_CUSTOM = array(
'key' => 'footnotes_inputfield_backlinks_terminator_custom', 'key' => 'footnotes_inputfield_backlinks_terminator_custom',
'name' => 'Custom Backlink Terminator Symbol', 'name' => 'Custom Backlink Terminator Symbol',
'description' => 'Your input overrides the selection.', 'description' => 'Your input overrides the selection.',
'default_value' => null, 'type' => 'string',
'type' => 'string', 'input_type' => 'text',
'input_type' => 'text', 'enabled_by' => self::BACKLINKS_TERMINATOR_ENABLED,
'enabled_by' => self::BACKLINKS_TERMINATOR_ENABLED
); );
/** /**
@ -548,11 +546,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const BACKLINKS_COLUMN_WIDTH_ENABLED = array( const BACKLINKS_COLUMN_WIDTH_ENABLED = array(
'key' => 'footnotes_inputfield_backlinks_column_width_enabled', 'key' => 'footnotes_inputfield_backlinks_column_width_enabled',
'name' => 'Set Backlinks Column Width', 'name' => 'Set Backlinks Column Width',
'default_value' => false, 'default_value' => false,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -568,14 +566,14 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const BACKLINKS_COLUMN_WIDTH_SCALAR = array( const BACKLINKS_COLUMN_WIDTH_SCALAR = array(
'key' => 'footnotes_inputfield_backlinks_column_width_scalar', 'key' => 'footnotes_inputfield_backlinks_column_width_scalar',
'name' => 'Backlinks Column Width', 'name' => 'Backlinks Column Width',
'default_value' => 50, 'default_value' => 50,
'type' => 'number', 'type' => 'number',
'input_type' => 'number', 'input_type' => 'number',
'input_max' => 500, 'input_max' => 500,
'input_min' => 0, 'input_min' => 0,
'enabled_by' => self::BACKLINKS_COLUMN_WIDTH_ENABLED 'enabled_by' => self::BACKLINKS_COLUMN_WIDTH_ENABLED,
); );
/** /**
@ -591,14 +589,14 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const BACKLINKS_COLUMN_WIDTH_UNIT = array( const BACKLINKS_COLUMN_WIDTH_UNIT = array(
'key' => 'footnotes_inputfield_backlinks_column_width_unit', 'key' => 'footnotes_inputfield_backlinks_column_width_unit',
'name' => '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.', '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', 'default_value' => 'px',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => Settings::WIDTH_UNIT_OPTIONS, 'input_options' => Settings::WIDTH_UNIT_OPTIONS,
'enabled_by' => self::BACKLINKS_COLUMN_WIDTH_ENABLED 'enabled_by' => self::BACKLINKS_COLUMN_WIDTH_ENABLED,
); );
/** /**
@ -615,11 +613,11 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const BACKLINKS_COLUMN_MAX_WIDTH_ENABLED = array( const BACKLINKS_COLUMN_MAX_WIDTH_ENABLED = array(
'key' => 'footnotes_inputfield_backlinks_column_max_width_enabled', 'key' => 'footnotes_inputfield_backlinks_column_max_width_enabled',
'name' => 'Set Backlinks Column Max. Width', 'name' => 'Set Backlinks Column Max. Width',
'default_value' => false, 'default_value' => false,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -635,14 +633,14 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const BACKLINKS_COLUMN_MAX_WIDTH_SCALAR = array( const BACKLINKS_COLUMN_MAX_WIDTH_SCALAR = array(
'key' => 'footnotes_inputfield_backlinks_column_max_width_scalar', 'key' => 'footnotes_inputfield_backlinks_column_max_width_scalar',
'name' => 'Backlinks Column Width', 'name' => 'Backlinks Column Width',
'default_value' => 140, 'default_value' => 140,
'type' => 'number', 'type' => 'number',
'input_type' => 'number', 'input_type' => 'number',
'input_max' => 500, 'input_max' => 500,
'input_min' => 0, 'input_min' => 0,
'enabled_by' => self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED 'enabled_by' => self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED,
); );
/** /**
@ -658,14 +656,14 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const BACKLINKS_COLUMN_MAX_WIDTH_UNIT = array( const BACKLINKS_COLUMN_MAX_WIDTH_UNIT = array(
'key' => 'footnotes_inputfield_backlinks_column_max_width_unit', 'key' => 'footnotes_inputfield_backlinks_column_max_width_unit',
'name' => '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.', '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', 'default_value' => 'px',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => Settings::WIDTH_UNIT_OPTIONS, 'input_options' => Settings::WIDTH_UNIT_OPTIONS,
'enabled_by' => self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED 'enabled_by' => self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED,
); );
/** /**
@ -681,12 +679,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const BACKLINKS_LINE_BREAKS_ENABLED = array( const BACKLINKS_LINE_BREAKS_ENABLED = array(
'key' => 'footnotes_inputfield_backlinks_line_breaks_enabled', 'key' => 'footnotes_inputfield_backlinks_line_breaks_enabled',
'name' => 'Stack Backlinks When Enumerating', 'name' => 'Stack Backlinks When Enumerating',
'description' => 'This option adds a line break before each added backlink when identical footnotes are combined.', 'description' => 'This option adds a line break before each added backlink when identical footnotes are combined.',
'default_value' => false, 'default_value' => false,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -700,12 +698,12 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* Convert setting data type from `string` to `boolean`. * Convert setting data type from `string` to `boolean`.
*/ */
const LINK_ELEMENT_ENABLED = array( const LINK_ELEMENT_ENABLED = array(
'key' => 'footnote_inputfield_link_element_enabled', 'key' => 'footnote_inputfield_link_element_enabled',
'name' => 'Use the Link Element for Referrers and Backlinks', '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.', '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, 'default_value' => true,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** /**
@ -722,121 +720,52 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* @todo Un-deprecate or delete. * @todo Un-deprecate or delete.
*/ */
const FOOTNOTES_EXPERT_MODE = array( const FOOTNOTES_EXPERT_MODE = array(
'key' => 'footnote_inputfield_enable_expert_mode', 'key' => 'footnote_inputfield_enable_expert_mode',
'name' => 'Expert Mode', 'name' => 'Expert Mode',
'description' => 'DEPRECATED', 'description' => 'DEPRECATED',
'default_value' => true, 'default_value' => true,
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox' 'input_type' => 'checkbox',
); );
/** protected function add_settings( array|false $options ): void {
* 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 {
$this->settings = array( $this->settings = array(
self::REFERENCE_CONTAINER_NAME['key'] => $this->add_setting(self::REFERENCE_CONTAINER_NAME), 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::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_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_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_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::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::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['key'] => $this->add_setting( self::REFERENCE_CONTAINER_POSITION ),
self::REFERENCE_CONTAINER_POSITION_SHORTCODE['key'] => $this->add_setting(self::REFERENCE_CONTAINER_POSITION_SHORTCODE), 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::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_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_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::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::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::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_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_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_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::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_ENABLED['key'] => $this->add_setting( self::BACKLINKS_SEPARATOR_ENABLED ),
self::BACKLINKS_SEPARATOR_OPTION['key'] => $this->add_setting(self::BACKLINKS_SEPARATOR_OPTION), 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_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_ENABLED['key'] => $this->add_setting( self::BACKLINKS_TERMINATOR_ENABLED ),
self::BACKLINKS_TERMINATOR_OPTION['key'] => $this->add_setting(self::BACKLINKS_TERMINATOR_OPTION), 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_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_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_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_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_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_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_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::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::LINK_ELEMENT_ENABLED['key'] => $this->add_setting( self::LINK_ELEMENT_ENABLED ),
self::FOOTNOTES_EXPERT_MODE['key'] => $this->add_setting(self::FOOTNOTES_EXPERT_MODE) self::FOOTNOTES_EXPERT_MODE['key'] => $this->add_setting( self::FOOTNOTES_EXPERT_MODE ),
); );
}
private function add_setting(array $setting): Setting { $this->load_values( $options );
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()
);
}
} }
} }

View file

@ -0,0 +1,189 @@
<?php
/**
* File providing the `ScrollingSettingsGroup` class.
*
* @package footnotes
* @since 2.8.0
*/
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;
/**
* Class defining the scrolling settings.
*
* @package footnotes
* @since 2.8.0
*/
class ScrollingSettingsGroup extends SettingsGroup {
/**
* Setting group ID.
*
* @var string
*
* @since 2.8.0
*/
const GROUP_ID = 'scrolling';
/**
* Settings container key to enable CSS smooth scrolling.
*
* Native smooth scrolling only works in recent browsers.
*
* @var array
*
* @since 2.5.12
* @since 2.8.0 Move from `Settings` to `ScrollingSettingsGroup`.
* Convert from `string` to `array`.
* Convert setting data type from `string` to `boolean`.
*/
const FOOTNOTES_CSS_SMOOTH_SCROLLING = array(
'key' => '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 );
}
}

View file

@ -0,0 +1,156 @@
<?php
/**
* File providing the `ShortcodeSettingsGroup` class.
*
* @package footnotes
* @since 2.8.0
*/
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;
/**
* Class defining the footnote shortcode delimiter settings.
*
* @package footnotes
* @since 2.8.0
*/
class ShortcodeSettingsGroup extends SettingsGroup {
/**
* Setting group ID.
*
* @var string
*
* @since 2.8.0
*/
const GROUP_ID = 'shortcode';
/**
* Settings container key to enable shortcode syntax validation.
*
* @var array
*
* @since 2.4.0
* @since 2.8.0 Move from `Settings` to `ShortcodeSettingsGroup`.
* Convert from `string` to `array`.
* Convert setting data type from `string` to `boolean`.
*/
const FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE = array(
'key' => '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 <q>((</q> or <q>(((</q>, 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>' => '&lt;fn&gt;',
'<ref>' => '&lt;ref&gt;',
'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>' => '&lt;/fn&gt;',
'</ref>' => '&lt;/ref&gt;',
'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 );
}
}