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;
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.
@ -47,13 +50,18 @@ class GeneralSettingsSection extends SettingsSection {
}
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 ),
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

@ -47,7 +47,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'name' => 'Combine Identical Footnotes',
'default_value' => true,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -64,7 +64,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'name' => 'Reference Container Title',
'default_value' => 'References',
'type' => 'string',
'input_type' => 'text'
'input_type' => 'text',
);
/**
@ -89,7 +89,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'h4' => 'heading 4',
'h5' => 'heading 5',
'h6' => 'heading 6',
)
),
);
/**
@ -107,7 +107,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'name' => 'Border Under the Heading',
'default_value' => true,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -125,7 +125,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'name' => 'Collapse by Default',
'default_value' => false,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -146,8 +146,8 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'input_type' => 'select',
'input_options' => array(
'jquery' => 'jQuery',
'js' => 'plain JavaScript'
)
'js' => 'plain JavaScript',
),
);
/**
@ -170,7 +170,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'post_end' => 'at the end of the post',
'widget' => 'in the widget area',
'footer' => 'in the footer',
)
),
);
/**
@ -188,7 +188,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'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'
'input_type' => 'text',
);
/**
@ -206,7 +206,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'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'
'input_type' => 'text',
);
/**
@ -224,7 +224,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'name' => 'Display on Start Page Too',
'default_value' => true,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -244,7 +244,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'type' => 'integer',
'input_type' => 'number',
'input_max' => 500,
'input_min' => -500
'input_min' => -500,
);
/**
@ -264,7 +264,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'type' => 'integer',
'input_type' => 'number',
'input_max' => 500,
'input_min' => -500
'input_min' => -500,
);
/**
@ -290,7 +290,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'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',
)
),
);
/**
@ -312,7 +312,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'description' => 'Unicode-conformant browsers don\'t need this fix.',
'default_value' => true,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -331,7 +331,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'description' => 'Please choose or input the symbol at the top of the next dashboard tab.',
'default_value' => true,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -349,7 +349,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'name' => 'Append Instead of Prepend Symbol',
'default_value' => false,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -368,7 +368,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'description' => 'This legacy layout is available if identical footnotes are not combined.',
'default_value' => false,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -386,7 +386,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'name' => 'Borders Around the Table Rows',
'default_value' => false,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -410,7 +410,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'name' => 'Add a Separator When Enumerating Backlinks',
'default_value' => true,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -438,7 +438,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'en_dash' => '',
),
'enabled_by' => self::BACKLINKS_SEPARATOR_ENABLED,
'overridden_by' => self::BACKLINKS_SEPARATOR_CUSTOM
'overridden_by' => self::BACKLINKS_SEPARATOR_CUSTOM,
);
/**
@ -457,10 +457,9 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'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
'enabled_by' => self::BACKLINKS_SEPARATOR_ENABLED,
);
/**
@ -481,7 +480,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'name' => 'Add a Terminal Punctuation to Backlinks',
'default_value' => false,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -509,7 +508,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'colon' => ':',
),
'enabled_by' => self::BACKLINKS_TERMINATOR_ENABLED,
'overridden_by' => self::BACKLINKS_TERMINATOR_CUSTOM
'overridden_by' => self::BACKLINKS_TERMINATOR_CUSTOM,
);
/**
@ -528,10 +527,9 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'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
'enabled_by' => self::BACKLINKS_TERMINATOR_ENABLED,
);
/**
@ -552,7 +550,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'name' => 'Set Backlinks Column Width',
'default_value' => false,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -575,7 +573,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'input_type' => 'number',
'input_max' => 500,
'input_min' => 0,
'enabled_by' => self::BACKLINKS_COLUMN_WIDTH_ENABLED
'enabled_by' => self::BACKLINKS_COLUMN_WIDTH_ENABLED,
);
/**
@ -598,7 +596,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'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,
);
/**
@ -619,7 +617,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'name' => 'Set Backlinks Column Max. Width',
'default_value' => false,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -642,7 +640,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'input_type' => 'number',
'input_max' => 500,
'input_min' => 0,
'enabled_by' => self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED
'enabled_by' => self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED,
);
/**
@ -665,7 +663,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'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,
);
/**
@ -686,7 +684,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'description' => 'This option adds a line break before each added backlink when identical footnotes are combined.',
'default_value' => false,
'type' => 'boolean',
'input_type' => 'checkbox'
'input_type' => 'checkbox',
);
/**
@ -705,7 +703,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'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'
'input_type' => 'checkbox',
);
/**
@ -727,47 +725,10 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'description' => 'DEPRECATED',
'default_value' => true,
'type' => 'boolean',
'input_type' => 'checkbox'
'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 ),
@ -802,41 +763,9 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
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::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 );
}
}

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 );
}
}