refactor: finish refactoring

This commit is contained in:
Ben Goldsworthy 2021-08-09 11:27:13 +01:00
parent facda599bb
commit fbb00fab2f
30 changed files with 599 additions and 108 deletions

View file

@ -10,8 +10,6 @@ declare(strict_types=1);
namespace footnotes\includes\settings\scopeandpriority;
require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php';
use footnotes\includes\Settings;
use footnotes\includes\settings\Setting;
use footnotes\includes\settings\SettingsGroup;
@ -30,7 +28,16 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
*
* @since 2.8.0
*/
const GROUP_ID = 'wordpress-hooks';
public const GROUP_ID = 'wordpress-hooks';
/**
* Setting group name.
*
* @var string
*
* @since 2.8.0
*/
const GROUP_NAME = 'WordPress Hooks with Priority Level';
/**
* Settings container key to enable the `the_title` hook.
@ -53,7 +60,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
* title string in menus and in the title element, but Footnotes doesn't
* delete footnotes in them.
*/
const EXPERT_LOOKUP_THE_TITLE = array(
public const EXPERT_LOOKUP_THE_TITLE = array(
'key' => 'footnote_inputfield_expert_lookup_the_title',
'name' => '<code>the_title()</code>',
'description' => '<a href="https://developer.wordpress.org/reference/hooks/the_title/" target="_blank">https://developer.wordpress.org/reference/hooks/the_title/</a>',
@ -71,7 +78,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `int` to `array`.
*/
const EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL = array(
public const EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL = array(
'key' => 'footnote_inputfield_expert_lookup_the_title_priority_level',
'name' => '<code>the_title()</code> Priority Level',
'description' => 'The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features. 9223372036854775807 is lowest priority, 0 is highest. To set priority level to lowest, set it to -1, interpreted as 9223372036854775807, the constant <code>PHP_INT_MAX</code>.',
@ -92,7 +99,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`.
* Convert setting data type from `string` to `boolean`.
*/
const EXPERT_LOOKUP_THE_CONTENT = array(
public const EXPERT_LOOKUP_THE_CONTENT = array(
'key' => 'footnote_inputfield_expert_lookup_the_content',
'name' => '<code>the_content()</code>',
'description' => '<a href="https://developer.wordpress.org/reference/hooks/the_content/" target="_blank">https://developer.wordpress.org/reference/hooks/the_content/</a>',
@ -126,7 +133,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `int` to `array`.
*/
const EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL = array(
public const EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL = array(
'key' => 'footnote_inputfield_expert_lookup_the_content_priority_level',
'name' => '<code>the_content()</code> Priority Level',
'description' => 'The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features. 9223372036854775807 is lowest priority, 0 is highest. To set priority level to lowest, set it to -1, interpreted as 9223372036854775807, the constant <code>PHP_INT_MAX</code>. For <code>the_content</code>, this figure must be lower than 99 so that certain strings added by a plugin running at 99 may not be mistaken as a footnote. This makes also sure that the reference container displays above a feature inserted by a plugin running at 1200.',
@ -148,7 +155,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`.
* Convert setting data type from `string` to `boolean`.
*/
const EXPERT_LOOKUP_THE_EXCERPT = array(
public const EXPERT_LOOKUP_THE_EXCERPT = array(
'key' => 'footnote_inputfield_expert_lookup_the_excerpt',
'name' => '<code>the_excerpt()</code>',
'description' => '<a href="https://developer.wordpress.org/reference/hooks/the_excerpt/" target="_blank">https://developer.wordpress.org/reference/hooks/the_excerpt/</a>',
@ -166,7 +173,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `int` to `array`.
*/
const EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL = array(
public const EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL = array(
'key' => 'footnote_inputfield_expert_lookup_the_excerpt_priority_level',
'name' => '<code>the_excerpt()</code> Priority Level',
'description' => 'The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features. 9223372036854775807 is lowest priority, 0 is highest. To set priority level to lowest, set it to -1, interpreted as 9223372036854775807, the constant <code>PHP_INT_MAX</code>.',
@ -187,7 +194,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`.
* Convert setting data type from `string` to `boolean`.
*/
const EXPERT_LOOKUP_WIDGET_TITLE = array(
public const EXPERT_LOOKUP_WIDGET_TITLE = array(
'key' => 'footnote_inputfield_expert_lookup_widget_title',
'name' => '<code>widget_title()</code>',
'description' => '<a href="https://codex.wordpress.org/Plugin_API/Filter_Reference/widget_title" target="_blank">https://codex.wordpress.org/Plugin_API/Filter_Reference/widget_title</a>',
@ -205,7 +212,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `int` to `array`.
*/
const EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL = array(
public const EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL = array(
'key' => 'footnote_inputfield_expert_lookup_widget_title_priority_level',
'name' => '<code>widget_title()</code> Priority Level',
'description' => 'The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features. 9223372036854775807 is lowest priority, 0 is highest. To set priority level to lowest, set it to -1, interpreted as 9223372036854775807, the constant <code>PHP_INT_MAX</code>.',
@ -231,7 +238,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`.
* Convert setting data type from `string` to `boolean`.
*/
const EXPERT_LOOKUP_WIDGET_TEXT = array(
public const EXPERT_LOOKUP_WIDGET_TEXT = array(
'key' => 'footnote_inputfield_expert_lookup_widget_text',
'name' => '<code>widget_text()</code>',
'description' => '<a href="https://codex.wordpress.org/Plugin_API/Filter_Reference/widget_text" target="_blank">https://codex.wordpress.org/Plugin_API/Filter_Reference/widget_text</a>. The <code>widget_text()</code> hook must be enabled either when footnotes are present in theme text widgets, or when Elementor accordions or toggles shall have a reference container per section. If they should not, this hook must be disabled.',
@ -249,7 +256,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `int` to `array`.
*/
const EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL = array(
public const EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL = array(
'key' => 'footnote_inputfield_expert_lookup_widget_text_priority_level',
'name' => '<code>widget_text()</code> Priority Level',
'description' => 'The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features. 9223372036854775807 is lowest priority, 0 is highest. To set priority level to lowest, set it to -1, interpreted as 9223372036854775807, the constant <code>PHP_INT_MAX</code>.',
@ -260,6 +267,9 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
'input_min' => -1,
);
/**
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {
$this->settings = array(
self::EXPERT_LOOKUP_THE_TITLE['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_TITLE ),