refactor: add scrolling and shortcode settings groups
This commit is contained in:
parent
c0628bc7e3
commit
751fa9d614
6 changed files with 654 additions and 308 deletions
156
src/includes/settings/general/class-shortcode-settings-group.php
Normal file
156
src/includes/settings/general/class-shortcode-settings-group.php
Normal 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>' => '<fn>',
|
||||
'<ref>' => '<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>' => '</fn>',
|
||||
'</ref>' => '</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 );
|
||||
}
|
||||
}
|
Reference in a new issue