chore: lint code
This commit is contained in:
parent
8b2f98184d
commit
8c639a97b5
36 changed files with 715 additions and 640 deletions
|
@ -106,20 +106,8 @@ abstract class Engine {
|
|||
$this->settings->settings_sections['scope_and_priority']->get_section_slug() => $this->settings->settings_sections['scope_and_priority'],
|
||||
$this->settings->settings_sections['custom_css']->get_section_slug() => $this->settings->settings_sections['custom_css'],
|
||||
);
|
||||
|
||||
/*foreach ( $this->get_sections() as $section ) {
|
||||
// Append tab to the tab-array.
|
||||
$this->sections[ $section['id'] ] = $section;
|
||||
add_settings_section(
|
||||
$section['id'],
|
||||
'',
|
||||
fn() => $this->description(),
|
||||
'footnotes'
|
||||
);
|
||||
$this->add_settings_fields();
|
||||
//$this->register_meta_boxes( $section['id'] );
|
||||
}*/
|
||||
}
|
||||
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
|
||||
/**
|
||||
* Displays the content of specific sub-page.
|
||||
|
@ -129,14 +117,14 @@ abstract class Engine {
|
|||
*/
|
||||
public function display_content(): void {
|
||||
// check user capabilities
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : array_key_first( $this->sections );
|
||||
$active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : array_key_first( $this->sections );
|
||||
$active_section = $this->sections[ $active_section_id ];
|
||||
|
||||
// Store settings.
|
||||
// Store settings.
|
||||
$settings_updated = false;
|
||||
if ( array_key_exists( 'save-settings', $_POST ) ) {
|
||||
if ( 'save' === $_POST['save-settings'] ) {
|
||||
|
@ -146,49 +134,50 @@ abstract class Engine {
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
||||
<h2 class="nav-tab-wrapper">
|
||||
<?php foreach ( $this->sections as $section_slug => $section ): ?>
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
||||
<h2 class="nav-tab-wrapper">
|
||||
<?php foreach ( $this->sections as $section_slug => $section ) : ?>
|
||||
<a
|
||||
class="nav-tab<?php echo ( $section_slug === $active_section->get_section_slug() ) ? ' nav-tab-active' : '' ?>"
|
||||
href="?page=<?php echo Init::MAIN_MENU_SLUG ?>&t=<?php echo $section_slug ?>">
|
||||
class="nav-tab<?php echo ( $section_slug === $active_section->get_section_slug() ) ? ' nav-tab-active' : ''; ?>"
|
||||
href="?page=<?php echo Init::MAIN_MENU_SLUG; ?>&t=<?php echo $section_slug; ?>">
|
||||
<?php echo $section->get_title(); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</h2>
|
||||
<?php
|
||||
|
||||
if ( $settings_updated ) {
|
||||
if ( $settings_updated ) {
|
||||
echo sprintf( '<div id="message" class="updated">%s</div>', __( 'Settings saved', 'footnotes' ) );
|
||||
}
|
||||
|
||||
// show error/update messages
|
||||
settings_errors( 'footnotes_messages' );
|
||||
?>
|
||||
<form action="" method="post">
|
||||
<input type="hidden" name="save-settings" value="save" />
|
||||
<?php
|
||||
// output security fields for the registered setting "footnotes"
|
||||
settings_fields( 'footnotes' );
|
||||
<form action="" method="post">
|
||||
<input type="hidden" name="save-settings" value="save" />
|
||||
<?php
|
||||
// output security fields for the registered setting "footnotes"
|
||||
settings_fields( 'footnotes' );
|
||||
|
||||
// output setting sections and their fields
|
||||
// (sections are registered for "footnotes", each field is registered to a specific section)
|
||||
do_settings_sections( 'footnotes' );
|
||||
// output setting sections and their fields
|
||||
// (sections are registered for "footnotes", each field is registered to a specific section)
|
||||
do_settings_sections( 'footnotes' );
|
||||
|
||||
//do_meta_boxes( $active_section['id'], 'main', null );
|
||||
// do_meta_boxes( $active_section['id'], 'main', null );
|
||||
|
||||
// Add submit button to active section if defined.
|
||||
//if ( $l_arr_active_section['submit'] ) {
|
||||
// if ( $l_arr_active_section['submit'] ) {
|
||||
submit_button();
|
||||
//}
|
||||
?>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
// }
|
||||
?>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
|
||||
|
||||
/**
|
||||
* Output the description of a section. May be overwritten in any section.
|
||||
*
|
||||
|
@ -395,8 +384,8 @@ abstract class Engine {
|
|||
$max_length ?? 999,
|
||||
$style ?? '',
|
||||
$value,
|
||||
isset($readonly) ? ' readonly="readonly"' : '',
|
||||
$disabled ? ' disabled': ''
|
||||
isset( $readonly ) ? ' readonly="readonly"' : '',
|
||||
$disabled ? ' disabled' : ''
|
||||
) );
|
||||
}
|
||||
|
||||
|
@ -417,8 +406,8 @@ abstract class Engine {
|
|||
$name,
|
||||
$name,
|
||||
$style ?? '',
|
||||
isset($readonly) ? ' readonly="readonly"' : '',
|
||||
$disabled ? ' disabled': '',
|
||||
isset( $readonly ) ? ' readonly="readonly"' : '',
|
||||
$disabled ? ' disabled' : '',
|
||||
$value,
|
||||
) );
|
||||
}
|
||||
|
@ -441,12 +430,12 @@ abstract class Engine {
|
|||
'<input type="number" name="%s" id="%s"%s%s value="%s"%s%s%s/>',
|
||||
$name,
|
||||
$name,
|
||||
isset($max) ? ' max="'.$max.'"' : '',
|
||||
isset($min) ? ' min="'.$min.'"' : '',
|
||||
is_float($value) ? number_format( $value, 1 ) : $value,
|
||||
is_float($value) ? ' step="0.1"' : '',
|
||||
isset($readonly) ? ' readonly="readonly"' : '',
|
||||
$disabled ? ' disabled': ''
|
||||
isset( $max ) ? ' max="' . $max . '"' : '',
|
||||
isset( $min ) ? ' min="' . $min . '"' : '',
|
||||
is_float( $value ) ? number_format( $value, 1 ) : $value,
|
||||
is_float( $value ) ? ' step="0.1"' : '',
|
||||
isset( $readonly ) ? ' readonly="readonly"' : '',
|
||||
$disabled ? ' disabled' : ''
|
||||
) );
|
||||
}
|
||||
|
||||
|
@ -463,7 +452,9 @@ abstract class Engine {
|
|||
protected function add_select( array $args ): void {
|
||||
extract( $args );
|
||||
|
||||
if (!isset($options)) trigger_error("No options passed to 'select' element.", E_USER_ERROR);
|
||||
if ( ! isset( $options ) ) {
|
||||
trigger_error( "No options passed to 'select' element.", E_USER_ERROR );
|
||||
}
|
||||
|
||||
$select_options = '';
|
||||
// Loop through all array keys.
|
||||
|
@ -484,7 +475,7 @@ abstract class Engine {
|
|||
'<select name="%s" id="%s"%s>%s</select>',
|
||||
$name,
|
||||
$name,
|
||||
$disabled ? ' disabled': '',
|
||||
$disabled ? ' disabled' : '',
|
||||
$select_options
|
||||
) );
|
||||
}
|
||||
|
@ -507,7 +498,7 @@ abstract class Engine {
|
|||
$name,
|
||||
$name,
|
||||
$value ? ' checked="checked"' : '',
|
||||
$disabled ? ' disabled': ''
|
||||
$disabled ? ' disabled' : ''
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -528,13 +519,13 @@ abstract class Engine {
|
|||
'<input type="color" name="%s" id="%s"%s/>',
|
||||
$name,
|
||||
$name,
|
||||
$disabled ? ' disabled': ''
|
||||
$disabled ? ' disabled' : ''
|
||||
);
|
||||
}
|
||||
|
||||
/******************************
|
||||
* OLD METHODS
|
||||
******************************/
|
||||
* OLD METHODS
|
||||
******************************/
|
||||
|
||||
/**
|
||||
* Registers all Meta boxes for a sub-page.
|
||||
|
|
|
@ -61,8 +61,8 @@ class SettingsPage extends Engine {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
protected Settings $settings
|
||||
) {
|
||||
}
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a priority index.
|
||||
|
@ -84,52 +84,56 @@ class SettingsPage extends Engine {
|
|||
$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()) {
|
||||
switch ( $active_section->get_section_slug() ) {
|
||||
case 'footnotes-settings':
|
||||
$this->settings->settings_sections['general']->add_settings_fields($this);
|
||||
$this->settings->settings_sections['general']->add_settings_fields( $this );
|
||||
break;
|
||||
case 'footnotes-customize':
|
||||
$this->settings->settings_sections['referrers_and_tooltips']->add_settings_fields($this);
|
||||
$this->settings->settings_sections['referrers_and_tooltips']->add_settings_fields( $this );
|
||||
break;
|
||||
case 'footnotes-expert':
|
||||
$this->settings->settings_sections['scope_and_priority']->add_settings_fields($this);
|
||||
$this->settings->settings_sections['scope_and_priority']->add_settings_fields( $this );
|
||||
break;
|
||||
case 'footnotes-customcss':
|
||||
$this->settings->settings_sections['custom_css']->add_settings_fields($this);
|
||||
$this->settings->settings_sections['custom_css']->add_settings_fields( $this );
|
||||
break;
|
||||
case 'footnotes-how-to':
|
||||
print_r("Demo goes here");
|
||||
print_r( 'Demo goes here' );
|
||||
break;
|
||||
default: print_r("ERR: section not found");
|
||||
default:
|
||||
print_r( 'ERR: section not found' );
|
||||
}
|
||||
}
|
||||
|
||||
public function setting_field_callback( array $args ): void {
|
||||
if (isset($args['type'])) {
|
||||
if ( isset( $args['type'] ) ) {
|
||||
echo $args['description'] . '</td><td>';
|
||||
|
||||
switch($args['type']) {
|
||||
switch ( $args['type'] ) {
|
||||
case 'text':
|
||||
$this->add_input_text($args);
|
||||
$this->add_input_text( $args );
|
||||
return;
|
||||
case 'textarea':
|
||||
$this->add_textarea($args);
|
||||
$this->add_textarea( $args );
|
||||
return;
|
||||
case 'number':
|
||||
$this->add_input_number($args);
|
||||
$this->add_input_number( $args );
|
||||
return;
|
||||
case 'select':
|
||||
$this->add_select($args);
|
||||
$this->add_select( $args );
|
||||
return;
|
||||
case 'checkbox':
|
||||
$this->add_input_checkbox($args);
|
||||
$this->add_input_checkbox( $args );
|
||||
return;
|
||||
case 'color':
|
||||
$this->add_input_color($args);
|
||||
$this->add_input_color( $args );
|
||||
return;
|
||||
default: trigger_error("Unknown setting type.", E_USER_ERROR);
|
||||
default:
|
||||
trigger_error( 'Unknown setting type.', E_USER_ERROR );
|
||||
}
|
||||
} else trigger_error("No setting type.", E_USER_ERROR);
|
||||
} else {
|
||||
trigger_error( 'No setting type.', E_USER_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -55,8 +55,10 @@ class Convert {
|
|||
* @since 1.0-beta
|
||||
* @todo Replace with built-in type casting.
|
||||
*/
|
||||
public static function to_bool( string|null $value ): bool {
|
||||
if (!$value) return false;
|
||||
public static function to_bool( ?string $value ): bool {
|
||||
if ( ! $value ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert string to lower-case to make it easier.
|
||||
$value = strtolower( $value );
|
||||
|
|
|
@ -101,7 +101,7 @@ class Core {
|
|||
|
||||
$this->load_dependencies();
|
||||
$this->set_locale();
|
||||
$this->settings = new Settings();
|
||||
$this->settings = new Settings();
|
||||
$this->define_admin_hooks();
|
||||
$this->define_public_hooks();
|
||||
}
|
||||
|
@ -123,9 +123,12 @@ class Core {
|
|||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function get_plugin_name(bool $html = false): string {
|
||||
if ( ! $html ) return $this->plugin_name;
|
||||
else return '<span class="footnotes_logo footnotes_logo_part1">foot</span><span class="footnotes_logo footnotes_logo_part2">notes</span>';
|
||||
public function get_plugin_name( bool $html = false ): string {
|
||||
if ( ! $html ) {
|
||||
return $this->plugin_name;
|
||||
} else {
|
||||
return '<span class="footnotes_logo footnotes_logo_part1">foot</span><span class="footnotes_logo footnotes_logo_part2">notes</span>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,10 +65,10 @@ class Settings {
|
|||
$this->load_dependencies();
|
||||
|
||||
$this->settings_sections = array(
|
||||
'general' => new GeneralSettingsSection('footnotes_storage', 'footnotes-settings', 'General Settings', $this ),
|
||||
'referrers_and_tooltips' => new ReferrersAndTooltipsSettingsSection('footnotes_storage_custom', 'footnotes-customize', 'Referrers and Tooltips', $this),
|
||||
'scope_and_priority' => new ScopeAndPrioritySettingsSection('footnotes_storage_expert', 'footnotes-expert', 'Scope and Priority', $this),
|
||||
'custom_css' => new CustomCSSSettingsSection('footnotes_storage_custom_css', 'footnotes-customcss', 'Custom CSS', $this),
|
||||
'general' => new GeneralSettingsSection( 'footnotes_storage', 'footnotes-settings', 'General Settings', $this ),
|
||||
'referrers_and_tooltips' => new ReferrersAndTooltipsSettingsSection( 'footnotes_storage_custom', 'footnotes-customize', 'Referrers and Tooltips', $this ),
|
||||
'scope_and_priority' => new ScopeAndPrioritySettingsSection( 'footnotes_storage_expert', 'footnotes-expert', 'Scope and Priority', $this ),
|
||||
'custom_css' => new CustomCSSSettingsSection( 'footnotes_storage_custom_css', 'footnotes-customcss', 'Custom CSS', $this ),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -92,20 +92,20 @@ class Settings {
|
|||
* @return void
|
||||
*/
|
||||
protected function load_dependencies(): void {
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-settings-section.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-setting.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-settingssection.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-settingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-setting.php';
|
||||
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/general/class-general-settings-section.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/referrers-and-tooltips/class-referrers-and-tooltips-settings-section.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/scope-and-priority/class-scope-and-priority-settings-section.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/custom-css/class-custom-css-settings-section.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/general/class-generalsettingssection.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/referrers-and-tooltips/class-referrersandtooltipssettingssection.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/scope-and-priority/class-scopeandprioritysettingssection.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/custom-css/class-customcsssettingssection.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a setting by its key.
|
||||
*
|
||||
* @param string $setting_key The key of the setting to search for.
|
||||
* @param string $setting_key The key of the setting to search for.
|
||||
* @return ?Setting Either the setting object, or `null` if none exists.
|
||||
*
|
||||
* @since 2.8.0
|
||||
|
@ -113,10 +113,12 @@ class Settings {
|
|||
* @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);
|
||||
foreach ( $this->settings_sections as $settings_section ) {
|
||||
$setting = $settings_section->get_setting( $setting_key );
|
||||
|
||||
if ($setting) return $setting;
|
||||
if ( $setting ) {
|
||||
return $setting;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -125,7 +127,7 @@ class Settings {
|
|||
/**
|
||||
* Retrieve a setting's value by its key.
|
||||
*
|
||||
* @param string $setting_key The key of the setting to search for.
|
||||
* @param string $setting_key The key of the setting to search for.
|
||||
* @return mixed Either the setting's value, or `null` if the setting does not exist.
|
||||
*
|
||||
* @since 2.8.0
|
||||
|
@ -134,10 +136,12 @@ class Settings {
|
|||
* @todo How to handle settings with a value of `null`?
|
||||
*/
|
||||
public function get_setting_value( string $setting_key ): mixed {
|
||||
foreach ($this->settings_sections as $settings_section) {
|
||||
$setting = $settings_section->get_setting($setting_key);
|
||||
foreach ( $this->settings_sections as $settings_section ) {
|
||||
$setting = $settings_section->get_setting( $setting_key );
|
||||
|
||||
if ($setting) return $setting->get_value();
|
||||
if ( $setting ) {
|
||||
return $setting->get_value();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -146,7 +150,7 @@ class Settings {
|
|||
/**
|
||||
* Retrieve a setting's default value by its key.
|
||||
*
|
||||
* @param string $setting_key The key of the setting to search for.
|
||||
* @param string $setting_key The key of the setting to search for.
|
||||
* @return mixed Either the setting's default value, or `null` if the setting does not exist.
|
||||
*
|
||||
* @since 2.8.0
|
||||
|
@ -155,10 +159,12 @@ class Settings {
|
|||
* @todo How to handle settings with a default value of `null`?
|
||||
*/
|
||||
public function get_setting_default_value( string $setting_key ): mixed {
|
||||
foreach ($this->settings_sections as $settings_section) {
|
||||
$setting = $settings_section->get_setting($setting_key);
|
||||
foreach ( $this->settings_sections as $settings_section ) {
|
||||
$setting = $settings_section->get_setting( $setting_key );
|
||||
|
||||
if ($setting) return $setting->get_default_value();
|
||||
if ( $setting ) {
|
||||
return $setting->get_default_value();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -167,7 +173,7 @@ class Settings {
|
|||
/**
|
||||
* Set a setting's value by its key.
|
||||
*
|
||||
* @param string $setting_key The key of the setting to search for.
|
||||
* @param string $setting_key The key of the setting to search for.
|
||||
* @param mixed $setting_value The new value to set.
|
||||
* @return mixed 'True' if the value was successfully set. 'False' otherwise.
|
||||
*
|
||||
|
@ -176,11 +182,13 @@ class Settings {
|
|||
* @todo This is an _O(n)_ linear search. Explore more scaleable alternatives.
|
||||
* @todo How to handle settings with a value of `null`?
|
||||
*/
|
||||
public function set_setting_value( string $setting_key, mixed $setting_value ): ?bool {
|
||||
foreach ($this->settings_sections as $settings_section) {
|
||||
$setting = $settings_section->get_setting($setting_key);
|
||||
public function set_setting_value( string $setting_key, $setting_value ): ?bool {
|
||||
foreach ( $this->settings_sections as $settings_section ) {
|
||||
$setting = $settings_section->get_setting( $setting_key );
|
||||
|
||||
if ($setting) return $setting->set_value( $setting_value );
|
||||
if ( $setting ) {
|
||||
return $setting->set_value( $setting_value );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -202,7 +210,7 @@ class Settings {
|
|||
/**
|
||||
* Updates a whole Setting Container on save.
|
||||
*
|
||||
* @param string $options_group_slug Options group slug to save.
|
||||
* @param string $options_group_slug Options group slug to save.
|
||||
* @param array $new_values The new Settings value(s).
|
||||
*
|
||||
* @since 1.5.0
|
||||
|
@ -210,8 +218,8 @@ class Settings {
|
|||
*/
|
||||
public function save_options_group( 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) {
|
||||
foreach ( $this->settings_sections as $settings_section ) {
|
||||
if ( $settings_section->get_options_group_slug() === $options_group_slug ) {
|
||||
$settings_section->load_options_group();
|
||||
}
|
||||
}
|
||||
|
@ -227,16 +235,16 @@ class Settings {
|
|||
* @since 2.8.0 Renamed from `load_all()` to `load_options_groups()`.
|
||||
*/
|
||||
protected function load_options_groups(): void {
|
||||
foreach ($this->options_group_slug as $options_group_slug) {
|
||||
$options_group = get_option($options_group_slug);
|
||||
foreach ( $this->options_group_slug as $options_group_slug ) {
|
||||
$options_group = get_option( $options_group_slug );
|
||||
|
||||
if (!! $options_group) {
|
||||
foreach ($this->settings_sections as $settings_section) {
|
||||
if ($settings_section->get_options_group_slug() === $options_group_slug) {
|
||||
$settings_section->load_options_group();
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! ! $options_group ) {
|
||||
foreach ( $this->settings_sections as $settings_section ) {
|
||||
if ( $settings_section->get_options_group_slug() === $options_group_slug ) {
|
||||
$settings_section->load_options_group();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,13 +42,13 @@ class Setting {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
const FONT_SIZE_UNIT_OPTIONS = array(
|
||||
'em' => 'em',
|
||||
'rem' => 'rem',
|
||||
'px' => 'pixels',
|
||||
'pt' => 'points',
|
||||
'pc' => 'picas',
|
||||
'mm' => 'millimeters',
|
||||
'%' => 'per cent',
|
||||
'em' => 'em',
|
||||
'rem' => 'rem',
|
||||
'px' => 'pixels',
|
||||
'pt' => 'points',
|
||||
'pc' => 'picas',
|
||||
'mm' => 'millimeters',
|
||||
'%' => 'per cent',
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -59,12 +59,12 @@ class Setting {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
const TEXT_ELEMENT_OPTIONS = array(
|
||||
'p' => 'paragraph',
|
||||
'h2' => 'heading 2',
|
||||
'h3' => 'heading 3',
|
||||
'h4' => 'heading 4',
|
||||
'h5' => 'heading 5',
|
||||
'h6' => 'heading 6',
|
||||
'p' => 'paragraph',
|
||||
'h2' => 'heading 2',
|
||||
'h3' => 'heading 3',
|
||||
'h4' => 'heading 4',
|
||||
'h5' => 'heading 5',
|
||||
'h6' => 'heading 6',
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -74,7 +74,7 @@ class Setting {
|
|||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
protected mixed $value;
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* Constructs the setting.
|
||||
|
@ -217,7 +217,7 @@ class Setting {
|
|||
) {
|
||||
$this->value = $this->default_value;
|
||||
|
||||
register_setting( $this->options_group_slug, $this->key, $this->get_setting_args());
|
||||
register_setting( $this->options_group_slug, $this->key, $this->get_setting_args() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -230,10 +230,10 @@ class Setting {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
public function get_setting_args(): array {
|
||||
return array (
|
||||
'type' => $this->type,
|
||||
return array(
|
||||
'type' => $this->type,
|
||||
'description' => $this->description,
|
||||
'default' => $this->default_value,
|
||||
'default' => $this->default_value,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -247,16 +247,16 @@ class Setting {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
public function get_setting_field_args(): array {
|
||||
return array (
|
||||
'name' => $this->key,
|
||||
'label_for' => $this->key,
|
||||
'value' => $this->value,
|
||||
return array(
|
||||
'name' => $this->key,
|
||||
'label_for' => $this->key,
|
||||
'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()
|
||||
'type' => $this->input_type,
|
||||
'options' => $this->input_options,
|
||||
'max' => $this->input_max,
|
||||
'min' => $this->input_min,
|
||||
'disabled' => $this->is_disabled_or_overridden(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -270,25 +270,33 @@ class Setting {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
private function is_disabled_or_overridden(): ?bool {
|
||||
if (isset($this->enabled_by)) {
|
||||
$enabled_by_value = $this->settings->get_setting_value($this->enabled_by);
|
||||
$is_enabled = (isset($enabled_by_value) || 'userdefined' === $enabled_by_value);
|
||||
if ( isset( $this->enabled_by ) ) {
|
||||
$enabled_by_value = $this->settings->get_setting_value( $this->enabled_by );
|
||||
$is_enabled = ( isset( $enabled_by_value ) || 'userdefined' === $enabled_by_value );
|
||||
}
|
||||
|
||||
if (isset($this->overridden_by)) {
|
||||
$overridden_by_value = $this->settings->get_setting_value($this->overridden_by);
|
||||
$is_overridden = !(null === $overridden_by_value || '' === $overridden_by_value);
|
||||
if ( isset( $this->overridden_by ) ) {
|
||||
$overridden_by_value = $this->settings->get_setting_value( $this->overridden_by );
|
||||
$is_overridden = ! ( null === $overridden_by_value || '' === $overridden_by_value );
|
||||
}
|
||||
|
||||
if (isset($is_enabled) || isset($is_overridden)) {
|
||||
if (isset($is_enabled) && !$is_enabled) return true;
|
||||
if ( isset( $is_enabled ) || isset( $is_overridden ) ) {
|
||||
if ( isset( $is_enabled ) && ! $is_enabled ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isset($is_enabled) && $is_enabled && (isset($is_overridden) && !$is_overridden)) return false;
|
||||
if ( isset( $is_enabled ) && $is_enabled && ( isset( $is_overridden ) && ! $is_overridden ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($is_overridden) && $is_overridden) return true;
|
||||
if ( isset( $is_overridden ) && $is_overridden ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} else return null;
|
||||
return false;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -354,7 +362,7 @@ class Setting {
|
|||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function set_value(mixed $value): bool {
|
||||
public function set_value( $value ): bool {
|
||||
$this->value = $value;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,10 @@ use footnotes\admin\layout\SettingsPage;
|
|||
/**
|
||||
* Class defining a group of plugin settings within a section.
|
||||
*
|
||||
* NB: the concept of a 'settings group' is just a semantic aide for developers,
|
||||
* it has no relevance within WordPress itself, which only recognises settings
|
||||
* sections and options groups.
|
||||
*
|
||||
* @package footnotes
|
||||
* @since 2.8.0
|
||||
*/
|
||||
|
@ -110,22 +114,22 @@ abstract class SettingsGroup {
|
|||
* Add the settings for this settings group.
|
||||
*
|
||||
* @abstract
|
||||
* @param array<string,mixed>|false $options Saved values for the settings in this group. 'False' if none exist.
|
||||
* @param array<string,mixed>|false $options Saved values for the settings in this group. 'False' if none exist.
|
||||
* @return void
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
protected abstract function add_settings(array|false $options): void;
|
||||
abstract protected function add_settings( array|false $options): void;
|
||||
|
||||
/**
|
||||
* Constructs settings from the provided details.
|
||||
*
|
||||
* @param array<string,mixed> $setting The setting details.
|
||||
* @param array<string,mixed> $setting The setting details.
|
||||
* @return Setting The constructed setting object.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
protected function add_setting(array $setting): Setting {
|
||||
protected function add_setting( array $setting ): Setting {
|
||||
extract( $setting );
|
||||
|
||||
return new Setting(
|
||||
|
@ -150,35 +154,38 @@ abstract class SettingsGroup {
|
|||
/**
|
||||
* Load the values for this settings group.
|
||||
*
|
||||
* @param array<string,mixed>|false $options Saved values for the settings in this group. 'False' if none exist.
|
||||
* @param array<string,mixed>|false $options Saved values for the settings in this group. 'False' if none exist.
|
||||
* @return void
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @todo Remove settings from options group when not found.
|
||||
* @todo Remove settings from options group when not found.
|
||||
*/
|
||||
protected function load_values(array|false $options): void {
|
||||
if ( ! $options ) return;
|
||||
protected function load_values( array|false $options ): void {
|
||||
if ( ! $options ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( $options as $setting_key => $setting_value ) {
|
||||
if ( array_key_exists( $setting_key, $this->settings ) )
|
||||
$this->settings[$setting_key]->set_value( $setting_value );
|
||||
}
|
||||
if ( array_key_exists( $setting_key, $this->settings ) ) {
|
||||
$this->settings[ $setting_key ]->set_value( $setting_value );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all the settings fields for this group to the admin. dashboard.
|
||||
*
|
||||
* @param SettingsPage $component The admin. dashboard settings page.
|
||||
* @param SettingsPage $component The admin. dashboard settings page.
|
||||
* @return void
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function add_settings_fields(SettingsPage $component): void {
|
||||
foreach ($this->settings as $setting) {
|
||||
public function add_settings_fields( SettingsPage $component ): void {
|
||||
foreach ( $this->settings as $setting ) {
|
||||
add_settings_field(
|
||||
$setting->key,
|
||||
__( $setting->name, 'footnotes' ),
|
||||
array ($component, 'setting_field_callback'),
|
||||
array( $component, 'setting_field_callback' ),
|
||||
'footnotes',
|
||||
$setting->get_section_slug(),
|
||||
$setting->get_setting_field_args()
|
||||
|
@ -187,43 +194,56 @@ abstract class SettingsGroup {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieve a setting by its key.
|
||||
*
|
||||
* @see Settings::get_setting()
|
||||
*/
|
||||
public function get_setting(string $setting_key): ?Setting {
|
||||
foreach ($this->settings as $setting) {
|
||||
if ($setting->key === $setting_key) return $setting;
|
||||
public function get_setting( string $setting_key ): ?Setting {
|
||||
foreach ( $this->settings as $setting ) {
|
||||
if ( $setting->key === $setting_key ) {
|
||||
return $setting;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an options group from the values of the settings in this section.
|
||||
*
|
||||
* @see SettingsSection::get_options()
|
||||
*/
|
||||
public function get_options(): array {
|
||||
$options = array();
|
||||
|
||||
foreach ($this->settings as $setting) {
|
||||
$options[$setting->key] = $setting->get_value();
|
||||
foreach ( $this->settings as $setting ) {
|
||||
$options[ $setting->key ] = $setting->get_value();
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a setting's value by its key.
|
||||
*
|
||||
* @see Settings::get_setting_value()
|
||||
*/
|
||||
public function get_setting_value(string $setting_key) {
|
||||
$setting = $this->get_setting($setting_key);
|
||||
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;
|
||||
if ( ! $setting ) {
|
||||
return null;
|
||||
} else {
|
||||
return $setting->value ?? $setting->default_value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a setting's value by its key.
|
||||
*
|
||||
* @see Settings::set_setting_value()
|
||||
*/
|
||||
public function set_setting_value(string $setting_key, $value): bool {
|
||||
return $this->get_setting($setting_key)->set_value($value);
|
||||
public function set_setting_value( string $setting_key, $value ): bool {
|
||||
return $this->get_setting( $setting_key )->set_value( $value );
|
||||
}
|
||||
}
|
|
@ -72,11 +72,11 @@ abstract class SettingsSection {
|
|||
}
|
||||
|
||||
public function load_options_group(): void {
|
||||
$options_group = get_option($this->options_group_slug);
|
||||
$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);
|
||||
if ( ! ! $options_group ) {
|
||||
foreach ( $options_group as $setting_key => $setting_value ) {
|
||||
$this->set_setting_value( $setting_key, $setting_value );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,20 +84,20 @@ abstract class SettingsSection {
|
|||
public function add_settings_section(): void {
|
||||
add_settings_section(
|
||||
$this->section_slug,
|
||||
__( $this->title, 'footnotes'),
|
||||
array($this, 'setting_section_callback'),
|
||||
__( $this->title, 'footnotes' ),
|
||||
array( $this, 'setting_section_callback' ),
|
||||
'footnotes'
|
||||
);
|
||||
}
|
||||
|
||||
public function add_settings_fields($component): void {
|
||||
foreach($this->settings_groups as $settings_group) {
|
||||
$settings_group->add_settings_fields($component);
|
||||
public function add_settings_fields( $component ): void {
|
||||
foreach ( $this->settings_groups as $settings_group ) {
|
||||
$settings_group->add_settings_fields( $component );
|
||||
}
|
||||
}
|
||||
|
||||
public function setting_section_callback(): void {
|
||||
echo "<hr>";
|
||||
echo '<hr>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,7 +108,7 @@ abstract class SettingsSection {
|
|||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
protected abstract function add_settings_groups(): void;
|
||||
abstract protected function add_settings_groups(): void;
|
||||
|
||||
public function get_options_group_slug(): string {
|
||||
return $this->options_group_slug;
|
||||
|
@ -139,23 +139,27 @@ abstract class SettingsSection {
|
|||
/**
|
||||
* Gets a settings groups from this section by its ID.
|
||||
*
|
||||
* @param string group_id The ID of the settings group.
|
||||
* @param string $group_id The ID of the settings group.
|
||||
* @return ?SettingsGroup The section group. 'None' if none found.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function get_settings_group(string $group_id): ?SettingsGroup {
|
||||
return $this->settings_groups[$group_id] ?? null;
|
||||
public function get_settings_group( string $group_id ): ?SettingsGroup {
|
||||
return $this->settings_groups[ $group_id ] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a setting by its key.
|
||||
*
|
||||
* @see Settings::get_setting()
|
||||
*/
|
||||
public function get_setting(string $setting_key): ?Setting {
|
||||
foreach ($this->settings_groups as $settings_group) {
|
||||
$setting = $settings_group->get_setting($setting_key);
|
||||
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;
|
||||
if ( $setting ) {
|
||||
return $setting;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -171,30 +175,40 @@ abstract class SettingsSection {
|
|||
public function get_options(): array {
|
||||
$options = array();
|
||||
|
||||
foreach ($this->settings_groups as $settings_group) {
|
||||
$options = array_merge($options, $settings_group->get_options());
|
||||
foreach ( $this->settings_groups as $settings_group ) {
|
||||
$options = array_merge( $options, $settings_group->get_options() );
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a setting's default value by its key.
|
||||
*
|
||||
* @see Settings::get_setting_value()
|
||||
*/
|
||||
public function get_setting_value(string $setting_key) {
|
||||
$setting = $this->get_setting($setting_key);
|
||||
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);
|
||||
if ( ! $setting ) {
|
||||
return null;
|
||||
} else {
|
||||
return $setting->value ?? $setting->default_value ?? trigger_error( 'No default value found for ' . $setting_key . '.', E_USER_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a setting's value by its key.
|
||||
*
|
||||
* @see Settings::set_setting_value()
|
||||
*/
|
||||
public function set_setting_value(string $setting_key, $value): ?bool {
|
||||
$setting = $this->get_setting($setting_key);
|
||||
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);
|
||||
if ( ! $setting ) {
|
||||
return null;
|
||||
} else {
|
||||
return $setting->set_value( $value );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -49,28 +49,15 @@ class CustomCSSSettingsGroup extends SettingsGroup {
|
|||
* Convert from `string` to `array`.
|
||||
*/
|
||||
public const CUSTOM_CSS = array(
|
||||
'key' => 'footnote_inputfield_custom_css_new',
|
||||
'name' => 'Your Existing Custom CSS Code',
|
||||
'type' => 'string',
|
||||
'input_type' => 'textarea',
|
||||
'key' => 'footnote_inputfield_custom_css_new',
|
||||
'name' => 'Your Existing Custom CSS Code',
|
||||
'type' => 'string',
|
||||
'input_type' => 'textarea',
|
||||
);
|
||||
|
||||
/**
|
||||
* Load the required dependencies.
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* Include the following files that provide the settings for this plugin:
|
||||
*
|
||||
* - {@see SettingsGroup}: defines a group of settings.
|
||||
*
|
||||
* @see SettingsGroup::load_dependencies()
|
||||
*/
|
||||
protected function load_dependencies(): void {
|
||||
parent::load_dependencies();
|
||||
|
||||
require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
|
@ -35,9 +35,9 @@ class CustomCSSSettingsSection extends SettingsSection {
|
|||
/**
|
||||
* Constructs the settings section.
|
||||
*
|
||||
* @param string options_group_slug The slug of the settings section's options group.
|
||||
* @param string section_slug The slug of the settings section.
|
||||
* @param string title The name of the settings section.
|
||||
* @param string $options_group_slug The slug of the settings section's options group.
|
||||
* @param string $section_slug The slug of the settings section.
|
||||
* @param string $title The name of the settings section.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
|
@ -55,12 +55,12 @@ class CustomCSSSettingsSection extends SettingsSection {
|
|||
private Settings $settings
|
||||
) {
|
||||
$this->options_group_slug = $options_group_slug;
|
||||
$this->section_slug = $section_slug;
|
||||
$this->title = $title;
|
||||
$this->section_slug = $section_slug;
|
||||
$this->title = $title;
|
||||
|
||||
$this->load_dependencies();
|
||||
|
||||
$this->add_settings_groups(get_option( $this->options_group_slug ));
|
||||
$this->add_settings_groups( get_option( $this->options_group_slug ) );
|
||||
|
||||
$this->load_options_group();
|
||||
}
|
||||
|
@ -76,19 +76,19 @@ class CustomCSSSettingsSection extends SettingsSection {
|
|||
* @see SettingsSection::load_dependencies()
|
||||
*/
|
||||
protected function load_dependencies(): void {
|
||||
parent::load_dependencies();
|
||||
parent::load_dependencies();
|
||||
|
||||
require_once plugin_dir_path( __DIR__ ) . 'class-settings-section.php';
|
||||
|
||||
require_once plugin_dir_path( __DIR__ ) . 'custom-css/class-custom-css-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'custom-css/class-customcsssettingsgroup.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the settings groups for this settings section.
|
||||
*
|
||||
* @see SettingsSection::add_settings_groups()
|
||||
*/
|
||||
protected function add_settings_groups(): void {
|
||||
$this->settings_groups = array (
|
||||
CustomCSSSettingsGroup::GROUP_ID => new CustomCSSSettingsGroup($this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
$this->settings_groups = array(
|
||||
CustomCSSSettingsGroup::GROUP_ID => new CustomCSSSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -62,6 +62,8 @@ class AMPCompatSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
|
@ -22,7 +22,7 @@ use footnotes\includes\settings\SettingsGroup;
|
|||
* @since 2.8.0
|
||||
*/
|
||||
class ExcerptsSettingsGroup extends SettingsGroup {
|
||||
/**
|
||||
/**
|
||||
* Setting group ID.
|
||||
*
|
||||
* @var string
|
||||
|
@ -59,11 +59,13 @@ class ExcerptsSettingsGroup extends SettingsGroup {
|
|||
'input_options' => array(
|
||||
'yes' => 'Yes, generate excerpts from posts with effectively processed footnotes and other markup',
|
||||
'no' => 'No, generate excerpts from posts but remove all footnotes and output plain text',
|
||||
'manual' => 'Yes but run the process only to display tooltips in manual excerpts with footnote short codes'
|
||||
'manual' => 'Yes but run the process only to display tooltips in manual excerpts with footnote short codes',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
|
@ -41,9 +41,9 @@ class GeneralSettingsSection extends SettingsSection {
|
|||
/**
|
||||
* Constructs the settings section.
|
||||
*
|
||||
* @param string options_group_slug The slug of the settings section's options group.
|
||||
* @param string section_slug The slug of the settings section.
|
||||
* @param string title The name of the settings section.
|
||||
* @param string $options_group_slug The slug of the settings section's options group.
|
||||
* @param string $section_slug The slug of the settings section.
|
||||
* @param string $title The name of the settings section.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
|
@ -91,17 +91,19 @@ class GeneralSettingsSection extends SettingsSection {
|
|||
protected function load_dependencies(): void {
|
||||
parent::load_dependencies();
|
||||
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-reference-container-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-scrolling-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-shortcode-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-numbering-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-hard-links-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-love-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-excerpts-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-amp-compat-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-referencecontainersettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-scrollingsettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-shortcodesettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-numberingsettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-hardlinkssettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-lovesettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-excerptssettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'general/class-ampcompatsettingsgroup.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the settings groups for this settings section.
|
||||
*
|
||||
* @see SettingsSection::add_settings_groups()
|
||||
*/
|
||||
protected function add_settings_groups(): void {
|
|
@ -159,16 +159,18 @@ class HardLinksSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
||||
$this->settings = array(
|
||||
self::FOOTNOTES_HARD_LINKS_ENABLE['key'] => $this->add_setting( self::FOOTNOTES_HARD_LINKS_ENABLE ),
|
||||
self::REFERRER_FRAGMENT_ID_SLUG['key'] => $this->add_setting( self::REFERRER_FRAGMENT_ID_SLUG ),
|
||||
self::FOOTNOTE_FRAGMENT_ID_SLUG['key'] => $this->add_setting( self::FOOTNOTE_FRAGMENT_ID_SLUG ),
|
||||
self::HARD_LINK_IDS_SEPARATOR['key'] => $this->add_setting( self::HARD_LINK_IDS_SEPARATOR ),
|
||||
self::FOOTNOTES_HARD_LINKS_ENABLE['key'] => $this->add_setting( self::FOOTNOTES_HARD_LINKS_ENABLE ),
|
||||
self::REFERRER_FRAGMENT_ID_SLUG['key'] => $this->add_setting( self::REFERRER_FRAGMENT_ID_SLUG ),
|
||||
self::FOOTNOTE_FRAGMENT_ID_SLUG['key'] => $this->add_setting( self::FOOTNOTE_FRAGMENT_ID_SLUG ),
|
||||
self::HARD_LINK_IDS_SEPARATOR['key'] => $this->add_setting( self::HARD_LINK_IDS_SEPARATOR ),
|
||||
self::FOOTNOTES_BACKLINK_TOOLTIP_ENABLE['key'] => $this->add_setting( self::FOOTNOTES_BACKLINK_TOOLTIP_ENABLE ),
|
||||
self::FOOTNOTES_BACKLINK_TOOLTIP_TEXT['key'] => $this->add_setting( self::FOOTNOTES_BACKLINK_TOOLTIP_TEXT ),
|
||||
self::FOOTNOTES_BACKLINK_TOOLTIP_TEXT['key'] => $this->add_setting( self::FOOTNOTES_BACKLINK_TOOLTIP_TEXT ),
|
||||
);
|
||||
|
||||
$this->load_values( $options );
|
|
@ -74,7 +74,7 @@ class LoveSettingsGroup extends SettingsGroup {
|
|||
'type' => 'string',
|
||||
'input_type' => 'select',
|
||||
'input_options' => array(
|
||||
// Logo only.
|
||||
// Logo only.
|
||||
'text-3' => self::PLUGIN_SYMBOL,
|
||||
// Logo followed by heart symbol.
|
||||
'text-4' => self::PLUGIN_SYMBOL . ' ' . self::LOVE_SYMBOL,
|
||||
|
@ -114,11 +114,13 @@ class LoveSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
||||
$this->settings = array(
|
||||
self::FOOTNOTES_LOVE['key'] => $this->add_setting( self::FOOTNOTES_LOVE ),
|
||||
self::FOOTNOTES_LOVE['key'] => $this->add_setting( self::FOOTNOTES_LOVE ),
|
||||
self::FOOTNOTES_NO_LOVE_SLUG['key'] => $this->add_setting( self::FOOTNOTES_NO_LOVE_SLUG ),
|
||||
);
|
||||
|
|
@ -77,7 +77,7 @@ class NumberingSettingsGroup extends SettingsGroup {
|
|||
'type' => 'string',
|
||||
'input_type' => 'select',
|
||||
'input_options' => array(
|
||||
'arabic_plain' => 'plain Arabic numbers (1, 2, 3, 4, 5, …)',
|
||||
'arabic_plain' => 'plain Arabic numbers (1, 2, 3, 4, 5, …)',
|
||||
'arabic_leading' => 'zero-padded Arabic numbers (01, 02, 03, 04, 05, …)',
|
||||
'latin_low' => 'lowercase Latin letters (a, b, c, d, e, …)',
|
||||
'latin_high' => 'uppercase Latin letters (A, B, C, D, E, …)',
|
||||
|
@ -87,12 +87,14 @@ class NumberingSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
||||
$this->settings = array(
|
||||
self::COMBINE_IDENTICAL_FOOTNOTES['key'] => $this->add_setting( self::COMBINE_IDENTICAL_FOOTNOTES ),
|
||||
self::FOOTNOTES_COUNTER_STYLE['key'] => $this->add_setting( self::FOOTNOTES_COUNTER_STYLE ),
|
||||
self::FOOTNOTES_COUNTER_STYLE['key'] => $this->add_setting( self::FOOTNOTES_COUNTER_STYLE ),
|
||||
);
|
||||
|
||||
$this->load_values( $options );
|
|
@ -71,7 +71,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
|
|||
'default_value' => 'p',
|
||||
'type' => 'string',
|
||||
'input_type' => 'select',
|
||||
'input_options' => Setting::TEXT_ELEMENT_OPTIONS
|
||||
'input_options' => Setting::TEXT_ELEMENT_OPTIONS,
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -689,6 +689,8 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
|
@ -181,6 +181,8 @@ class ScrollingSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
|
@ -150,6 +150,8 @@ class ShortcodeSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
|
@ -56,18 +56,18 @@ class BacklinkSymbolSettingsGroup extends SettingsGroup {
|
|||
'default_value' => 0,
|
||||
'type' => 'number',
|
||||
'input_type' => 'select',
|
||||
'input_options' => array(
|
||||
'↑',
|
||||
'↥',
|
||||
'↟',
|
||||
'↩',
|
||||
'↲',
|
||||
'↵',
|
||||
'⇑',
|
||||
'⇡',
|
||||
'⇧',
|
||||
'↑'
|
||||
),
|
||||
'input_options' => array(
|
||||
'↑',
|
||||
'↥',
|
||||
'↟',
|
||||
'↩',
|
||||
'↲',
|
||||
'↵',
|
||||
'⇑',
|
||||
'⇡',
|
||||
'⇧',
|
||||
'↑',
|
||||
),
|
||||
'overridden_by' => self::HYPERLINK_ARROW_USER_DEFINED,
|
||||
);
|
||||
|
||||
|
@ -81,19 +81,21 @@ class BacklinkSymbolSettingsGroup extends SettingsGroup {
|
|||
* Convert from `string` to `array`.
|
||||
*/
|
||||
const HYPERLINK_ARROW_USER_DEFINED = array(
|
||||
'key' => 'footnote_inputfield_custom_hyperlink_symbol_user',
|
||||
'name' => 'Input the Backlink Symbol',
|
||||
'description' => 'Your input overrides the selection.',
|
||||
'type' => 'string',
|
||||
'input_type' => 'text',
|
||||
'key' => 'footnote_inputfield_custom_hyperlink_symbol_user',
|
||||
'name' => 'Input the Backlink Symbol',
|
||||
'description' => 'Your input overrides the selection.',
|
||||
'type' => 'string',
|
||||
'input_type' => 'text',
|
||||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
||||
$this->settings = array(
|
||||
self::HYPERLINK_ARROW['key'] => $this->add_setting( self::HYPERLINK_ARROW ),
|
||||
self::HYPERLINK_ARROW['key'] => $this->add_setting( self::HYPERLINK_ARROW ),
|
||||
self::HYPERLINK_ARROW_USER_DEFINED['key'] => $this->add_setting( self::HYPERLINK_ARROW_USER_DEFINED ),
|
||||
);
|
||||
|
|
@ -32,9 +32,9 @@ class ReferrersAndTooltipsSettingsSection extends SettingsSection {
|
|||
/**
|
||||
* Constructs the settings section.
|
||||
*
|
||||
* @param string options_group_slug The slug of the settings section's options group.
|
||||
* @param string section_slug The slug of the settings section.
|
||||
* @param string title The name of the settings section.
|
||||
* @param string $options_group_slug The slug of the settings section's options group.
|
||||
* @param string $section_slug The slug of the settings section.
|
||||
* @param string $title The name of the settings section.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
|
@ -52,12 +52,12 @@ class ReferrersAndTooltipsSettingsSection extends SettingsSection {
|
|||
private Settings $settings
|
||||
) {
|
||||
$this->options_group_slug = $options_group_slug;
|
||||
$this->section_slug = $section_slug;
|
||||
$this->title = $title;
|
||||
$this->section_slug = $section_slug;
|
||||
$this->title = $title;
|
||||
|
||||
$this->load_dependencies();
|
||||
|
||||
$this->add_settings_groups(get_option( $this->options_group_slug ));
|
||||
$this->add_settings_groups( get_option( $this->options_group_slug ) );
|
||||
|
||||
$this->load_options_group();
|
||||
}
|
||||
|
@ -82,34 +82,36 @@ class ReferrersAndTooltipsSettingsSection extends SettingsSection {
|
|||
* @see SettingsSection::load_dependencies()
|
||||
*/
|
||||
protected function load_dependencies(): void {
|
||||
parent::load_dependencies();
|
||||
parent::load_dependencies();
|
||||
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-backlink-symbol-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-referrers-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-referrers-in-labels-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltips-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltip-appearance-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltip-dimensions-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltip-position-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltip-text-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltip-timing-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltip-truncation-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-backlinksymbolsettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-referrerssettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-referrersinlabelssettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltipssettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltipappearancesettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltipdimensionssettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltippositionsettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltiptextsettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltiptimingsettingsgroup.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltiptruncationsettingsgroup.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the settings groups for this settings section.
|
||||
*
|
||||
* @see SettingsSection::add_settings_groups()
|
||||
*/
|
||||
protected function add_settings_groups(): void {
|
||||
$this->settings_groups = array (
|
||||
BacklinkSymbolSettingsGroup::GROUP_ID => new BacklinkSymbolSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
ReferrersSettingsGroup::GROUP_ID => new ReferrersSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
$this->settings_groups = array(
|
||||
BacklinkSymbolSettingsGroup::GROUP_ID => new BacklinkSymbolSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
ReferrersSettingsGroup::GROUP_ID => new ReferrersSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
ReferrersInLabelsSettingsGroup::GROUP_ID => new ReferrersInLabelsSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
TooltipsSettingsGroup::GROUP_ID => new TooltipsSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
TooltipsSettingsGroup::GROUP_ID => new TooltipsSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
TooltipAppearanceSettingsGroup::GROUP_ID => new TooltipAppearanceSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
TooltipDimensionsSettingsGroup::GROUP_ID => new TooltipDimensionsSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
TooltipPositionSettingsGroup::GROUP_ID => new TooltipPositionSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
TooltipTextSettingsGroup::GROUP_ID => new TooltipTextSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
TooltipTimingSettingsGroup::GROUP_ID => new TooltipTimingSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
TooltipPositionSettingsGroup::GROUP_ID => new TooltipPositionSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
TooltipTextSettingsGroup::GROUP_ID => new TooltipTextSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
TooltipTimingSettingsGroup::GROUP_ID => new TooltipTimingSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
TooltipTruncationSettingsGroup::GROUP_ID => new TooltipTruncationSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
);
|
||||
}
|
|
@ -64,13 +64,15 @@ class ReferrersInLabelsSettingsGroup extends SettingsGroup {
|
|||
'type' => 'string',
|
||||
'input_type' => 'select',
|
||||
'input_options' => array(
|
||||
'none' => '0. No problem or solved otherwise',
|
||||
'move' => 'A. Footnotes are moved out and appended after the label\'s end (recommended)',
|
||||
'disconnect' => 'B. Labels with footnotes are disconnected from input element (discouraged)'
|
||||
'none' => '0. No problem or solved otherwise',
|
||||
'move' => 'A. Footnotes are moved out and appended after the label\'s end (recommended)',
|
||||
'disconnect' => 'B. Labels with footnotes are disconnected from input element (discouraged)',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
|
@ -74,9 +74,9 @@ class ReferrersSettingsGroup extends SettingsGroup {
|
|||
'type' => 'string',
|
||||
'input_type' => 'select',
|
||||
'input_options' => array(
|
||||
'no' => 'No',
|
||||
'referrers' => 'Footnote referrers',
|
||||
'all' => 'All superscript elements'
|
||||
'no' => 'No',
|
||||
'referrers' => 'Footnote referrers',
|
||||
'all' => 'All superscript elements',
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -139,6 +139,8 @@ class ReferrersSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
||||
|
@ -146,8 +148,8 @@ class ReferrersSettingsGroup extends SettingsGroup {
|
|||
self::FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS['key'] => $this->add_setting( self::FOOTNOTES_REFERRER_SUPERSCRIPT_TAGS ),
|
||||
self::FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT['key'] => $this->add_setting( self::FOOTNOTE_REFERRERS_NORMAL_SUPERSCRIPT ),
|
||||
self::FOOTNOTES_STYLING_BEFORE['key'] => $this->add_setting( self::FOOTNOTES_STYLING_BEFORE ),
|
||||
self::FOOTNOTES_STYLING_AFTER['key'] => $this->add_setting( self::FOOTNOTES_STYLING_AFTER ),
|
||||
self::LINK_ELEMENT_ENABLED['key'] => $this->add_setting( self::LINK_ELEMENT_ENABLED ),
|
||||
self::FOOTNOTES_STYLING_AFTER['key'] => $this->add_setting( self::FOOTNOTES_STYLING_AFTER ),
|
||||
self::LINK_ELEMENT_ENABLED['key'] => $this->add_setting( self::LINK_ELEMENT_ENABLED ),
|
||||
);
|
||||
|
||||
$this->load_values( $options );
|
|
@ -79,7 +79,7 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
|
|||
'type' => 'number',
|
||||
'input_type' => 'number',
|
||||
'input_max' => 50.0,
|
||||
'input_min' => 0.0
|
||||
'input_min' => 0.0,
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -97,7 +97,7 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
|
|||
'default_value' => 'px',
|
||||
'type' => 'string',
|
||||
'input_type' => 'select',
|
||||
'input_options' => Setting::FONT_SIZE_UNIT_OPTIONS
|
||||
'input_options' => Setting::FONT_SIZE_UNIT_OPTIONS,
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -157,8 +157,8 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
|
|||
'default_value' => 1.0,
|
||||
'type' => 'number',
|
||||
'input_type' => 'number',
|
||||
'input_max' => 4.0,
|
||||
'input_min' => 0.0,
|
||||
'input_max' => 4.0,
|
||||
'input_min' => 0.0,
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -195,8 +195,8 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
|
|||
'default_value' => 0,
|
||||
'type' => 'number',
|
||||
'input_type' => 'number',
|
||||
'input_max' => 500,
|
||||
'input_min' => 0,
|
||||
'input_max' => 500,
|
||||
'input_min' => 0,
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -218,14 +218,16 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
||||
$this->settings = array(
|
||||
self::MOUSE_OVER_BOX_FONT_SIZE_ENABLED['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FONT_SIZE_ENABLED ),
|
||||
self::MOUSE_OVER_BOX_FONT_SIZE_SCALAR['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FONT_SIZE_SCALAR ),
|
||||
self::MOUSE_OVER_BOX_FONT_SIZE_UNIT['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FONT_SIZE_UNIT ),
|
||||
self::FOOTNOTES_MOUSE_OVER_BOX_COLOR['key'] => $this->add_setting( self::FOOTNOTES_MOUSE_OVER_BOX_COLOR ),
|
||||
self::MOUSE_OVER_BOX_FONT_SIZE_SCALAR['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FONT_SIZE_SCALAR ),
|
||||
self::MOUSE_OVER_BOX_FONT_SIZE_UNIT['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FONT_SIZE_UNIT ),
|
||||
self::FOOTNOTES_MOUSE_OVER_BOX_COLOR['key'] => $this->add_setting( self::FOOTNOTES_MOUSE_OVER_BOX_COLOR ),
|
||||
self::FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND['key'] => $this->add_setting( self::FOOTNOTES_MOUSE_OVER_BOX_BACKGROUND ),
|
||||
self::FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH['key'] => $this->add_setting( self::FOOTNOTES_MOUSE_OVER_BOX_BORDER_WIDTH ),
|
||||
self::FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR['key'] => $this->add_setting( self::FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR ),
|
|
@ -78,6 +78,8 @@ class TooltipDimensionsSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
|
@ -89,10 +89,10 @@ class TooltipPositionSettingsGroup extends SettingsGroup {
|
|||
'type' => 'string',
|
||||
'input_type' => 'select',
|
||||
'input_options' => array(
|
||||
'top left' => 'top left',
|
||||
'top right' => 'top right',
|
||||
'bottom right' => 'bottom right',
|
||||
'bottom left' => 'bottom left',
|
||||
'top left' => 'top left',
|
||||
'top right' => 'top right',
|
||||
'bottom right' => 'bottom right',
|
||||
'bottom left' => 'bottom left',
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -172,6 +172,8 @@ class TooltipPositionSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
|
@ -83,6 +83,8 @@ class TooltipsSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
|
@ -111,6 +111,8 @@ class TooltipTextSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
|
@ -120,13 +120,15 @@ class TooltipTimingSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
||||
$this->settings = array(
|
||||
self::MOUSE_OVER_BOX_FADE_IN_DELAY['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FADE_IN_DELAY ),
|
||||
self::MOUSE_OVER_BOX_FADE_IN_DURATION['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FADE_IN_DURATION ),
|
||||
self::MOUSE_OVER_BOX_FADE_OUT_DELAY['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FADE_OUT_DELAY ),
|
||||
self::MOUSE_OVER_BOX_FADE_IN_DELAY['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FADE_IN_DELAY ),
|
||||
self::MOUSE_OVER_BOX_FADE_IN_DURATION['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FADE_IN_DURATION ),
|
||||
self::MOUSE_OVER_BOX_FADE_OUT_DELAY['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FADE_OUT_DELAY ),
|
||||
self::MOUSE_OVER_BOX_FADE_OUT_DURATION['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FADE_OUT_DURATION ),
|
||||
);
|
||||
|
|
@ -101,6 +101,8 @@ class TooltipTruncationSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
|
@ -34,9 +34,9 @@ class ScopeAndPrioritySettingsSection extends SettingsSection {
|
|||
/**
|
||||
* Constructs the settings section.
|
||||
*
|
||||
* @param string options_group_slug The slug of the settings section's options group.
|
||||
* @param string section_slug The slug of the settings section.
|
||||
* @param string title The name of the settings section.
|
||||
* @param string $options_group_slug The slug of the settings section's options group.
|
||||
* @param string $section_slug The slug of the settings section.
|
||||
* @param string $title The name of the settings section.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
|
@ -54,12 +54,12 @@ class ScopeAndPrioritySettingsSection extends SettingsSection {
|
|||
private Settings $settings
|
||||
) {
|
||||
$this->options_group_slug = $options_group_slug;
|
||||
$this->section_slug = $section_slug;
|
||||
$this->title = $title;
|
||||
$this->section_slug = $section_slug;
|
||||
$this->title = $title;
|
||||
|
||||
$this->load_dependencies();
|
||||
|
||||
$this->add_settings_groups(get_option( $this->options_group_slug ));
|
||||
$this->add_settings_groups( get_option( $this->options_group_slug ) );
|
||||
|
||||
$this->load_options_group();
|
||||
}
|
||||
|
@ -75,17 +75,19 @@ class ScopeAndPrioritySettingsSection extends SettingsSection {
|
|||
* @see SettingsSection::load_dependencies()
|
||||
*/
|
||||
protected function load_dependencies(): void {
|
||||
parent::load_dependencies();
|
||||
parent::load_dependencies();
|
||||
|
||||
require_once plugin_dir_path( __DIR__ ) . 'scope-and-priority/class-wordpress-hooks-settings-group.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'scope-and-priority/class-wordpresshookssettingsgroup.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the settings groups for this settings section.
|
||||
*
|
||||
* @see SettingsSection::add_settings_groups()
|
||||
*/
|
||||
protected function add_settings_groups(): void {
|
||||
$this->settings_groups = array (
|
||||
WordPressHooksSettingsGroup::GROUP_ID => new WordPressHooksSettingsGroup($this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
$this->settings_groups = array(
|
||||
WordPressHooksSettingsGroup::GROUP_ID => new WordPressHooksSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -268,19 +268,21 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
|
|||
);
|
||||
|
||||
/**
|
||||
* Add the settings for this settings group.
|
||||
*
|
||||
* @see SettingsGroup::add_settings()
|
||||
*/
|
||||
protected function add_settings( array|false $options ): void {
|
||||
$this->settings = array(
|
||||
self::EXPERT_LOOKUP_THE_TITLE['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_TITLE ),
|
||||
self::EXPERT_LOOKUP_THE_TITLE['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_TITLE ),
|
||||
self::EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL ),
|
||||
self::EXPERT_LOOKUP_THE_CONTENT['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_CONTENT ),
|
||||
self::EXPERT_LOOKUP_THE_CONTENT['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_CONTENT ),
|
||||
self::EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL ),
|
||||
self::EXPERT_LOOKUP_THE_EXCERPT['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_EXCERPT ),
|
||||
self::EXPERT_LOOKUP_THE_EXCERPT['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_EXCERPT ),
|
||||
self::EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL['key'] => $this->add_setting( self::EXPERT_LOOKUP_THE_EXCERPT_PRIORITY_LEVEL ),
|
||||
self::EXPERT_LOOKUP_WIDGET_TITLE['key'] => $this->add_setting( self::EXPERT_LOOKUP_WIDGET_TITLE ),
|
||||
self::EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL['key'] => $this->add_setting( self::EXPERT_LOOKUP_WIDGET_TITLE_PRIORITY_LEVEL ),
|
||||
self::EXPERT_LOOKUP_WIDGET_TEXT['key'] => $this->add_setting( self::EXPERT_LOOKUP_WIDGET_TEXT ),
|
||||
self::EXPERT_LOOKUP_WIDGET_TEXT['key'] => $this->add_setting( self::EXPERT_LOOKUP_WIDGET_TEXT ),
|
||||
self::EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL['key'] => $this->add_setting( self::EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL ),
|
||||
);
|
||||
|
|
@ -12,9 +12,7 @@ namespace footnotes\general;
|
|||
|
||||
use footnotes\includes\{Footnotes, Convert, Settings};
|
||||
|
||||
/**
|
||||
* @todo Replace with constant imports.
|
||||
*/
|
||||
/* TODO Replace with constant imports. */
|
||||
use footnotes\includes\settings\general\ReferenceContainerSettingsGroup;
|
||||
use footnotes\includes\settings\general\AMPCompatSettingsGroup;
|
||||
use footnotes\includes\settings\referrersandtooltips\TooltipsSettingsGroup;
|
||||
|
@ -123,7 +121,7 @@ class General {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
private Settings $settings
|
||||
) {
|
||||
) {
|
||||
|
||||
$this->load_dependencies();
|
||||
|
||||
|
@ -156,7 +154,7 @@ class General {
|
|||
|
||||
$this->reference_container_widget = new Widget\Reference_Container( $this->plugin_name );
|
||||
|
||||
$this->task = new Parser($this->settings);
|
||||
$this->task = new Parser( $this->settings );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,29 +15,27 @@ namespace footnotes\general;
|
|||
|
||||
use footnotes\includes\{Settings, Config, Convert, Template};
|
||||
|
||||
/**
|
||||
* @todo Replace with constant imports.
|
||||
*/
|
||||
/* TODO Replace with constant imports. */
|
||||
use footnotes\includes\settings\general\{
|
||||
ExcerptsSettingsGroup,
|
||||
HardLinksSettingsGroup,
|
||||
LoveSettingsGroup,
|
||||
NumberingSettingsGroup,
|
||||
ReferenceContainerSettingsGroup,
|
||||
ScrollingSettingsGroup,
|
||||
ShortcodeSettingsGroup,
|
||||
ExcerptsSettingsGroup,
|
||||
HardLinksSettingsGroup,
|
||||
LoveSettingsGroup,
|
||||
NumberingSettingsGroup,
|
||||
ReferenceContainerSettingsGroup,
|
||||
ScrollingSettingsGroup,
|
||||
ShortcodeSettingsGroup,
|
||||
};
|
||||
use footnotes\includes\settings\referrersandtooltips\{
|
||||
BacklinkSymbolSettingsGroup,
|
||||
ReferrersSettingsGroup,
|
||||
ReferrersInLabelsSettingsGroup,
|
||||
TooltipsSettingsGroup,
|
||||
TooltipAppearanceSettingsGroup,
|
||||
TooltipDimensionsSettingsGroup,
|
||||
TooltipPositionSettingsGroup,
|
||||
TooltipTextSettingsGroup,
|
||||
TooltipTimingSettingsGroup,
|
||||
TooltipTruncationSettingsGroup
|
||||
BacklinkSymbolSettingsGroup,
|
||||
ReferrersSettingsGroup,
|
||||
ReferrersInLabelsSettingsGroup,
|
||||
TooltipsSettingsGroup,
|
||||
TooltipAppearanceSettingsGroup,
|
||||
TooltipDimensionsSettingsGroup,
|
||||
TooltipPositionSettingsGroup,
|
||||
TooltipTextSettingsGroup,
|
||||
TooltipTimingSettingsGroup,
|
||||
TooltipTruncationSettingsGroup
|
||||
};
|
||||
use footnotes\includes\settings\scopeandpriority\WordPressHooksSettingsGroup;
|
||||
use footnotes\includes\settings\customcss\CustomCSSSettingsGroup;
|
||||
|
@ -284,7 +282,7 @@ class Parser {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
private Settings $settings
|
||||
) {
|
||||
) {
|
||||
// TODO: Reorg dependencies.
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/class-config.php';
|
||||
require_once plugin_dir_path( __DIR__ ) . 'includes/class-convert.php';
|
||||
|
@ -481,7 +479,7 @@ class Parser {
|
|||
// Reference container label bottom border.
|
||||
if ( ( $this->settings->get_setting_value( ReferenceContainerSettingsGroup::REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER['key'] ) ) ) {
|
||||
echo '.footnote_container_prepare > ';
|
||||
echo $this->settings->get_setting_value( ReferenceContainerSettingsGroup::REFERENCE_CONTAINER_LABEL_ELEMENT['key'] ) ;
|
||||
echo $this->settings->get_setting_value( ReferenceContainerSettingsGroup::REFERENCE_CONTAINER_LABEL_ELEMENT['key'] );
|
||||
echo " {border-bottom: 1px solid #aaaaaa !important;}\r\n";
|
||||
}
|
||||
|
||||
|
@ -545,7 +543,7 @@ class Parser {
|
|||
}
|
||||
|
||||
// Hard links scroll offset.
|
||||
// TODO: remove cast
|
||||
// TODO: remove cast.
|
||||
self::$hard_links_enabled = (bool) $this->settings->get_setting_value( HardLinksSettingsGroup::FOOTNOTES_HARD_LINKS_ENABLE['key'] );
|
||||
|
||||
// Correct hard links enabled status depending on AMP-compatible or alternative reference container enabled status.
|
||||
|
@ -721,7 +719,7 @@ class Parser {
|
|||
* for transparency. It isn’t indented though (the PHP open tag neither).
|
||||
*/
|
||||
if ( General::$alternative_tooltips_enabled ) {
|
||||
echo ('
|
||||
echo ( '
|
||||
<script content="text/javascript">
|
||||
function footnote_tooltip_show(footnote_tooltip_id) {
|
||||
document.getElementById(footnote_tooltip_id).classList.remove("hidden");
|
||||
|
@ -732,7 +730,7 @@ class Parser {
|
|||
document.getElementById(footnote_tooltip_id).classList.add("hidden");
|
||||
}
|
||||
</script>
|
||||
');
|
||||
' );
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -820,7 +818,7 @@ class Parser {
|
|||
$footnote_section_shortcode_length = strlen( $footnote_section_shortcode );
|
||||
|
||||
// TODO: Replace with `str_contains()`, but currently breaks Rector downgrade.
|
||||
// https://github.com/rectorphp/rector/issues/6315
|
||||
// <https://github.com/rectorphp/rector/issues/6315>.
|
||||
if ( ! strpos( $content, (string) $footnote_section_shortcode ) ) {
|
||||
|
||||
// phpcs:disable WordPress.PHP.YodaConditions.NotYoda
|
||||
|
@ -838,8 +836,8 @@ class Parser {
|
|||
$section_end = strpos( $rest_content, (string) $footnote_section_shortcode );
|
||||
$sections_raw[] = substr( $rest_content, 0, $section_end );
|
||||
$rest_content = substr( $rest_content, $section_end + $footnote_section_shortcode_length );
|
||||
// TODO: Replace with `str_contains()`, but currently breaks Rector downgrade.
|
||||
// https://github.com/rectorphp/rector/issues/6315
|
||||
// TODO: Replace with `str_contains()`, but currently breaks Rector downgrade.
|
||||
// <https://github.com/rectorphp/rector/issues/6315>.
|
||||
} while ( strpos( $rest_content, (string) $footnote_section_shortcode ) );
|
||||
$sections_raw[] = $rest_content;
|
||||
|
||||
|
@ -1199,7 +1197,7 @@ class Parser {
|
|||
*/
|
||||
|
||||
// If enabled.
|
||||
if ( $this->settings->get_setting( ShortcodeSettingsGroup::FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE['key']) ->get_value() ) {
|
||||
if ( $this->settings->get_setting( ShortcodeSettingsGroup::FOOTNOTE_SHORTCODE_SYNTAX_VALIDATION_ENABLE['key'] )->get_value() ) {
|
||||
|
||||
// Apply different regex depending on whether start shortcode is double/triple opening parenthesis.
|
||||
if ( '((' === self::$start_tag || '(((' === self::$start_tag ) {
|
||||
|
@ -1709,11 +1707,11 @@ class Parser {
|
|||
*/
|
||||
|
||||
// If the backlink symbol is enabled.
|
||||
if ( $this->settings->get_setting_value( ReferenceContainerSettingsGroup::REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE['key'] )) {
|
||||
$arrow_setting = $this->settings->get_setting( BacklinkSymbolSettingsGroup::HYPERLINK_ARROW['key']);
|
||||
if ( $this->settings->get_setting_value( ReferenceContainerSettingsGroup::REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE['key'] ) ) {
|
||||
$arrow_setting = $this->settings->get_setting( BacklinkSymbolSettingsGroup::HYPERLINK_ARROW['key'] );
|
||||
|
||||
// Get html arrow.
|
||||
$arrow = $arrow_setting->get_input_options()[$arrow_setting->get_value() || 0];
|
||||
$arrow = $arrow_setting->get_input_options()[ $arrow_setting->get_value() || 0 ];
|
||||
|
||||
// Get user defined arrow.
|
||||
$arrow_user_defined = $this->settings->get_setting_value( BacklinkSymbolSettingsGroup::HYPERLINK_ARROW_USER_DEFINED['key'] );
|
||||
|
@ -1745,10 +1743,9 @@ class Parser {
|
|||
|
||||
// If it is not, check which option is on.
|
||||
$separator_option = $this->settings->get_setting_value( ReferenceContainerSettingsGroup::BACKLINKS_SEPARATOR_OPTION['key'] );
|
||||
// TODO: replace with `match` (but currently it breaks the Rector
|
||||
// downgrade to PHP 7.4.
|
||||
// https://github.com/rectorphp/rector/issues/6315
|
||||
switch ($separator_option) {
|
||||
// TODO: replace with `match` (but currently it breaks the Rector downgrade to PHP 7.4.
|
||||
// <https://github.com/rectorphp/rector/issues/6315>.
|
||||
switch ( $separator_option ) {
|
||||
case 'comma':
|
||||
$separator = ',';
|
||||
break;
|
||||
|
@ -1779,10 +1776,9 @@ class Parser {
|
|||
|
||||
// If it is not, check which option is on.
|
||||
$terminator_option = $this->settings->get_setting_value( ReferenceContainerSettingsGroup::BACKLINKS_TERMINATOR_OPTION['key'] );
|
||||
// TODO: replace with `match` (but currently it breaks the Rector
|
||||
// downgrade to PHP 7.4.
|
||||
// https://github.com/rectorphp/rector/issues/6315
|
||||
switch ($terminator_option) {
|
||||
// TODO: replace with `match` (but currently it breaks the Rector downgrade to PHP 7.4.
|
||||
// <https://github.com/rectorphp/rector/issues/6315>.
|
||||
switch ( $terminator_option ) {
|
||||
case 'period':
|
||||
$terminator = '.';
|
||||
break;
|
||||
|
@ -2138,7 +2134,7 @@ class Parser {
|
|||
}
|
||||
|
||||
// Call again for robustness when priority levels don't match any longer.
|
||||
// TODO: remove cast
|
||||
// TODO: remove cast.
|
||||
self::$scroll_offset = (int) $this->settings->get_setting_value( ScrollingSettingsGroup::FOOTNOTES_SCROLL_OFFSET['key'] );
|
||||
|
||||
// Streamline.
|
||||
|
|
Reference in a new issue