diff --git a/src/admin/layout/class-engine.php b/src/admin/layout/class-engine.php
index 8340987..df726dc 100644
--- a/src/admin/layout/class-engine.php
+++ b/src/admin/layout/class-engine.php
@@ -100,7 +100,12 @@ abstract class Engine {
* @since 1.5.0
*/
public function add_settings_sections(): void {
- $this->sections[Settings::instance()->settings_sections['general']->get_section_slug()] = Settings::instance()->settings_sections['general'];
+ $this->sections = array(
+ Settings::instance()->settings_sections['general']->get_section_slug() => Settings::instance()->settings_sections['general'],
+ Settings::instance()->settings_sections['referrers_and_tooltips']->get_section_slug() => Settings::instance()->settings_sections['referrers_and_tooltips'],
+ Settings::instance()->settings_sections['scope_and_priority']->get_section_slug() => Settings::instance()->settings_sections['scope_and_priority'],
+ Settings::instance()->settings_sections['custom_css']->get_section_slug() => Settings::instance()->settings_sections['custom_css'],
+ );
/*foreach ( $this->get_sections() as $section ) {
// Append tab to the tab-array.
@@ -130,104 +135,58 @@ abstract class Engine {
$active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : array_key_first( $this->sections );
$active_section = $this->sections[ $active_section_id ];
-
+
+ // Store settings.
+ $settings_updated = false;
+ if ( array_key_exists( 'save-settings', $_POST ) ) {
+ if ( 'save' === $_POST['save-settings'] ) {
+ unset( $_POST['save-settings'] );
+ unset( $_POST['submit'] );
+ $settings_updated = $this->save_settings();
+ }
+ }
+
?>
', __( 'Settings saved', 'footnotes' ) );
+ }
+
+ // show error/update messages
+ settings_errors( 'footnotes_messages' );
+ ?>
+
append_scripts();
- $active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : array_key_first( $this->sections );
- $active_section = $this->sections[ $active_section_id ];
-
- // Store settings.
- $settings_updated = false;
- if ( array_key_exists( 'save-settings', $_POST ) && 'save' === $_POST['save-settings'] ) {
- unset( $_POST['save-settings'] );
- unset( $_POST['submit'] );
- $settings_updated = $this->save_settings();
- }
-
- // Display all sections and highlight the active section.
- echo '';
- echo '
';
- // Iterate through all register sections.
- foreach ( $this->sections as $id => $description ) {
- echo sprintf(
- '%s',
- ( $id === $active_section['id'] ) ? ' nav-tab-active' : '',
- Init::MAIN_MENU_SLUG,
- $id,
- $description['title']
- );
- }
- echo '
';
-
- if ( $settings_updated ) {
- echo sprintf( '
%s
', __( 'Settings saved', 'footnotes' ) );
- }
-
- // Form to submit the active section.
- echo '
';
- echo '
';*/
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
/**
@@ -439,19 +398,85 @@ abstract class Engine {
$readonly ? 'readonly="readonly"' : ''
);
}
- public function new_add_text_box( array $args ): void {
+
+ /**************************************************************************
+ * NEW METHODS
+ **************************************************************************/
+
+ protected function add_input_text( array $args ): void {
extract( $args );
echo ( sprintf(
- '',
+ '',
$name,
$name,
$max_length ?? 999,
$style ?? '',
$value,
- isset($readonly) ? 'readonly="readonly"' : ''
+ isset($readonly) ? ' readonly="readonly"' : '',
+ $disabled ? ' disabled': ''
) );
}
+
+ protected function add_input_number( array $args ): void {
+ extract( $args );
+
+ echo ( sprintf(
+ '',
+ $name,
+ $name,
+ isset($max) ? ' max="'.$max.'"' : '',
+ isset($min) ? ' min="'.$min.'"' : '',
+ $value,
+ isset($readonly) ? ' readonly="readonly"' : '',
+ $disabled ? ' disabled': ''
+ ) );
+ }
+
+ protected function add_input_select( array $args ): void {
+ extract( $args );
+
+ if (!isset($options)) trigger_error("No options passed to 'select' element.", E_USER_ERROR);
+
+ $select_options = '';
+ // Loop through all array keys.
+ foreach ( $options as $option_value => $option_text ) {
+ $select_options .= sprintf(
+ '',
+ $option_value,
+ // Only check for equality, not identity, WRT backlink symbol arrows.
+ // phpcs:disable WordPress.PHP.StrictComparisons.LooseComparison
+ $option_value == $value ? ' selected' : '',
+ // phpcs:enable WordPress.PHP.StrictComparisons.LooseComparison
+ $option_text
+ );
+ }
+
+ echo ( sprintf(
+ '',
+ $name,
+ $name,
+ $disabled ? ' disabled': '',
+ $select_options
+ ) );
+ }
+
+ protected function add_input_checkbox( array $args ): void {
+ extract( $args );
+
+ echo sprintf(
+ '',
+ $name,
+ $name,
+ $value ? ' checked="checked"' : '',
+ $disabled ? ' disabled': ''
+ );
+ }
+
+
+ /**************************************************************************
+ * NEW METHODS END
+ **************************************************************************/
/**
* Constructs the HTML for a checkbox 'input' element.
@@ -507,31 +532,6 @@ abstract class Engine {
$select_options
);
}
- public function new_add_select_box( array $args ): void {
- $select_options = '';
- $setting_value = ( !isset( $options[$args['name']] ) )
- ? null : $options[$args['name']];
-
- // Loop through all array keys.
- foreach ( $args['options'] as $option_value => $caption ) {
- $select_options .= sprintf(
- '',
- $option_value,
- // Only check for equality, not identity, WRT backlink symbol arrows.
- // phpcs:disable WordPress.PHP.StrictComparisons.LooseComparison
- $option_value == $setting_value ? 'selected' : '',
- // phpcs:enable WordPress.PHP.StrictComparisons.LooseComparison
- $caption
- );
- }
-
- echo ( sprintf(
- '',
- $args['name'],
- $args['name'],
- $select_options
- ) );
- }
/**
* Constructs the HTML for a 'textarea' element.
@@ -648,6 +648,7 @@ abstract class Engine {
wp_enqueue_script( 'wp-color-picker' );
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
+
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
/**
* Save all plugin settings.
@@ -663,11 +664,12 @@ abstract class Engine {
$active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : array_key_first( $this->sections );
$active_section = $this->sections[ $active_section_id ];
- foreach ( array_keys( Settings::instance()->get_defaults( $active_section['container'] ) ) as $key ) {
- $new_settings[ $key ] = array_key_exists( $key, $_POST ) ? wp_unslash( $_POST[ $key ] ) : '';
+ foreach ( array_keys( $active_section->get_options() ) as $setting_key ) {
+ $new_settings[ $setting_key ] = array_key_exists( $setting_key, $_POST ) ? wp_unslash( $_POST[ $setting_key ] ) : '';
}
+
// Update settings.
- return Settings::instance()->save_options( $active_section['container'], $new_settings );
+ return Settings::instance()->save_options( $active_section->get_options_group_slug(), $new_settings );
}
}
diff --git a/src/admin/layout/class-settings.php b/src/admin/layout/class-settings-page.php
similarity index 54%
rename from src/admin/layout/class-settings.php
rename to src/admin/layout/class-settings-page.php
index 8b04d95..f659dd1 100644
--- a/src/admin/layout/class-settings.php
+++ b/src/admin/layout/class-settings-page.php
@@ -9,8 +9,8 @@
*
* @package footnotes\admin_layout
* @since 1.5.0
- * @since 2.8.0 Rename file from `subpage-main.php` to `class-footnotes-layout-settings.php`,
- * rename `dashboard/` sub-directory to `layout/`.
+ * @since 2.8.0 Rename file from `subpage-main.php` to `class-settings-page.php`,
+ * Rename `dashboard/` sub-directory to `layout/`.
*/
declare(strict_types=1);
@@ -19,8 +19,9 @@ namespace footnotes\admin\layout;
require_once plugin_dir_path( dirname( __FILE__, 2 ) ) . 'includes/class-settings.php';
-use footnotes\includes as Includes;
-use footnotes\general as General;
+use footnotes\includes\{Template, Settings, Parser, Config, Convert};
+use footnotes\general\General;
+use const footnotes\settings\general\ReferenceContainerSettingsGroup\{COMBINE_IDENTICAL_FOOTNOTES};
/**
* Provides the abstract class to be extended for page layouts.
@@ -32,10 +33,11 @@ require_once plugin_dir_path( __DIR__ ) . 'layout/class-engine.php';
*
* @package footnotes
* @since 1.5.0
+ * @since 2.8.0 Rename class from `Settings` to `SettingsPage`.
*
* @see Engine
*/
-class Settings extends Engine {
+class SettingsPage extends Engine {
/**
* Initialize the class and set its properties.
@@ -59,22 +61,26 @@ class Settings extends Engine {
return 10;
}
+ /**************************************************************************
+ * NEW METHODS
+ **************************************************************************/
+
public function add_settings_fields(): void {
$active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : array_key_first( $this->sections );
$active_section = $this->sections[ $active_section_id ];
switch ($active_section->get_section_slug()) {
case 'footnotes-settings':
- $this->add_general_settings_fields();
+ Settings::instance()->settings_sections['general']->add_settings_fields($this);
break;
case 'footnotes-customize':
- $this->add_customize_settings_fields();
+ Settings::instance()->settings_sections['referrers_and_tooltips']->add_settings_fields($this);
break;
case 'footnotes-expert':
- $this->add_expert_settings_fields();
+ Settings::instance()->settings_sections['scope_and_priority']->add_settings_fields($this);
break;
case 'footnotes-customcss':
- $this->add_customcss_settings_fields();
+ Settings::instance()->settings_sections['custom_css']->add_settings_fields($this);
break;
case 'footnotes-how-to':
print_r("Demo goes here");
@@ -145,79 +151,34 @@ class Settings extends Engine {
'yes' => __( 'Yes', 'footnotes' ),
'no' => __( 'No', 'footnotes' ),
);
-
- Includes\Settings::instance()->general_settings->add_settings_fields($this);
-
- /*
- add_settings_field(
- \footnotes\includes\Settings::REFERENCE_CONTAINER_LABEL_ELEMENT,
- __( 'Heading\'s HTML element', 'footnotes' ),
- array ($this, 'new_add_select_box'),
- 'footnotes',
- 'footnotes-settings',
- array(
- 'name' => \footnotes\includes\Settings::REFERENCE_CONTAINER_LABEL_ELEMENT,
- 'label_for' => \footnotes\includes\Settings::REFERENCE_CONTAINER_LABEL_ELEMENT,
- 'value' => get_option(\footnotes\includes\Settings::REFERENCE_CONTAINER_LABEL_ELEMENT),
- 'options' => $label_element_options
- )
- );
-
- add_settings_field(
- \footnotes\includes\Settings::REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER,
- __( 'Border under the heading', 'footnotes' ),
- array ($this, 'new_add_select_box'),
- 'footnotes',
- 'footnotes-settings',
- array(
- 'name' => \footnotes\includes\Settings::REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER,
- 'label_for' => \footnotes\includes\Settings::REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER,
- 'value' => get_option(\footnotes\includes\Settings::REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER),
- 'options' => $enabled_options
- )
- );
-
- add_settings_field(
- \footnotes\includes\Settings::REFERENCE_CONTAINER_COLLAPSE,
- __( 'Collapse by default', 'footnotes' ),
- array ($this, 'new_add_select_box'),
- 'footnotes',
- 'footnotes-settings',
- array(
- 'name' => \footnotes\includes\Settings::REFERENCE_CONTAINER_COLLAPSE,
- 'label_for' => \footnotes\includes\Settings::REFERENCE_CONTAINER_COLLAPSE,
- 'value' => get_option(\footnotes\includes\Settings::REFERENCE_CONTAINER_COLLAPSE),
- 'options' => $enabled_options
- )
- );
-
- add_settings_field(
- \footnotes\includes\Settings::FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE,
- __( 'Script mode', 'footnotes' ),
- array ($this, 'new_add_select_box'),
- 'footnotes',
- 'footnotes-settings',
- array(
- 'name' => \footnotes\includes\Settings::FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE,
- 'label_for' => \footnotes\includes\Settings::FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE,
- 'value' => get_option(\footnotes\includes\Settings::FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE),
- 'options' => $script_mode_options,
- 'description' => __( 'The plain JavaScript mode will enable hard links with configurable scroll offset', 'footnotes')
- )
- );*/
}
public function setting_field_callback( array $args ): void {
if (isset($args['type'])) {
+ echo $args['description'] . '';
+
switch($args['type']) {
case 'text':
- $this->new_add_text_box($args);
+ $this->add_input_text($args);
return;
- default: return;
+ case 'number':
+ $this->add_input_number($args);
+ return;
+ case 'select':
+ $this->add_input_select($args);
+ return;
+ case 'checkbox':
+ $this->add_input_checkbox($args);
+ return;
+ default: trigger_error("Unknown setting type.", E_USER_ERROR);
}
- } else return;
+ } else trigger_error("No setting type.", E_USER_ERROR);
}
+ /**************************************************************************
+ * NEW METHODS END
+ **************************************************************************/
+
/**
* Displays the AMP compatibility mode option.
*
@@ -226,17 +187,17 @@ class Settings extends Engine {
public function amp_compat(): void {
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'settings-amp' );
+ $template = new Template( Template::DASHBOARD, 'settings-amp' );
// Replace all placeholders.
$template->replace(
array(
// Translators: '%s' is the link text 'AMP-WP' linked to the plugin's front page on WordPress.org.
'description-1-amp' => sprintf( __( 'The official %s plugin is required when this option is enabled.', 'footnotes' ), 'AMP-WP' ),
- 'label-amp' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_AMP_COMPATIBILITY_ENABLE, __( 'Enable AMP compatibility mode:', 'footnotes' ) ),
- 'amp' => $this->add_checkbox( \footnotes\includes\Settings::FOOTNOTES_AMP_COMPATIBILITY_ENABLE ),
+ 'label-amp' => $this->add_label( Settings::FOOTNOTES_AMP_COMPATIBILITY_ENABLE, __( 'Enable AMP compatibility mode:', 'footnotes' ) ),
+ 'amp' => $this->add_checkbox( Settings::FOOTNOTES_AMP_COMPATIBILITY_ENABLE ),
'notice-amp' => __( 'This option enables hard links with configurable scroll offset in % viewport height.', 'footnotes' ),
// Translators: '%s' is the logogram of the 'Footnotes' plugin.
- 'description-2-amp' => sprintf( __( '%s is becoming AMP compatible when this box is checked. Styled tooltips are displayed with fade-in/fade-out effect if enabled, and the reference container expands also on clicking a referrer if it\'s collapsed by default.', 'footnotes' ), '' . \footnotes\includes\Config::PLUGIN_PUBLIC_NAME . '' ),
+ 'description-2-amp' => sprintf( __( '%s is becoming AMP compatible when this box is checked. Styled tooltips are displayed with fade-in/fade-out effect if enabled, and the reference container expands also on clicking a referrer if it\'s collapsed by default.', 'footnotes' ), '' . Config::PLUGIN_PUBLIC_NAME . '' ),
)
);
// Display template with replaced placeholders.
@@ -245,107 +206,6 @@ class Settings extends Engine {
// phpcs:enable
}
- /**
- * Displays all settings for the reference container.
- *
- * @since 1.5.0
- */
- public function reference_container(): void {
-
-
-
-
- // Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'settings-reference-container' );
- // Replace all placeholders.
- $template->replace(
- array(
- 'label-position' => $this->add_label( \footnotes\includes\Settings::REFERENCE_CONTAINER_POSITION, __( 'Default position:', 'footnotes' ) ),
- 'position' => $this->add_select_box( \footnotes\includes\Settings::REFERENCE_CONTAINER_POSITION, $positions_options ),
- // Translators: %s: at the end of the post.
- 'notice-position' => sprintf( __( 'To use the position or section shortcode, please set the position to: %s', 'footnotes' ), '' . __( 'at the end of the post', 'footnotes' ) . '' ),
-
- 'label-shortcode' => $this->add_label( \footnotes\includes\Settings::REFERENCE_CONTAINER_POSITION_SHORTCODE, __( 'Position shortcode:', 'footnotes' ) ),
- 'shortcode' => $this->add_text_box( \footnotes\includes\Settings::REFERENCE_CONTAINER_POSITION_SHORTCODE ),
- 'notice-shortcode' => __( 'If present in the content, any shortcode in this text box will be replaced with the reference container.', 'footnotes' ),
-
- 'label-section' => $this->add_label( \footnotes\includes\Settings::FOOTNOTE_SECTION_SHORTCODE, __( 'Footnote section shortcode:', 'footnotes' ) ),
- 'section' => $this->add_text_box( \footnotes\includes\Settings::FOOTNOTE_SECTION_SHORTCODE ),
- 'notice-section' => __( 'If present in the content, any shortcode in this text box will delimit a section terminated by a reference container.', 'footnotes' ),
-
- 'label-startpage' => $this->add_label( \footnotes\includes\Settings::REFERENCE_CONTAINER_START_PAGE_ENABLE, __( 'Display on start page too:', 'footnotes' ) ),
- 'startpage' => $this->add_select_box( \footnotes\includes\Settings::REFERENCE_CONTAINER_START_PAGE_ENABLE, $enabled_options ),
-
- 'label-margin-top' => $this->add_label( \footnotes\includes\Settings::REFERENCE_CONTAINER_TOP_MARGIN, __( 'Top margin:', 'footnotes' ) ),
- 'margin-top' => $this->add_num_box( \footnotes\includes\Settings::REFERENCE_CONTAINER_TOP_MARGIN, -500, 500 ),
- 'notice-margin-top' => __( 'pixels; may be negative', 'footnotes' ),
-
- 'label-margin-bottom' => $this->add_label( \footnotes\includes\Settings::REFERENCE_CONTAINER_BOTTOM_MARGIN, __( 'Bottom margin:', 'footnotes' ) ),
- 'margin-bottom' => $this->add_num_box( \footnotes\includes\Settings::REFERENCE_CONTAINER_BOTTOM_MARGIN, -500, 500 ),
- 'notice-margin-bottom' => __( 'pixels; may be negative', 'footnotes' ),
-
- 'label-page-layout' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_PAGE_LAYOUT_SUPPORT, __( 'Apply basic responsive page layout:', 'footnotes' ) ),
- 'page-layout' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_PAGE_LAYOUT_SUPPORT, $page_layout_options ),
- 'notice-page-layout' => __( 'Most themes don\'t need this fix.', 'footnotes' ),
-
- 'label-url-wrap' => $this->add_label( \footnotes\includes\Settings::FOOTNOTE_URL_WRAP_ENABLED, __( 'Allow URLs to line-wrap anywhere:', 'footnotes' ) ),
- 'url-wrap' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTE_URL_WRAP_ENABLED, $enabled_options ),
- 'notice-url-wrap' => __( 'Unicode-conformant browsers don\'t need this fix.', 'footnotes' ),
-
- 'label-symbol' => $this->add_label( \footnotes\includes\Settings::REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE, __( 'Display a backlink symbol:', 'footnotes' ) ),
- 'symbol-enable' => $this->add_select_box( \footnotes\includes\Settings::REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE, $enabled_options ),
- 'notice-symbol' => __( 'Please choose or input the symbol at the top of the next dashboard tab.', 'footnotes' ),
-
- 'label-switch' => $this->add_label( \footnotes\includes\Settings::REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH, __( 'Symbol appended, not prepended:', 'footnotes' ) ),
- 'switch' => $this->add_select_box( \footnotes\includes\Settings::REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH, $enabled_options ),
-
- 'label-3column' => $this->add_label( \footnotes\includes\Settings::REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE, __( 'Backlink symbol in an extra column:', 'footnotes' ) ),
- '3column' => $this->add_select_box( \footnotes\includes\Settings::REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE, $enabled_options ),
- 'notice-3column' => __( 'This legacy layout is available if identical footnotes are not combined.', 'footnotes' ),
-
- 'label-row-borders' => $this->add_label( \footnotes\includes\Settings::REFERENCE_CONTAINER_ROW_BORDERS_ENABLE, __( 'Borders around the table rows:', 'footnotes' ) ),
- 'row-borders' => $this->add_select_box( \footnotes\includes\Settings::REFERENCE_CONTAINER_ROW_BORDERS_ENABLE, $enabled_options ),
-
- 'label-separator' => $this->add_label( \footnotes\includes\Settings::BACKLINKS_SEPARATOR_ENABLED, __( 'Add a separator when enumerating backlinks:', 'footnotes' ) ),
- 'separator-enable' => $this->add_select_box( \footnotes\includes\Settings::BACKLINKS_SEPARATOR_ENABLED, $enabled_options ),
- 'separator-options' => $this->add_select_box( \footnotes\includes\Settings::BACKLINKS_SEPARATOR_OPTION, $separators_options ),
- 'separator-custom' => $this->add_text_box( \footnotes\includes\Settings::BACKLINKS_SEPARATOR_CUSTOM ),
- 'notice-separator' => __( 'Your input overrides the selection.', 'footnotes' ),
-
- 'label-terminator' => $this->add_label( \footnotes\includes\Settings::BACKLINKS_TERMINATOR_ENABLED, __( 'Add a terminal punctuation to backlinks:', 'footnotes' ) ),
- 'terminator-enable' => $this->add_select_box( \footnotes\includes\Settings::BACKLINKS_TERMINATOR_ENABLED, $enabled_options ),
- 'terminator-options' => $this->add_select_box( \footnotes\includes\Settings::BACKLINKS_TERMINATOR_OPTION, $terminators_options ),
- 'terminator-custom' => $this->add_text_box( \footnotes\includes\Settings::BACKLINKS_TERMINATOR_CUSTOM ),
- 'notice-terminator' => __( 'Your input overrides the selection.', 'footnotes' ),
-
- 'label-width' => $this->add_label( \footnotes\includes\Settings::BACKLINKS_COLUMN_WIDTH_ENABLED, __( 'Set backlinks column width:', 'footnotes' ) ),
- 'width-enable' => $this->add_select_box( \footnotes\includes\Settings::BACKLINKS_COLUMN_WIDTH_ENABLED, $enabled_options ),
- 'width-scalar' => $this->add_num_box( \footnotes\includes\Settings::BACKLINKS_COLUMN_WIDTH_SCALAR, 0, 500, true ),
- 'width-unit' => $this->add_select_box( \footnotes\includes\Settings::BACKLINKS_COLUMN_WIDTH_UNIT, $width_units_options ),
- 'notice-width' => __( 'Absolute width in pixels doesn\'t need to be accurate to the tenth, but relative width in rem or em may.', 'footnotes' ),
-
- 'label-max-width' => $this->add_label( \footnotes\includes\Settings::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED, __( 'Set backlinks column maximum width:', 'footnotes' ) ),
- 'max-width-enable' => $this->add_select_box( \footnotes\includes\Settings::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED, $enabled_options ),
- 'max-width-scalar' => $this->add_num_box( \footnotes\includes\Settings::BACKLINKS_COLUMN_MAX_WIDTH_SCALAR, 0, 500, true ),
- 'max-width-unit' => $this->add_select_box( \footnotes\includes\Settings::BACKLINKS_COLUMN_MAX_WIDTH_UNIT, $width_units_options ),
- 'notice-max-width' => __( 'Absolute width in pixels doesn\'t need to be accurate to the tenth, but relative width in rem or em may.', 'footnotes' ),
-
- 'label-line-break' => $this->add_label( \footnotes\includes\Settings::BACKLINKS_LINE_BREAKS_ENABLED, __( 'Stack backlinks when enumerating:', 'footnotes' ) ),
- 'line-break' => $this->add_select_box( \footnotes\includes\Settings::BACKLINKS_LINE_BREAKS_ENABLED, $enabled_options ),
- 'notice-line-break' => __( 'This option adds a line break before each added backlink when identical footnotes are combined.', 'footnotes' ),
-
- 'label-link' => $this->add_label( \footnotes\includes\Settings::LINK_ELEMENT_ENABLED, __( 'Use the link element for referrers and backlinks:', 'footnotes' ) ),
- 'link' => $this->add_select_box( \footnotes\includes\Settings::LINK_ELEMENT_ENABLED, $enabled_options ),
- 'notice-link' => __( 'The link element is needed to apply the theme\'s link color.', 'footnotes' ),
- 'description-link' => __( 'If the link element is not desired for styling, a simple span is used instead when the above is set to No.', 'footnotes' ),
- )
- );
- // Display template with replaced placeholders.
- // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
- echo $template->get_content();
- // phpcs:enable
- }
-
/**
* Displays all options for the footnotes start and end tag short codes.
*
@@ -387,31 +247,31 @@ class Settings extends Engine {
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'settings-start-end' );
+ $template = new Template( Template::DASHBOARD, 'settings-start-end' );
// Replace all placeholders.
$template->replace(
array(
'description-escapement' => __( 'When delimiters with pointy brackets are used, the diverging escapement schemas will be unified before footnotes are processed.', 'footnotes' ),
- 'label-short-code-start' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_START, __( 'Footnote start tag short code:', 'footnotes' ) ),
- 'short-code-start' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_START, $shortcode_start ),
- 'short-code-start-user' => $this->add_text_box( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_START_USER_DEFINED ),
+ 'label-short-code-start' => $this->add_label( Settings::FOOTNOTES_SHORT_CODE_START, __( 'Footnote start tag short code:', 'footnotes' ) ),
+ 'short-code-start' => $this->add_select_box( Settings::FOOTNOTES_SHORT_CODE_START, $shortcode_start ),
+ 'short-code-start-user' => $this->add_text_box( Settings::FOOTNOTES_SHORT_CODE_START_USER_DEFINED ),
- 'label-short-code-end' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_END, __( 'Footnote end tag short code:', 'footnotes' ) ),
- 'short-code-end' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_END, $shortcode_end ),
- 'short-code-end-user' => $this->add_text_box( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_END_USER_DEFINED ),
+ 'label-short-code-end' => $this->add_label( Settings::FOOTNOTES_SHORT_CODE_END, __( 'Footnote end tag short code:', 'footnotes' ) ),
+ 'short-code-end' => $this->add_select_box( Settings::FOOTNOTES_SHORT_CODE_END, $shortcode_end ),
+ 'short-code-end-user' => $this->add_text_box( Settings::FOOTNOTES_SHORT_CODE_END_USER_DEFINED ),
// For script showing/hiding user defined text boxes.
- 'short-code-start-id' => \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_START,
- 'short-code-end-id' => \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_END,
- 'short-code-start-user-id' => \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_START_USER_DEFINED,
- 'short-code-end-user-id' => \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_END_USER_DEFINED,
+ 'short-code-start-id' => Settings::FOOTNOTES_SHORT_CODE_START,
+ 'short-code-end-id' => Settings::FOOTNOTES_SHORT_CODE_END,
+ 'short-code-start-user-id' => Settings::FOOTNOTES_SHORT_CODE_START_USER_DEFINED,
+ 'short-code-end-user-id' => Settings::FOOTNOTES_SHORT_CODE_END_USER_DEFINED,
'description-parentheses' => __( '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.', 'footnotes' ),
// Option to enable syntax validation, label mirrored in task.php.
- 'label-syntax' => $this->add_label( \footnotes\includes\Settings::FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE, __( 'Check for balanced shortcodes:', 'footnotes' ) ),
- 'syntax' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE, $enable ),
+ 'label-syntax' => $this->add_label( Settings::FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE, __( 'Check for balanced shortcodes:', 'footnotes' ) ),
+ 'syntax' => $this->add_select_box( Settings::FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE, $enable ),
'notice-syntax' => __( 'In the presence of a lone start tag shortcode, a warning displays below the post title.', 'footnotes' ),
'description-syntax' => __( 'If the start tag short code is \'((\' or \'(((\', it will not be reported as unbalanced if the following string contains braces hinting that it is a script.', 'footnotes' ),
@@ -447,16 +307,16 @@ class Settings extends Engine {
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'settings-numbering' );
+ $template = new Template( Template::DASHBOARD, 'settings-numbering' );
// Replace all placeholders.
$template->replace(
array(
- 'label-counter-style' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_COUNTER_STYLE, __( 'Numbering style:', 'footnotes' ) ),
- 'counter-style' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_COUNTER_STYLE, $counter_style ),
+ 'label-counter-style' => $this->add_label( Settings::FOOTNOTES_COUNTER_STYLE, __( 'Numbering style:', 'footnotes' ) ),
+ 'counter-style' => $this->add_select_box( Settings::FOOTNOTES_COUNTER_STYLE, $counter_style ),
// Algorithmically combine identicals.
- 'label-identical' => $this->add_label( \footnotes\includes\Settings::COMBINE_IDENTICAL_FOOTNOTES, __( 'Combine identical footnotes:', 'footnotes' ) ),
- 'identical' => $this->add_select_box( \footnotes\includes\Settings::COMBINE_IDENTICAL_FOOTNOTES, $enable ),
+ 'label-identical' => $this->add_label( COMBINE_IDENTICAL_FOOTNOTES, __( 'Combine identical footnotes:', 'footnotes' ) ),
+ 'identical' => $this->add_select_box( COMBINE_IDENTICAL_FOOTNOTES, $enable ),
'notice-identical' => __( 'This option may require copy-pasting footnotes in multiple instances.', 'footnotes' ),
// Support for Ibid. notation added thanks to @meglio in .
'description-identical' => __( 'Even when footnotes are combined, footnote numbers keep incrementing. This avoids suboptimal referrer and backlink disambiguation using a secondary numbering system. The Ibid. notation and the op. cit. abbreviation followed by the current page number avoid repeating the footnote content. For changing sources, shortened citations may be used. Repeating full citations is also an opportunity to add details.', 'footnotes' ),
@@ -482,38 +342,38 @@ class Settings extends Engine {
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'settings-scrolling' );
+ $template = new Template( Template::DASHBOARD, 'settings-scrolling' );
// Replace all placeholders.
$template->replace(
array(
- 'label-scroll-css' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_CSS_SMOOTH_SCROLLING, __( 'CSS-based smooth scrolling:', 'footnotes' ) ),
- 'scroll-css' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_CSS_SMOOTH_SCROLLING, $enable ),
+ 'label-scroll-css' => $this->add_label( Settings::FOOTNOTES_CSS_SMOOTH_SCROLLING, __( 'CSS-based smooth scrolling:', 'footnotes' ) ),
+ 'scroll-css' => $this->add_select_box( Settings::FOOTNOTES_CSS_SMOOTH_SCROLLING, $enable ),
'notice-scroll-css' => __( 'May slightly disturb jQuery scrolling and is therefore disabled by default. Works in recent browsers.', 'footnotes' ),
- 'label-scroll-offset' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_SCROLL_OFFSET, __( 'Scroll offset:', 'footnotes' ) ),
- 'scroll-offset' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_SCROLL_OFFSET, 0, 100 ),
+ 'label-scroll-offset' => $this->add_label( Settings::FOOTNOTES_SCROLL_OFFSET, __( 'Scroll offset:', 'footnotes' ) ),
+ 'scroll-offset' => $this->add_num_box( Settings::FOOTNOTES_SCROLL_OFFSET, 0, 100 ),
'notice-scroll-offset' => __( 'per cent viewport height from the upper edge', 'footnotes' ),
- 'label-scroll-duration' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_SCROLL_DURATION, __( 'Scroll duration:', 'footnotes' ) ),
- 'scroll-duration' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_SCROLL_DURATION, 0, 20000 ),
+ 'label-scroll-duration' => $this->add_label( Settings::FOOTNOTES_SCROLL_DURATION, __( 'Scroll duration:', 'footnotes' ) ),
+ 'scroll-duration' => $this->add_num_box( Settings::FOOTNOTES_SCROLL_DURATION, 0, 20000 ),
'notice-scroll-duration' => __( 'milliseconds. If asymmetric scroll durations are enabled, this is the scroll-up duration.', 'footnotes' ),
// Enable scroll duration asymmetricity.
- 'label-scroll-asymmetricity' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY, __( 'Enable asymmetric scroll durations:', 'footnotes' ) ),
- 'scroll-asymmetricity' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY, $enable ),
+ 'label-scroll-asymmetricity' => $this->add_label( Settings::FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY, __( 'Enable asymmetric scroll durations:', 'footnotes' ) ),
+ 'scroll-asymmetricity' => $this->add_select_box( Settings::FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY, $enable ),
'notice-scroll-asymmetricity' => __( 'With this option enabled, scrolling up may take longer than down, or conversely.', 'footnotes' ),
- 'label-scroll-down-duration' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_SCROLL_DOWN_DURATION, __( 'Scroll-down duration:', 'footnotes' ) ),
- 'scroll-down-duration' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_SCROLL_DOWN_DURATION, 0, 20000 ),
+ 'label-scroll-down-duration' => $this->add_label( Settings::FOOTNOTES_SCROLL_DOWN_DURATION, __( 'Scroll-down duration:', 'footnotes' ) ),
+ 'scroll-down-duration' => $this->add_num_box( Settings::FOOTNOTES_SCROLL_DOWN_DURATION, 0, 20000 ),
'notice-scroll-down-duration' => __( 'milliseconds', 'footnotes' ),
- 'label-scroll-down-delay' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_SCROLL_DOWN_DELAY, __( 'Scroll-down delay:', 'footnotes' ) ),
- 'scroll-down-delay' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_SCROLL_DOWN_DELAY, 0, 20000 ),
+ 'label-scroll-down-delay' => $this->add_label( Settings::FOOTNOTES_SCROLL_DOWN_DELAY, __( 'Scroll-down delay:', 'footnotes' ) ),
+ 'scroll-down-delay' => $this->add_num_box( Settings::FOOTNOTES_SCROLL_DOWN_DELAY, 0, 20000 ),
'notice-scroll-down-delay' => __( 'milliseconds. Useful to see the effect on input elements when referrers without hard links are clicked in form labels.', 'footnotes' ),
- 'label-scroll-up-delay' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_SCROLL_UP_DELAY, __( 'Scroll-up delay:', 'footnotes' ) ),
- 'scroll-up-delay' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_SCROLL_UP_DELAY, 0, 20000 ),
+ 'label-scroll-up-delay' => $this->add_label( Settings::FOOTNOTES_SCROLL_UP_DELAY, __( 'Scroll-up delay:', 'footnotes' ) ),
+ 'scroll-up-delay' => $this->add_num_box( Settings::FOOTNOTES_SCROLL_UP_DELAY, 0, 20000 ),
'notice-scroll-up-delay' => __( 'milliseconds. Less useful than the scroll-down delay.', 'footnotes' ),
)
@@ -538,34 +398,34 @@ class Settings extends Engine {
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'settings-hard-links' );
+ $template = new Template( Template::DASHBOARD, 'settings-hard-links' );
// Replace all placeholders.
$template->replace(
array(
- 'label-hard-links' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_HARD_LINKS_ENABLE, __( 'Enable hard links:', 'footnotes' ) ),
- 'hard-links' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_HARD_LINKS_ENABLE, $enable ),
+ 'label-hard-links' => $this->add_label( Settings::FOOTNOTES_HARD_LINKS_ENABLE, __( 'Enable hard links:', 'footnotes' ) ),
+ 'hard-links' => $this->add_select_box( Settings::FOOTNOTES_HARD_LINKS_ENABLE, $enable ),
'notice-hard-links' => __( 'Hard links disable jQuery delays but have the same scroll offset, and allow to share footnotes (accessed if the list is not collapsed by default).', 'footnotes' ),
- 'label-footnote' => $this->add_label( \footnotes\includes\Settings::FOOTNOTE_FRAGMENT_ID_SLUG, __( 'Fragment identifier slug for footnotes:', 'footnotes' ) ),
- 'footnote' => $this->add_text_box( \footnotes\includes\Settings::FOOTNOTE_FRAGMENT_ID_SLUG ),
+ 'label-footnote' => $this->add_label( Settings::FOOTNOTE_FRAGMENT_ID_SLUG, __( 'Fragment identifier slug for footnotes:', 'footnotes' ) ),
+ 'footnote' => $this->add_text_box( Settings::FOOTNOTE_FRAGMENT_ID_SLUG ),
'notice-footnote' => __( 'This will show up in the address bar after clicking on a hard-linked footnote referrer.', 'footnotes' ),
- 'label-referrer' => $this->add_label( \footnotes\includes\Settings::REFERRER_FRAGMENT_ID_SLUG, __( 'Fragment identifier slug for footnote referrers:', 'footnotes' ) ),
- 'referrer' => $this->add_text_box( \footnotes\includes\Settings::REFERRER_FRAGMENT_ID_SLUG ),
+ 'label-referrer' => $this->add_label( Settings::REFERRER_FRAGMENT_ID_SLUG, __( 'Fragment identifier slug for footnote referrers:', 'footnotes' ) ),
+ 'referrer' => $this->add_text_box( Settings::REFERRER_FRAGMENT_ID_SLUG ),
'notice-referrer' => __( 'This will show up in the address bar after clicking on a hard-linked backlink.', 'footnotes' ),
- 'label-separator' => $this->add_label( \footnotes\includes\Settings::HARD_LINK_IDS_SEPARATOR, __( 'ID separator:', 'footnotes' ) ),
- 'separator' => $this->add_text_box( \footnotes\includes\Settings::HARD_LINK_IDS_SEPARATOR ),
+ 'label-separator' => $this->add_label( Settings::HARD_LINK_IDS_SEPARATOR, __( 'ID separator:', 'footnotes' ) ),
+ 'separator' => $this->add_text_box( Settings::HARD_LINK_IDS_SEPARATOR ),
'notice-separator' => __( 'May be empty or any string, for example _, - or +, to distinguish post number, container number and footnote number.', 'footnotes' ),
// Enable backlink tooltips.
- 'label-backlink-tooltips' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_BACKLINK_TOOLTIP_ENABLE, __( 'Enable backlink tooltips:', 'footnotes' ) ),
- 'backlink-tooltips' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_BACKLINK_TOOLTIP_ENABLE, $enable ),
+ 'label-backlink-tooltips' => $this->add_label( Settings::FOOTNOTES_BACKLINK_TOOLTIP_ENABLE, __( 'Enable backlink tooltips:', 'footnotes' ) ),
+ 'backlink-tooltips' => $this->add_select_box( Settings::FOOTNOTES_BACKLINK_TOOLTIP_ENABLE, $enable ),
'notice-backlink-tooltips' => __( 'Hard backlinks get ordinary tooltips hinting to use the backbutton instead to keep it usable.', 'footnotes' ),
- 'label-backlink-tooltip-text' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_BACKLINK_TOOLTIP_TEXT, __( 'Backlink tooltip text:', 'footnotes' ) ),
- 'backlink-tooltip-text' => $this->add_text_box( \footnotes\includes\Settings::FOOTNOTES_BACKLINK_TOOLTIP_TEXT ),
+ 'label-backlink-tooltip-text' => $this->add_label( Settings::FOOTNOTES_BACKLINK_TOOLTIP_TEXT, __( 'Backlink tooltip text:', 'footnotes' ) ),
+ 'backlink-tooltip-text' => $this->add_text_box( Settings::FOOTNOTES_BACKLINK_TOOLTIP_TEXT ),
'notice-backlink-tooltip-text' => __( 'Default text is the keyboard shortcut; may be a localized descriptive hint.', 'footnotes' ),
)
@@ -585,35 +445,35 @@ class Settings extends Engine {
// Options for the acknowledgment display in the footer.
$love = array(
// Logo only.
- 'text-3' => \footnotes\includes\Config::PLUGIN_PUBLIC_NAME,
+ 'text-3' => Config::PLUGIN_PUBLIC_NAME,
// Logo followed by heart symbol.
- 'text-4' => sprintf( '%s %s', \footnotes\includes\Config::PLUGIN_PUBLIC_NAME, \footnotes\includes\Config::LOVE_SYMBOL ),
+ 'text-4' => sprintf( '%s %s', Config::PLUGIN_PUBLIC_NAME, Config::LOVE_SYMBOL ),
// Logo preceded by heart symbol.
- 'text-5' => sprintf( '%s %s', \footnotes\includes\Config::LOVE_SYMBOL, \footnotes\includes\Config::PLUGIN_PUBLIC_NAME ),
+ 'text-5' => sprintf( '%s %s', Config::LOVE_SYMBOL, Config::PLUGIN_PUBLIC_NAME ),
// Translators: 2: heart symbol 1: footnotes logogram.
- 'text-1' => sprintf( __( 'I %2$s %1$s', 'footnotes' ), \footnotes\includes\Config::PLUGIN_PUBLIC_NAME, \footnotes\includes\Config::LOVE_SYMBOL ),
+ 'text-1' => sprintf( __( 'I %2$s %1$s', 'footnotes' ), Config::PLUGIN_PUBLIC_NAME, Config::LOVE_SYMBOL ),
// Translators: %s: Footnotes plugin logo.
- 'text-6' => sprintf( __( 'This website uses %s.', 'footnotes' ), \footnotes\includes\Config::PLUGIN_PUBLIC_NAME ),
+ 'text-6' => sprintf( __( 'This website uses %s.', 'footnotes' ), Config::PLUGIN_PUBLIC_NAME ),
// Translators: %s: Footnotes plugin logo.
- 'text-7' => sprintf( __( 'This website uses the %s plugin.', 'footnotes' ), \footnotes\includes\Config::PLUGIN_PUBLIC_NAME ),
+ 'text-7' => sprintf( __( 'This website uses the %s plugin.', 'footnotes' ), Config::PLUGIN_PUBLIC_NAME ),
// Translators: %s: Footnotes plugin logo.
- 'text-2' => sprintf( __( 'This website uses the awesome %s plugin.', 'footnotes' ), \footnotes\includes\Config::PLUGIN_PUBLIC_NAME ),
+ 'text-2' => sprintf( __( 'This website uses the awesome %s plugin.', 'footnotes' ), Config::PLUGIN_PUBLIC_NAME ),
'random' => __( 'randomly determined display of either mention', 'footnotes' ),
// Translators: 1: Plugin logo.2: heart symbol.
- 'no' => sprintf( __( 'no display of any "%1$s %2$s" mention in the footer', 'footnotes' ), \footnotes\includes\Config::PLUGIN_PUBLIC_NAME, \footnotes\includes\Config::LOVE_SYMBOL ),
+ 'no' => sprintf( __( 'no display of any "%1$s %2$s" mention in the footer', 'footnotes' ), Config::PLUGIN_PUBLIC_NAME, Config::LOVE_SYMBOL ),
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'settings-love' );
+ $template = new Template( Template::DASHBOARD, 'settings-love' );
// Replace all placeholders.
$template->replace(
array(
// Translators: %s: Footnotes plugin logo.
- 'label-love' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_LOVE, sprintf( __( 'Tell the world you\'re using %s:', 'footnotes' ), \footnotes\includes\Config::PLUGIN_PUBLIC_NAME ) ),
- 'love' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_LOVE, $love ),
+ 'label-love' => $this->add_label( Settings::FOOTNOTES_LOVE, sprintf( __( 'Tell the world you\'re using %s:', 'footnotes' ), Config::PLUGIN_PUBLIC_NAME ) ),
+ 'love' => $this->add_select_box( Settings::FOOTNOTES_LOVE, $love ),
// Translators: %s: Footnotes plugin logo.
- 'label-no-love' => $this->add_text( sprintf( __( 'Shortcode to inhibit the display of the %s mention on specific pages:', 'footnotes' ), \footnotes\includes\Config::PLUGIN_PUBLIC_NAME ) ),
- 'no-love' => $this->add_text( \footnotes\includes\Config::NO_LOVE_SLUG ),
+ 'label-no-love' => $this->add_text( sprintf( __( 'Shortcode to inhibit the display of the %s mention on specific pages:', 'footnotes' ), Config::PLUGIN_PUBLIC_NAME ) ),
+ 'no-love' => $this->add_text( Config::NO_LOVE_SLUG ),
)
);
// Display template with replaced placeholders.
@@ -636,16 +496,16 @@ class Settings extends Engine {
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'settings-excerpts' );
+ $template = new Template( Template::DASHBOARD, 'settings-excerpts' );
// Replace all placeholders.
$template->replace(
array(
- 'label-excerpts' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_IN_EXCERPT, __( 'Process footnotes in excerpts:', 'footnotes' ) ),
- 'excerpts' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_IN_EXCERPT, $excerpt_mode ),
+ 'label-excerpts' => $this->add_label( Settings::FOOTNOTES_IN_EXCERPT, __( 'Process footnotes in excerpts:', 'footnotes' ) ),
+ 'excerpts' => $this->add_select_box( Settings::FOOTNOTES_IN_EXCERPT, $excerpt_mode ),
'notice-excerpts' => __( 'If the_excerpt is enabled.', 'footnotes' ),
// Translators: %s: link text 'Advanced Excerpt' linked to the plugin\'s WordPress.org front page.
// Translators: %s: Footnotes plugin logo.
- 'description-excerpts' => sprintf( __( 'To not display footnotes in excerpts, the %s plugin generates excerpts on the basis of the posts to be able to remove the footnotes. Else, footnotes may be processed in manual excerpts OR processed based on the posts. — For this setting to be effective, the hook the_excerpt must be enabled under Scope and priority.', 'footnotes' ), '' . \footnotes\includes\Config::PLUGIN_PUBLIC_NAME . '' ),
+ 'description-excerpts' => sprintf( __( 'To not display footnotes in excerpts, the %s plugin generates excerpts on the basis of the posts to be able to remove the footnotes. Else, footnotes may be processed in manual excerpts OR processed based on the posts. — For this setting to be effective, the hook the_excerpt must be enabled under Scope and priority.', 'footnotes' ), '' . Config::PLUGIN_PUBLIC_NAME . '' ),
)
);
// Display template with replaced placeholders.
@@ -672,24 +532,24 @@ class Settings extends Engine {
'all' => __( 'All superscript elements', 'footnotes' ),
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'customize-superscript' );
+ $template = new Template( Template::DASHBOARD, 'customize-superscript' );
// Replace all placeholders.
$template->replace(
array(
- 'label-superscript' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS, __( 'Display footnote referrers in superscript:', 'footnotes' ) ),
- 'superscript' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS, $enabled ),
+ 'label-superscript' => $this->add_label( Settings::FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS, __( 'Display footnote referrers in superscript:', 'footnotes' ) ),
+ 'superscript' => $this->add_select_box( Settings::FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS, $enabled ),
- 'label-normalize' => $this->add_label( \footnotes\includes\Settings::FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, __( 'Normalize vertical alignment and font size:', 'footnotes' ) ),
- 'normalize' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, $normalize_superscript ),
+ 'label-normalize' => $this->add_label( Settings::FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, __( 'Normalize vertical alignment and font size:', 'footnotes' ) ),
+ 'normalize' => $this->add_select_box( Settings::FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT, $normalize_superscript ),
'notice-normalize' => __( 'Most themes don\'t need this fix.', 'footnotes' ),
- 'label-before' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_STYLING_BEFORE, __( 'At the start of the footnote referrers:', 'footnotes' ) ),
- 'before' => $this->add_text_box( \footnotes\includes\Settings::FOOTNOTES_STYLING_BEFORE ),
+ 'label-before' => $this->add_label( Settings::FOOTNOTES_STYLING_BEFORE, __( 'At the start of the footnote referrers:', 'footnotes' ) ),
+ 'before' => $this->add_text_box( Settings::FOOTNOTES_STYLING_BEFORE ),
- 'label-after' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_STYLING_AFTER, __( 'At the end of the footnote referrers:', 'footnotes' ) ),
- 'after' => $this->add_text_box( \footnotes\includes\Settings::FOOTNOTES_STYLING_AFTER ),
+ 'label-after' => $this->add_label( Settings::FOOTNOTES_STYLING_AFTER, __( 'At the end of the footnote referrers:', 'footnotes' ) ),
+ 'after' => $this->add_text_box( Settings::FOOTNOTES_STYLING_AFTER ),
- 'label-link' => $this->add_label( \footnotes\includes\Settings::LINK_ELEMENT_ENABLED, __( 'Use the link element for referrers and backlinks:', 'footnotes' ) ),
+ 'label-link' => $this->add_label( Settings::LINK_ELEMENT_ENABLED, __( 'Use the link element for referrers and backlinks:', 'footnotes' ) ),
'notice-link' => __( 'Please find this setting at the end of the reference container settings. The link element is needed to apply the theme\'s link color.', 'footnotes' ),
)
);
@@ -712,13 +572,13 @@ class Settings extends Engine {
'disconnect' => __( 'B. Labels with footnotes are disconnected from input element (discouraged)', 'footnotes' ),
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'configure-label-solution' );
+ $template = new Template( Template::DASHBOARD, 'configure-label-solution' );
// Replace all placeholders.
$template->replace(
array(
'description-1-selection' => __( 'Clicking a footnote referrer in an input element label toggles the input except when hard links are enabled. In jQuery mode, the recommended solution is to move footnotes and append them after the label (option A).', 'footnotes' ),
- 'label-selection' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_LABEL_ISSUE_SOLUTION, __( 'Solve input label issue:', 'footnotes' ) ),
- 'selection' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_LABEL_ISSUE_SOLUTION, $issue_solutions ),
+ 'label-selection' => $this->add_label( Settings::FOOTNOTES_LABEL_ISSUE_SOLUTION, __( 'Solve input label issue:', 'footnotes' ) ),
+ 'selection' => $this->add_select_box( Settings::FOOTNOTES_LABEL_ISSUE_SOLUTION, $issue_solutions ),
'description-2-selection' => __( 'Option B is discouraged because disconnecting a label from its input element may compromise accessibility. This option is a last resort in case footnotes must absolutely stay inside the label. (Using jQuery \'event.stopPropagation\' failed.)', 'footnotes' ),
)
);
@@ -741,20 +601,20 @@ class Settings extends Engine {
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'mouse-over-box-display' );
+ $template = new Template( Template::DASHBOARD, 'mouse-over-box-display' );
// Replace all placeholders.
$template->replace(
array(
- 'label-enable' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_ENABLED, __( 'Display tooltips:', 'footnotes' ) ),
- 'enable' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_ENABLED, $enabled ),
+ 'label-enable' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_ENABLED, __( 'Display tooltips:', 'footnotes' ) ),
+ 'enable' => $this->add_select_box( Settings::FOOTNOTES_MOUSE_OVER_BOX_ENABLED, $enabled ),
'notice-enable' => __( 'Formatted text boxes allowing hyperlinks, displayed on mouse-over or tap and hold.', 'footnotes' ),
- 'label-alternative' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, __( 'Display alternative tooltips:', 'footnotes' ) ),
- 'alternative' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, $enabled ),
+ 'label-alternative' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, __( 'Display alternative tooltips:', 'footnotes' ) ),
+ 'alternative' => $this->add_select_box( Settings::FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE, $enabled ),
'notice-alternative' => __( 'Intended to work around a configuration-related tooltip outage.', 'footnotes' ),
// Translators: %s: Footnotes plugin logo.
- 'description-alternative' => sprintf( __( 'These alternative tooltips work around a website related jQuery UI outage. They are low-script but use the AMP incompatible onmouseover and onmouseout arguments, along with CSS transitions for fade-in/out. The very small script is inserted after Footnotes\' internal stylesheet. When this option is enabled, %s does not load jQuery UI nor jQuery Tools.', 'footnotes' ), '' . \footnotes\includes\Config::PLUGIN_PUBLIC_NAME . '' ),
+ 'description-alternative' => sprintf( __( 'These alternative tooltips work around a website related jQuery UI outage. They are low-script but use the AMP incompatible onmouseover and onmouseout arguments, along with CSS transitions for fade-in/out. The very small script is inserted after Footnotes\' internal stylesheet. When this option is enabled, %s does not load jQuery UI nor jQuery Tools.', 'footnotes' ), '' . Config::PLUGIN_PUBLIC_NAME . '' ),
)
);
@@ -791,24 +651,24 @@ class Settings extends Engine {
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'mouse-over-box-position' );
+ $template = new Template( Template::DASHBOARD, 'mouse-over-box-position' );
// Replace all placeholders.
$template->replace(
array(
- 'label-position' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_POSITION, __( 'Position:', 'footnotes' ) ),
- 'position' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_POSITION, $position ),
- 'position-alternative' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION, $alternative_position ),
+ 'label-position' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_POSITION, __( 'Position:', 'footnotes' ) ),
+ 'position' => $this->add_select_box( Settings::FOOTNOTES_MOUSE_OVER_BOX_POSITION, $position ),
+ 'position-alternative' => $this->add_select_box( Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION, $alternative_position ),
'notice-position' => __( 'The second column of settings boxes is for the alternative tooltips.', 'footnotes' ),
- 'label-offset-x' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X, __( 'Horizontal offset:', 'footnotes' ) ),
- 'offset-x' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X, -500, 500 ),
- 'offset-x-alternative' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X, -500, 500 ),
+ 'label-offset-x' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X, __( 'Horizontal offset:', 'footnotes' ) ),
+ 'offset-x' => $this->add_num_box( Settings::FOOTNOTES_MOUSE_OVER_BOX_OFFSET_X, -500, 500 ),
+ 'offset-x-alternative' => $this->add_num_box( Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_X, -500, 500 ),
'notice-offset-x' => __( 'pixels; negative value for a leftwards offset; alternative tooltips: direction depends on position', 'footnotes' ),
- 'label-offset-y' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y, __( 'Vertical offset:', 'footnotes' ) ),
- 'offset-y' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y, -500, 500 ),
- 'offset-y-alternative' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_Y, -500, 500 ),
+ 'label-offset-y' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y, __( 'Vertical offset:', 'footnotes' ) ),
+ 'offset-y' => $this->add_num_box( Settings::FOOTNOTES_MOUSE_OVER_BOX_OFFSET_Y, -500, 500 ),
+ 'offset-y-alternative' => $this->add_num_box( Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_OFFSET_Y, -500, 500 ),
'notice-offset-y' => __( 'pixels; negative value for an upwards offset; alternative tooltips: direction depends on position', 'footnotes' ),
)
@@ -827,14 +687,14 @@ class Settings extends Engine {
public function mouseover_box_dimensions(): void {
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'mouse-over-box-dimensions' );
+ $template = new Template( Template::DASHBOARD, 'mouse-over-box-dimensions' );
// Replace all placeholders.
$template->replace(
array(
- 'label-max-width' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, __( 'Maximum width:', 'footnotes' ) ),
- 'max-width' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, 0, 1280 ),
- 'width' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH, 0, 1280 ),
+ 'label-max-width' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, __( 'Maximum width:', 'footnotes' ) ),
+ 'max-width' => $this->add_num_box( Settings::FOOTNOTES_MOUSE_OVER_BOX_MAX_WIDTH, 0, 1280 ),
+ 'width' => $this->add_num_box( Settings::FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH, 0, 1280 ),
'notice-max-width' => __( 'pixels; set to 0 for jQuery tooltips without max width; alternative tooltips are given the value in the second box as fixed width.', 'footnotes' ),
)
@@ -853,25 +713,25 @@ class Settings extends Engine {
public function mouseover_box_timing(): void {
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'mouse-over-box-timing' );
+ $template = new Template( Template::DASHBOARD, 'mouse-over-box-timing' );
// Replace all placeholders.
$template->replace(
array(
- 'label-fade-in-delay' => $this->add_label( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_IN_DELAY, __( 'Fade-in delay:', 'footnotes' ) ),
- 'fade-in-delay' => $this->add_num_box( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_IN_DELAY, 0, 20000 ),
+ 'label-fade-in-delay' => $this->add_label( Settings::MOUSE_OVER_BOX_FADE_IN_DELAY, __( 'Fade-in delay:', 'footnotes' ) ),
+ 'fade-in-delay' => $this->add_num_box( Settings::MOUSE_OVER_BOX_FADE_IN_DELAY, 0, 20000 ),
'notice-fade-in-delay' => __( 'milliseconds', 'footnotes' ),
- 'label-fade-in-duration' => $this->add_label( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_IN_DURATION, __( 'Fade-in duration:', 'footnotes' ) ),
- 'fade-in-duration' => $this->add_num_box( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_IN_DURATION, 0, 20000 ),
+ 'label-fade-in-duration' => $this->add_label( Settings::MOUSE_OVER_BOX_FADE_IN_DURATION, __( 'Fade-in duration:', 'footnotes' ) ),
+ 'fade-in-duration' => $this->add_num_box( Settings::MOUSE_OVER_BOX_FADE_IN_DURATION, 0, 20000 ),
'notice-fade-in-duration' => __( 'milliseconds', 'footnotes' ),
- 'label-fade-out-delay' => $this->add_label( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_OUT_DELAY, __( 'Fade-out delay:', 'footnotes' ) ),
- 'fade-out-delay' => $this->add_num_box( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_OUT_DELAY, 0, 20000 ),
+ 'label-fade-out-delay' => $this->add_label( Settings::MOUSE_OVER_BOX_FADE_OUT_DELAY, __( 'Fade-out delay:', 'footnotes' ) ),
+ 'fade-out-delay' => $this->add_num_box( Settings::MOUSE_OVER_BOX_FADE_OUT_DELAY, 0, 20000 ),
'notice-fade-out-delay' => __( 'milliseconds', 'footnotes' ),
- 'label-fade-out-duration' => $this->add_label( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_OUT_DURATION, __( 'Fade-out duration:', 'footnotes' ) ),
- 'fade-out-duration' => $this->add_num_box( \footnotes\includes\Settings::MOUSE_OVER_BOX_FADE_OUT_DURATION, 0, 20000 ),
+ 'label-fade-out-duration' => $this->add_label( Settings::MOUSE_OVER_BOX_FADE_OUT_DURATION, __( 'Fade-out duration:', 'footnotes' ) ),
+ 'fade-out-duration' => $this->add_num_box( Settings::MOUSE_OVER_BOX_FADE_OUT_DURATION, 0, 20000 ),
'notice-fade-out-duration' => __( 'milliseconds', 'footnotes' ),
)
@@ -895,21 +755,21 @@ class Settings extends Engine {
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'mouse-over-box-truncation' );
+ $template = new Template( Template::DASHBOARD, 'mouse-over-box-truncation' );
// Replace all placeholders.
$template->replace(
array(
- 'label-truncation' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, __( 'Truncate the note in the tooltip:', 'footnotes' ) ),
- 'truncation' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, $enabled ),
+ 'label-truncation' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, __( 'Truncate the note in the tooltip:', 'footnotes' ) ),
+ 'truncation' => $this->add_select_box( Settings::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, $enabled ),
- 'label-max-length' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH, __( 'Maximum number of characters in the tooltip:', 'footnotes' ) ),
- 'max-length' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH, 3, 10000 ),
+ 'label-max-length' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH, __( 'Maximum number of characters in the tooltip:', 'footnotes' ) ),
+ 'max-length' => $this->add_num_box( Settings::FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH, 3, 10000 ),
// The feature trims back until the last full word.
'notice-max-length' => __( 'No weird cuts.', 'footnotes' ),
- 'label-readon' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_TOOLTIP_READON_LABEL, __( '\'Read on\' button label:', 'footnotes' ) ),
- 'readon' => $this->add_text_box( \footnotes\includes\Settings::FOOTNOTES_TOOLTIP_READON_LABEL ),
+ 'label-readon' => $this->add_label( Settings::FOOTNOTES_TOOLTIP_READON_LABEL, __( '\'Read on\' button label:', 'footnotes' ) ),
+ 'readon' => $this->add_text_box( Settings::FOOTNOTES_TOOLTIP_READON_LABEL ),
)
);
@@ -932,23 +792,23 @@ class Settings extends Engine {
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'mouse-over-box-text' );
+ $template = new Template( Template::DASHBOARD, 'mouse-over-box-text' );
// Replace all placeholders.
$template->replace(
array(
'description-delimiter' => __( 'Tooltips can display another content than the footnote entry in the reference container. The trigger is a shortcode in the footnote text separating the tooltip text from the note. That is consistent with what WordPress does for excerpts.', 'footnotes' ),
- 'label-delimiter' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER, __( 'Delimiter for dedicated tooltip text:', 'footnotes' ) ),
- 'delimiter' => $this->add_text_box( \footnotes\includes\Settings::FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER ),
+ 'label-delimiter' => $this->add_label( Settings::FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER, __( 'Delimiter for dedicated tooltip text:', 'footnotes' ) ),
+ 'delimiter' => $this->add_text_box( Settings::FOOTNOTES_TOOLTIP_EXCERPT_DELIMITER ),
'notice-delimiter' => __( 'If the delimiter shortcode is present, the tooltip text will be the part before it.', 'footnotes' ),
- 'label-mirror' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE, __( 'Mirror the tooltip in the reference container:', 'footnotes' ) ),
- 'mirror' => $this->add_select_box( \footnotes\includes\Settings::FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE, $enabled ),
+ 'label-mirror' => $this->add_label( Settings::FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE, __( 'Mirror the tooltip in the reference container:', 'footnotes' ) ),
+ 'mirror' => $this->add_select_box( Settings::FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_ENABLE, $enabled ),
'notice-mirror' => __( 'Tooltips may be harder to use on mobiles. This option allows to read it in the reference container.', 'footnotes' ),
- 'label-separator' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR, __( 'Separator between tooltip text and footnote text:', 'footnotes' ) ),
- 'separator' => $this->add_text_box( \footnotes\includes\Settings::FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR ),
+ 'label-separator' => $this->add_label( Settings::FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR, __( 'Separator between tooltip text and footnote text:', 'footnotes' ) ),
+ 'separator' => $this->add_text_box( Settings::FOOTNOTES_TOOLTIP_EXCERPT_MIRROR_SEPARATOR ),
'notice-separator' => __( 'May be a simple space, or a line break <br />, or any string in your language.', 'footnotes' ),
'description-mirror' => __( 'Tooltips, even jQuery-driven, may be hard to consult on mobiles. This option allows to read the tooltip content in the reference container too.', 'footnotes' ),
@@ -984,42 +844,42 @@ class Settings extends Engine {
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'mouse-over-box-appearance' );
+ $template = new Template( Template::DASHBOARD, 'mouse-over-box-appearance' );
// Replace all placeholders.
$template->replace(
array(
- 'label-font-size' => $this->add_label( \footnotes\includes\Settings::MOUSE_OVER_BOX_FONT_SIZE_ENABLED, __( 'Set font size:', 'footnotes' ) ),
- 'font-size-enable' => $this->add_select_box( \footnotes\includes\Settings::MOUSE_OVER_BOX_FONT_SIZE_ENABLED, $enabled ),
- 'font-size-scalar' => $this->add_num_box( \footnotes\includes\Settings::MOUSE_OVER_BOX_FONT_SIZE_SCALAR, 0, 50, true ),
- 'font-size-unit' => $this->add_select_box( \footnotes\includes\Settings::MOUSE_OVER_BOX_FONT_SIZE_UNIT, $font_size_units ),
+ 'label-font-size' => $this->add_label( Settings::MOUSE_OVER_BOX_FONT_SIZE_ENABLED, __( 'Set font size:', 'footnotes' ) ),
+ 'font-size-enable' => $this->add_select_box( Settings::MOUSE_OVER_BOX_FONT_SIZE_ENABLED, $enabled ),
+ 'font-size-scalar' => $this->add_num_box( Settings::MOUSE_OVER_BOX_FONT_SIZE_SCALAR, 0, 50, true ),
+ 'font-size-unit' => $this->add_select_box( Settings::MOUSE_OVER_BOX_FONT_SIZE_UNIT, $font_size_units ),
'notice-font-size' => __( 'By default, the font size is set to equal the surrounding text.', 'footnotes' ),
- 'label-color' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_COLOR, __( 'Text color:', 'footnotes' ) ),
- 'color' => $this->add_color_selection( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_COLOR ),
+ 'label-color' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_COLOR, __( 'Text color:', 'footnotes' ) ),
+ 'color' => $this->add_color_selection( Settings::FOOTNOTES_MOUSE_OVER_BOX_COLOR ),
// Translators: %s: Clear or leave empty.
'notice-color' => sprintf( __( 'To use the current theme\'s default text color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ),
- 'label-background' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND, __( 'Background color:', 'footnotes' ) ),
- 'background' => $this->add_color_selection( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND ),
+ 'label-background' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND, __( 'Background color:', 'footnotes' ) ),
+ 'background' => $this->add_color_selection( Settings::FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND ),
// Translators: %s: Clear or leave empty.
'notice-background' => sprintf( __( 'To use the current theme\'s default background color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ),
- 'label-border-width' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, __( 'Border width:', 'footnotes' ) ),
- 'border-width' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, 0, 4, true ),
+ 'label-border-width' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, __( 'Border width:', 'footnotes' ) ),
+ 'border-width' => $this->add_num_box( Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH, 0, 4, true ),
'notice-border-width' => __( 'pixels; 0 for borderless', 'footnotes' ),
- 'label-border-color' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR, __( 'Border color:', 'footnotes' ) ),
- 'border-color' => $this->add_color_selection( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR ),
+ 'label-border-color' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR, __( 'Border color:', 'footnotes' ) ),
+ 'border-color' => $this->add_color_selection( Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR ),
// Translators: %s: Clear or leave empty.
'notice-border-color' => sprintf( __( 'To use the current theme\'s default border color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ),
- 'label-border-radius' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, __( 'Rounded corner radius:', 'footnotes' ) ),
- 'border-radius' => $this->add_num_box( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, 0, 500 ),
+ 'label-border-radius' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, __( 'Rounded corner radius:', 'footnotes' ) ),
+ 'border-radius' => $this->add_num_box( Settings::FOOTNOTES_MOUSE_OVER_BOX_BORDER_RADIUS, 0, 500 ),
'notice-border-radius' => __( 'pixels; 0 for sharp corners', 'footnotes' ),
- 'label-box-shadow-color' => $this->add_label( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR, __( 'Box shadow color:', 'footnotes' ) ),
- 'box-shadow-color' => $this->add_color_selection( \footnotes\includes\Settings::FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR ),
+ 'label-box-shadow-color' => $this->add_label( Settings::FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR, __( 'Box shadow color:', 'footnotes' ) ),
+ 'box-shadow-color' => $this->add_color_selection( Settings::FOOTNOTES_MOUSE_OVER_BOX_SHADOW_COLOR ),
// Translators: %s: Clear or leave empty.
'notice-box-shadow-color' => sprintf( __( 'To use the current theme\'s default box shadow color: %s', 'footnotes' ), __( 'Clear or leave empty.', 'footnotes' ) ),
@@ -1038,13 +898,13 @@ class Settings extends Engine {
*/
public function hyperlink_arrow(): void {
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'customize-hyperlink-arrow' );
+ $template = new Template( Template::DASHBOARD, 'customize-hyperlink-arrow' );
// Replace all placeholders.
$template->replace(
array(
- 'label-symbol' => $this->add_label( \footnotes\includes\Settings::HYPERLINK_ARROW, __( 'Select or input the backlink symbol:', 'footnotes' ) ),
- 'symbol-options' => $this->add_select_box( \footnotes\includes\Settings::HYPERLINK_ARROW, Includes\Convert::get_arrow() ),
- 'symbol-custom' => $this->add_text_box( \footnotes\includes\Settings::HYPERLINK_ARROW_USER_DEFINED ),
+ 'label-symbol' => $this->add_label( Settings::HYPERLINK_ARROW, __( 'Select or input the backlink symbol:', 'footnotes' ) ),
+ 'symbol-options' => $this->add_select_box( Settings::HYPERLINK_ARROW, Convert::get_arrow() ),
+ 'symbol-custom' => $this->add_text_box( Settings::HYPERLINK_ARROW_USER_DEFINED ),
'notice-symbol' => __( 'Your input overrides the selection.', 'footnotes' ),
'description-symbol' => __( 'This symbol is used in the reference container. But this setting pre-existed under this tab and cannot be moved to another one.', 'footnotes' ),
)
@@ -1062,12 +922,12 @@ class Settings extends Engine {
*/
public function custom_css() {
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'customize-css' );
+ $template = new Template( Template::DASHBOARD, 'customize-css' );
// Replace all placeholders.
$template->replace(
array(
- 'label-css' => $this->add_label( \footnotes\includes\Settings::CUSTOM_CSS, __( 'Your existing Custom CSS code:', 'footnotes' ) ),
- 'css' => $this->add_textarea( \footnotes\includes\Settings::CUSTOM_CSS ),
+ '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
@@ -1109,16 +969,16 @@ class Settings extends Engine {
);
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'customize-css-migration' );
+ $template = new Template( Template::DASHBOARD, 'customize-css-migration' );
// Replace all placeholders.
$template->replace(
array(
- 'label-css' => $this->add_label( \footnotes\includes\Settings::CUSTOM_CSS, __( 'Your existing Custom CSS code:', 'footnotes' ) ),
- 'css' => $this->add_textarea( \footnotes\includes\Settings::CUSTOM_CSS ),
+ '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( \footnotes\includes\Settings::CUSTOM_CSS_LEGACY_ENABLE, 'Show legacy Custom CSS settings containers:' ),
- 'show-legacy' => $this->add_select_box( \footnotes\includes\Settings::CUSTOM_CSS_LEGACY_ENABLE, $enabled ),
+ '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' ) ),
@@ -1138,11 +998,11 @@ class Settings extends Engine {
*/
public function custom_css_new(): void {
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'customize-css-new' );
+ $template = new Template( Template::DASHBOARD, 'customize-css-new' );
// Replace all placeholders.
$template->replace(
array(
- 'css' => $this->add_textarea( \footnotes\includes\Settings::CUSTOM_CSS_NEW ),
+ 'css' => $this->add_textarea( Settings::CUSTOM_CSS_NEW ),
'headline' => $this->add_text( __( 'Recommended CSS classes:', 'footnotes' ) ),
@@ -1168,7 +1028,7 @@ class Settings extends Engine {
*/
public function lookup_hooks(): void {
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'expert-lookup' );
+ $template = new Template( Template::DASHBOARD, 'expert-lookup' );
// Replace all placeholders.
$template->replace(
@@ -1185,29 +1045,29 @@ class Settings extends Engine {
'head-numbox' => __( 'Priority level', 'footnotes' ),
'head-url' => __( 'WordPress documentation', 'footnotes' ),
- 'label-the-title' => $this->add_label( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_TITLE, 'the_title' ),
- 'the-title' => $this->add_checkbox( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_TITLE ),
- 'priority-the-title' => $this->add_num_box( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL, -1, PHP_INT_MAX ),
+ '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( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_CONTENT, 'the_content' ),
- 'the-content' => $this->add_checkbox( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_CONTENT ),
- 'priority-the-content' => $this->add_num_box( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL, -1, PHP_INT_MAX ),
+ '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( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_EXCERPT, 'the_excerpt' ),
- 'the-excerpt' => $this->add_checkbox( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_EXCERPT ),
- 'priority-the-excerpt' => $this->add_num_box( \footnotes\includes\Settings::EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL, -1, PHP_INT_MAX ),
+ '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( \footnotes\includes\Settings::EXPERT_LOOKUP_WIDGET_TITLE, 'widget_title' ),
- 'widget-title' => $this->add_checkbox( \footnotes\includes\Settings::EXPERT_LOOKUP_WIDGET_TITLE ),
- 'priority-widget-title' => $this->add_num_box( \footnotes\includes\Settings::EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL, -1, PHP_INT_MAX ),
+ '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( \footnotes\includes\Settings::EXPERT_LOOKUP_WIDGET_TEXT, 'widget_text' ),
- 'widget-text' => $this->add_checkbox( \footnotes\includes\Settings::EXPERT_LOOKUP_WIDGET_TEXT ),
- 'priority-widget-text' => $this->add_num_box( \footnotes\includes\Settings::EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL, -1, PHP_INT_MAX ),
+ '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',
)
);
@@ -1224,16 +1084,16 @@ class Settings extends Engine {
* @todo Review in light of admin/public split.
*/
public function help(): void {
- $general = new General\General( $this->plugin_name, 'foo' );
+ $general = new General( $this->plugin_name, 'foo' );
// Load footnotes starting and end tag.
- $footnote_starting_tag = $this->load_setting( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_START );
- $footnote_ending_tag = $this->load_setting( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_END );
+ $footnote_starting_tag = $this->load_setting( Settings::FOOTNOTES_SHORT_CODE_START );
+ $footnote_ending_tag = $this->load_setting( Settings::FOOTNOTES_SHORT_CODE_END );
if ( 'userdefined' === $footnote_starting_tag['value'] || 'userdefined' === $footnote_ending_tag['value'] ) {
// Load user defined starting and end tag.
- $footnote_starting_tag = $this->load_setting( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_START_USER_DEFINED );
- $footnote_ending_tag = $this->load_setting( \footnotes\includes\Settings::FOOTNOTES_SHORT_CODE_END_USER_DEFINED );
+ $footnote_starting_tag = $this->load_setting( Settings::FOOTNOTES_SHORT_CODE_START_USER_DEFINED );
+ $footnote_ending_tag = $this->load_setting( Settings::FOOTNOTES_SHORT_CODE_END_USER_DEFINED );
}
$example = 'Hello' . $footnote_starting_tag['value'] .
'Sed ut perspiciatis, unde omnis iste natus error ' .
@@ -1251,7 +1111,7 @@ class Settings extends Engine {
$footnote_ending_tag['value'] . ' World!';
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'how-to-help' );
+ $template = new Template( Template::DASHBOARD, 'how-to-help' );
// Replace all placeholders.
$template->replace(
array(
@@ -1268,7 +1128,7 @@ class Settings extends Engine {
);
/*
- * Call {@see Includes\Parser::footnotes_output_head()} function to get
+ * Call {@see Parser::footnotes_output_head()} function to get
* the styling of the mouse-over box.
*
* The name of the callback function ought to be distinct from
@@ -1290,7 +1150,7 @@ class Settings extends Engine {
*/
public function donate(): void {
// Load template file.
- $template = new Includes\Template( \footnotes\includes\Template::DASHBOARD, 'how-to-donate' );
+ $template = new Template( Template::DASHBOARD, 'how-to-donate' );
// Replace all placeholders.
$template->replace(
array(
@@ -1318,7 +1178,7 @@ class Settings extends Engine {
* @return string
*/
protected function get_sub_page_title(): string {
- return \footnotes\includes\Config::PLUGIN_PUBLIC_NAME;
+ return Config::PLUGIN_PUBLIC_NAME;
}
/**
* Returns an array of all registered sections for the sub-page.
@@ -1364,7 +1224,7 @@ class Settings extends Engine {
$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', \footnotes\includes\Config::PLUGIN_HEADING_NAME . ' ' . \footnotes\includes\Config::LOVE_SYMBOL_HEADING, 'love' );
+ $meta_boxes[] = $this->add_meta_box( 'settings', 'love', Config::PLUGIN_HEADING_NAME . ' ' . Config::LOVE_SYMBOL_HEADING, 'love' );
$meta_boxes[] = $this->add_meta_box( 'customize', 'hyperlink-arrow', __( 'Backlink symbol', 'footnotes' ), 'hyperlink_arrow' );
$meta_boxes[] = $this->add_meta_box( 'customize', 'superscript', __( 'Referrers', 'footnotes' ), 'superscript' );
@@ -1376,13 +1236,13 @@ class Settings extends Engine {
$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 ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::CUSTOM_CSS_LEGACY_ENABLE ) ) ) {
+ 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 ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::CUSTOM_CSS_LEGACY_ENABLE ) ) ) {
+ 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' );
diff --git a/src/includes/class-settings.php b/src/includes/class-settings.php
index 5888b8a..b2f5597 100644
--- a/src/includes/class-settings.php
+++ b/src/includes/class-settings.php
@@ -38,44 +38,20 @@ use footnotes\includes\settings\{
*/
class Settings {
/**
- * Settings container key for the label of the reference container.
+ * Options for the custom width units (per cent is a ratio, not a unit).
*
- * @var string
+ * @var array
*
- * @since 1.5.0
+ * @since 2.8.0
*/
- const REFERENCE_CONTAINER_NAME = 'footnote_inputfield_references_label';
-
- /**
- * Settings container key to collapse the reference container by default.
- *
- * The string is converted to Boolean false if 'no', true if 'yes'.
- *
- * @var string
- *
- * @since 1.5.0
- * @todo Refactor to use sane typing.
- */
- const REFERENCE_CONTAINER_COLLAPSE = 'footnote_inputfield_collapse_references';
-
- /**
- * Settings container key for the position of the reference container.
- *
- * @var string
- *
- * @since 1.5.0
- */
- const REFERENCE_CONTAINER_POSITION = 'footnote_inputfield_reference_container_place';
-
- /**
- * Settings container key for combining identical footnotes.
- *
- * @var string
- *
- * @since 1.5.0
- */
- const COMBINE_IDENTICAL_FOOTNOTES = 'footnote_inputfield_combine_identical';
-
+ const WIDTH_UNIT_OPTIONS = array(
+ '%' => 'per cent',
+ 'px' => 'pixels',
+ 'rem' => 'root em',
+ 'em' => 'em',
+ 'vw' => 'viewport width',
+ );
+
/**
* Settings container key for the short code of the footnote's start.
*
@@ -288,21 +264,6 @@ class Settings {
*/
const EXPERT_LOOKUP_WIDGET_TEXT = 'footnote_inputfield_expert_lookup_widget_text';
- /**
- * 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.
- */
- const FOOTNOTES_EXPERT_MODE = 'footnote_inputfield_enable_expert_mode';
-
/**
* Settings container key for the mouse-over box to define the color.
*
@@ -445,33 +406,6 @@ class Settings {
*/
const FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS = 'footnotes_inputfield_referrer_superscript_tags';
- /**
- * Settings container key to enable the display of a backlink symbol.
- *
- * @var string
- *
- * @since 2.1.1
- */
- const REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE = 'footnotes_inputfield_reference_container_backlink_symbol_enable';
-
- /**
- * Settings container key to not display the reference container on the homepage.
- *
- * @var string
- *
- * @since 2.1.1
- */
- const REFERENCE_CONTAINER_START_PAGE_ENABLE = 'footnotes_inputfield_reference_container_start_page_enable';
-
- /**
- * Settings container key to enable the legacy layout of the reference container.
- *
- * @var string
- *
- * @since 2.1.1
- */
- const REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE = 'footnotes_inputfield_reference_container_3column_layout_enable';
-
/**
* Settings container key to get the backlink symbol switch side.
*
@@ -542,136 +476,6 @@ class Settings {
*/
const EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL = 'footnote_inputfield_expert_lookup_the_excerpt_priority_level';
- /**
- * Settings container key for the link element option.
- *
- * @var string
- *
- * @since 2.1.4
- */
- const LINK_ELEMENT_ENABLED = 'footnote_inputfield_link_element_enabled';
-
- /**
- * Settings container key to enable the presence of a backlink separator.
- *
- * Backlink separators and terminators are often not preferred, but a choice
- * should be provided along with the ability to customize.
- *
- * @var string
- *
- * @since 2.1.4
- */
- const BACKLINKS_SEPARATOR_ENABLED = 'footnotes_inputfield_backlinks_separator_enabled';
-
- /**
- * Settings container key for the backlink separator options.
- *
- * @var string
- *
- * @since 2.1.4
- */
- const BACKLINKS_SEPARATOR_OPTION = 'footnotes_inputfield_backlinks_separator_option';
-
- /**
- * Settings container key for a custom backlink separator.
- *
- * @var string
- *
- * @since 2.1.4
- */
- const BACKLINKS_SEPARATOR_CUSTOM = 'footnotes_inputfield_backlinks_separator_custom';
-
- /**
- * Settings container key to enable the presence of a backlink terminator.
- *
- * @var string
- *
- * @since 2.1.4
- */
- const BACKLINKS_TERMINATOR_ENABLED = 'footnotes_inputfield_backlinks_terminator_enabled';
-
- /**
- * Settings container key for the backlink terminator options.
- *
- * @var string
- *
- * @since 2.1.4
- */
- const BACKLINKS_TERMINATOR_OPTION = 'footnotes_inputfield_backlinks_terminator_option';
-
- /**
- * Settings container key for a custom backlink terminator.
- *
- * @var string
- *
- * @since 2.1.4
- */
- const BACKLINKS_TERMINATOR_CUSTOM = 'footnotes_inputfield_backlinks_terminator_custom';
-
- /**
- * Settings container key to enable the backlinks column width.
- *
- * @var string
- *
- * @since 2.1.4
- */
- const BACKLINKS_COLUMN_WIDTH_ENABLED = 'footnotes_inputfield_backlinks_column_width_enabled';
-
- /**
- * Settings container key for the backlinks column width scalar.
- *
- * @var int
- *
- * @since 2.1.4
- */
- const BACKLINKS_COLUMN_WIDTH_SCALAR = 'footnotes_inputfield_backlinks_column_width_scalar';
-
- /**
- * Settings container key for the backlinks column width unit.
- *
- * @var string
- *
- * @since 2.1.4
- */
- const BACKLINKS_COLUMN_WIDTH_UNIT = 'footnotes_inputfield_backlinks_column_width_unit';
-
- /**
- * Settings container key to enable a max width for the backlinks column.
- *
- * @var string
- *
- * @since 2.1.4
- */
- const BACKLINKS_COLUMN_MAX_WIDTH_ENABLED = 'footnotes_inputfield_backlinks_column_max_width_enabled';
-
- /**
- * Settings container key for the backlinks column max width scalar.
- *
- * @var int
- *
- * @since 2.1.4
- */
- const BACKLINKS_COLUMN_MAX_WIDTH_SCALAR = 'footnotes_inputfield_backlinks_column_max_width_scalar';
-
- /**
- * Settings container key for the backlinks column max width unit.
- *
- * @var string
- *
- * @since 2.1.4
- */
- const BACKLINKS_COLUMN_MAX_WIDTH_UNIT = 'footnotes_inputfield_backlinks_column_max_width_unit';
-
- /**
- * Settings container key to enable line breaks between backlinks.
- *
- * @var string
- *
- * @since 2.1.4
- * Whether a tag is inserted.
- */
- const BACKLINKS_LINE_BREAKS_ENABLED = 'footnotes_inputfield_backlinks_line_breaks_enabled';
-
/**
* Settings container key to enable setting the tooltip font size.
*
@@ -702,18 +506,7 @@ class Settings {
* @since 2.1.4
*/
const MOUSE_OVER_BOX_FONT_SIZE_UNIT = 'footnotes_inputfield_mouse_over_box_font_size_unit';
-
- /**
- * Settings container key for basic responsive page layout support options.
- *
- * Whether to concatenate an additional stylesheet.
- *
- * @var string
- *
- * @since 2.1.4
- */
- const FOOTNOTES_PAGE_LAYOUT_SUPPORT = 'footnotes_inputfield_page_layout_support';
-
+
/**
* Settings container key for scroll offset.
*
@@ -767,19 +560,7 @@ class Settings {
* @since 2.1.4
*/
const MOUSE_OVER_BOX_FADE_OUT_DURATION = 'footnotes_inputfield_mouse_over_box_fade_out_duration';
-
- /**
- * Settings container key for URL wrap option.
- *
- * This is made optional because it causes weird line breaks. Unicode-compliant
- * browsers break URLs at slashes.
- *
- * @var string
- *
- * @since 2.1.6
- */
- const FOOTNOTE_URL_WRAP_ENABLED = 'footnote_inputfield_url_wrap_enabled';
-
+
/**
* Settings container key for reference container position shortcode.
*
@@ -851,52 +632,6 @@ class Settings {
*/
const FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_WIDTH = 'footnotes_inputfield_alternative_mouse_over_box_width';
-
- /**
- * Settings container key for the reference container label element.
- *
- * @var string
- *
- * @since 2.2.5
- */
- const REFERENCE_CONTAINER_LABEL_ELEMENT = 'footnotes_inputfield_reference_container_label_element';
-
- /**
- * Settings container key to enable the reference container label bottom border.
- *
- * @var string
- *
- * @since 2.2.5
- */
- const REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER = 'footnotes_inputfield_reference_container_label_bottom_border';
-
- /**
- * Settings container key to enable reference container table row borders.
- *
- * @var string
- *
- * @since 2.2.10
- */
- const REFERENCE_CONTAINER_ROW_BORDERS_ENABLE = 'footnotes_inputfield_reference_container_row_borders_enable';
-
- /**
- * Settings container key for reference container top margin.
- *
- * @var int
- *
- * @since 2.3.0
- */
- const REFERENCE_CONTAINER_TOP_MARGIN = 'footnotes_inputfield_reference_container_top_margin';
-
- /**
- * Settings container key for reference container bottom margin.
- *
- * @var int
- *
- * @since 2.3.0
- */
- const REFERENCE_CONTAINER_BOTTOM_MARGIN = 'footnotes_inputfield_reference_container_bottom_margin';
-
/**
* Settings container key to enable hard links.
*
@@ -1021,15 +756,6 @@ class Settings {
*/
const FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT = 'footnotes_inputfield_referrers_normal_superscript';
- /**
- * Settings container key to select the script mode for the reference container.
- *
- * @var string
- *
- * @since 2.5.6
- */
- const FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE = 'footnotes_inputfield_reference_container_script_mode';
-
/**
* Settings container key to enable AMP compatibility mode.
*
@@ -1103,15 +829,6 @@ class Settings {
*/
const FOOTNOTES_CSS_SMOOTH_SCROLLING = 'footnotes_inputfield_css_smooth_scrolling';
- /**
- * Settings container key for the footnote section shortcode.
- *
- * @var string
- *
- * @since 2.7.0
- */
- const FOOTNOTE_SECTION_SHORTCODE = 'footnotes_inputfield_section_shortcode';
-
/**
* Contains all Settings option group slugs.
*
@@ -1120,9 +837,9 @@ class Settings {
* @var string[]
*
* @since 1.5.0
- * @since 2.8.0 Renamed from `container` to `option_groups`.
+ * @since 2.8.0 Renamed from `container` to `options_group_slugs`.
*/
- private array $option_groups = array(
+ private array $options_group_slugs = array(
'footnotes_storage',
'footnotes_storage_custom',
'footnotes_storage_expert',
@@ -1133,9 +850,10 @@ class Settings {
* Contains all default values for each Settings Container.
*
* @since 1.5.0
- * @todo Review. Why are the constants just initialised with these values?
- * At the very least, we should stop using ‘yes’ to mean `true` etc.
- * @todo Create `PreferencesSet` class.
+ * @since 2.8.0 Rename from `default` to `default_settings`.
+ * @deprecated
+ *
+ * @todo Move to new setting definitions.
*
* @var (string|int)[]
*/
@@ -1156,7 +874,7 @@ class Settings {
// Footnotes numbering.
self::FOOTNOTES_COUNTER_STYLE => 'arabic_plain',
- self::COMBINE_IDENTICAL_FOOTNOTES => 'yes',
+ //self::COMBINE_IDENTICAL_FOOTNOTES => 'yes',
// Scrolling behavior.
self::FOOTNOTES_CSS_SMOOTH_SCROLLING => 'no',
@@ -1173,67 +891,11 @@ class Settings {
self::FOOTNOTES_BACKLINK_TOOLTIP_ENABLE => 'yes',
self::FOOTNOTES_BACKLINK_TOOLTIP_TEXT => 'Alt+ ←',
- // Reference container.
- self::REFERENCE_CONTAINER_NAME => array(
- 'title' => 'Reference container title',
- 'setting_args' => array (
- 'type' => 'string',
- 'description' => 'The title of the reference container',
- 'default' => 'References',
- ),
- 'field_args' => array (
- 'name' => self::REFERENCE_CONTAINER_NAME,
- 'label_for' => self::REFERENCE_CONTAINER_NAME,
- 'type' => 'text',
- 'value' => 'References',
- 'description' => 'The title of the reference container',
- ),
- ),
- self::REFERENCE_CONTAINER_LABEL_ELEMENT => 'p',
- self::REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER => 'yes',
- self::REFERENCE_CONTAINER_COLLAPSE => 'no',
- self::FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE => 'jquery',
- self::REFERENCE_CONTAINER_POSITION => 'post_end',
- self::REFERENCE_CONTAINER_POSITION_SHORTCODE => '[[references]]',
- self::FOOTNOTE_SECTION_SHORTCODE => '[[/footnotesection]]',
- self::REFERENCE_CONTAINER_START_PAGE_ENABLE => 'yes',
- self::REFERENCE_CONTAINER_TOP_MARGIN => 24,
- self::REFERENCE_CONTAINER_BOTTOM_MARGIN => 0,
- self::FOOTNOTES_PAGE_LAYOUT_SUPPORT => 'none',
- self::FOOTNOTE_URL_WRAP_ENABLED => 'yes',
- self::REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE => 'yes',
- self::REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH => 'no',
- self::REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE => 'no',
- self::REFERENCE_CONTAINER_ROW_BORDERS_ENABLE => 'no',
-
- self::BACKLINKS_SEPARATOR_ENABLED => 'yes',
- self::BACKLINKS_SEPARATOR_OPTION => 'comma',
- self::BACKLINKS_SEPARATOR_CUSTOM => '',
-
- self::BACKLINKS_TERMINATOR_ENABLED => 'no',
- self::BACKLINKS_TERMINATOR_OPTION => 'full_stop',
- self::BACKLINKS_TERMINATOR_CUSTOM => '',
-
- self::BACKLINKS_COLUMN_WIDTH_ENABLED => 'no',
- self::BACKLINKS_COLUMN_WIDTH_SCALAR => '50',
- self::BACKLINKS_COLUMN_WIDTH_UNIT => 'px',
-
- self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED => 'no',
- self::BACKLINKS_COLUMN_MAX_WIDTH_SCALAR => '140',
- self::BACKLINKS_COLUMN_MAX_WIDTH_UNIT => 'px',
-
- self::BACKLINKS_LINE_BREAKS_ENABLED => 'no',
- self::LINK_ELEMENT_ENABLED => 'yes',
-
// Footnotes in excerpts.
self::FOOTNOTES_IN_EXCERPT => 'manual',
// Footnotes love.
self::FOOTNOTES_LOVE => 'no',
-
- // Deprecated.
- self::FOOTNOTES_EXPERT_MODE => 'yes',
-
),
// Referrers and tooltips.
@@ -1341,45 +1003,80 @@ class Settings {
* @var (string|int)[]
*
* @since 1.5.0
- * @todo Create `PreferencesSet` class.
+ * @deprecated
*/
public array $settings = array();
- public GeneralSettingsSection $general_settings;
+ /**
+ * Contains each section of settings.
+ *
+ * @var SettingsSection[]
+ *
+ * @since 2.8.0
+ */
+ public $settings_sections = array();
/**********************************************************************
* SETTINGS STORAGE.
**********************************************************************/
+
/**
* Stores a singleton reference of this class.
*
* @since 1.5.0
*/
- private static ?\footnotes\includes\Settings $instance = null;
+ private static ?Settings $instance = null;
/**
* Loads all Settings from each WordPress Settings Container.
*
* @since 1.5.0
*/
- private function __construct() {
- $this->load_options();
-
+ public function __construct() {
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-general-settings-section.php';
+ require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-referrers-and-tooltips-settings-section.php';
+ require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-scope-and-priority-settings-section.php';
+ require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-custom-css-settings-section.php';
- $this->general_settings = new GeneralSettingsSection('footnotes_storage', 'footnotes-settings', 'General Settings');
+ $this->settings_sections = array(
+ 'general' => new GeneralSettingsSection('footnotes_storage', 'footnotes-settings', 'General Settings'),
+ 'referrers_and_tooltips' => new ReferrersAndTooltipsSettingsSection('footnotes_storage_custom', 'footnotes-customize', 'Referrers and Tooltips'),
+ 'scope_and_priority' => new ScopeAndPrioritySettingsSection('footnotes_storage_expert', 'footnotes-expert', 'Scope and Priority'),
+ 'custom_css' => new CustomCSSSettingsSection('footnotes_storage_custom_css', 'footnotes-customcss', 'Custom CSS'),
+ );
+ }
+
+ /**
+ * Retrieve a setting by its key.
+ *
+ * @param string $setting_key The key of the setting to search for.
+ * @return ?Setting Either the setting object, or `null` if non exists.
+ *
+ * @since 2.8.0
+ *
+ * @todo This is an _O(n)_ linear search. Explore more scaleable alternatives.
+ */
+ public function get_setting( string $setting_key ): ?Setting {
+ foreach ($this->settings_sections as $settings_section) {
+ $setting = $settings_section->get_setting($setting_key);
+
+ if ($setting) return $setting;
+ }
+
+ return null;
}
/**
* Returns the name of a specified Settings Container.
*
- * @param int $index Settings Container index.
- * @return string Settings Container name.
+ * @param int $index Options group index.
+ * @return string Options group slug name.
*
* @since 1.5.0
+ * @since 2.8.0 Renamed from `get_container()` to `get_options_group_slug()`.
*/
- public function get_container( int $index ): string {
- return $this->option_groups[ $index ];
+ public function get_options_group_slug( int $index ): string {
+ return $this->options_group_slugs[ $index ];
}
/**
@@ -1389,26 +1086,43 @@ class Settings {
* @return (string|int)[] Settings Container default value(s).
*
* @since 1.5.6
+ * @deprecated
*/
public function get_defaults( int $index ): array {
- return $this->default[ $this->option_groups[ $index ] ];
+ return $this->default_settings[ $this->get_options_group_slug[ $index ] ];
}
/**
* Updates a whole Setting Container on save.
*
- * @param int $index Index of the Setting Container.
- * @param array $new_values The new Settings value(s).
+ * @param string $options_group_slug Options group slug to save.
+ * @param array $new_values The new Settings value(s).
*
* @since 1.5.0
+ * @since 2.8.0 Change first parameter type from `int` to `string`.
*/
- public function save_options( int $index, array $new_values ): bool {
- if ( update_option( $this->get_container( $index ), $new_values ) ) {
- $this->load_all();
+ public function save_options( string $options_group_slug, array $new_values ): bool {
+ if ( update_option( $options_group_slug, $new_values ) ) {
+ foreach ($this->settings_sections as $settings_section) {
+ if ($settings_section->get_options_group_slug() === $options_group_slug) {
+ $settings_section->load_options_group();
+ }
+ }
return true;
}
return false;
}
+
+
+ protected function load_options_group(): void {
+ $options_group = get_option($this->options_group_slug);
+
+ if (!! $options_group) {
+ foreach ($options_group as $setting_key => $setting_value) {
+ $this->set_setting_value($setting_key, $setting_value);
+ }
+ }
+ }
/**
* Returns the value of specified Setting.
@@ -1433,12 +1147,12 @@ class Settings {
*/
public function register_settings(): void {
// Register all settings.
- foreach ($this->default_settings as $option_groups_name => $option_groups_values) {
- foreach ($option_groups_values as $setting_name => $setting_value) {
+ 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( $option_groups_name, $setting_name );
+ register_setting( $options_groups_name, $setting_name );
} else {
- register_setting( $option_groups_name, $setting_name, $setting_value['setting_args']);
+ register_setting( $options_groups_name, $setting_name, $setting_value['setting_args']);
}
}
}
@@ -1468,37 +1182,38 @@ class Settings {
// Clear current settings.
$this->settings = array();
- foreach ($this->option_groups as $option_group) {
- $this->settings[$option_group] = $this->load_option( $option_group );
+ foreach ($this->options_group_slugs as $options_group_slug) {
+ $this->settings[$options_group_slug] = $this->load_option( $options_group_slug );
}
}
/**
* Loads all settings from a given option group.
*
- * @param string $option_group Option group slug.
+ * @param string $options_group Option group slug.
* @return (string|int)[] Loaded settings (or defaults if specified option group is empty).
*
* @since 1.5.0
* @since 2.8.0 Renamed from `load()` to `load_option()`.
*/
- private function load_option(string $option_group): array {
+ private function load_option(string $options_group_slug): array {
// Load all settings from option group.
- $options = get_option( $option_group );
+ $options_group = get_option( $options_group_slug );
// No settings found, set them to their default value.
- if ( empty( $options ) ) {
- return $this->default_settings[$option_group];
+ if ( empty( $options_group ) ) {
+ print_r("Options group ".$options_group_slug." is empty!");
+ return $this->default_settings[$options_group_slug];
}
- foreach ( $this->default_settings[$option_group] as $setting_name => $setting_value ) {
+ foreach ( $this->default_settings[$options_group_slug] as $setting_name => $setting_value ) {
// Available setting not found in the option group.
- if ( ! array_key_exists( $setting_name, $options ) ) {
+ if ( ! array_key_exists( $setting_name, $options_group ) ) {
// Define the setting with its default value.
- $options[ $setting_name ] = $setting_value;
+ $options_group[ $setting_name ] = $setting_value;
}
}
// Return settings loaded from option group.
- return $options;
+ return $options_group;
}
}
diff --git a/src/includes/settings/class-custom-css-settings-section.php b/src/includes/settings/class-custom-css-settings-section.php
new file mode 100644
index 0000000..c65d94c
--- /dev/null
+++ b/src/includes/settings/class-custom-css-settings-section.php
@@ -0,0 +1,62 @@
+options_group_slug = $options_group_slug;
+ $this->section_slug = $section_slug;
+ $this->title = $title;
+
+ $this->load_dependencies();
+
+ $this->add_settings_groups(get_option( $this->options_group_slug ));
+
+ $this->load_options_group();
+ }
+
+ protected function load_dependencies(): void {
+ require_once plugin_dir_path( __DIR__ ) . 'settings/class-setting.php';
+ // Require settings groups.
+ //require_once plugin_dir_path( __DIR__ ) . 'settings/custom-css/...';
+ }
+
+ protected function add_settings_groups(): void {
+ $this->settings_groups = array (
+ // Add settings groups.
+ //...::GROUP_ID => new ...($this->options_group_slug, $this->section_slug),
+ );
+ }
+}
diff --git a/src/includes/settings/class-general-settings-section.php b/src/includes/settings/class-general-settings-section.php
index cc7fc14..30e8de7 100644
--- a/src/includes/settings/class-general-settings-section.php
+++ b/src/includes/settings/class-general-settings-section.php
@@ -42,9 +42,12 @@ class GeneralSettingsSection extends SettingsSection {
$this->load_dependencies();
$this->add_settings_groups(get_option( $this->options_group_slug ));
+
+ $this->load_options_group();
}
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';
}
diff --git a/src/includes/settings/class-referrers-and-tooltips-settings-section.php b/src/includes/settings/class-referrers-and-tooltips-settings-section.php
new file mode 100644
index 0000000..0c56cd1
--- /dev/null
+++ b/src/includes/settings/class-referrers-and-tooltips-settings-section.php
@@ -0,0 +1,62 @@
+options_group_slug = $options_group_slug;
+ $this->section_slug = $section_slug;
+ $this->title = $title;
+
+ $this->load_dependencies();
+
+ $this->add_settings_groups(get_option( $this->options_group_slug ));
+
+ $this->load_options_group();
+ }
+
+ protected function load_dependencies(): void {
+ require_once plugin_dir_path( __DIR__ ) . 'settings/class-setting.php';
+ // Require settings groups.
+ //require_once plugin_dir_path( __DIR__ ) . 'settings/referrers-and-tooltips/...';
+ }
+
+ protected function add_settings_groups(): void {
+ $this->settings_groups = array (
+ // Add settings groups.
+ //...::GROUP_ID => new ...($this->options_group_slug, $this->section_slug),
+ );
+ }
+}
diff --git a/src/includes/settings/class-scope-and-priority-settings-section.php b/src/includes/settings/class-scope-and-priority-settings-section.php
new file mode 100644
index 0000000..3a007a2
--- /dev/null
+++ b/src/includes/settings/class-scope-and-priority-settings-section.php
@@ -0,0 +1,62 @@
+options_group_slug = $options_group_slug;
+ $this->section_slug = $section_slug;
+ $this->title = $title;
+
+ $this->load_dependencies();
+
+ $this->add_settings_groups(get_option( $this->options_group_slug ));
+
+ $this->load_options_group();
+ }
+
+ protected function load_dependencies(): void {
+ require_once plugin_dir_path( __DIR__ ) . 'settings/class-setting.php';
+ // Require settings groups.
+ //require_once plugin_dir_path( __DIR__ ) . 'settings/scope-and-priority/...';
+ }
+
+ protected function add_settings_groups(): void {
+ $this->settings_groups = array (
+ // Add settings groups.
+ //...::GROUP_ID => new ...($this->options_group_slug, $this->section_slug),
+ );
+ }
+}
diff --git a/src/includes/settings/class-setting.php b/src/includes/settings/class-setting.php
index 4d2f6a8..44f59b3 100644
--- a/src/includes/settings/class-setting.php
+++ b/src/includes/settings/class-setting.php
@@ -26,7 +26,7 @@ class Setting {
*
* @since 2.8.0
*/
- private $value;
+ protected $value;
public function __construct(
/**
@@ -106,8 +106,55 @@ class Setting {
*
* @since 2.8.0
*/
- private string $input_type
+ private string $input_type,
+
+ /**
+ * Setting input field options (for 'select' inputs).
+ *
+ * @var array
+ *
+ * @since 2.8.0
+ */
+ private ?array $input_options,
+
+ /**
+ * Setting input field max. value (for 'number' inputs).
+ *
+ * @var int
+ *
+ * @since 2.8.0
+ */
+ private ?int $input_max,
+
+ /**
+ * Setting input field min. value (for 'number' inputs).
+ *
+ * @var int
+ *
+ * @since 2.8.0
+ */
+ private ?int $input_min,
+
+ /**
+ * The setting for whether this setting is enabled or not.
+ *
+ * @var string
+ *
+ * @since 2.8.0
+ */
+ private ?string $enabled_by,
+
+ /**
+ * Any setting that overrides this setting.
+ *
+ * @var string
+ *
+ * @since 2.8.0
+ */
+ private ?string $overridden_by,
) {
+ $this->value = $this->default_value;
+
register_setting( $this->options_group_slug, $this->key, $this->get_setting_args());
}
@@ -123,12 +170,26 @@ class Setting {
return array (
'name' => $this->key,
'label_for' => $this->key,
- 'type' => $this->input_type,
'value' => $this->value,
'description' => $this->description,
+ 'type' => $this->input_type,
+ 'options' => $this->input_options,
+ 'max' => $this->input_max,
+ 'min' => $this->input_min,
+ 'disabled' => $this->is_disabled_or_overridden()
);
}
+ private function is_disabled_or_overridden(): ?bool {
+ if ($this->enabled_by) {
+ if (!Settings::instance()->get_setting($this->enabled_by)->value) return true;
+
+ if (!$this->overridden_by) return false;
+ else if (isset(Settings::instance()->get_setting($this->overridden_by)->value)) return true;
+ else return false;
+ } else return null;
+ }
+
public function get_options_group_slug(): string {
return $this->options_group_slug;
}
@@ -136,4 +197,19 @@ class Setting {
public function get_section_slug(): string {
return $this->section_slug;
}
+
+ /**
+ * @todo Add type safety.
+ */
+ public function get_value() {
+ return $this->value ?? $this->default_value ?? null;
+ }
+
+ /**
+ * @todo Add type safety.
+ */
+ public function set_value($value): bool {
+ $this->value = $value;
+ return true;
+ }
}
diff --git a/src/includes/settings/class-settings-group.php b/src/includes/settings/class-settings-group.php
index ceb7191..b9b531a 100644
--- a/src/includes/settings/class-settings-group.php
+++ b/src/includes/settings/class-settings-group.php
@@ -68,4 +68,33 @@ abstract class SettingsGroup {
protected abstract function add_settings(array $options): void;
protected abstract function add_settings_fields(Layout\Settings $component): void;
+
+ public function get_setting(string $setting_key): ?Setting {
+ foreach ($this->settings as $setting) {
+ if ($setting->key === $setting_key) return $setting;
+ }
+
+ return null;
+ }
+
+ public function get_options(): array {
+ $options = array();
+
+ foreach ($this->settings as $setting) {
+ $options[$setting->key] = $setting->get_value();
+ }
+
+ return $options;
+ }
+
+ public function get_setting_value(string $setting_key) {
+ $setting = $this->get_setting($setting_key);
+
+ if (! $setting) return null;
+ else return $setting->value ?? $setting->default_value;
+ }
+
+ public function set_setting_value(string $setting_key, $value): bool {
+ return $this->get_setting($setting_key)->set_value($value);
+ }
}
diff --git a/src/includes/settings/class-settings-section.php b/src/includes/settings/class-settings-section.php
index 5bc10cd..42807cf 100644
--- a/src/includes/settings/class-settings-section.php
+++ b/src/includes/settings/class-settings-section.php
@@ -57,10 +57,20 @@ abstract class SettingsSection {
protected abstract function load_dependencies(): void;
+ public function load_options_group(): void {
+ $options_group = get_option($this->options_group_slug);
+
+ if (!! $options_group) {
+ foreach ($options_group as $setting_key => $setting_value) {
+ $this->set_setting_value($setting_key, $setting_value);
+ }
+ }
+ }
+
public function add_settings_section(): void {
add_settings_section(
$this->section_slug,
- $this->title,
+ __( $this->title, 'footnotes'),
array($this, 'setting_section_callback'),
'footnotes'
);
@@ -93,4 +103,38 @@ abstract class SettingsSection {
public function get_settings_group(string $group_id) {
return $this->settings_groups[$group_id];
}
+
+ public function get_setting(string $setting_key): ?Setting {
+ foreach ($this->settings_groups as $settings_group) {
+ $setting = $settings_group->get_setting($setting_key);
+
+ if ($setting) return $setting;
+ }
+
+ return null;
+ }
+
+ public function get_options(): array {
+ $options = array();
+
+ foreach ($this->settings_groups as $settings_group) {
+ $options = array_merge($options, $settings_group->get_options());
+ }
+
+ return $options;
+ }
+
+ public function get_setting_value(string $setting_key) {
+ $setting = $this->get_setting($setting_key);
+
+ if (! $setting) return null;
+ else return $setting->value ?? $setting->default_value ?? trigger_error("No default value found for ".$setting_key.".", E_USER_ERROR);
+ }
+
+ public function set_setting_value(string $setting_key, $value): ?bool {
+ $setting = $this->get_setting($setting_key);
+
+ if (! $setting) return null;
+ else return $setting->set_value($value);
+ }
}
diff --git a/src/includes/settings/general/class-reference-container-settings-group.php b/src/includes/settings/general/class-reference-container-settings-group.php
index 89fbf74..9fa7de6 100644
--- a/src/includes/settings/general/class-reference-container-settings-group.php
+++ b/src/includes/settings/general/class-reference-container-settings-group.php
@@ -33,21 +33,704 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
const GROUP_ID = 'reference-container';
/**
- * Settings container key for the label of the reference container.
+ * Settings container key for combining identical footnotes.
*
- * @var string
+ * @var array
*
* @since 1.5.0
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const COMBINE_IDENTICAL_FOOTNOTES = array(
+ 'key' => 'footnote_inputfield_combine_identical',
+ 'name' => 'Combine Identical Footnotes',
+ 'description' => 'Whether to combine identical footnotes.',
+ 'default_value' => true,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key for the label of the reference container.
+ *
+ * @var array
+ *
+ * @since 1.5.0
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
*/
const REFERENCE_CONTAINER_NAME = array(
'key' => 'footnote_inputfield_references_label',
- 'name' => 'Reference Container Name',
- 'description' => 'The title of the reference container.',
- 'default_value' => 'Reference',
+ 'name' => 'Reference Container Title',
+ 'default_value' => 'References',
'type' => 'string',
'input_type' => 'text'
);
+ /**
+ * Settings container key for the reference container label element.
+ *
+ * @var array
+ *
+ * @since 2.2.5
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const REFERENCE_CONTAINER_LABEL_ELEMENT =array(
+ 'key' => 'footnote_inputfield_references_label',
+ 'name' => 'Heading\'s HTML Element',
+ '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',
+ )
+ );
+
+ /**
+ * Settings container key to enable the reference container label bottom border.
+ *
+ * @var array
+ *
+ * @since 2.2.5
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER = array(
+ 'key' => 'footnotes_inputfield_reference_container_label_bottom_border',
+ 'name' => 'Border Under the Heading',
+ 'default_value' => true,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key to collapse the reference container by default.
+ *
+ * @var bool
+ *
+ * @since 1.5.0
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const REFERENCE_CONTAINER_COLLAPSE = array(
+ 'key' => 'footnote_inputfield_collapse_references',
+ 'name' => 'Collapse by Default',
+ 'default_value' => false,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key to select the script mode for the reference container.
+ *
+ * @var array
+ *
+ * @since 2.5.6
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE = array(
+ 'key' => 'footnotes_inputfield_reference_container_script_mode',
+ 'name' => 'Script Mode',
+ 'description' => 'The plain JavaScript mode will enable hard links with configurable scroll offset.',
+ 'default_value' => 'jquery',
+ 'type' => 'string',
+ 'input_type' => 'select',
+ 'input_options' => array(
+ 'jquery' => 'jQuery',
+ 'js' => 'plain JavaScript'
+ )
+ );
+
+ /**
+ * Settings container key for the position of the reference container.
+ *
+ * @var array
+ *
+ * @since 1.5.0
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const REFERENCE_CONTAINER_POSITION = array(
+ 'key' => 'footnote_inputfield_reference_container_place',
+ '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',
+ 'default_value' => 'post_end',
+ 'type' => 'string',
+ 'input_type' => 'select',
+ 'input_options' => array(
+ 'post_end' => 'at the end of the post',
+ 'widget' => 'in the widget area',
+ 'footer' => 'in the footer',
+ )
+ );
+
+ /**
+ * Settings container key for reference container position shortcode.
+ *
+ * @var array
+ *
+ * @since 2.2.0
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const REFERENCE_CONTAINER_POSITION_SHORTCODE = array(
+ 'key' => 'footnote_inputfield_reference_container_position_shortcode',
+ 'name' => 'Position Shortcode',
+ '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'
+ );
+
+ /**
+ * Settings container key for the footnote section shortcode.
+ *
+ * @var array
+ *
+ * @since 2.7.0
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const FOOTNOTE_SECTION_SHORTCODE = array(
+ 'key' => 'footnotes_inputfield_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.',
+ 'default_value' => '[[/footnotesection]]',
+ 'type' => 'string',
+ 'input_type' => 'text'
+ );
+
+ /**
+ * Settings container key to not display the reference container on the homepage.
+ *
+ * @var array
+ *
+ * @since 2.1.1
+ * @since 2.8.0 Move from `Settings` to `Refere\nceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const REFERENCE_CONTAINER_START_PAGE_ENABLE = array(
+ 'key' => 'footnotes_inputfield_reference_container_start_page_enable',
+ 'name' => 'Display on Start Page Too',
+ 'default_value' => true,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key for reference container top margin.
+ *
+ * @var int
+ *
+ * @since 2.3.0
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `int` to `array`.
+ */
+ const REFERENCE_CONTAINER_TOP_MARGIN = array(
+ 'key' => 'footnotes_inputfield_reference_container_top_margin',
+ 'name' => 'Top Margin',
+ 'description' => 'pixels; may be negative',
+ 'default_value' => 24,
+ 'type' => 'integer',
+ 'input_type' => 'number',
+ 'input_max' => 500,
+ 'input_min' => -500
+ );
+
+ /**
+ * Settings container key for reference container bottom margin.
+ *
+ * @var int
+ *
+ * @since 2.3.0
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `int` to `array`.
+ */
+ const REFERENCE_CONTAINER_BOTTOM_MARGIN = array(
+ 'key' => 'footnotes_inputfield_reference_container_bottom_margin',
+ 'name' => 'Bottom Margin',
+ 'description' => 'pixels; may be negative',
+ 'default_value' => 0,
+ 'type' => 'integer',
+ 'input_type' => 'number',
+ 'input_max' => 500,
+ 'input_min' => -500
+ );
+
+ /**
+ * Settings container key for basic responsive page layout support options.
+ *
+ * Whether to concatenate an additional stylesheet.
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const FOOTNOTES_PAGE_LAYOUT_SUPPORT = array(
+ 'key' => 'footnotes_inputfield_page_layout_support',
+ 'name' => 'Apply Basic Responsive Page Layout',
+ 'description' => 'Most themes don\'t need this fix.',
+ 'default_value' => 'none',
+ 'type' => 'string',
+ 'input_type' => 'select',
+ 'input_options' => array(
+ 'none' => 'No',
+ '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',
+ )
+ );
+
+ /**
+ * Settings container key for URL wrap option.
+ *
+ * This is made optional because it causes weird line breaks. Unicode-compliant
+ * browsers break URLs at slashes.
+ *
+ * @var array
+ *
+ * @since 2.1.6
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const FOOTNOTE_URL_WRAP_ENABLED = array(
+ 'key' => 'footnote_inputfield_url_wrap_enabled',
+ 'name' => 'Allow URLs to Line-Wrap Anywhere',
+ 'description' => 'Unicode-conformant browsers don\'t need this fix.',
+ 'default_value' => true,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key to enable the display of a backlink symbol.
+ *
+ * @var array
+ *
+ * @since 2.1.1
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE = array(
+ 'key' => 'footnotes_inputfield_reference_container_backlink_symbol_enable',
+ 'name' => 'Display a Backlink Symbol',
+ 'description' => 'Please choose or input the symbol at the top of the next dashboard tab.',
+ 'default_value' => true,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key to get the backlink symbol switch side.
+ *
+ * @var array
+ *
+ * @since 2.1.1
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const REFERENCE_CONTAINER_BACKLINK_SYMBOL_SWITCH = array(
+ 'key' => 'footnotes_inputfield_reference_container_backlink_symbol_switch',
+ 'name' => 'Append Instead of Prepend Symbol',
+ 'default_value' => false,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key to enable the legacy layout of the reference container.
+ *
+ * @var array
+ *
+ * @since 2.1.1
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const REFERENCE_CONTAINER_3COLUMN_LAYOUT_ENABLE = array(
+ 'key' => 'footnotes_inputfield_reference_container_3column_layout_enable',
+ 'name' => 'Backlink Symbol in an Extra Column',
+ 'description' => 'This legacy layout is available if identical footnotes are not combined.',
+ 'default_value' => false,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key to enable reference container table row borders.
+ *
+ * @var array
+ *
+ * @since 2.2.10
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const REFERENCE_CONTAINER_ROW_BORDERS_ENABLE = array(
+ 'key' => 'footnotes_inputfield_reference_container_row_borders_enable',
+ 'name' => 'Borders Around the Table Rows',
+ 'default_value' => false,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key to enable the presence of a backlink separator.
+ *
+ * Backlink separators and terminators are often not preferred, but a choice
+ * should be provided along with the ability to customize.
+ *
+ * @see BACKLINKS_SEPARATOR_OPTION
+ * @see BACKLINKS_SEPARATOR_CUSTOM
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const BACKLINKS_SEPARATOR_ENABLED = array(
+ 'key' => 'footnotes_inputfield_backlinks_separator_enabled',
+ 'name' => 'Add a Separator When Enumerating Backlinks',
+ 'default_value' => true,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key for the backlink separator options.
+ *
+ * @see BACKLINKS_SEPARATOR_ENABLED
+ * @see BACKLINKS_SEPARATOR_CUSTOM
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const BACKLINKS_SEPARATOR_OPTION = array(
+ 'key' => 'footnotes_inputfield_backlinks_separator_option',
+ 'name' => 'Backlink Separator Symbol',
+ 'default_value' => 'comma',
+ 'type' => 'string',
+ 'input_type' => 'select',
+ 'input_options' => array(
+ // Unicode character names are conventionally uppercase.
+ 'comma' => ',',
+ 'semicolon' => ';',
+ 'en_dash' => '–',
+ ),
+ 'enabled_by' => self::BACKLINKS_SEPARATOR_ENABLED,
+ 'overridden_by' => self::BACKLINKS_SEPARATOR_CUSTOM
+ );
+
+ /**
+ * Settings container key for a custom backlink separator.
+ *
+ * @see BACKLINKS_SEPARATOR_ENABLED
+ * @see BACKLINKS_SEPARATOR_OPTION
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const BACKLINKS_SEPARATOR_CUSTOM = array(
+ '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
+ );
+
+ /**
+ * Settings container key to enable the presence of a backlink terminator.
+ *
+ * @see BACKLINKS_TERMINATOR_OPTION
+ * @see BACKLINKS_TERMINATOR_CUSTOM
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const BACKLINKS_TERMINATOR_ENABLED = array(
+ 'key' => 'footnotes_inputfield_backlinks_terminator_enabled',
+ 'name' => 'Add a Terminal Punctuation to Backlinks',
+ 'default_value' => false,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key for the backlink terminator options.
+ *
+ * @see BACKLINKS_TERMINATOR_ENABLED
+ * @see BACKLINKS_TERMINATOR_CUSTOM
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const BACKLINKS_TERMINATOR_OPTION = array(
+ 'key' => 'footnotes_inputfield_backlinks_terminator_option',
+ 'name' => 'Backlink Terminator Symbol',
+ 'default_value' => 'period',
+ 'type' => 'string',
+ 'input_type' => 'select',
+ 'input_options' => array(
+ 'period' => '.',
+ // Unicode 1.0 name of RIGHT PARENTHESIS (represented as a left parenthesis in right-to-left scripts).
+ 'parenthesis' => ')',
+ 'colon' => ':',
+ ),
+ 'enabled_by' => self::BACKLINKS_TERMINATOR_ENABLED,
+ 'overridden_by' => self::BACKLINKS_TERMINATOR_CUSTOM
+ );
+
+ /**
+ * Settings container key for a custom backlink terminator.
+ *
+ * @see BACKLINKS_TERMINATOR_ENABLED
+ * @see BACKLINKS_TERMINATOR_OPTION
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const BACKLINKS_TERMINATOR_CUSTOM = array(
+ '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
+ );
+
+ /**
+ * Settings container key to enable the backlinks column width.
+ *
+ * @see BACKLINKS_COLUMN_WIDTH_SCALAR
+ * @see BACKLINKS_COLUMN_WIDTH_UNIT
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const BACKLINKS_COLUMN_WIDTH_ENABLED = array(
+ 'key' => 'footnotes_inputfield_backlinks_column_width_enabled',
+ 'name' => 'Set Backlinks Column Width',
+ 'default_value' => false,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key for the backlinks column width scalar.
+ *
+ * @see BACKLINKS_COLUMN_WIDTH_ENABLED
+ * @see BACKLINKS_COLUMN_WIDTH_UNIT
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const BACKLINKS_COLUMN_WIDTH_SCALAR = array(
+ 'key' => 'footnotes_inputfield_backlinks_column_width_scalar',
+ 'name' => 'Backlinks Column Width',
+ 'default_value' => 50,
+ 'type' => 'number',
+ 'input_type' => 'number',
+ 'input_max' => 500,
+ 'input_min' => 0,
+ 'enabled_by' => self::BACKLINKS_COLUMN_WIDTH_ENABLED
+ );
+
+ /**
+ * Settings container key for the backlinks column width unit.
+ *
+ * @see BACKLINKS_COLUMN_WIDTH_ENABLED
+ * @see BACKLINKS_COLUMN_WIDTH_SCALAR
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const BACKLINKS_COLUMN_WIDTH_UNIT = array(
+ 'key' => 'footnotes_inputfield_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.',
+ 'default_value' => 'px',
+ 'type' => 'string',
+ 'input_type' => 'select',
+ 'input_options' => Settings::WIDTH_UNIT_OPTIONS,
+ 'enabled_by' => self::BACKLINKS_COLUMN_WIDTH_ENABLED
+ );
+
+ /**
+ * Settings container key to enable a max width for the backlinks column.
+ *
+ * @see BACKLINKS_COLUMN_MAX_WIDTH_SCALAR
+ * @see BACKLINKS_COLUMN_MAX_WIDTH_UNIT
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const BACKLINKS_COLUMN_MAX_WIDTH_ENABLED = array(
+ 'key' => 'footnotes_inputfield_backlinks_column_max_width_enabled',
+ 'name' => 'Set Backlinks Column Max. Width',
+ 'default_value' => false,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key for the backlinks column max width scalar.
+ *
+ * @see BACKLINKS_COLUMN_MAX_WIDTH_ENABLED
+ * @see BACKLINKS_COLUMN_MAX_WIDTH_UNIT
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const BACKLINKS_COLUMN_MAX_WIDTH_SCALAR = array(
+ 'key' => 'footnotes_inputfield_backlinks_column_max_width_scalar',
+ 'name' => 'Backlinks Column Width',
+ 'default_value' => 140,
+ 'type' => 'number',
+ 'input_type' => 'number',
+ 'input_max' => 500,
+ 'input_min' => 0,
+ 'enabled_by' => self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED
+ );
+
+ /**
+ * Settings container key for the backlinks column max width unit.
+ *
+ * @see BACKLINKS_COLUMN_MAX_WIDTH_ENABLED
+ * @see BACKLINKS_COLUMN_MAX_WIDTH_SCALAR
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ */
+ const BACKLINKS_COLUMN_MAX_WIDTH_UNIT = array(
+ 'key' => 'footnotes_inputfield_backlinks_column_max_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.',
+ 'default_value' => 'px',
+ 'type' => 'string',
+ 'input_type' => 'select',
+ 'input_options' => Settings::WIDTH_UNIT_OPTIONS,
+ 'enabled_by' => self::BACKLINKS_COLUMN_MAX_WIDTH_ENABLED
+ );
+
+ /**
+ * Settings container key to enable line breaks between backlinks.
+ *
+ * Whether a ` ` HTML element is inserted.
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const BACKLINKS_LINE_BREAKS_ENABLED = array(
+ 'key' => 'footnotes_inputfield_backlinks_line_breaks_enabled',
+ 'name' => 'Stack Backlinks When Enumerating',
+ 'description' => 'This option adds a line break before each added backlink when identical footnotes are combined.',
+ 'default_value' => false,
+ 'type' => 'boolean',
+ 'input_type' => 'checkbox'
+ );
+
+ /**
+ * Settings container key for the link element option.
+ *
+ * @var array
+ *
+ * @since 2.1.4
+ * @since 2.8.0 Move from `Settings` to `ReferenceContainerSettingsGroup`.
+ * Convert from `string` to `array`.
+ * Convert setting data type from `string` to `boolean`.
+ */
+ const LINK_ELEMENT_ENABLED = array(
+ 'key' => 'footnote_inputfield_link_element_enabled',
+ '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.',
+ 'default_value' => true,
+ 'type' => 'boolean',
+ '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'
+ );
+
/**
* The general settings.
*
@@ -87,7 +770,40 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
protected function add_settings(array $options): void {
$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::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_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::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_SHORTCODE['key'] => $this->add_setting(self::REFERENCE_CONTAINER_POSITION_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_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::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::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_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::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_CUSTOM['key'] => $this->add_setting(self::BACKLINKS_SEPARATOR_CUSTOM),
+ 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_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_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_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_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)
);
}
@@ -100,10 +816,15 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
$this->section_slug,
$key,
$name,
- $description,
+ $description ?? null,
$default_value,
$type,
- $input_type
+ $input_type,
+ $input_options ?? null,
+ $input_max ?? null,
+ $input_min ?? null,
+ $enabled_by['key'] ?? null,
+ $overridden_by['key'] ?? null
);
}
diff --git a/src/includes/settings/general/reference-container/class-reference-container-name-setting.php b/src/includes/settings/general/reference-container/class-reference-container-name-setting.php
deleted file mode 100644
index 8794351..0000000
--- a/src/includes/settings/general/reference-container/class-reference-container-name-setting.php
+++ /dev/null
@@ -1,106 +0,0 @@
-options_group_slug, self::NAME, $this->get_setting_args());
- }
-}
diff --git a/src/public/class-general.php b/src/public/class-general.php
index d836c78..b67db93 100644
--- a/src/public/class-general.php
+++ b/src/public/class-general.php
@@ -9,6 +9,8 @@
declare(strict_types=1);
namespace footnotes\general;
+
+require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/settings/general/class-reference-container-settings-group.php';
use footnotes\includes\{Footnotes, Convert, Settings};
|