refactor: redo remaining settings

Note: the already-deprecated `FOOTNOTES_EXPERT_MODE`, `CUSTOM_CSS` and
`CUSTOM_CSS_LEGACY_MODE_ENABLE` settings have been dropped. The original
`CUSTOM_CSS_NEW` setting has been renamed to `CUSTOM_CSS`.
This commit is contained in:
Ben Goldsworthy 2021-08-08 15:01:01 +01:00
parent 08bc338690
commit bdb7dee5ee
16 changed files with 445 additions and 584 deletions

Binary file not shown.

View file

@ -418,6 +418,20 @@ abstract class Engine {
) );
}
protected function add_input_textarea( array $args ): void {
extract( $args );
echo ( sprintf(
'<textarea name="%s" id="%s" rows="4" cols="50" style="%s" %s%s>%s</textarea>',
$name,
$name,
$style ?? '',
isset($readonly) ? ' readonly="readonly"' : '',
$disabled ? ' disabled': '',
$value,
) );
}
protected function add_input_number( array $args ): void {
extract( $args );
@ -484,7 +498,6 @@ abstract class Engine {
);
}
/**************************************************************************
* NEW METHODS END
**************************************************************************/

View file

@ -92,8 +92,6 @@ class Init {
* @since 1.5.0
*/
public function initialize_settings(): void {
Settings::instance()->register_settings();
Settings::instance()->settings_sections['general']->add_settings_section();
Settings::instance()->settings_sections['referrers_and_tooltips']->add_settings_section();
Settings::instance()->settings_sections['scope_and_priority']->add_settings_section();

View file

@ -97,6 +97,9 @@ class SettingsPage extends Engine {
case 'text':
$this->add_input_text($args);
return;
case 'textarea':
$this->add_input_textarea($args);
return;
case 'number':
$this->add_input_number($args);
return;
@ -118,168 +121,6 @@ class SettingsPage extends Engine {
* NEW METHODS END
**************************************************************************/
/**
* Displays the Custom CSS box.
*
* @since 1.5.0
*/
public function custom_css() {
// Load template file.
$template = new Template( Template::DASHBOARD, 'customize-css' );
// Replace all placeholders.
$template->replace(
array(
'label-css' => $this->add_label( Settings::CUSTOM_CSS, __( 'Your existing Custom CSS code:', 'footnotes' ) ),
'css' => $this->add_textarea( Settings::CUSTOM_CSS ),
'description-css' => __( 'Custom CSS migrates to a dedicated tab. This text area is intended to keep your data safe, and the code remains valid while visible. Please copy-paste the content into the new text area under the new tab.', 'footnotes' ),
// phpcs:disable Squiz.PHP.CommentedOutCode.Found
// CSS classes are listed in the template.
// Localized notices are dropped to ease translators' task.
// "label-class-1" => ".footnote_plugin_tooltip_text",.
// "class-1" => $this->add_text(__("superscript, Footnotes index", $this->plugin_name)),.
// "label-class-2" => ".footnote_tooltip",.
// "class-2" => $this->add_text(__("mouse-over box, tooltip for each superscript", $this->plugin_name)),.
// "label-class-3" => ".footnote_plugin_index",.
// "class-3" => $this->add_text(__("1st column of the Reference Container, Footnotes index", $this->plugin_name)),.
// "label-class-4" => ".footnote_plugin_text",.
// "class-4" => $this->add_text(__("2nd column of the Reference Container, Footnote text", $this->plugin_name)).
// phpcs:enable
)
);
// Display template with replaced placeholders.
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
echo $template->get_content();
// phpcs:enable
}
/**
* Displays transitional legacy Custom CSS box.
*
* @since 2.2.2
* @deprecated
*/
public function custom_css_migration(): void {
// Options for Yes/No select box.
$enabled = array(
'yes' => __( 'Yes', 'footnotes' ),
'no' => __( 'No', 'footnotes' ),
);
// Load template file.
$template = new Template( Template::DASHBOARD, 'customize-css-migration' );
// Replace all placeholders.
$template->replace(
array(
'label-css' => $this->add_label( Settings::CUSTOM_CSS, __( 'Your existing Custom CSS code:', 'footnotes' ) ),
'css' => $this->add_textarea( Settings::CUSTOM_CSS ),
'description-css' => __( 'Custom CSS migrates to a dedicated tab. This text area is intended to keep your data safe, and the code remains valid while visible. Please copy-paste the content into the new text area below. Set Show legacy to No. Save twice.', 'footnotes' ),
'label-show-legacy' => $this->add_label( Settings::CUSTOM_CSS_LEGACY_ENABLE, 'Show legacy Custom CSS settings containers:' ),
'show-legacy' => $this->add_select_box( Settings::CUSTOM_CSS_LEGACY_ENABLE, $enabled ),
'notice-show-legacy' => __( 'Please set to No when you are done migrating, for the legacy Custom CSS containers to disappear.', 'footnotes' ),
// Translators: %s: Referres and tooltips.
'description-show-legacy' => sprintf( __( 'The legacy Custom CSS under the %s tab and its mirror here are emptied, and the select box saved as No, when the settings tab is saved while the settings container is not displayed.', 'footnotes' ), __( 'Referrers and tooltips', 'footnotes' ) ),
)
);
// Display template with replaced placeholders.
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
echo $template->get_content();
// phpcs:enable
}
/**
* Displays the new Custom CSS box.
*
* @since 2.2.2
*/
public function custom_css_new(): void {
// Load template file.
$template = new Template( Template::DASHBOARD, 'customize-css-new' );
// Replace all placeholders.
$template->replace(
array(
'css' => $this->add_textarea( Settings::CUSTOM_CSS_NEW ),
'headline' => $this->add_text( __( 'Recommended CSS classes:', 'footnotes' ) ),
)
);
// Display template with replaced placeholders.
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
echo $template->get_content();
// phpcs:enable
}
/**
* Displays available Hooks to look for Footnote short codes.
*
* Priority level was initially a hard-coded default
* shows 9223372036854775807 in the numbox
* empty should be interpreted as `PHP_INT_MAX`,
* but a numbox cannot be set to empty, see {@link https://github.com/Modernizr/Modernizr/issues/171
* here}
* define -1 as `PHP_INT_MAX` instead
*
* @since 1.5.5
*/
public function lookup_hooks(): void {
// Load template file.
$template = new Template( Template::DASHBOARD, 'expert-lookup' );
// Replace all placeholders.
$template->replace(
array(
'description-1' => __( 'The priority level determines whether Footnotes is executed timely before other plugins, and how the reference container is positioned relative to other features.', 'footnotes' ),
// Translators: 1: 99; 2: 1200.
'description-2' => sprintf( __( 'For the_content, this figure must be lower than %1$d so that certain strings added by a plugin running at %1$d 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 %2$d.', 'footnotes' ), 99, 1200 ),
// Translators: 1: PHP_INT_MAX; 2: 0; 3: -1; 4: 'PHP_INT_MAX'.
'description-3' => sprintf( __( '%1$d is lowest priority, %2$d is highest. To set priority level to lowest, set it to %3$d, interpreted as %1$d, the constant %4$s.', 'footnotes' ), PHP_INT_MAX, 0, -1, 'PHP_INT_MAX' ),
'description-4' => __( 'The widget_text 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.', 'footnotes' ),
'head-hook' => __( 'WordPress hook function name', 'footnotes' ),
'head-checkbox' => __( 'Activate', 'footnotes' ),
'head-numbox' => __( 'Priority level', 'footnotes' ),
'head-url' => __( 'WordPress documentation', 'footnotes' ),
'label-the-title' => $this->add_label( Settings::EXPERT_LOOKUP_THE_TITLE, 'the_title' ),
'the-title' => $this->add_checkbox( Settings::EXPERT_LOOKUP_THE_TITLE ),
'priority-the-title' => $this->add_num_box( Settings::EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL, -1, PHP_INT_MAX ),
'url-the-title' => 'https://developer.wordpress.org/reference/hooks/the_title/',
'label-the-content' => $this->add_label( Settings::EXPERT_LOOKUP_THE_CONTENT, 'the_content' ),
'the-content' => $this->add_checkbox( Settings::EXPERT_LOOKUP_THE_CONTENT ),
'priority-the-content' => $this->add_num_box( Settings::EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL, -1, PHP_INT_MAX ),
'url-the-content' => 'https://developer.wordpress.org/reference/hooks/the_content/',
'label-the-excerpt' => $this->add_label( Settings::EXPERT_LOOKUP_THE_EXCERPT, 'the_excerpt' ),
'the-excerpt' => $this->add_checkbox( Settings::EXPERT_LOOKUP_THE_EXCERPT ),
'priority-the-excerpt' => $this->add_num_box( Settings::EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL, -1, PHP_INT_MAX ),
'url-the-excerpt' => 'https://developer.wordpress.org/reference/functions/the_excerpt/',
'label-widget-title' => $this->add_label( Settings::EXPERT_LOOKUP_WIDGET_TITLE, 'widget_title' ),
'widget-title' => $this->add_checkbox( Settings::EXPERT_LOOKUP_WIDGET_TITLE ),
'priority-widget-title' => $this->add_num_box( Settings::EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL, -1, PHP_INT_MAX ),
'url-widget-title' => 'https://codex.wordpress.org/Plugin_API/Filter_Reference/widget_title',
'label-widget-text' => $this->add_label( Settings::EXPERT_LOOKUP_WIDGET_TEXT, 'widget_text' ),
'widget-text' => $this->add_checkbox( Settings::EXPERT_LOOKUP_WIDGET_TEXT ),
'priority-widget-text' => $this->add_num_box( Settings::EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL, -1, PHP_INT_MAX ),
'url-widget-text' => 'https://codex.wordpress.org/Plugin_API/Filter_Reference/widget_text',
)
);
// Display template with replaced placeholders.
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
echo $template->get_content();
// phpcs:enable
}
/**
* Displays a short introduction to the plugin.
*
@ -420,34 +261,6 @@ class SettingsPage extends Engine {
protected function get_meta_boxes(): array {
$meta_boxes = array();
$meta_boxes[] = $this->add_meta_box( 'settings', 'amp-compat', __( 'AMP compatibility', 'footnotes' ), 'amp_compat' );
$meta_boxes[] = $this->add_meta_box( 'settings', 'numbering', __( 'Footnotes numbering', 'footnotes' ), 'numbering' );
$meta_boxes[] = $this->add_meta_box( 'settings', 'scrolling', __( 'Scrolling behavior', 'footnotes' ), 'scrolling' );
$meta_boxes[] = $this->add_meta_box( 'settings', 'hard-links', __( 'URL fragment ID configuration', 'footnotes' ), 'hard_links' );
$meta_boxes[] = $this->add_meta_box( 'settings', 'reference-container', __( 'Reference container', 'footnotes' ), 'reference_container' );
$meta_boxes[] = $this->add_meta_box( 'settings', 'excerpts', __( 'Footnotes in excerpts', 'footnotes' ), 'excerpts' );
$meta_boxes[] = $this->add_meta_box( 'settings', 'love', Config::PLUGIN_HEADING_NAME . '&nbsp;' . Config::LOVE_SYMBOL_HEADING, 'love' );
$meta_boxes[] = $this->add_meta_box( 'customize', 'superscript', __( 'Referrers', 'footnotes' ), 'superscript' );
$meta_boxes[] = $this->add_meta_box( 'customize', 'label-solution', __( 'Referrers in labels', 'footnotes' ), 'label_solution' );
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box', __( 'Tooltips', 'footnotes' ), 'mouseover_box' );
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-position', __( 'Tooltip position', 'footnotes' ), 'mouseover_box_position' );
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-dimensions', __( 'Tooltip dimensions', 'footnotes' ), 'mouseover_box_dimensions' );
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-timing', __( 'Tooltip timing', 'footnotes' ), 'mouseover_box_timing' );
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-truncation', __( 'Tooltip truncation', 'footnotes' ), 'mouseover_box_truncation' );
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-text', __( 'Tooltip text', 'footnotes' ), 'mouseover_box_text' );
$meta_boxes[] = $this->add_meta_box( 'customize', 'mouse-over-box-appearance', __( 'Tooltip appearance', 'footnotes' ), 'mouseover_box_appearance' );
if ( Convert::to_bool( Settings::instance()->get( Settings::CUSTOM_CSS_LEGACY_ENABLE ) ) ) {
$meta_boxes[] = $this->add_meta_box( 'customize', 'custom-css', __( 'Your existing Custom CSS code', 'footnotes' ), 'custom_css' );
}
$meta_boxes[] = $this->add_meta_box( 'expert', 'lookup', __( 'WordPress hooks with priority level', 'footnotes' ), 'lookup_hooks' );
if ( Convert::to_bool( Settings::instance()->get( Settings::CUSTOM_CSS_LEGACY_ENABLE ) ) ) {
$meta_boxes[] = $this->add_meta_box( 'customcss', 'custom-css-migration', __( 'Your existing Custom CSS code', 'footnotes' ), 'custom_css_migration' );
}
$meta_boxes[] = $this->add_meta_box( 'customcss', 'custom-css-new', __( 'Custom CSS', 'footnotes' ), 'custom_css_new' );
$meta_boxes[] = $this->add_meta_box( 'how-to', 'help', __( 'Brief introduction: How to use the plugin', 'footnotes' ), 'help' );
$meta_boxes[] = $this->add_meta_box( 'how-to', 'donate', __( 'Help us to improve our Plugin', 'footnotes' ), 'donate' );

View file

@ -192,7 +192,6 @@ class Core {
require_once plugin_dir_path( __DIR__ ) . 'public/class-general.php';
$this->loader = new Loader();
}
/**
* Define the locale for this plugin for internationalization.

View file

@ -35,226 +35,6 @@ use footnotes\includes\settings\customcss\CustomCSSSettingsSection;
* Moved under `footnotes\includes` namespace.
*/
class Settings {
/**
* Options for the custom width units (per cent is a ratio, not a unit).
*
* @var array
*
* @since 2.8.0
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const WIDTH_UNIT_OPTIONS = array(
'%' => 'per cent',
'px' => 'pixels',
'rem' => 'root em',
'em' => 'em',
'vw' => 'viewport width',
);
/**
* Settings container key for the Custom CSS.
*
* @var string
*
* @since 1.5.0
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const CUSTOM_CSS = 'footnote_inputfield_custom_css';
/**
* Settings container key to enable the `the_title` hook.
*
* These are checkboxes; the keyword `checked` is converted to `true`, whilst
* an empty string (the default) is converted to `false`.
*
* Hooks should all be enabled by default to prevent users from thinking at
* first that the feature is broken in post titles (see {@link
* https://wordpress.org/support/topic/more-feature-ideas/ here} for more
* information).
*
* @var string
*
* @since 1.5.5
* @todo In titles, footnotes are still buggy, because WordPress uses the
* title string in menus and in the title element, but Footnotes doesn't
* delete footnotes in them.
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const EXPERT_LOOKUP_THE_TITLE = 'footnote_inputfield_expert_lookup_the_title';
/**
* Settings container key to enable the `the_content` hook.
*
* @var string
*
* @since 1.5.5
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const EXPERT_LOOKUP_THE_CONTENT = 'footnote_inputfield_expert_lookup_the_content';
/**
* Settings container key to enable the `the_excerpt` hook.
*
* @var string
*
* @see FOOTNOTES_IN_EXCERPT
*
* @since 1.5.5
* @since 2.6.3 Enable by default.
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const EXPERT_LOOKUP_THE_EXCERPT = 'footnote_inputfield_expert_lookup_the_excerpt';
/**
* Settings container key to enable the `widget_title` hook.
*
* @var string
*
* @since 1.5.5
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const EXPERT_LOOKUP_WIDGET_TITLE = 'footnote_inputfield_expert_lookup_widget_title';
/**
* Settings container key to enable the `widget_text` hook.
*
* The `widget_text` hook must be disabled by default, because it causes
* multiple reference containers to appear in Elementor accordions, but
* it must be enabled if multiple reference containers are desired, as
* in Elementor toggles.
*
* @var string
*
* @since 1.5.5
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const EXPERT_LOOKUP_WIDGET_TEXT = 'footnote_inputfield_expert_lookup_widget_text';
/**
* Settings container key for the mouse-over box to define the max. width.
*
* The width should be limited to start with, for the box to have shape.
*
* The default width is 450.
*
* @var int
*
* @since 1.5.6
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH = 'footnote_inputfield_custom_mouse_over_box_max_width';
/**
* Settings container key to get the backlink symbol switch side.
*
* @var string
*
* @since 2.1.1
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH = 'footnotes_inputfield_reference_container_backlink_symbol_switch';
/**
* Settings container key for `the_content` hook priority level.
*
* Priority level of `the_content` and of `widget_text` as the only relevant
* hooks must be less than 99 because social buttons may yield scripts
* that contain the strings (( and )) (i.e., the default footnote
* start and end shortcodes), which causes issues with fake footnotes.
*
* Setting `the_content` priority to 10 instead of `PHP_INT_MAX` makes the
* footnotes reference container display beneath the post and above other
* features added by other plugins, e.g. related post lists and social buttons.
*
* For the {@link https://wordpress.org/plugins/yet-another-related-posts-plugin/
* YARPP} plugin to display related posts below the Footnotes reference container,
* priority needs to be at least 1,200.
*
* `PHP_INT_MAX` cannot be reset by leaving the number box empty, because
* WebKit browsers don't allow it, so we must resort to -1.
*
* @var int
*
* @since 2.0.5
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL = 'footnote_inputfield_expert_lookup_the_content_priority_level';
/**
* Settings container key for `the_title` hook priority level.
*
* @var int
*
* @since 2.1.2
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL = 'footnote_inputfield_expert_lookup_the_title_priority_level';
/**
* Settings container key for `widget_title` hook priority level.
*
* @var int
*
* @since 2.1.2
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL = 'footnote_inputfield_expert_lookup_widget_title_priority_level';
/**
* Settings container key for `widget_text` hook priority level.
*
* @var int
*
* @since 2.1.2
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL = 'footnote_inputfield_expert_lookup_widget_text_priority_level';
/**
* Settings container key for `the_excerpt` hook priority level.
*
* @var int
*
* @since 2.1.2
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL = 'footnote_inputfield_expert_lookup_the_excerpt_priority_level';
/**
* Settings container key for reference container position shortcode.
*
* @var string
*
* @since 2.2.0
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const REFERENCE_CONTAINER_POSITION_SHORTCODE = 'footnote_inputfield_reference_container_position_shortcode';
/**
* Settings container key for the Custom CSS migrated to a dedicated tab.
*
* @var string
*
* @since 2.2.2
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const CUSTOM_CSS_NEW = 'footnote_inputfield_custom_css_new';
/**
* Settings container key to enable display of legacy Custom CSS metaboxes.
*
* This must be `false` if its setting is contained in the container to be hidden
* because when saving, all missing constants are emptied, and {@see
* Footnotes_Convert::to_bool()} converts empty to `false`.
*
* @var string
*
* @since 2.2.2
* @since 2.3.0 Swap migration Boolean, meaning show legacy instead of
* migration complete, due to storage data structure constraints.
* @todo Move to `SettingsSection`/`SettingsGroup`.
*/
const CUSTOM_CSS_LEGACY_ENABLE = 'footnote_inputfield_custom_css_legacy_enable';
/**
* Contains all Settings option group slugs.
@ -273,73 +53,6 @@ class Settings {
'footnotes_storage_custom_css',
);
/**
* Contains all default values for each Settings Container.
*
* @var (string|int)[]
*
* @since 1.5.0
* @since 2.8.0 Rename from `default` to `default_settings`.
* @deprecated
*
* @todo Delete once moved to `SettingsSection`/`SettingsGroup`s.
*/
private array $default_settings = array(
// Referrers and tooltips.
'footnotes_storage_custom' => array(
// Your existing Custom CSS code.
self::CUSTOM_CSS => '',
),
// Scope and priority.
'footnotes_storage_expert' => array(
// WordPress hooks with priority level.
self::EXPERT_LOOKUP_THE_TITLE => "",
self::EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL => PHP_INT_MAX,
self::EXPERT_LOOKUP_THE_CONTENT => 'checked',
self::EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL => 98,
self::EXPERT_LOOKUP_THE_EXCERPT => '',
self::EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL => PHP_INT_MAX,
self::EXPERT_LOOKUP_WIDGET_TITLE => '',
self::EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL => PHP_INT_MAX,
self::EXPERT_LOOKUP_WIDGET_TEXT => '',
self::EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL => 98,
),
// Custom CSS.
'footnotes_storage_custom_css' => array(
// Your existing Custom CSS code.
self::CUSTOM_CSS_LEGACY_ENABLE => 'yes',
// Custom CSS.
self::CUSTOM_CSS_NEW => '',
),
);
/**
* Contains all Settings from each Settings Container.
*
* @var (string|int)[]
*
* @since 1.5.0
* @deprecated
*
* @todo Delete once all `SettingsSection`/`SettingsGroup`s set up.
*/
public array $settings = array();
/**
* Contains each section of settings.
*
@ -491,27 +204,6 @@ class Settings {
return $this->settings[ $key ] ?? null;
}
/**
* Register all Settings Containers for the plugin Settings Page in the Dashboard.
*
* The Settings Container label will be the same as the Settings Container name.
*
* @since 1.5.0
* @todo Only register current tab?
*/
public function register_settings(): void {
// Register all settings.
foreach ($this->default_settings as $options_groups_name => $options_groups_values) {
foreach ($options_groups_values as $setting_name => $setting_value) {
if (!is_array($setting_value)) {
register_setting( $options_groups_name, $setting_name );
} else {
register_setting( $options_groups_name, $setting_name, $setting_value['setting_args']);
}
}
}
}
/**
* Returns a singleton of this class.
*

View file

@ -19,6 +19,54 @@ use footnotes\includes\Settings;
* @since 2.8.0
*/
class Setting {
/**
* Options for the custom width units (per cent is a ratio, not a unit).
*
* @var array
*
* @since 2.8.0
*/
const WIDTH_UNIT_OPTIONS = array(
'%' => 'per cent',
'px' => 'pixels',
'rem' => 'root em',
'em' => 'em',
'vw' => 'viewport width',
);
/**
* Options for the custom font size units (per cent is a ratio, not a unit).
*
* @var array
*
* @since 2.8.0
*/
const FONT_SIZE_UNIT_OPTIONS = array(
'em' => 'em',
'rem' => 'rem',
'px' => 'pixels',
'pt' => 'points',
'pc' => 'picas',
'mm' => 'millimeters',
'%' => 'per cent',
);
/**
* Options for the HTML text elements.
*
* @var array
*
* @since 2.8.0
*/
const TEXT_ELEMENT_OPTIONS = array(
'p' => 'paragraph',
'h2' => 'heading 2',
'h3' => 'heading 3',
'h4' => 'heading 4',
'h5' => 'heading 5',
'h6' => 'heading 6',
);
/**
* Setting value.
*

View file

@ -109,9 +109,12 @@ abstract class SettingsGroup {
protected function load_values(array|false $options): void {
if ( ! $options ) return;
// TODO remove unfound settings from option
foreach ( $options as $setting_key => $setting_value ) {
$this->settings[$setting_key]->set_value( $setting_value );
}
$setting = $this->settings[$setting_key];
if ($setting) $setting->set_value( $setting_value );
else trigger_error("Setting with key {$setting_key} not found, skipping...", E_USER_WARNING);
}
}
public function add_settings_fields(Layout\SettingsPage $component): void {

View file

@ -0,0 +1,58 @@
<?php
/**
* File providing the `CustomCSSSettingsGroup` class.
*
* @package footnotes
* @since 2.8.0
*/
declare(strict_types=1);
namespace footnotes\includes\settings\customcss;
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 custom CSS settings.
*
* @package footnotes
* @since 2.8.0
*/
class CustomCSSSettingsGroup extends SettingsGroup {
/**
* Setting group ID.
*
* @var string
*
* @since 2.8.0
*/
const GROUP_ID = 'custom-css';
/**
* Settings container key for the Custom CSS.
*
* @var array
*
* @since 2.2.2
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `string` to `array`.
*/
const CUSTOM_CSS = array(
'key' => 'footnote_inputfield_custom_css_new',
'name' => 'Your Existing Custom CSS Code',
'type' => 'string',
'input_type' => 'textarea',
);
protected function add_settings( array|false $options ): void {
$this->settings = array(
self::CUSTOM_CSS['key'] => $this->add_setting( self::CUSTOM_CSS ),
);
$this->load_values( $options );
}
}

View file

@ -15,7 +15,7 @@ require_once plugin_dir_path( __DIR__ ) . 'class-settings-section.php';
use footnotes\includes\settings\SettingsSection;
// Import settings groups.
//use footnotes\includes\settings\custom-css\...;
use footnotes\includes\settings\customcss\CustomCSSSettingsGroup;
/**
* Class defining plugin referrer and tooltips settings.
@ -52,13 +52,12 @@ class CustomCSSSettingsSection extends SettingsSection {
protected function load_dependencies(): void {
parent::load_dependencies();
//require_once plugin_dir_path( __DIR__ ) . 'general/class-reference-container-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'custom-css/class-custom-css-settings-group.php';
}
protected function add_settings_groups(): void {
$this->settings_groups = array (
// Add settings groups.
//...::GROUP_ID => new ...($this->options_group_slug, $this->section_slug),
CustomCSSSettingsGroup::GROUP_ID => new CustomCSSSettingsGroup($this->options_group_slug, $this->section_slug),
);
}
}

View file

@ -64,14 +64,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'default_value' => 'p',
'type' => 'string',
'input_type' => 'select',
'input_options' => array(
'p' => 'paragraph',
'h2' => 'heading 2',
'h3' => 'heading 3',
'h4' => 'heading 4',
'h5' => 'heading 5',
'h6' => 'heading 6',
),
'input_options' => Setting::TEXT_ELEMENT_OPTIONS
);
/**
@ -577,7 +570,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'default_value' => 'px',
'type' => 'string',
'input_type' => 'select',
'input_options' => Settings::WIDTH_UNIT_OPTIONS,
'input_options' => Setting::WIDTH_UNIT_OPTIONS,
'enabled_by' => self::BACKLINKS_COLUMN_WIDTH_ENABLED,
);
@ -644,7 +637,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'default_value' => 'px',
'type' => 'string',
'input_type' => 'select',
'input_options' => Settings::WIDTH_UNIT_OPTIONS,
'input_options' => Setting::WIDTH_UNIT_OPTIONS,
'enabled_by' => self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED,
);
@ -688,28 +681,6 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'input_type' => 'checkbox',
);
/**
* Settings container key for the Expert mode.
*
* Since the removal of the `the_post` hook, the tab is no danger zone any longer.
* All users, not experts only, need to be able to control relative positioning.
*
* @var string
*
* @since 1.5.5
* @since 2.1.6 Setting deprecated.
* @deprecated
* @todo Un-deprecate or delete.
*/
const FOOTNOTES_EXPERT_MODE = array(
'key' => 'footnote_inputfield_enable_expert_mode',
'name' => 'Expert Mode',
'description' => 'DEPRECATED',
'default_value' => true,
'type' => 'boolean',
'input_type' => 'checkbox',
);
protected function add_settings( array|false $options ): void {
$this->settings = array(
self::REFERENCE_CONTAINER_NAME['key'] => $this->add_setting( self::REFERENCE_CONTAINER_NAME ),
@ -744,7 +715,6 @@ 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 ),
);
$this->load_values( $options );

View file

@ -90,15 +90,7 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
'default_value' => 'px',
'type' => 'string',
'input_type' => 'select',
'input_options' => array(
'em' => 'em',
'rem' => 'rem',
'px' => 'pixels',
'pt' => 'points',
'pc' => 'picas',
'mm' => 'millimeters',
'%' => 'per cent',
),
'input_options' => Setting::FONT_SIZE_UNIT_OPTIONS
);
/**

View file

@ -35,6 +35,8 @@ class TooltipDimensionsSettingsGroup extends SettingsGroup {
/**
* Settings container key for the mouse-over box to define the max. width.
*
* The width should be limited to start with, for the box to have shape.
*
* @var array
*
* @since 1.5.6

View file

@ -13,11 +13,11 @@ namespace footnotes\includes\settings\scopeandpriority;
require_once plugin_dir_path( __DIR__ ) . 'class-settings-section.php';
use footnotes\includes\settings\SettingsSection;
// Import settings groups.
//use footnotes\includes\settings\scope-and-priority\...;
use footnotes\includes\settings\scopeandpriority\WordPressHooksSettingsGroup;
/**
* Class defining plugin referrer and tooltips settings.
* Class defining plugin hook priority settings.
*
* @package footnotes
* @since 2.8.0
@ -51,13 +51,12 @@ class ScopeAndPrioritySettingsSection extends SettingsSection {
protected function load_dependencies(): void {
parent::load_dependencies();
//require_once plugin_dir_path( __DIR__ ) . 'general/class-reference-container-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'scope-and-priority/class-wordpress-hooks-settings-group.php';
}
protected function add_settings_groups(): void {
$this->settings_groups = array (
// Add settings groups.
//...::GROUP_ID => new ...($this->options_group_slug, $this->section_slug),
WordPressHooksSettingsGroup::GROUP_ID => new WordPressHooksSettingsGroup($this->options_group_slug, $this->section_slug),
);
}
}

View file

@ -0,0 +1,279 @@
<?php
/**
* File providing the `WordPressHooksSettingsGroup` class.
*
* @package footnotes
* @since 2.8.0
*/
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;
/**
* Class defining the WordPress hook settings.
*
* @package footnotes
* @since 2.8.0
*/
class WordPressHooksSettingsGroup extends SettingsGroup {
/**
* Setting group ID.
*
* @var string
*
* @since 2.8.0
*/
const GROUP_ID = 'wordpress-hooks';
/**
* Settings container key to enable the `the_title` hook.
*
* These are checkboxes; the keyword `checked` is converted to `true`, whilst
* an empty string (the default) is converted to `false`.
*
* Hooks should all be enabled by default to prevent users from thinking at
* first that the feature is broken in post titles (see {@link
* https://wordpress.org/support/topic/more-feature-ideas/ here} for more
* information).
*
* @var array
*
* @since 1.5.5
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `string` to `array`.
* Convert setting data type from `string` to `boolean`.
* @todo In titles, footnotes are still buggy, because WordPress uses the
* title string in menus and in the title element, but Footnotes doesn't
* delete footnotes in them.
*/
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>',
'default_value' => false,
'type' => 'boolean',
'input_type' => 'checkbox',
);
/**
* Settings container key for `the_title` hook priority level.
*
* @var array
*
* @since 2.1.2
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `int` to `array`.
*/
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>.',
'default_value' => PHP_INT_MAX,
'type' => 'number',
'input_type' => 'number',
'input_max' => PHP_INT_MAX,
'input_min' => -1,
);
/**
* Settings container key to enable the `the_content` hook.
*
* @var array
*
* @since 1.5.5
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `string` to `array`.
* Convert setting data type from `string` to `boolean`.
*/
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>',
'default_value' => true,
'type' => 'boolean',
'input_type' => 'checkbox',
);
/**
* Settings container key for `the_content` hook priority level.
*
* Priority level of `the_content` and of `widget_text` as the only relevant
* hooks must be less than 99 because social buttons may yield scripts
* that contain the strings (( and )) (i.e., the default footnote
* start and end shortcodes), which causes issues with fake footnotes.
*
* Setting `the_content` priority to 10 instead of `PHP_INT_MAX` makes the
* footnotes reference container display beneath the post and above other
* features added by other plugins, e.g. related post lists and social buttons.
*
* For the {@link https://wordpress.org/plugins/yet-another-related-posts-plugin/
* YARPP} plugin to display related posts below the Footnotes reference container,
* priority needs to be at least 1,200.
*
* `PHP_INT_MAX` cannot be reset by leaving the number box empty, because
* WebKit browsers don't allow it, so we must resort to -1.
*
* @var array
*
* @since 2.0.5
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `int` to `array`.
*/
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.',
'default_value' => 98,
'type' => 'number',
'input_type' => 'number',
'input_max' => PHP_INT_MAX,
'input_min' => -1,
);
/**
* Settings container key to enable the `the_excerpt` hook.
*
* @var array
*
* @since 1.5.5
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `string` to `array`.
* Convert setting data type from `string` to `boolean`.
*/
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>',
'default_value' => false,
'type' => 'boolean',
'input_type' => 'checkbox',
);
/**
* Settings container key for `the_excerpt` hook priority level.
*
* @var array
*
* @since 2.1.2
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `int` to `array`.
*/
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>.',
'default_value' => PHP_INT_MAX,
'type' => 'number',
'input_type' => 'number',
'input_max' => PHP_INT_MAX,
'input_min' => -1,
);
/**
* Settings container key to enable the `widget_title` hook.
*
* @var array
*
* @since 1.5.5
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `string` to `array`.
* Convert setting data type from `string` to `boolean`.
*/
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>',
'default_value' => false,
'type' => 'boolean',
'input_type' => 'checkbox',
);
/**
* Settings container key for `widget_title` hook priority level.
*
* @var array
*
* @since 2.1.2
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `int` to `array`.
*/
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>.',
'default_value' => PHP_INT_MAX,
'type' => 'number',
'input_type' => 'number',
'input_max' => PHP_INT_MAX,
'input_min' => -1,
);
/**
* Settings container key to enable the `widget_text` hook.
*
* The `widget_text` hook must be disabled by default, because it causes
* multiple reference containers to appear in Elementor accordions, but
* it must be enabled if multiple reference containers are desired, as
* in Elementor toggles.
*
* @var array
*
* @since 1.5.5
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `string` to `array`.
* Convert setting data type from `string` to `boolean`.
*/
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.',
'default_value' => false,
'type' => 'boolean',
'input_type' => 'checkbox',
);
/**
* Settings container key for `widget_text` hook priority level.
*
* @var array
*
* @since 2.1.2
* @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
* Convert from `int` to `array`.
*/
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>.',
'default_value' => 98,
'type' => 'number',
'input_type' => 'number',
'input_max' => PHP_INT_MAX,
'input_min' => -1,
);
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 ),
self::EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL ),
self::EXPERT_LOOKUP_THE_CONTENT['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_CONTENT ),
self::EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL ),
self::EXPERT_LOOKUP_THE_EXCERPT['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_EXCERPT ),
self::EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL ),
self::EXPERT_LOOKUP_WIDGET_TITLE['key'] => $this->add_setting( self::EXPERT_LOOKUP_WIDGET_TITLE ),
self::EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL['key'] => $this->add_setting( self::EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL ),
self::EXPERT_LOOKUP_WIDGET_TEXT['key'] => $this->add_setting( self::EXPERT_LOOKUP_WIDGET_TEXT ),
self::EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL['key'] => $this->add_setting( self::EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL ),
);
$this->load_values( $options );
}
}

View file

@ -13,7 +13,7 @@ declare(strict_types=1);
namespace footnotes\general;
use footnotes\includes\{Settings, Convert, Template};
use footnotes\includes\{Settings, Config, Convert, Template};
/**
* @todo Replace with constant imports.
@ -39,6 +39,8 @@ use footnotes\includes\settings\referrersandtooltips\{
TooltipTimingSettingsGroup,
TooltipTruncationSettingsGroup
};
use footnotes\includes\settings\scopeandpriority\WordPressHooksSettingsGroup;
use footnotes\includes\settings\customcss\CustomCSSSettingsGroup;
/**
* Searches and replaces the footnotes and generates the reference container.
@ -297,11 +299,11 @@ class Parser {
*/
public function register_hooks(): void {
// Get values from settings.
$the_title_priority = (int) Settings::instance()->get( Settings::EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL );
$the_content_priority = (int) Settings::instance()->get( Settings::EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL );
$the_excerpt_priority = (int) Settings::instance()->get( Settings::EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL );
$widget_title_priority = (int) Settings::instance()->get( Settings::EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL );
$widget_text_priority = (int) Settings::instance()->get( Settings::EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL );
$the_title_priority = Settings::instance()->get_setting( WordPressHooksSettingsGroup::EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL['key'] )->get_value();
$the_content_priority = Settings::instance()->get_setting( WordPressHooksSettingsGroup::EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL['key'] )->get_value();
$the_excerpt_priority = Settings::instance()->get_setting( WordPressHooksSettingsGroup::EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL['key'] )->get_value();
$widget_title_priority = Settings::instance()->get_setting( WordPressHooksSettingsGroup::EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL['key'] )->get_value();
$widget_text_priority = Settings::instance()->get_setting( WordPressHooksSettingsGroup::EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL['key'] )->get_value();
// PHP_INT_MAX can be set by -1.
$the_title_priority = ( -1 === $the_title_priority ) ? PHP_INT_MAX : $the_title_priority;
@ -324,7 +326,7 @@ class Parser {
PHP_INT_MAX
);
if ( Convert::to_bool( Settings::instance()->get( Settings::EXPERT_LOOKUP_THE_TITLE ) ) ) {
if ( Settings::instance()->get_setting( WordPressHooksSettingsGroup::EXPERT_LOOKUP_THE_TITLE['key'] )->get_value() ) {
add_filter(
'the_title',
fn( string $content): string => $this->footnotes_in_title( $content ),
@ -333,7 +335,7 @@ class Parser {
}
// Configurable priority level for reference container relative positioning; default 98.
if ( Convert::to_bool( Settings::instance()->get( Settings::EXPERT_LOOKUP_THE_CONTENT ) ) ) {
if ( Settings::instance()->get_setting( WordPressHooksSettingsGroup::EXPERT_LOOKUP_THE_CONTENT['key'] )->get_value() ) {
add_filter(
'the_content',
fn( string $content): string => $this->footnotes_in_content( $content ),
@ -375,7 +377,7 @@ class Parser {
);
}
if ( Convert::to_bool( Settings::instance()->get( Settings::EXPERT_LOOKUP_THE_EXCERPT ) ) ) {
if ( Settings::instance()->get_setting( WordPressHooksSettingsGroup::EXPERT_LOOKUP_THE_EXCERPT['key'] )->get_value() ) {
/**
* Adds a filter to the excerpt hook.
*
@ -391,7 +393,7 @@ class Parser {
);
}
if ( Convert::to_bool( Settings::instance()->get( Settings::EXPERT_LOOKUP_WIDGET_TITLE ) ) ) {
if ( Settings::instance()->get_setting( WordPressHooksSettingsGroup::EXPERT_LOOKUP_WIDGET_TITLE['key'] )->get_value() ) {
/**
* TODO
*/
@ -402,7 +404,7 @@ class Parser {
);
}
if ( Convert::to_bool( Settings::instance()->get( Settings::EXPERT_LOOKUP_WIDGET_TEXT ) ) ) {
if ( Settings::instance()->get_setting( WordPressHooksSettingsGroup::EXPERT_LOOKUP_WIDGET_TEXT['key'] )->get_value() ) {
/**
* TODO
*/
@ -699,11 +701,7 @@ class Parser {
* Set custom CSS to override settings, not conversely.
* Legacy Custom CSS is used until its set to disappear after dashboard tab migration.
*/
if ( Convert::to_bool( Settings::instance()->get( Settings::CUSTOM_CSS_LEGACY_ENABLE ) ) ) {
echo Settings::instance()->get( Settings::CUSTOM_CSS );
echo "\r\n";
}
echo Settings::instance()->get( Settings::CUSTOM_CSS_NEW );
echo Settings::instance()->get_setting( CustomCSSSettingsGroup::CUSTOM_CSS['key'] )->get_value();
// Insert end tag without switching out of PHP.
echo "\r\n</style>\r\n";
@ -1116,11 +1114,11 @@ class Parser {
public function unify_delimiters( string $content ): string {
// Get footnotes start and end tag short codes.
$starting_tag = Settings::instance()->get_setting( ShortcodeSettingsGroup::FOOTNOTES_SHORT_CODE_START )->get_value();
$ending_tag = Settings::instance()->get_setting( ShortcodeSettingsGroup::FOOTNOTES_SHORT_CODE_END )->get_value();
$starting_tag = Settings::instance()->get_setting( ShortcodeSettingsGroup::FOOTNOTES_SHORT_CODE_START['key'] )->get_value();
$ending_tag = Settings::instance()->get_setting( ShortcodeSettingsGroup::FOOTNOTES_SHORT_CODE_END['key'] )->get_value();
if ( 'userdefined' === $starting_tag || 'userdefined' === $ending_tag ) {
$starting_tag = Settings::instance()->get_setting( ShortcodeSettingsGroup::FOOTNOTES_SHORT_CODE_START_USER_DEFINED )->get_value();
$ending_tag = Settings::instance()->get_setting( ShortcodeSettingsGroup::FOOTNOTES_SHORT_CODE_END_USER_DEFINED )->get_value();
$starting_tag = Settings::instance()->get_setting( ShortcodeSettingsGroup::FOOTNOTES_SHORT_CODE_START_USER_DEFINED['key'] )->get_value();
$ending_tag = Settings::instance()->get_setting( ShortcodeSettingsGroup::FOOTNOTES_SHORT_CODE_END_USER_DEFINED['key'] )->get_value();
}
// If any footnotes short code is empty, return the content without changes.
@ -1184,8 +1182,6 @@ class Parser {
// Get footnote delimiter shortcodes and unify them.
$content = self::unify_delimiters( $content );
print_r('FOO');
print_r($content);
/*
* Checks for balanced footnote delimiters; delimiter syntax validation.
@ -1195,7 +1191,7 @@ class Parser {
*/
// If enabled.
if ( Settings::instance()->get_setting( ShortcodeSettingsGroup::FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE['key'] ->get_value()) ) {
if ( Settings::instance()->get_setting( ShortcodeSettingsGroup::FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE['key']) ->get_value() ) {
// Apply different regex depending on whether start shortcode is double/triple opening parenthesis.
if ( '((' === self::$start_tag || '(((' === self::$start_tag ) {
@ -1623,7 +1619,7 @@ class Parser {
$offset_x = Settings::instance()->get_setting( TooltipPositionSettingsGroup::FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X['key'] )->get_value();
$fade_in_delay = Settings::instance()->get_setting( TooltipTimingSettingsGroup::MOUSE_OVER_BOX_FADE_IN_DELAY['key'] )->get_value();
$fade_in_duration = Settings::instance()->get_setting( TooltipTimingSettingsGroup::MOUSE_OVER_BOX_FADE_IN_DURATION['key'] )->get_value();
$fade_out_delay = Settings::instance()->get_settingget( TooltipTimingSettingsGroup::MOUSE_OVER_BOX_FADE_OUT_DELAY['key'] )->get_value();
$fade_out_delay = Settings::instance()->get_setting( TooltipTimingSettingsGroup::MOUSE_OVER_BOX_FADE_OUT_DELAY['key'] )->get_value();
$fade_out_duration = Settings::instance()->get_setting( TooltipTimingSettingsGroup::MOUSE_OVER_BOX_FADE_OUT_DURATION['key'] )->get_value();
// Fill in 'public/partials/tooltip.html'.
@ -2206,7 +2202,7 @@ class Parser {
array(
'post_id' => self::$post_id,
'container_id' => self::$reference_container_id,
'element' => Settings::instance()->get_setting( ReferenceContainerSettingsGroup::REFERENCE_CONTAINER_LABEL_ELEMENT ),
'element' => Settings::instance()->get_setting( ReferenceContainerSettingsGroup::REFERENCE_CONTAINER_LABEL_ELEMENT['key'] )->get_value(),
'name' => empty( $reference_container_label ) ? '&#x202F;' : $reference_container_label,
'button-style' => $collapse_default ? '' : 'display: none;',
'style' => $collapse_default ? 'display: none;' : '',