chore: lint code

This commit is contained in:
Ben Goldsworthy 2021-08-09 11:48:58 +01:00
parent 8b2f98184d
commit 8c639a97b5
36 changed files with 715 additions and 640 deletions

View file

@ -60,14 +60,14 @@ class Admin {
* @see Footnotes::$version * @see Footnotes::$version
*/ */
private string $version, private string $version,
/** /**
* The plugin settings object. * The plugin settings object.
* *
* @access private * @access private
* @since 2.8.0 * @since 2.8.0
*/ */
private Settings $settings private Settings $settings
) { ) {
$this->load_dependencies(); $this->load_dependencies();

View file

@ -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['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'], $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 // phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
/** /**
* Displays the content of specific sub-page. * Displays the content of specific sub-page.
@ -129,14 +117,14 @@ abstract class Engine {
*/ */
public function display_content(): void { public function display_content(): void {
// check user capabilities // check user capabilities
if ( ! current_user_can( 'manage_options' ) ) { if ( ! current_user_can( 'manage_options' ) ) {
return; 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 ]; $active_section = $this->sections[ $active_section_id ];
// Store settings. // Store settings.
$settings_updated = false; $settings_updated = false;
if ( array_key_exists( 'save-settings', $_POST ) ) { if ( array_key_exists( 'save-settings', $_POST ) ) {
if ( 'save' === $_POST['save-settings'] ) { if ( 'save' === $_POST['save-settings'] ) {
@ -145,50 +133,51 @@ abstract class Engine {
$settings_updated = $this->save_settings(); $settings_updated = $this->save_settings();
} }
} }
?> ?>
<div class="wrap"> <div class="wrap">
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1> <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
<h2 class="nav-tab-wrapper"> <h2 class="nav-tab-wrapper">
<?php foreach ( $this->sections as $section_slug => $section ): ?> <?php foreach ( $this->sections as $section_slug => $section ) : ?>
<a <a
class="nav-tab<?php echo ( $section_slug === $active_section->get_section_slug() ) ? ' nav-tab-active' : '' ?>" 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 ?>"> href="?page=<?php echo Init::MAIN_MENU_SLUG; ?>&t=<?php echo $section_slug; ?>">
<?php echo $section->get_title(); ?> <?php echo $section->get_title(); ?>
</a> </a>
<?php endforeach; ?> <?php endforeach; ?>
</h2> </h2>
<?php <?php
if ( $settings_updated ) { if ( $settings_updated ) {
echo sprintf( '<div id="message" class="updated">%s</div>', __( 'Settings saved', 'footnotes' ) ); echo sprintf( '<div id="message" class="updated">%s</div>', __( 'Settings saved', 'footnotes' ) );
} }
// show error/update messages // show error/update messages
settings_errors( 'footnotes_messages' ); settings_errors( 'footnotes_messages' );
?> ?>
<form action="" method="post"> <form action="" method="post">
<input type="hidden" name="save-settings" value="save" /> <input type="hidden" name="save-settings" value="save" />
<?php <?php
// output security fields for the registered setting "footnotes" // output security fields for the registered setting "footnotes"
settings_fields( 'footnotes' ); settings_fields( 'footnotes' );
// output setting sections and their fields // output setting sections and their fields
// (sections are registered for "footnotes", each field is registered to a specific section) // (sections are registered for "footnotes", each field is registered to a specific section)
do_settings_sections( 'footnotes' ); 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. // Add submit button to active section if defined.
//if ( $l_arr_active_section['submit'] ) { // if ( $l_arr_active_section['submit'] ) {
submit_button(); submit_button();
//} // }
?> ?>
</form> </form>
</div> </div>
<?php <?php
} }
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing // phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
/** /**
* Output the description of a section. May be overwritten in any section. * Output the description of a section. May be overwritten in any section.
* *
@ -238,8 +227,8 @@ abstract class Engine {
* @since 1.5.0 * @since 1.5.0
*/ */
abstract protected function get_meta_boxes(): array; abstract protected function get_meta_boxes(): array;
abstract protected function add_settings_fields(): void; abstract protected function add_settings_fields(): void;
/** /**
@ -370,11 +359,11 @@ abstract class Engine {
*/ */
return sprintf( '<label for="%s">%s</label>', $setting_name, $caption ); return sprintf( '<label for="%s">%s</label>', $setting_name, $caption );
} }
/************************************************************************** /**************************************************************************
* NEW METHODS * NEW METHODS
**************************************************************************/ **************************************************************************/
/** /**
* Constructs the HTML for a text 'input' element. * Constructs the HTML for a text 'input' element.
* *
@ -387,7 +376,7 @@ abstract class Engine {
*/ */
protected function add_input_text( array $args ): void { protected function add_input_text( array $args ): void {
extract( $args ); extract( $args );
echo ( sprintf( echo ( sprintf(
'<input type="text" name="%s" id="%s" maxlength="%d" style="%s" value="%s"%s%s/>', '<input type="text" name="%s" id="%s" maxlength="%d" style="%s" value="%s"%s%s/>',
$name, $name,
@ -395,11 +384,11 @@ abstract class Engine {
$max_length ?? 999, $max_length ?? 999,
$style ?? '', $style ?? '',
$value, $value,
isset($readonly) ? ' readonly="readonly"' : '', isset( $readonly ) ? ' readonly="readonly"' : '',
$disabled ? ' disabled': '' $disabled ? ' disabled' : ''
) ); ) );
} }
/** /**
* Constructs the HTML for a 'textarea' element. * Constructs the HTML for a 'textarea' element.
* *
@ -411,18 +400,18 @@ abstract class Engine {
*/ */
protected function add_textarea( array $args ): void { protected function add_textarea( array $args ): void {
extract( $args ); extract( $args );
echo ( sprintf( echo ( sprintf(
'<textarea name="%s" id="%s" rows="4" cols="50" style="%s" %s%s>%s</textarea>', '<textarea name="%s" id="%s" rows="4" cols="50" style="%s" %s%s>%s</textarea>',
$name, $name,
$name, $name,
$style ?? '', $style ?? '',
isset($readonly) ? ' readonly="readonly"' : '', isset( $readonly ) ? ' readonly="readonly"' : '',
$disabled ? ' disabled': '', $disabled ? ' disabled' : '',
$value, $value,
) ); ) );
} }
/** /**
* Constructs the HTML for a numeric 'input' element. * Constructs the HTML for a numeric 'input' element.
* *
@ -436,17 +425,17 @@ abstract class Engine {
*/ */
protected function add_input_number( array $args ): void { protected function add_input_number( array $args ): void {
extract( $args ); extract( $args );
echo ( sprintf( echo ( sprintf(
'<input type="number" name="%s" id="%s"%s%s value="%s"%s%s%s/>', '<input type="number" name="%s" id="%s"%s%s value="%s"%s%s%s/>',
$name, $name,
$name, $name,
isset($max) ? ' max="'.$max.'"' : '', isset( $max ) ? ' max="' . $max . '"' : '',
isset($min) ? ' min="'.$min.'"' : '', isset( $min ) ? ' min="' . $min . '"' : '',
is_float($value) ? number_format( $value, 1 ) : $value, is_float( $value ) ? number_format( $value, 1 ) : $value,
is_float($value) ? ' step="0.1"' : '', is_float( $value ) ? ' step="0.1"' : '',
isset($readonly) ? ' readonly="readonly"' : '', isset( $readonly ) ? ' readonly="readonly"' : '',
$disabled ? ' disabled': '' $disabled ? ' disabled' : ''
) ); ) );
} }
@ -462,9 +451,11 @@ abstract class Engine {
*/ */
protected function add_select( array $args ): void { protected function add_select( array $args ): void {
extract( $args ); 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 = ''; $select_options = '';
// Loop through all array keys. // Loop through all array keys.
foreach ( $options as $option_value => $option_text ) { foreach ( $options as $option_value => $option_text ) {
@ -479,16 +470,16 @@ abstract class Engine {
$option_text $option_text
); );
} }
echo ( sprintf( echo ( sprintf(
'<select name="%s" id="%s"%s>%s</select>', '<select name="%s" id="%s"%s>%s</select>',
$name, $name,
$name, $name,
$disabled ? ' disabled': '', $disabled ? ' disabled' : '',
$select_options $select_options
) ); ) );
} }
/** /**
* Constructs the HTML for a checkbox 'input' element. * Constructs the HTML for a checkbox 'input' element.
* *
@ -501,16 +492,16 @@ abstract class Engine {
*/ */
protected function add_input_checkbox( array $args ): void { protected function add_input_checkbox( array $args ): void {
extract( $args ); extract( $args );
echo sprintf( echo sprintf(
'<input type="checkbox" name="%s" id="%s"%s%s/>', '<input type="checkbox" name="%s" id="%s"%s%s/>',
$name, $name,
$name, $name,
$value ? ' checked="checked"' : '', $value ? ' checked="checked"' : '',
$disabled ? ' disabled': '' $disabled ? ' disabled' : ''
); );
} }
/** /**
* Constructs the HTML for a color 'input' element. * Constructs the HTML for a color 'input' element.
* *
@ -523,19 +514,19 @@ abstract class Engine {
*/ */
protected function add_input_color( array $args ): void { protected function add_input_color( array $args ): void {
extract( $args ); extract( $args );
echo sprintf( echo sprintf(
'<input type="color" name="%s" id="%s"%s/>', '<input type="color" name="%s" id="%s"%s/>',
$name, $name,
$name, $name,
$disabled ? ' disabled': '' $disabled ? ' disabled' : ''
); );
} }
/****************************** /******************************
* OLD METHODS * OLD METHODS
******************************/ ******************************/
/** /**
* Registers all Meta boxes for a sub-page. * Registers all Meta boxes for a sub-page.
* *
@ -573,9 +564,9 @@ abstract class Engine {
wp_enqueue_script( 'wp-color-picker' ); wp_enqueue_script( 'wp-color-picker' );
} }
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing // phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing // phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
/** /**
* Save plugin settings. * Save plugin settings.
* *
@ -594,7 +585,7 @@ abstract class Engine {
foreach ( array_keys( $active_section->get_options() ) as $setting_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 ] ) : ''; $new_settings[ $setting_key ] = array_key_exists( $setting_key, $_POST ) ? wp_unslash( $_POST[ $setting_key ] ) : '';
} }
// Update settings. // Update settings.
return $this->settings->save_options_group( $active_section->get_options_group_slug(), $new_settings ); return $this->settings->save_options_group( $active_section->get_options_group_slug(), $new_settings );
} }

View file

@ -61,14 +61,14 @@ class Init {
* @since 2.8.0 * @since 2.8.0
*/ */
private string $plugin_name, private string $plugin_name,
/** /**
* The plugin settings object. * The plugin settings object.
* *
* @access private * @access private
* @since 2.8.0 * @since 2.8.0
*/ */
private Settings $settings private Settings $settings
) { ) {
$this->load_dependencies(); $this->load_dependencies();
@ -99,12 +99,12 @@ class Init {
* *
* @since 1.5.0 * @since 1.5.0
*/ */
public function initialize_settings(): void { public function initialize_settings(): void {
$this->settings->settings_sections['general']->add_settings_section(); $this->settings->settings_sections['general']->add_settings_section();
$this->settings->settings_sections['referrers_and_tooltips']->add_settings_section(); $this->settings->settings_sections['referrers_and_tooltips']->add_settings_section();
$this->settings->settings_sections['scope_and_priority']->add_settings_section(); $this->settings->settings_sections['scope_and_priority']->add_settings_section();
$this->settings->settings_sections['custom_css']->add_settings_section(); $this->settings->settings_sections['custom_css']->add_settings_section();
$this->settings_page->add_settings_sections(); $this->settings_page->add_settings_sections();
$this->settings_page->add_settings_fields(); $this->settings_page->add_settings_fields();
} }

View file

@ -53,16 +53,16 @@ class SettingsPage extends Engine {
* @since 2.8.0 * @since 2.8.0
*/ */
protected string $plugin_name, protected string $plugin_name,
/** /**
* The plugin settings object. * The plugin settings object.
* *
* @access private * @access private
* @since 2.8.0 * @since 2.8.0
*/ */
protected Settings $settings protected Settings $settings
) { ) {
} }
/** /**
* Returns a priority index. * Returns a priority index.
@ -75,67 +75,71 @@ class SettingsPage extends Engine {
public function get_priority(): int { public function get_priority(): int {
return 10; return 10;
} }
/************************************************************************** /**************************************************************************
* NEW METHODS * NEW METHODS
**************************************************************************/ **************************************************************************/
public function add_settings_fields(): void { public function add_settings_fields(): void {
$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 ]; $active_section = $this->sections[ $active_section_id ];
switch ($active_section->get_section_slug()) { switch ( $active_section->get_section_slug() ) {
case 'footnotes-settings': case 'footnotes-settings':
$this->settings->settings_sections['general']->add_settings_fields($this); $this->settings->settings_sections['general']->add_settings_fields( $this );
break; break;
case 'footnotes-customize': 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; break;
case 'footnotes-expert': 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; break;
case 'footnotes-customcss': case 'footnotes-customcss':
$this->settings->settings_sections['custom_css']->add_settings_fields($this); $this->settings->settings_sections['custom_css']->add_settings_fields( $this );
break; break;
case 'footnotes-how-to': case 'footnotes-how-to':
print_r("Demo goes here"); print_r( 'Demo goes here' );
break; break;
default: print_r("ERR: section not found"); default:
} print_r( 'ERR: section not found' );
}
} }
public function setting_field_callback( array $args ): void { public function setting_field_callback( array $args ): void {
if (isset($args['type'])) { if ( isset( $args['type'] ) ) {
echo $args['description'] . '</td><td>'; echo $args['description'] . '</td><td>';
switch($args['type']) { switch ( $args['type'] ) {
case 'text': case 'text':
$this->add_input_text($args); $this->add_input_text( $args );
return; return;
case 'textarea': case 'textarea':
$this->add_textarea($args); $this->add_textarea( $args );
return; return;
case 'number': case 'number':
$this->add_input_number($args); $this->add_input_number( $args );
return; return;
case 'select': case 'select':
$this->add_select($args); $this->add_select( $args );
return; return;
case 'checkbox': case 'checkbox':
$this->add_input_checkbox($args); $this->add_input_checkbox( $args );
return; return;
case 'color': case 'color':
$this->add_input_color($args); $this->add_input_color( $args );
return; 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 );
}
} }
/************************************************************************** /**************************************************************************
* NEW METHODS END * NEW METHODS END
**************************************************************************/ **************************************************************************/
/** /**
* Displays a short introduction to the plugin. * Displays a short introduction to the plugin.
* *

View file

@ -55,9 +55,11 @@ class Convert {
* @since 1.0-beta * @since 1.0-beta
* @todo Replace with built-in type casting. * @todo Replace with built-in type casting.
*/ */
public static function to_bool( string|null $value ): bool { public static function to_bool( ?string $value ): bool {
if (!$value) return false; if ( ! $value ) {
return false;
}
// Convert string to lower-case to make it easier. // Convert string to lower-case to make it easier.
$value = strtolower( $value ); $value = strtolower( $value );
// Check if string seems to contain a "true" value. // Check if string seems to contain a "true" value.
@ -86,7 +88,7 @@ class Convert {
public static function get_arrow( int $index = -1 ): string|array { public static function get_arrow( int $index = -1 ): string|array {
// Define all possible arrows. // Define all possible arrows.
$arrows = array( '&#8593;', '&#8613;', '&#8607;', '&#8617;', '&#8626;', '&#8629;', '&#8657;', '&#8673;', '&#8679;', '&#65514;' ); $arrows = array( '&#8593;', '&#8613;', '&#8607;', '&#8617;', '&#8626;', '&#8629;', '&#8657;', '&#8673;', '&#8679;', '&#65514;' );
// Return the whole arrow array. // Return the whole arrow array.
if ( $index < 0 ) { if ( $index < 0 ) {
return $arrows; return $arrows;

View file

@ -74,7 +74,7 @@ class Core {
* @var string $version The current version of the plugin. * @var string $version The current version of the plugin.
*/ */
protected string $version; protected string $version;
/** /**
* The plugin settings object. * The plugin settings object.
* *
@ -101,7 +101,7 @@ class Core {
$this->load_dependencies(); $this->load_dependencies();
$this->set_locale(); $this->set_locale();
$this->settings = new Settings(); $this->settings = new Settings();
$this->define_admin_hooks(); $this->define_admin_hooks();
$this->define_public_hooks(); $this->define_public_hooks();
} }
@ -123,9 +123,12 @@ class Core {
* *
* @since 2.8.0 * @since 2.8.0
*/ */
public function get_plugin_name(bool $html = false): string { public function get_plugin_name( bool $html = false ): string {
if ( ! $html ) return $this->plugin_name; if ( ! $html ) {
else return '<span class="footnotes_logo footnotes_logo_part1">foot</span><span class="footnotes_logo footnotes_logo_part2">notes</span>'; return $this->plugin_name;
} else {
return '<span class="footnotes_logo footnotes_logo_part1">foot</span><span class="footnotes_logo footnotes_logo_part2">notes</span>';
}
} }
/** /**
@ -145,7 +148,7 @@ class Core {
public function get_version(): string { public function get_version(): string {
return $this->version; return $this->version;
} }
/** /**
* Load the required dependencies for this plugin. * Load the required dependencies for this plugin.
* *

View file

@ -46,7 +46,7 @@ class Settings {
'footnotes_storage_expert', 'footnotes_storage_expert',
'footnotes_storage_custom_css', 'footnotes_storage_custom_css',
); );
/** /**
* Contains each section of settings. * Contains each section of settings.
* *
@ -61,17 +61,17 @@ class Settings {
* *
* @since 1.5.0 * @since 1.5.0
*/ */
public function __construct() { public function __construct() {
$this->load_dependencies(); $this->load_dependencies();
$this->settings_sections = array( $this->settings_sections = array(
'general' => new GeneralSettingsSection('footnotes_storage', 'footnotes-settings', 'General Settings', $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), '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), '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), 'custom_css' => new CustomCSSSettingsSection( 'footnotes_storage_custom_css', 'footnotes-customcss', 'Custom CSS', $this ),
); );
} }
/** /**
* Load the required dependencies for this file. * Load the required dependencies for this file.
* *
@ -92,40 +92,42 @@ class Settings {
* @return void * @return void
*/ */
protected function load_dependencies(): 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-settingssection.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-settings-group.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/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/general/class-generalsettingssection.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/referrers-and-tooltips/class-referrersandtooltipssettingssection.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/scope-and-priority/class-scopeandprioritysettingssection.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/custom-css/class-customcsssettingssection.php';
} }
/** /**
* Retrieve a setting by its key. * 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. * @return ?Setting Either the setting object, or `null` if none exists.
* *
* @since 2.8.0 * @since 2.8.0
* *
* @todo This is an _O(n)_ linear search. Explore more scaleable alternatives. * @todo This is an _O(n)_ linear search. Explore more scaleable alternatives.
*/ */
public function get_setting( string $setting_key ): ?Setting { public function get_setting( string $setting_key ): ?Setting {
foreach ($this->settings_sections as $settings_section) { foreach ( $this->settings_sections as $settings_section ) {
$setting = $settings_section->get_setting($setting_key); $setting = $settings_section->get_setting( $setting_key );
if ($setting) return $setting; if ( $setting ) {
return $setting;
}
} }
return null; return null;
} }
/** /**
* Retrieve a setting's value by its key. * 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. * @return mixed Either the setting's value, or `null` if the setting does not exist.
* *
* @since 2.8.0 * @since 2.8.0
@ -133,20 +135,22 @@ class Settings {
* @todo This is an _O(n)_ linear search. Explore more scaleable alternatives. * @todo This is an _O(n)_ linear search. Explore more scaleable alternatives.
* @todo How to handle settings with a value of `null`? * @todo How to handle settings with a value of `null`?
*/ */
public function get_setting_value( string $setting_key ): mixed { public function get_setting_value( string $setting_key ): mixed {
foreach ($this->settings_sections as $settings_section) { foreach ( $this->settings_sections as $settings_section ) {
$setting = $settings_section->get_setting($setting_key); $setting = $settings_section->get_setting( $setting_key );
if ($setting) return $setting->get_value(); if ( $setting ) {
return $setting->get_value();
}
} }
return null; return null;
} }
/** /**
* Retrieve a setting's default value by its key. * 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. * @return mixed Either the setting's default value, or `null` if the setting does not exist.
* *
* @since 2.8.0 * @since 2.8.0
@ -154,20 +158,22 @@ class Settings {
* @todo This is an _O(n)_ linear search. Explore more scaleable alternatives. * @todo This is an _O(n)_ linear search. Explore more scaleable alternatives.
* @todo How to handle settings with a default value of `null`? * @todo How to handle settings with a default value of `null`?
*/ */
public function get_setting_default_value( string $setting_key ): mixed { public function get_setting_default_value( string $setting_key ): mixed {
foreach ($this->settings_sections as $settings_section) { foreach ( $this->settings_sections as $settings_section ) {
$setting = $settings_section->get_setting($setting_key); $setting = $settings_section->get_setting( $setting_key );
if ($setting) return $setting->get_default_value(); if ( $setting ) {
return $setting->get_default_value();
}
} }
return null; return null;
} }
/** /**
* Set a setting's value by its key. * 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. * @param mixed $setting_value The new value to set.
* @return mixed 'True' if the value was successfully set. 'False' otherwise. * @return mixed 'True' if the value was successfully set. 'False' otherwise.
* *
@ -176,13 +182,15 @@ class Settings {
* @todo This is an _O(n)_ linear search. Explore more scaleable alternatives. * @todo This is an _O(n)_ linear search. Explore more scaleable alternatives.
* @todo How to handle settings with a value of `null`? * @todo How to handle settings with a value of `null`?
*/ */
public function set_setting_value( string $setting_key, mixed $setting_value ): ?bool { public function set_setting_value( string $setting_key, $setting_value ): ?bool {
foreach ($this->settings_sections as $settings_section) { foreach ( $this->settings_sections as $settings_section ) {
$setting = $settings_section->get_setting($setting_key); $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; return false;
} }
@ -202,7 +210,7 @@ class Settings {
/** /**
* Updates a whole Setting Container on save. * 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). * @param array $new_values The new Settings value(s).
* *
* @since 1.5.0 * @since 1.5.0
@ -210,8 +218,8 @@ class Settings {
*/ */
public function save_options_group( string $options_group_slug, array $new_values ): bool { public function save_options_group( string $options_group_slug, array $new_values ): bool {
if ( update_option( $options_group_slug, $new_values ) ) { if ( update_option( $options_group_slug, $new_values ) ) {
foreach ($this->settings_sections as $settings_section) { foreach ( $this->settings_sections as $settings_section ) {
if ($settings_section->get_options_group_slug() === $options_group_slug) { if ( $settings_section->get_options_group_slug() === $options_group_slug ) {
$settings_section->load_options_group(); $settings_section->load_options_group();
} }
} }
@ -219,7 +227,7 @@ class Settings {
} }
return false; return false;
} }
/** /**
* Loads all settings from each option group. * Loads all settings from each option group.
* *
@ -227,16 +235,16 @@ class Settings {
* @since 2.8.0 Renamed from `load_all()` to `load_options_groups()`. * @since 2.8.0 Renamed from `load_all()` to `load_options_groups()`.
*/ */
protected function load_options_groups(): void { protected function load_options_groups(): void {
foreach ($this->options_group_slug as $options_group_slug) { foreach ( $this->options_group_slug as $options_group_slug ) {
$options_group = get_option($options_group_slug); $options_group = get_option( $options_group_slug );
if (!! $options_group) { if ( ! ! $options_group ) {
foreach ($this->settings_sections as $settings_section) { foreach ( $this->settings_sections as $settings_section ) {
if ($settings_section->get_options_group_slug() === $options_group_slug) { if ( $settings_section->get_options_group_slug() === $options_group_slug ) {
$settings_section->load_options_group(); $settings_section->load_options_group();
} }
} }
} }
} }
} }
} }

View file

@ -18,7 +18,7 @@ use footnotes\includes\{Core, Settings};
* @package footnotes * @package footnotes
* @since 2.8.0 * @since 2.8.0
*/ */
class Setting { class Setting {
/** /**
* Options for the custom width units (per cent is a ratio, not a unit). * Options for the custom width units (per cent is a ratio, not a unit).
* *
@ -33,7 +33,7 @@ class Setting {
'em' => 'em', 'em' => 'em',
'vw' => 'viewport width', 'vw' => 'viewport width',
); );
/** /**
* Options for the custom font size units (per cent is a ratio, not a unit). * Options for the custom font size units (per cent is a ratio, not a unit).
* *
@ -41,16 +41,16 @@ class Setting {
* *
* @since 2.8.0 * @since 2.8.0
*/ */
const FONT_SIZE_UNIT_OPTIONS = array( const FONT_SIZE_UNIT_OPTIONS = array(
'em' => 'em', 'em' => 'em',
'rem' => 'rem', 'rem' => 'rem',
'px' => 'pixels', 'px' => 'pixels',
'pt' => 'points', 'pt' => 'points',
'pc' => 'picas', 'pc' => 'picas',
'mm' => 'millimeters', 'mm' => 'millimeters',
'%' => 'per cent', '%' => 'per cent',
); );
/** /**
* Options for the HTML text elements. * Options for the HTML text elements.
* *
@ -59,14 +59,14 @@ class Setting {
* @since 2.8.0 * @since 2.8.0
*/ */
const TEXT_ELEMENT_OPTIONS = array( const TEXT_ELEMENT_OPTIONS = array(
'p' => 'paragraph', 'p' => 'paragraph',
'h2' => 'heading 2', 'h2' => 'heading 2',
'h3' => 'heading 3', 'h3' => 'heading 3',
'h4' => 'heading 4', 'h4' => 'heading 4',
'h5' => 'heading 5', 'h5' => 'heading 5',
'h6' => 'heading 6', 'h6' => 'heading 6',
); );
/** /**
* Setting value. * Setting value.
* *
@ -74,7 +74,7 @@ class Setting {
* *
* @since 2.8.0 * @since 2.8.0
*/ */
protected mixed $value; protected $value;
/** /**
* Constructs the setting. * Constructs the setting.
@ -97,7 +97,7 @@ class Setting {
* *
* @since 2.8.0 * @since 2.8.0
*/ */
private string $options_group_slug, private string $options_group_slug,
/** /**
* Setting section slug. * Setting section slug.
* *
@ -106,7 +106,7 @@ class Setting {
* @since 2.8.0 * @since 2.8.0
*/ */
private string $section_slug, private string $section_slug,
/** /**
* Setting slug. * Setting slug.
* *
@ -124,7 +124,7 @@ class Setting {
* @since 2.8.0 * @since 2.8.0
*/ */
public string $name, public string $name,
/** /**
* Setting description. * Setting description.
* *
@ -133,7 +133,7 @@ class Setting {
* @since 2.8.0 * @since 2.8.0
*/ */
public ?string $description, public ?string $description,
/** /**
* Setting default value. * Setting default value.
* *
@ -142,7 +142,7 @@ class Setting {
* @since 2.8.0 * @since 2.8.0
*/ */
private mixed $default_value, private mixed $default_value,
/** /**
* Setting data type. * Setting data type.
* *
@ -151,7 +151,7 @@ class Setting {
* @since 2.8.0 * @since 2.8.0
*/ */
private string $type, private string $type,
/** /**
* Setting input field type. * Setting input field type.
* *
@ -160,7 +160,7 @@ class Setting {
* @since 2.8.0 * @since 2.8.0
*/ */
private string $input_type, private string $input_type,
/** /**
* Setting input field options (for 'select' inputs). * Setting input field options (for 'select' inputs).
* *
@ -169,7 +169,7 @@ class Setting {
* @since 2.8.0 * @since 2.8.0
*/ */
private ?array $input_options, private ?array $input_options,
/** /**
* Setting input field max. value (for 'number' inputs). * Setting input field max. value (for 'number' inputs).
* *
@ -178,7 +178,7 @@ class Setting {
* @since 2.8.0 * @since 2.8.0
*/ */
private int|float|null $input_max, private int|float|null $input_max,
/** /**
* Setting input field min. value (for 'number' inputs). * Setting input field min. value (for 'number' inputs).
* *
@ -187,7 +187,7 @@ class Setting {
* @since 2.8.0 * @since 2.8.0
*/ */
private int|float|null $input_min, private int|float|null $input_min,
/** /**
* The setting for whether this setting is enabled or not. * The setting for whether this setting is enabled or not.
* *
@ -196,7 +196,7 @@ class Setting {
* @since 2.8.0 * @since 2.8.0
*/ */
private ?string $enabled_by, private ?string $enabled_by,
/** /**
* Any setting that overrides this setting. * Any setting that overrides this setting.
* *
@ -204,8 +204,8 @@ class Setting {
* *
* @since 2.8.0 * @since 2.8.0
*/ */
private ?string $overridden_by, private ?string $overridden_by,
/** /**
* The plugin settings object. * The plugin settings object.
* *
@ -216,10 +216,10 @@ class Setting {
private Settings $settings private Settings $settings
) { ) {
$this->value = $this->default_value; $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() );
} }
/** /**
* Get the args for registering the settings with WordPress. * Get the args for registering the settings with WordPress.
* *
@ -230,13 +230,13 @@ class Setting {
* @since 2.8.0 * @since 2.8.0
*/ */
public function get_setting_args(): array { public function get_setting_args(): array {
return array ( return array(
'type' => $this->type, 'type' => $this->type,
'description' => $this->description, 'description' => $this->description,
'default' => $this->default_value, 'default' => $this->default_value,
); );
} }
/** /**
* Get the args for rendering setting fields on the admin. dashboard. * Get the args for rendering setting fields on the admin. dashboard.
* *
@ -247,19 +247,19 @@ class Setting {
* @since 2.8.0 * @since 2.8.0
*/ */
public function get_setting_field_args(): array { public function get_setting_field_args(): array {
return array ( return array(
'name' => $this->key, 'name' => $this->key,
'label_for' => $this->key, 'label_for' => $this->key,
'value' => $this->value, 'value' => $this->value,
'description' => $this->description, 'description' => $this->description,
'type' => $this->input_type, 'type' => $this->input_type,
'options' => $this->input_options, 'options' => $this->input_options,
'max' => $this->input_max, 'max' => $this->input_max,
'min' => $this->input_min, 'min' => $this->input_min,
'disabled' => $this->is_disabled_or_overridden() 'disabled' => $this->is_disabled_or_overridden(),
); );
} }
/** /**
* Check whether a setting is enabled and/or overridden. * Check whether a setting is enabled and/or overridden.
* *
@ -269,28 +269,36 @@ class Setting {
* *
* @since 2.8.0 * @since 2.8.0
*/ */
private function is_disabled_or_overridden(): ?bool { private function is_disabled_or_overridden(): ?bool {
if (isset($this->enabled_by)) { if ( isset( $this->enabled_by ) ) {
$enabled_by_value = $this->settings->get_setting_value($this->enabled_by); $enabled_by_value = $this->settings->get_setting_value( $this->enabled_by );
$is_enabled = (isset($enabled_by_value) || 'userdefined' === $enabled_by_value); $is_enabled = ( isset( $enabled_by_value ) || 'userdefined' === $enabled_by_value );
} }
if (isset($this->overridden_by)) { if ( isset( $this->overridden_by ) ) {
$overridden_by_value = $this->settings->get_setting_value($this->overridden_by); $overridden_by_value = $this->settings->get_setting_value( $this->overridden_by );
$is_overridden = !(null === $overridden_by_value || '' === $overridden_by_value); $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 ) && $is_enabled && ( isset( $is_overridden ) && ! $is_overridden ) ) {
return false;
}
if ( isset( $is_overridden ) && $is_overridden ) {
return true;
}
return false;
} else {
return null;
} }
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_overridden) && $is_overridden) return true;
return false;
} else return null;
} }
/** /**
* Gets the slug of the setting's options group. * Gets the slug of the setting's options group.
* *
@ -301,7 +309,7 @@ class Setting {
public function get_options_group_slug(): string { public function get_options_group_slug(): string {
return $this->options_group_slug; return $this->options_group_slug;
} }
/** /**
* Gets the slug of the setting's section. * Gets the slug of the setting's section.
* *
@ -312,7 +320,7 @@ class Setting {
public function get_section_slug(): string { public function get_section_slug(): string {
return $this->section_slug; return $this->section_slug;
} }
/** /**
* Gets the value of the setting. * Gets the value of the setting.
* *
@ -323,7 +331,7 @@ class Setting {
public function get_value(): mixed { public function get_value(): mixed {
return $this->value ?? $this->default_value ?? null; return $this->value ?? $this->default_value ?? null;
} }
/** /**
* Gets the default value of the setting. * Gets the default value of the setting.
* *
@ -334,7 +342,7 @@ class Setting {
public function get_default_value(): mixed { public function get_default_value(): mixed {
return $this->default_value ?? null; return $this->default_value ?? null;
} }
/** /**
* Gets the input options of the setting. * Gets the input options of the setting.
* *
@ -345,7 +353,7 @@ class Setting {
public function get_input_options(): ?array { public function get_input_options(): ?array {
return $this->input_options ?? null; return $this->input_options ?? null;
} }
/** /**
* Sets the value of the setting. * Sets the value of the setting.
* *
@ -354,7 +362,7 @@ class Setting {
* *
* @since 2.8.0 * @since 2.8.0
*/ */
public function set_value(mixed $value): bool { public function set_value( $value ): bool {
$this->value = $value; $this->value = $value;
return true; return true;
} }

View file

@ -16,10 +16,14 @@ use footnotes\admin\layout\SettingsPage;
/** /**
* Class defining a group of plugin settings within a section. * 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 * @package footnotes
* @since 2.8.0 * @since 2.8.0
*/ */
abstract class SettingsGroup { abstract class SettingsGroup {
/** /**
* Setting group ID. * Setting group ID.
* *
@ -28,7 +32,7 @@ abstract class SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'undefined'; const GROUP_ID = 'undefined';
/** /**
* Setting group name. * Setting group name.
* *
@ -37,7 +41,7 @@ abstract class SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_NAME = 'undefined'; const GROUP_NAME = 'undefined';
/** /**
* The setting classes. * The setting classes.
* *
@ -46,7 +50,7 @@ abstract class SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
protected array $setting_classes; protected array $setting_classes;
/** /**
* The settings in this group. * The settings in this group.
* *
@ -55,7 +59,7 @@ abstract class SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
protected array $settings; protected array $settings;
/** /**
* Constructs the settings section. * Constructs the settings section.
* *
@ -69,8 +73,8 @@ abstract class SettingsGroup {
* *
* @since 2.8.0 * @since 2.8.0
*/ */
protected string $options_group_slug, protected string $options_group_slug,
/** /**
* Setting section slug. * Setting section slug.
* *
@ -79,7 +83,7 @@ abstract class SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
protected string $section_slug, protected string $section_slug,
/** /**
* The plugin settings object. * The plugin settings object.
* *
@ -87,12 +91,12 @@ abstract class SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
protected Settings $settings_obj protected Settings $settings_obj
) { ) {
$this->load_dependencies(); $this->load_dependencies();
$this->add_settings( get_option( $this->options_group_slug ) ); $this->add_settings( get_option( $this->options_group_slug ) );
} }
/** /**
* Load the required dependencies. * Load the required dependencies.
* *
@ -105,32 +109,32 @@ abstract class SettingsGroup {
protected function load_dependencies(): void { protected function load_dependencies(): void {
require_once plugin_dir_path( __DIR__ ) . 'settings/class-setting.php'; require_once plugin_dir_path( __DIR__ ) . 'settings/class-setting.php';
} }
/** /**
* Add the settings for this settings group. * Add the settings for this settings group.
* *
* @abstract * @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 * @return void
* *
* @since 2.8.0 * @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. * 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. * @return Setting The constructed setting object.
* *
* @since 2.8.0 * @since 2.8.0
*/ */
protected function add_setting(array $setting): Setting { protected function add_setting( array $setting ): Setting {
extract( $setting ); extract( $setting );
return new Setting( return new Setting(
self::GROUP_ID, self::GROUP_ID,
$this->options_group_slug, $this->options_group_slug,
$this->section_slug, $this->section_slug,
$key, $key,
$name, $name,
@ -146,84 +150,100 @@ abstract class SettingsGroup {
$this->settings_obj $this->settings_obj
); );
} }
/** /**
* Load the values for this settings group. * 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 * @return void
* *
* @since 2.8.0 * @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 { protected function load_values( array|false $options ): void {
if ( ! $options ) return; if ( ! $options ) {
return;
}
foreach ( $options as $setting_key => $setting_value ) { foreach ( $options as $setting_key => $setting_value ) {
if ( array_key_exists( $setting_key, $this->settings ) ) if ( array_key_exists( $setting_key, $this->settings ) ) {
$this->settings[$setting_key]->set_value( $setting_value ); $this->settings[ $setting_key ]->set_value( $setting_value );
} }
}
} }
/** /**
* Adds all the settings fields for this group to the admin. dashboard. * 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 * @return void
* *
* @since 2.8.0 * @since 2.8.0
*/ */
public function add_settings_fields(SettingsPage $component): void { public function add_settings_fields( SettingsPage $component ): void {
foreach ($this->settings as $setting) { foreach ( $this->settings as $setting ) {
add_settings_field( add_settings_field(
$setting->key, $setting->key,
__( $setting->name, 'footnotes' ), __( $setting->name, 'footnotes' ),
array ($component, 'setting_field_callback'), array( $component, 'setting_field_callback' ),
'footnotes', 'footnotes',
$setting->get_section_slug(), $setting->get_section_slug(),
$setting->get_setting_field_args() $setting->get_setting_field_args()
); );
} }
} }
/** /**
* Retrieve a setting by its key.
*
* @see Settings::get_setting() * @see Settings::get_setting()
*/ */
public function get_setting(string $setting_key): ?Setting { public function get_setting( string $setting_key ): ?Setting {
foreach ($this->settings as $setting) { foreach ( $this->settings as $setting ) {
if ($setting->key === $setting_key) return $setting; if ( $setting->key === $setting_key ) {
return $setting;
}
} }
return null; return null;
} }
/** /**
* Creates an options group from the values of the settings in this section.
*
* @see SettingsSection::get_options() * @see SettingsSection::get_options()
*/ */
public function get_options(): array { public function get_options(): array {
$options = array(); $options = array();
foreach ($this->settings as $setting) { foreach ( $this->settings as $setting ) {
$options[$setting->key] = $setting->get_value(); $options[ $setting->key ] = $setting->get_value();
} }
return $options; return $options;
} }
/** /**
* Get a setting's value by its key.
*
* @see Settings::get_setting_value() * @see Settings::get_setting_value()
*/ */
public function get_setting_value(string $setting_key) { public function get_setting_value( string $setting_key ) {
$setting = $this->get_setting($setting_key); $setting = $this->get_setting( $setting_key );
if (! $setting) return null; if ( ! $setting ) {
else return $setting->value ?? $setting->default_value; return null;
} else {
return $setting->value ?? $setting->default_value;
}
} }
/** /**
* Set a setting's value by its key.
*
* @see Settings::set_setting_value() * @see Settings::set_setting_value()
*/ */
public function set_setting_value(string $setting_key, $value): bool { public function set_setting_value( string $setting_key, $value ): bool {
return $this->get_setting($setting_key)->set_value($value); return $this->get_setting( $setting_key )->set_value( $value );
} }
} }

View file

@ -21,7 +21,7 @@ use footnotes\admin\layout as Layout;
* @package footnotes * @package footnotes
* @since 2.8.0 * @since 2.8.0
*/ */
abstract class SettingsSection { abstract class SettingsSection {
/** /**
* Setting options group slug. * Setting options group slug.
* *
@ -30,7 +30,7 @@ abstract class SettingsSection {
* @since 2.8.0 * @since 2.8.0
*/ */
protected string $options_group_slug; protected string $options_group_slug;
/** /**
* Settings section slug. * Settings section slug.
* *
@ -39,7 +39,7 @@ abstract class SettingsSection {
* @since 2.8.0 * @since 2.8.0
*/ */
protected string $section_slug = ''; protected string $section_slug = '';
/** /**
* Settings section title. * Settings section title.
* *
@ -48,7 +48,7 @@ abstract class SettingsSection {
* @since 2.8.0 * @since 2.8.0
*/ */
protected string $title = ''; protected string $title = '';
/** /**
* The groups of settings within this section. * The groups of settings within this section.
* *
@ -57,7 +57,7 @@ abstract class SettingsSection {
* @since 2.8.0 * @since 2.8.0
*/ */
protected array $settings_groups; protected array $settings_groups;
/** /**
* Load the required dependencies. * Load the required dependencies.
* *
@ -70,36 +70,36 @@ abstract class SettingsSection {
protected function load_dependencies(): void { protected function load_dependencies(): void {
require_once plugin_dir_path( __DIR__ ) . 'settings/class-setting.php'; require_once plugin_dir_path( __DIR__ ) . 'settings/class-setting.php';
} }
public function load_options_group(): void { 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) { if ( ! ! $options_group ) {
foreach ($options_group as $setting_key => $setting_value) { foreach ( $options_group as $setting_key => $setting_value ) {
$this->set_setting_value($setting_key, $setting_value); $this->set_setting_value( $setting_key, $setting_value );
} }
} }
} }
public function add_settings_section(): void { public function add_settings_section(): void {
add_settings_section( add_settings_section(
$this->section_slug, $this->section_slug,
__( $this->title, 'footnotes'), __( $this->title, 'footnotes' ),
array($this, 'setting_section_callback'), array( $this, 'setting_section_callback' ),
'footnotes' 'footnotes'
); );
} }
public function add_settings_fields($component): void { public function add_settings_fields( $component ): void {
foreach($this->settings_groups as $settings_group) { foreach ( $this->settings_groups as $settings_group ) {
$settings_group->add_settings_fields($component); $settings_group->add_settings_fields( $component );
} }
} }
public function setting_section_callback(): void { public function setting_section_callback(): void {
echo "<hr>"; echo '<hr>';
} }
/** /**
* Add the settings groups for this settings section. * Add the settings groups for this settings section.
* *
@ -108,12 +108,12 @@ abstract class SettingsSection {
* *
* @since 2.8.0 * @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 { public function get_options_group_slug(): string {
return $this->options_group_slug; return $this->options_group_slug;
} }
/** /**
* Gets the settings section slug. * Gets the settings section slug.
* *
@ -124,7 +124,7 @@ abstract class SettingsSection {
public function get_section_slug(): string { public function get_section_slug(): string {
return $this->section_slug; return $this->section_slug;
} }
/** /**
* Gets the settings section title. * Gets the settings section title.
* *
@ -135,32 +135,36 @@ abstract class SettingsSection {
public function get_title(): string { public function get_title(): string {
return $this->title; return $this->title;
} }
/** /**
* Gets a settings groups from this section by its ID. * 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. * @return ?SettingsGroup The section group. 'None' if none found.
* *
* @since 2.8.0 * @since 2.8.0
*/ */
public function get_settings_group(string $group_id): ?SettingsGroup { public function get_settings_group( string $group_id ): ?SettingsGroup {
return $this->settings_groups[$group_id] ?? null; return $this->settings_groups[ $group_id ] ?? null;
} }
/** /**
* Retrieve a setting by its key.
*
* @see Settings::get_setting() * @see Settings::get_setting()
*/ */
public function get_setting(string $setting_key): ?Setting { public function get_setting( string $setting_key ): ?Setting {
foreach ($this->settings_groups as $settings_group) { foreach ( $this->settings_groups as $settings_group ) {
$setting = $settings_group->get_setting($setting_key); $setting = $settings_group->get_setting( $setting_key );
if ($setting) return $setting; if ( $setting ) {
return $setting;
}
} }
return null; return null;
} }
/** /**
* Creates an options group from the values of the settings in this section. * Creates an options group from the values of the settings in this section.
* *
@ -170,31 +174,41 @@ abstract class SettingsSection {
*/ */
public function get_options(): array { public function get_options(): array {
$options = array(); $options = array();
foreach ($this->settings_groups as $settings_group) { foreach ( $this->settings_groups as $settings_group ) {
$options = array_merge($options, $settings_group->get_options()); $options = array_merge( $options, $settings_group->get_options() );
} }
return $options; return $options;
} }
/** /**
* Retrieve a setting's default value by its key.
*
* @see Settings::get_setting_value() * @see Settings::get_setting_value()
*/ */
public function get_setting_value(string $setting_key) { public function get_setting_value( string $setting_key ) {
$setting = $this->get_setting($setting_key); $setting = $this->get_setting( $setting_key );
if (! $setting) return null; if ( ! $setting ) {
else return $setting->value ?? $setting->default_value ?? trigger_error("No default value found for ".$setting_key.".", E_USER_ERROR); 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() * @see Settings::set_setting_value()
*/ */
public function set_setting_value(string $setting_key, $value): ?bool { public function set_setting_value( string $setting_key, $value ): ?bool {
$setting = $this->get_setting($setting_key); $setting = $this->get_setting( $setting_key );
if (! $setting) return null; if ( ! $setting ) {
else return $setting->set_value($value); return null;
} else {
return $setting->set_value( $value );
}
} }
} }

View file

@ -29,7 +29,7 @@ class CustomCSSSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
public const GROUP_ID = 'custom-css'; public const GROUP_ID = 'custom-css';
/** /**
* Setting group name. * Setting group name.
* *
@ -49,28 +49,15 @@ class CustomCSSSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
public const CUSTOM_CSS = array( public const CUSTOM_CSS = array(
'key' => 'footnote_inputfield_custom_css_new', 'key' => 'footnote_inputfield_custom_css_new',
'name' => 'Your Existing Custom CSS Code', 'name' => 'Your Existing Custom CSS Code',
'type' => 'string', 'type' => 'string',
'input_type' => 'textarea', '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() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {

View file

@ -22,7 +22,7 @@ use footnotes\includes\settings\customcss\CustomCSSSettingsGroup;
* @package footnotes * @package footnotes
* @since 2.8.0 * @since 2.8.0
*/ */
class CustomCSSSettingsSection extends SettingsSection { class CustomCSSSettingsSection extends SettingsSection {
/** /**
* The groups of settings within this section. * The groups of settings within this section.
* *
@ -31,13 +31,13 @@ class CustomCSSSettingsSection extends SettingsSection {
* @since 2.8.0 * @since 2.8.0
*/ */
protected array $settings_groups; protected array $settings_groups;
/** /**
* Constructs the settings section. * Constructs the settings section.
* *
* @param string options_group_slug The slug of the settings section's options group. * @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 $section_slug The slug of the settings section.
* @param string title The name of the settings section. * @param string $title The name of the settings section.
* *
* @since 2.8.0 * @since 2.8.0
*/ */
@ -45,7 +45,7 @@ class CustomCSSSettingsSection extends SettingsSection {
$options_group_slug, $options_group_slug,
$section_slug, $section_slug,
$title, $title,
/** /**
* The plugin settings object. * The plugin settings object.
* *
@ -55,12 +55,12 @@ class CustomCSSSettingsSection extends SettingsSection {
private Settings $settings private Settings $settings
) { ) {
$this->options_group_slug = $options_group_slug; $this->options_group_slug = $options_group_slug;
$this->section_slug = $section_slug; $this->section_slug = $section_slug;
$this->title = $title; $this->title = $title;
$this->load_dependencies(); $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(); $this->load_options_group();
} }
@ -76,19 +76,19 @@ class CustomCSSSettingsSection extends SettingsSection {
* @see SettingsSection::load_dependencies() * @see SettingsSection::load_dependencies()
*/ */
protected function load_dependencies(): void { 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-customcsssettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'custom-css/class-custom-css-settings-group.php';
} }
/** /**
* Add the settings groups for this settings section.
*
* @see SettingsSection::add_settings_groups() * @see SettingsSection::add_settings_groups()
*/ */
protected function add_settings_groups(): void { protected function add_settings_groups(): void {
$this->settings_groups = array ( $this->settings_groups = array(
CustomCSSSettingsGroup::GROUP_ID => new CustomCSSSettingsGroup($this->options_group_slug, $this->section_slug, $this->settings ), CustomCSSSettingsGroup::GROUP_ID => new CustomCSSSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
); );
} }
} }

View file

@ -32,7 +32,7 @@ class AMPCompatSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'amp-compat'; const GROUP_ID = 'amp-compat';
/** /**
* Setting group name. * Setting group name.
* *
@ -60,8 +60,10 @@ class AMPCompatSettingsGroup extends SettingsGroup {
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox', 'input_type' => 'checkbox',
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {

View file

@ -22,7 +22,7 @@ use footnotes\includes\settings\SettingsGroup;
* @since 2.8.0 * @since 2.8.0
*/ */
class ExcerptsSettingsGroup extends SettingsGroup { class ExcerptsSettingsGroup extends SettingsGroup {
/** /**
* Setting group ID. * Setting group ID.
* *
* @var string * @var string
@ -30,7 +30,7 @@ class ExcerptsSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'excerpts'; const GROUP_ID = 'excerpts';
/** /**
* Setting group name. * Setting group name.
* *
@ -59,11 +59,13 @@ class ExcerptsSettingsGroup extends SettingsGroup {
'input_options' => array( 'input_options' => array(
'yes' => 'Yes, generate excerpts from posts with effectively processed footnotes and other markup', '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', '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() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {

View file

@ -41,9 +41,9 @@ class GeneralSettingsSection extends SettingsSection {
/** /**
* Constructs the settings section. * Constructs the settings section.
* *
* @param string options_group_slug The slug of the settings section's options group. * @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 $section_slug The slug of the settings section.
* @param string title The name of the settings section. * @param string $title The name of the settings section.
* *
* @since 2.8.0 * @since 2.8.0
*/ */
@ -51,7 +51,7 @@ class GeneralSettingsSection extends SettingsSection {
$options_group_slug, $options_group_slug,
$section_slug, $section_slug,
$title, $title,
/** /**
* The plugin settings object. * The plugin settings object.
* *
@ -91,17 +91,19 @@ class GeneralSettingsSection extends SettingsSection {
protected function load_dependencies(): void { protected function load_dependencies(): void {
parent::load_dependencies(); parent::load_dependencies();
require_once plugin_dir_path( __DIR__ ) . 'general/class-reference-container-settings-group.php'; require_once plugin_dir_path( __DIR__ ) . 'general/class-referencecontainersettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-scrolling-settings-group.php'; require_once plugin_dir_path( __DIR__ ) . 'general/class-scrollingsettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-shortcode-settings-group.php'; require_once plugin_dir_path( __DIR__ ) . 'general/class-shortcodesettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-numbering-settings-group.php'; require_once plugin_dir_path( __DIR__ ) . 'general/class-numberingsettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-hard-links-settings-group.php'; require_once plugin_dir_path( __DIR__ ) . 'general/class-hardlinkssettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-love-settings-group.php'; require_once plugin_dir_path( __DIR__ ) . 'general/class-lovesettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-excerpts-settings-group.php'; require_once plugin_dir_path( __DIR__ ) . 'general/class-excerptssettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'general/class-amp-compat-settings-group.php'; require_once plugin_dir_path( __DIR__ ) . 'general/class-ampcompatsettingsgroup.php';
} }
/** /**
* Add the settings groups for this settings section.
*
* @see SettingsSection::add_settings_groups() * @see SettingsSection::add_settings_groups()
*/ */
protected function add_settings_groups(): void { protected function add_settings_groups(): void {

View file

@ -29,7 +29,7 @@ class HardLinksSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'hard-links'; const GROUP_ID = 'hard-links';
/** /**
* Setting group name. * Setting group name.
* *
@ -157,18 +157,20 @@ class HardLinksSettingsGroup extends SettingsGroup {
'type' => 'string', 'type' => 'string',
'input_type' => 'text', 'input_type' => 'text',
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {
$this->settings = array( $this->settings = array(
self::FOOTNOTES_HARD_LINKS_ENABLE['key'] => $this->add_setting( self::FOOTNOTES_HARD_LINKS_ENABLE ), 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::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::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::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_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 ); $this->load_values( $options );

View file

@ -30,7 +30,7 @@ class LoveSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const LOVE_SYMBOL = '<span style="color:#ff6d3b; font-weight:bold;">&hearts;</span>'; const LOVE_SYMBOL = '<span style="color:#ff6d3b; font-weight:bold;">&hearts;</span>';
/** /**
* The HTML Plugin logogram. * The HTML Plugin logogram.
* *
@ -39,7 +39,7 @@ class LoveSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const PLUGIN_SYMBOL = '<span class="footnotes_logo footnotes_logo_part1">foot</span><span class="footnotes_logo footnotes_logo_part2">notes</span>'; const PLUGIN_SYMBOL = '<span class="footnotes_logo footnotes_logo_part1">foot</span><span class="footnotes_logo footnotes_logo_part2">notes</span>';
/** /**
* Setting group ID. * Setting group ID.
* *
@ -48,7 +48,7 @@ class LoveSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'love'; const GROUP_ID = 'love';
/** /**
* Setting group name. * Setting group name.
* *
@ -74,7 +74,7 @@ class LoveSettingsGroup extends SettingsGroup {
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => array( 'input_options' => array(
// Logo only. // Logo only.
'text-3' => self::PLUGIN_SYMBOL, 'text-3' => self::PLUGIN_SYMBOL,
// Logo followed by heart symbol. // Logo followed by heart symbol.
'text-4' => self::PLUGIN_SYMBOL . ' ' . self::LOVE_SYMBOL, 'text-4' => self::PLUGIN_SYMBOL . ' ' . self::LOVE_SYMBOL,
@ -93,9 +93,9 @@ class LoveSettingsGroup extends SettingsGroup {
'no' => 'no display of any mention in the footer', 'no' => 'no display of any mention in the footer',
), ),
); );
/** /**
* Settings container key for the shortcode to NOT display the LOVE ME slug * Settings container key for the shortcode to NOT display the LOVE ME slug
* on certain pages. * on certain pages.
* *
* @var array * @var array
@ -112,13 +112,15 @@ class LoveSettingsGroup extends SettingsGroup {
'type' => 'string', 'type' => 'string',
'input_type' => 'text', 'input_type' => 'text',
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {
$this->settings = array( $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 ), self::FOOTNOTES_NO_LOVE_SLUG['key'] => $this->add_setting( self::FOOTNOTES_NO_LOVE_SLUG ),
); );

View file

@ -29,7 +29,7 @@ class NumberingSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'numbering'; const GROUP_ID = 'numbering';
/** /**
* Setting group name. * Setting group name.
* *
@ -42,7 +42,7 @@ class NumberingSettingsGroup extends SettingsGroup {
/** /**
* Settings container key for combining identical footnotes. * Settings container key for combining identical footnotes.
* *
* @link https://wordpress.org/support/topic/add-support-for-ibid-notation * @link https://wordpress.org/support/topic/add-support-for-ibid-notation
* Support for Ibid. notation added thanks to @meglio. * Support for Ibid. notation added thanks to @meglio.
* *
* @var array * @var array
@ -60,7 +60,7 @@ class NumberingSettingsGroup extends SettingsGroup {
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox', 'input_type' => 'checkbox',
); );
/** /**
* Settings container key for the counter style of the footnotes. * Settings container key for the counter style of the footnotes.
* *
@ -77,7 +77,7 @@ class NumberingSettingsGroup extends SettingsGroup {
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => array( 'input_options' => array(
'arabic_plain' => 'plain Arabic numbers (1, 2, 3, 4, 5, &hellip;)', 'arabic_plain' => 'plain Arabic numbers (1, 2, 3, 4, 5, &hellip;)',
'arabic_leading' => 'zero-padded Arabic numbers (01, 02, 03, 04, 05, &hellip;)', 'arabic_leading' => 'zero-padded Arabic numbers (01, 02, 03, 04, 05, &hellip;)',
'latin_low' => 'lowercase Latin letters (a, b, c, d, e, &hellip;)', 'latin_low' => 'lowercase Latin letters (a, b, c, d, e, &hellip;)',
'latin_high' => 'uppercase Latin letters (A, B, C, D, E, &hellip;)', 'latin_high' => 'uppercase Latin letters (A, B, C, D, E, &hellip;)',
@ -85,14 +85,16 @@ class NumberingSettingsGroup extends SettingsGroup {
'roman_low' => 'lowercase Roman numerals (i, ii, iii, iv, v, &hellip;)', 'roman_low' => 'lowercase Roman numerals (i, ii, iii, iv, v, &hellip;)',
), ),
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {
$this->settings = array( $this->settings = array(
self::COMBINE_IDENTICAL_FOOTNOTES['key'] => $this->add_setting( self::COMBINE_IDENTICAL_FOOTNOTES ), 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 ); $this->load_values( $options );

View file

@ -29,7 +29,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'reference-container'; const GROUP_ID = 'reference-container';
/** /**
* Setting group name. * Setting group name.
* *
@ -71,7 +71,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'default_value' => 'p', 'default_value' => 'p',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => Setting::TEXT_ELEMENT_OPTIONS 'input_options' => Setting::TEXT_ELEMENT_OPTIONS,
); );
/** /**
@ -687,8 +687,10 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox', 'input_type' => 'checkbox',
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {

View file

@ -29,7 +29,7 @@ class ScrollingSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'scrolling'; const GROUP_ID = 'scrolling';
/** /**
* Setting group name. * Setting group name.
* *
@ -179,8 +179,10 @@ class ScrollingSettingsGroup extends SettingsGroup {
'input_min' => 0, 'input_min' => 0,
'enabled_by' => self::FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY, 'enabled_by' => self::FOOTNOTES_SCROLL_DURATION_ASYMMETRICITY,
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {

View file

@ -29,7 +29,7 @@ class ShortcodeSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'shortcode'; const GROUP_ID = 'shortcode';
/** /**
* Setting group name. * Setting group name.
* *
@ -148,8 +148,10 @@ class ShortcodeSettingsGroup extends SettingsGroup {
'input_type' => 'text', 'input_type' => 'text',
'enabled_by' => self::FOOTNOTES_SHORT_CODE_END, 'enabled_by' => self::FOOTNOTES_SHORT_CODE_END,
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {

View file

@ -29,7 +29,7 @@ class BacklinkSymbolSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'backlink-symbol'; const GROUP_ID = 'backlink-symbol';
/** /**
* Setting group name. * Setting group name.
* *
@ -56,21 +56,21 @@ class BacklinkSymbolSettingsGroup extends SettingsGroup {
'default_value' => 0, 'default_value' => 0,
'type' => 'number', 'type' => 'number',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => array( 'input_options' => array(
'&#8593;', '&#8593;',
'&#8613;', '&#8613;',
'&#8607;', '&#8607;',
'&#8617;', '&#8617;',
'&#8626;', '&#8626;',
'&#8629;', '&#8629;',
'&#8657;', '&#8657;',
'&#8673;', '&#8673;',
'&#8679;', '&#8679;',
'&#65514;' '&#65514;',
), ),
'overridden_by' => self::HYPERLINK_ARROW_USER_DEFINED, 'overridden_by' => self::HYPERLINK_ARROW_USER_DEFINED,
); );
/** /**
* Settings container key for the user-defined backlink symbol. * Settings container key for the user-defined backlink symbol.
* *
@ -81,19 +81,21 @@ class BacklinkSymbolSettingsGroup extends SettingsGroup {
* Convert from `string` to `array`. * Convert from `string` to `array`.
*/ */
const HYPERLINK_ARROW_USER_DEFINED = array( const HYPERLINK_ARROW_USER_DEFINED = array(
'key' => 'footnote_inputfield_custom_hyperlink_symbol_user', 'key' => 'footnote_inputfield_custom_hyperlink_symbol_user',
'name' => 'Input the Backlink Symbol', 'name' => 'Input the Backlink Symbol',
'description' => 'Your input overrides the selection.', 'description' => 'Your input overrides the selection.',
'type' => 'string', 'type' => 'string',
'input_type' => 'text', 'input_type' => 'text',
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {
$this->settings = array( $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 ), self::HYPERLINK_ARROW_USER_DEFINED['key'] => $this->add_setting( self::HYPERLINK_ARROW_USER_DEFINED ),
); );

View file

@ -19,7 +19,7 @@ use footnotes\includes\settings\SettingsSection;
* @package footnotes * @package footnotes
* @since 2.8.0 * @since 2.8.0
*/ */
class ReferrersAndTooltipsSettingsSection extends SettingsSection { class ReferrersAndTooltipsSettingsSection extends SettingsSection {
/** /**
* The groups of settings within this section. * The groups of settings within this section.
* *
@ -28,13 +28,13 @@ class ReferrersAndTooltipsSettingsSection extends SettingsSection {
* @since 2.8.0 * @since 2.8.0
*/ */
protected array $settings_groups; protected array $settings_groups;
/** /**
* Constructs the settings section. * Constructs the settings section.
* *
* @param string options_group_slug The slug of the settings section's options group. * @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 $section_slug The slug of the settings section.
* @param string title The name of the settings section. * @param string $title The name of the settings section.
* *
* @since 2.8.0 * @since 2.8.0
*/ */
@ -42,7 +42,7 @@ class ReferrersAndTooltipsSettingsSection extends SettingsSection {
$options_group_slug, $options_group_slug,
$section_slug, $section_slug,
$title, $title,
/** /**
* The plugin settings object. * The plugin settings object.
* *
@ -52,16 +52,16 @@ class ReferrersAndTooltipsSettingsSection extends SettingsSection {
private Settings $settings private Settings $settings
) { ) {
$this->options_group_slug = $options_group_slug; $this->options_group_slug = $options_group_slug;
$this->section_slug = $section_slug; $this->section_slug = $section_slug;
$this->title = $title; $this->title = $title;
$this->load_dependencies(); $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(); $this->load_options_group();
} }
/** /**
* Load the required dependencies. * Load the required dependencies.
* *
@ -82,34 +82,36 @@ class ReferrersAndTooltipsSettingsSection extends SettingsSection {
* @see SettingsSection::load_dependencies() * @see SettingsSection::load_dependencies()
*/ */
protected function load_dependencies(): void { 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-backlinksymbolsettingsgroup.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-referrerssettingsgroup.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-referrersinlabelssettingsgroup.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-tooltipssettingsgroup.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-tooltipappearancesettingsgroup.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-tooltipdimensionssettingsgroup.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-tooltippositionsettingsgroup.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-tooltiptextsettingsgroup.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-tooltiptimingsettingsgroup.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-tooltiptruncationsettingsgroup.php';
} }
/** /**
* Add the settings groups for this settings section.
*
* @see SettingsSection::add_settings_groups() * @see SettingsSection::add_settings_groups()
*/ */
protected function add_settings_groups(): void { protected function add_settings_groups(): void {
$this->settings_groups = array ( $this->settings_groups = array(
BacklinkSymbolSettingsGroup::GROUP_ID => new BacklinkSymbolSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ), 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 ), 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 ), 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 ), 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 ), 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 ), 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 ), 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 ), 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 ), TooltipTruncationSettingsGroup::GROUP_ID => new TooltipTruncationSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
); );
} }

View file

@ -29,7 +29,7 @@ class ReferrersInLabelsSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'referrers-in-label'; const GROUP_ID = 'referrers-in-label';
/** /**
* Setting group name. * Setting group name.
* *
@ -63,14 +63,16 @@ class ReferrersInLabelsSettingsGroup extends SettingsGroup {
'default_value' => 'none', 'default_value' => 'none',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => array( 'input_options' => array(
'none' => '0. No problem or solved otherwise', 'none' => '0. No problem or solved otherwise',
'move' => 'A. Footnotes are moved out and appended after the label\'s end (recommended)', '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)' 'disconnect' => 'B. Labels with footnotes are disconnected from input element (discouraged)',
), ),
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {

View file

@ -29,7 +29,7 @@ class ReferrersSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'referrers'; const GROUP_ID = 'referrers';
/** /**
* Setting group name. * Setting group name.
* *
@ -56,7 +56,7 @@ class ReferrersSettingsGroup extends SettingsGroup {
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox', 'input_type' => 'checkbox',
); );
/** /**
* Settings container key to enable superscript style normalization. * Settings container key to enable superscript style normalization.
* *
@ -73,13 +73,13 @@ class ReferrersSettingsGroup extends SettingsGroup {
'default_value' => 'no', 'default_value' => 'no',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => array( 'input_options' => array(
'no' => 'No', 'no' => 'No',
'referrers' => 'Footnote referrers', 'referrers' => 'Footnote referrers',
'all' => 'All superscript elements' 'all' => 'All superscript elements',
), ),
); );
/** /**
* Settings container key for the string before the footnote referrer. * Settings container key for the string before the footnote referrer.
* *
@ -101,7 +101,7 @@ class ReferrersSettingsGroup extends SettingsGroup {
'type' => 'string', 'type' => 'string',
'input_type' => 'text', 'input_type' => 'text',
); );
/** /**
* Settings container key for the string after the footnote referrer. * Settings container key for the string after the footnote referrer.
* *
@ -118,7 +118,7 @@ class ReferrersSettingsGroup extends SettingsGroup {
'type' => 'string', 'type' => 'string',
'input_type' => 'text', 'input_type' => 'text',
); );
/** /**
* Settings container key * Settings container key
* *
@ -137,8 +137,10 @@ class ReferrersSettingsGroup extends SettingsGroup {
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox', 'input_type' => 'checkbox',
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { 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::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::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_BEFORE['key'] => $this->add_setting( self::FOOTNOTES_STYLING_BEFORE ),
self::FOOTNOTES_STYLING_AFTER['key'] => $this->add_setting( self::FOOTNOTES_STYLING_AFTER ), 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::LINK_ELEMENT_ENABLED['key'] => $this->add_setting( self::LINK_ELEMENT_ENABLED ),
); );
$this->load_values( $options ); $this->load_values( $options );

View file

@ -29,7 +29,7 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'tooltip-appearance'; const GROUP_ID = 'tooltip-appearance';
/** /**
* Setting group name. * Setting group name.
* *
@ -79,7 +79,7 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
'type' => 'number', 'type' => 'number',
'input_type' => 'number', 'input_type' => 'number',
'input_max' => 50.0, 'input_max' => 50.0,
'input_min' => 0.0 'input_min' => 0.0,
); );
/** /**
@ -97,7 +97,7 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
'default_value' => 'px', 'default_value' => 'px',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => Setting::FONT_SIZE_UNIT_OPTIONS 'input_options' => Setting::FONT_SIZE_UNIT_OPTIONS,
); );
/** /**
@ -140,7 +140,7 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
'type' => 'string', 'type' => 'string',
'input_type' => 'color', 'input_type' => 'color',
); );
/** /**
* Settings container key for the mouse-over box to define the border width. * Settings container key for the mouse-over box to define the border width.
* *
@ -157,8 +157,8 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
'default_value' => 1.0, 'default_value' => 1.0,
'type' => 'number', 'type' => 'number',
'input_type' => 'number', 'input_type' => 'number',
'input_max' => 4.0, 'input_max' => 4.0,
'input_min' => 0.0, 'input_min' => 0.0,
); );
/** /**
@ -178,7 +178,7 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
'type' => 'string', 'type' => 'string',
'input_type' => 'color', 'input_type' => 'color',
); );
/** /**
* Settings container key for the mouse-over box to define the border radius. * Settings container key for the mouse-over box to define the border radius.
* *
@ -195,8 +195,8 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
'default_value' => 0, 'default_value' => 0,
'type' => 'number', 'type' => 'number',
'input_type' => 'number', 'input_type' => 'number',
'input_max' => 500, 'input_max' => 500,
'input_min' => 0, 'input_min' => 0,
); );
/** /**
@ -216,16 +216,18 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
'type' => 'string', 'type' => 'string',
'input_type' => 'color', 'input_type' => 'color',
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {
$this->settings = array( $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_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_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::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_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_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_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 ), self::FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR['key'] => $this->add_setting( self::FOOTNOTES_MOUSE_OVER_BOX_BORDER_COLOR ),

View file

@ -29,7 +29,7 @@ class TooltipDimensionsSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'tooltip-dimensions'; const GROUP_ID = 'tooltip-dimensions';
/** /**
* Setting group name. * Setting group name.
* *
@ -59,7 +59,7 @@ class TooltipDimensionsSettingsGroup extends SettingsGroup {
'type' => 'number', 'type' => 'number',
'input_type' => 'number', 'input_type' => 'number',
); );
/** /**
* Settings container key for alternative tooltip width. * Settings container key for alternative tooltip width.
* *
@ -76,8 +76,10 @@ class TooltipDimensionsSettingsGroup extends SettingsGroup {
'type' => 'number', 'type' => 'number',
'input_type' => 'number', 'input_type' => 'number',
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {

View file

@ -29,7 +29,7 @@ class TooltipPositionSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'tooltip-position'; const GROUP_ID = 'tooltip-position';
/** /**
* Setting group name. * Setting group name.
* *
@ -59,7 +59,7 @@ class TooltipPositionSettingsGroup extends SettingsGroup {
'default_value' => 'top center', 'default_value' => 'top center',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => array( 'input_options' => array(
'top left' => 'top left', 'top left' => 'top left',
'top center' => 'top center', 'top center' => 'top center',
'top right' => 'top right', 'top right' => 'top right',
@ -88,11 +88,11 @@ class TooltipPositionSettingsGroup extends SettingsGroup {
'default_value' => 'top right', 'default_value' => 'top right',
'type' => 'string', 'type' => 'string',
'input_type' => 'select', 'input_type' => 'select',
'input_options' => array( 'input_options' => array(
'top left' => 'top left', 'top left' => 'top left',
'top right' => 'top right', 'top right' => 'top right',
'bottom right' => 'bottom right', 'bottom right' => 'bottom right',
'bottom left' => 'bottom left', 'bottom left' => 'bottom left',
), ),
); );
@ -170,8 +170,10 @@ class TooltipPositionSettingsGroup extends SettingsGroup {
'type' => 'number', 'type' => 'number',
'input_type' => 'number', 'input_type' => 'number',
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {

View file

@ -29,7 +29,7 @@ class TooltipsSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'tooltips'; const GROUP_ID = 'tooltips';
/** /**
* Setting group name. * Setting group name.
* *
@ -81,8 +81,10 @@ class TooltipsSettingsGroup extends SettingsGroup {
'type' => 'boolean', 'type' => 'boolean',
'input_type' => 'checkbox', 'input_type' => 'checkbox',
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {

View file

@ -29,7 +29,7 @@ class TooltipTextSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'tooltip-text'; const GROUP_ID = 'tooltip-text';
/** /**
* Setting group name. * Setting group name.
* *
@ -109,8 +109,10 @@ class TooltipTextSettingsGroup extends SettingsGroup {
'type' => 'string', 'type' => 'string',
'input_type' => 'text', 'input_type' => 'text',
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {

View file

@ -29,7 +29,7 @@ class TooltipTimingSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'tooltip-timing'; const GROUP_ID = 'tooltip-timing';
/** /**
* Setting group name. * Setting group name.
* *
@ -118,15 +118,17 @@ class TooltipTimingSettingsGroup extends SettingsGroup {
'input_max' => 20000, 'input_max' => 20000,
'input_min' => 0, 'input_min' => 0,
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {
$this->settings = array( $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_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_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_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 ), self::MOUSE_OVER_BOX_FADE_OUT_DURATION['key'] => $this->add_setting( self::MOUSE_OVER_BOX_FADE_OUT_DURATION ),
); );

View file

@ -29,7 +29,7 @@ class TooltipTruncationSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
const GROUP_ID = 'tooltip-truncation'; const GROUP_ID = 'tooltip-truncation';
/** /**
* Setting group name. * Setting group name.
* *
@ -99,8 +99,10 @@ class TooltipTruncationSettingsGroup extends SettingsGroup {
'type' => 'string', 'type' => 'string',
'input_type' => 'text', 'input_type' => 'text',
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {

View file

@ -21,7 +21,7 @@ use footnotes\includes\settings\scopeandpriority\WordPressHooksSettingsGroup;
* @package footnotes * @package footnotes
* @since 2.8.0 * @since 2.8.0
*/ */
class ScopeAndPrioritySettingsSection extends SettingsSection { class ScopeAndPrioritySettingsSection extends SettingsSection {
/** /**
* The groups of settings within this section. * The groups of settings within this section.
* *
@ -30,13 +30,13 @@ class ScopeAndPrioritySettingsSection extends SettingsSection {
* @since 2.8.0 * @since 2.8.0
*/ */
protected array $settings_groups; protected array $settings_groups;
/** /**
* Constructs the settings section. * Constructs the settings section.
* *
* @param string options_group_slug The slug of the settings section's options group. * @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 $section_slug The slug of the settings section.
* @param string title The name of the settings section. * @param string $title The name of the settings section.
* *
* @since 2.8.0 * @since 2.8.0
*/ */
@ -44,7 +44,7 @@ class ScopeAndPrioritySettingsSection extends SettingsSection {
$options_group_slug, $options_group_slug,
$section_slug, $section_slug,
$title, $title,
/** /**
* The plugin settings object. * The plugin settings object.
* *
@ -54,16 +54,16 @@ class ScopeAndPrioritySettingsSection extends SettingsSection {
private Settings $settings private Settings $settings
) { ) {
$this->options_group_slug = $options_group_slug; $this->options_group_slug = $options_group_slug;
$this->section_slug = $section_slug; $this->section_slug = $section_slug;
$this->title = $title; $this->title = $title;
$this->load_dependencies(); $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(); $this->load_options_group();
} }
/** /**
* Load the required dependencies. * Load the required dependencies.
* *
@ -75,17 +75,19 @@ class ScopeAndPrioritySettingsSection extends SettingsSection {
* @see SettingsSection::load_dependencies() * @see SettingsSection::load_dependencies()
*/ */
protected function load_dependencies(): void { 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() * @see SettingsSection::add_settings_groups()
*/ */
protected function add_settings_groups(): void { protected function add_settings_groups(): void {
$this->settings_groups = array ( $this->settings_groups = array(
WordPressHooksSettingsGroup::GROUP_ID => new WordPressHooksSettingsGroup($this->options_group_slug, $this->section_slug, $this->settings ), WordPressHooksSettingsGroup::GROUP_ID => new WordPressHooksSettingsGroup( $this->options_group_slug, $this->section_slug, $this->settings ),
); );
} }
} }

View file

@ -29,7 +29,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
* @since 2.8.0 * @since 2.8.0
*/ */
public const GROUP_ID = 'wordpress-hooks'; public const GROUP_ID = 'wordpress-hooks';
/** /**
* Setting group name. * Setting group name.
* *
@ -183,7 +183,7 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
'input_max' => PHP_INT_MAX, 'input_max' => PHP_INT_MAX,
'input_min' => -1, 'input_min' => -1,
); );
/** /**
* Settings container key to enable the `widget_title` hook. * Settings container key to enable the `widget_title` hook.
* *
@ -266,21 +266,23 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
'input_max' => PHP_INT_MAX, 'input_max' => PHP_INT_MAX,
'input_min' => -1, 'input_min' => -1,
); );
/** /**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings() * @see SettingsGroup::add_settings()
*/ */
protected function add_settings( array|false $options ): void { protected function add_settings( array|false $options ): void {
$this->settings = array( $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_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_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_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['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_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 ), self::EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL['key'] => $this->add_setting( self::EXPERT_LOOKUP_WIDGET_TEXT_PRIORITY_LEVEL ),
); );

View file

@ -12,9 +12,7 @@ namespace footnotes\general;
use footnotes\includes\{Footnotes, Convert, Settings}; 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\ReferenceContainerSettingsGroup;
use footnotes\includes\settings\general\AMPCompatSettingsGroup; use footnotes\includes\settings\general\AMPCompatSettingsGroup;
use footnotes\includes\settings\referrersandtooltips\TooltipsSettingsGroup; use footnotes\includes\settings\referrersandtooltips\TooltipsSettingsGroup;
@ -115,15 +113,15 @@ class General {
* @see Footnotes::$version * @see Footnotes::$version
*/ */
private string $version, private string $version,
/** /**
* The plugin settings object. * The plugin settings object.
* *
* @access private * @access private
* @since 2.8.0 * @since 2.8.0
*/ */
private Settings $settings private Settings $settings
) { ) {
$this->load_dependencies(); $this->load_dependencies();
@ -156,9 +154,9 @@ class General {
$this->reference_container_widget = new Widget\Reference_Container( $this->plugin_name ); $this->reference_container_widget = new Widget\Reference_Container( $this->plugin_name );
$this->task = new Parser($this->settings); $this->task = new Parser( $this->settings );
} }
/** /**
* Register the stylesheets for the public-facing side of the site. * Register the stylesheets for the public-facing side of the site.
* *

View file

@ -15,29 +15,27 @@ namespace footnotes\general;
use footnotes\includes\{Settings, Config, Convert, Template}; use footnotes\includes\{Settings, Config, Convert, Template};
/** /* TODO Replace with constant imports. */
* @todo Replace with constant imports.
*/
use footnotes\includes\settings\general\{ use footnotes\includes\settings\general\{
ExcerptsSettingsGroup, ExcerptsSettingsGroup,
HardLinksSettingsGroup, HardLinksSettingsGroup,
LoveSettingsGroup, LoveSettingsGroup,
NumberingSettingsGroup, NumberingSettingsGroup,
ReferenceContainerSettingsGroup, ReferenceContainerSettingsGroup,
ScrollingSettingsGroup, ScrollingSettingsGroup,
ShortcodeSettingsGroup, ShortcodeSettingsGroup,
}; };
use footnotes\includes\settings\referrersandtooltips\{ use footnotes\includes\settings\referrersandtooltips\{
BacklinkSymbolSettingsGroup, BacklinkSymbolSettingsGroup,
ReferrersSettingsGroup, ReferrersSettingsGroup,
ReferrersInLabelsSettingsGroup, ReferrersInLabelsSettingsGroup,
TooltipsSettingsGroup, TooltipsSettingsGroup,
TooltipAppearanceSettingsGroup, TooltipAppearanceSettingsGroup,
TooltipDimensionsSettingsGroup, TooltipDimensionsSettingsGroup,
TooltipPositionSettingsGroup, TooltipPositionSettingsGroup,
TooltipTextSettingsGroup, TooltipTextSettingsGroup,
TooltipTimingSettingsGroup, TooltipTimingSettingsGroup,
TooltipTruncationSettingsGroup TooltipTruncationSettingsGroup
}; };
use footnotes\includes\settings\scopeandpriority\WordPressHooksSettingsGroup; use footnotes\includes\settings\scopeandpriority\WordPressHooksSettingsGroup;
use footnotes\includes\settings\customcss\CustomCSSSettingsGroup; use footnotes\includes\settings\customcss\CustomCSSSettingsGroup;
@ -49,7 +47,7 @@ use footnotes\includes\settings\customcss\CustomCSSSettingsGroup;
* @since 1.5.0 * @since 1.5.0
* @since 2.8.0 Rename class from `Footnotes_Task` to `Parser`. * @since 2.8.0 Rename class from `Footnotes_Task` to `Parser`.
*/ */
class Parser { class Parser {
/** /**
* Contains all footnotes found in the searched content. * Contains all footnotes found in the searched content.
* *
@ -276,15 +274,15 @@ class Parser {
* @todo Reorganise dependencies. * @todo Reorganise dependencies.
* @todo Move call to `register_hooks()` to {@see General}. * @todo Move call to `register_hooks()` to {@see General}.
*/ */
public function __construct( public function __construct(
/** /**
* The plugin settings object. * The plugin settings object.
* *
* @access private * @access private
* @since 2.8.0 * @since 2.8.0
*/ */
private Settings $settings private Settings $settings
) { ) {
// TODO: Reorg dependencies. // TODO: Reorg dependencies.
require_once plugin_dir_path( __DIR__ ) . 'includes/class-config.php'; require_once plugin_dir_path( __DIR__ ) . 'includes/class-config.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/class-convert.php'; require_once plugin_dir_path( __DIR__ ) . 'includes/class-convert.php';
@ -481,7 +479,7 @@ class Parser {
// Reference container label bottom border. // Reference container label bottom border.
if ( ( $this->settings->get_setting_value( ReferenceContainerSettingsGroup::REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER['key'] ) ) ) { if ( ( $this->settings->get_setting_value( ReferenceContainerSettingsGroup::REFERENCE_CONTAINER_LABEL_BOTTOM_BORDER['key'] ) ) ) {
echo '.footnote_container_prepare > '; 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"; echo " {border-bottom: 1px solid #aaaaaa !important;}\r\n";
} }
@ -545,7 +543,7 @@ class Parser {
} }
// Hard links scroll offset. // 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'] ); 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. // Correct hard links enabled status depending on AMP-compatible or alternative reference container enabled status.
@ -721,7 +719,7 @@ class Parser {
* for transparency. It isnt indented though (the PHP open tag neither). * for transparency. It isnt indented though (the PHP open tag neither).
*/ */
if ( General::$alternative_tooltips_enabled ) { if ( General::$alternative_tooltips_enabled ) {
echo (' echo ( '
<script content="text/javascript"> <script content="text/javascript">
function footnote_tooltip_show(footnote_tooltip_id) { function footnote_tooltip_show(footnote_tooltip_id) {
document.getElementById(footnote_tooltip_id).classList.remove("hidden"); document.getElementById(footnote_tooltip_id).classList.remove("hidden");
@ -732,7 +730,7 @@ class Parser {
document.getElementById(footnote_tooltip_id).classList.add("hidden"); document.getElementById(footnote_tooltip_id).classList.add("hidden");
} }
</script> </script>
'); ' );
}; };
} }
@ -820,7 +818,7 @@ class Parser {
$footnote_section_shortcode_length = strlen( $footnote_section_shortcode ); $footnote_section_shortcode_length = strlen( $footnote_section_shortcode );
// TODO: Replace with `str_contains()`, but currently breaks Rector downgrade. // 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 ) ) { if ( ! strpos( $content, (string) $footnote_section_shortcode ) ) {
// phpcs:disable WordPress.PHP.YodaConditions.NotYoda // phpcs:disable WordPress.PHP.YodaConditions.NotYoda
@ -838,8 +836,8 @@ class Parser {
$section_end = strpos( $rest_content, (string) $footnote_section_shortcode ); $section_end = strpos( $rest_content, (string) $footnote_section_shortcode );
$sections_raw[] = substr( $rest_content, 0, $section_end ); $sections_raw[] = substr( $rest_content, 0, $section_end );
$rest_content = substr( $rest_content, $section_end + $footnote_section_shortcode_length ); $rest_content = substr( $rest_content, $section_end + $footnote_section_shortcode_length );
// TODO: Replace with `str_contains()`, but currently breaks Rector downgrade. // TODO: Replace with `str_contains()`, but currently breaks Rector downgrade.
// https://github.com/rectorphp/rector/issues/6315 // <https://github.com/rectorphp/rector/issues/6315>.
} while ( strpos( $rest_content, (string) $footnote_section_shortcode ) ); } while ( strpos( $rest_content, (string) $footnote_section_shortcode ) );
$sections_raw[] = $rest_content; $sections_raw[] = $rest_content;
@ -1199,7 +1197,7 @@ class Parser {
*/ */
// If enabled. // 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. // Apply different regex depending on whether start shortcode is double/triple opening parenthesis.
if ( '((' === self::$start_tag || '(((' === self::$start_tag ) { if ( '((' === self::$start_tag || '(((' === self::$start_tag ) {
@ -1709,12 +1707,12 @@ class Parser {
*/ */
// If the backlink symbol is enabled. // If the backlink symbol is enabled.
if ( $this->settings->get_setting_value( ReferenceContainerSettingsGroup::REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE['key'] )) { if ( $this->settings->get_setting_value( ReferenceContainerSettingsGroup::REFERENCE_CONTAINER_BACKLINK_SYMBOL_ENABLE['key'] ) ) {
$arrow_setting = $this->settings->get_setting( BacklinkSymbolSettingsGroup::HYPERLINK_ARROW['key']); $arrow_setting = $this->settings->get_setting( BacklinkSymbolSettingsGroup::HYPERLINK_ARROW['key'] );
// Get html arrow. // 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. // Get user defined arrow.
$arrow_user_defined = $this->settings->get_setting_value( BacklinkSymbolSettingsGroup::HYPERLINK_ARROW_USER_DEFINED['key'] ); $arrow_user_defined = $this->settings->get_setting_value( BacklinkSymbolSettingsGroup::HYPERLINK_ARROW_USER_DEFINED['key'] );
if ( ! empty( $arrow_user_defined ) ) { if ( ! empty( $arrow_user_defined ) ) {
@ -1745,10 +1743,9 @@ class Parser {
// If it is not, check which option is on. // If it is not, check which option is on.
$separator_option = $this->settings->get_setting_value( ReferenceContainerSettingsGroup::BACKLINKS_SEPARATOR_OPTION['key'] ); $separator_option = $this->settings->get_setting_value( ReferenceContainerSettingsGroup::BACKLINKS_SEPARATOR_OPTION['key'] );
// TODO: replace with `match` (but currently it breaks the Rector // TODO: replace with `match` (but currently it breaks the Rector downgrade to PHP 7.4.
// downgrade to PHP 7.4. // <https://github.com/rectorphp/rector/issues/6315>.
// https://github.com/rectorphp/rector/issues/6315 switch ( $separator_option ) {
switch ($separator_option) {
case 'comma': case 'comma':
$separator = ','; $separator = ',';
break; break;
@ -1779,10 +1776,9 @@ class Parser {
// If it is not, check which option is on. // If it is not, check which option is on.
$terminator_option = $this->settings->get_setting_value( ReferenceContainerSettingsGroup::BACKLINKS_TERMINATOR_OPTION['key'] ); $terminator_option = $this->settings->get_setting_value( ReferenceContainerSettingsGroup::BACKLINKS_TERMINATOR_OPTION['key'] );
// TODO: replace with `match` (but currently it breaks the Rector // TODO: replace with `match` (but currently it breaks the Rector downgrade to PHP 7.4.
// downgrade to PHP 7.4. // <https://github.com/rectorphp/rector/issues/6315>.
// https://github.com/rectorphp/rector/issues/6315 switch ( $terminator_option ) {
switch ($terminator_option) {
case 'period': case 'period':
$terminator = '.'; $terminator = '.';
break; break;
@ -2138,7 +2134,7 @@ class Parser {
} }
// Call again for robustness when priority levels don't match any longer. // 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'] ); self::$scroll_offset = (int) $this->settings->get_setting_value( ScrollingSettingsGroup::FOOTNOTES_SCROLL_OFFSET['key'] );
// Streamline. // Streamline.