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

@ -106,20 +106,8 @@ abstract class Engine {
$this->settings->settings_sections['scope_and_priority']->get_section_slug() => $this->settings->settings_sections['scope_and_priority'],
$this->settings->settings_sections['custom_css']->get_section_slug() => $this->settings->settings_sections['custom_css'],
);
/*foreach ( $this->get_sections() as $section ) {
// Append tab to the tab-array.
$this->sections[ $section['id'] ] = $section;
add_settings_section(
$section['id'],
'',
fn() => $this->description(),
'footnotes'
);
$this->add_settings_fields();
//$this->register_meta_boxes( $section['id'] );
}*/
}
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
/**
* Displays the content of specific sub-page.
@ -152,8 +140,8 @@ abstract class Engine {
<h2 class="nav-tab-wrapper">
<?php foreach ( $this->sections as $section_slug => $section ) : ?>
<a
class="nav-tab<?php echo ( $section_slug === $active_section->get_section_slug() ) ? ' nav-tab-active' : '' ?>"
href="?page=<?php echo Init::MAIN_MENU_SLUG ?>&t=<?php echo $section_slug ?>">
class="nav-tab<?php echo ( $section_slug === $active_section->get_section_slug() ) ? ' nav-tab-active' : ''; ?>"
href="?page=<?php echo Init::MAIN_MENU_SLUG; ?>&t=<?php echo $section_slug; ?>">
<?php echo $section->get_title(); ?>
</a>
<?php endforeach; ?>
@ -189,6 +177,7 @@ abstract class Engine {
<?php
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
/**
* Output the description of a section. May be overwritten in any section.
*
@ -463,7 +452,9 @@ abstract class Engine {
protected function add_select( array $args ): void {
extract( $args );
if (!isset($options)) trigger_error("No options passed to 'select' element.", E_USER_ERROR);
if ( ! isset( $options ) ) {
trigger_error( "No options passed to 'select' element.", E_USER_ERROR );
}
$select_options = '';
// Loop through all array keys.

View file

@ -98,9 +98,10 @@ class SettingsPage extends Engine {
$this->settings->settings_sections['custom_css']->add_settings_fields( $this );
break;
case 'footnotes-how-to':
print_r("Demo goes here");
print_r( 'Demo goes here' );
break;
default: print_r("ERR: section not found");
default:
print_r( 'ERR: section not found' );
}
}
@ -127,9 +128,12 @@ class SettingsPage extends Engine {
case 'color':
$this->add_input_color( $args );
return;
default: trigger_error("Unknown setting type.", E_USER_ERROR);
default:
trigger_error( 'Unknown setting type.', E_USER_ERROR );
}
} else {
trigger_error( 'No setting type.', E_USER_ERROR );
}
} else trigger_error("No setting type.", E_USER_ERROR);
}
/**************************************************************************

View file

@ -55,8 +55,10 @@ class Convert {
* @since 1.0-beta
* @todo Replace with built-in type casting.
*/
public static function to_bool( string|null $value ): bool {
if (!$value) return false;
public static function to_bool( ?string $value ): bool {
if ( ! $value ) {
return false;
}
// Convert string to lower-case to make it easier.
$value = strtolower( $value );

View file

@ -124,8 +124,11 @@ class Core {
* @since 2.8.0
*/
public function get_plugin_name( bool $html = false ): string {
if ( ! $html ) return $this->plugin_name;
else return '<span class="footnotes_logo footnotes_logo_part1">foot</span><span class="footnotes_logo footnotes_logo_part2">notes</span>';
if ( ! $html ) {
return $this->plugin_name;
} else {
return '<span class="footnotes_logo footnotes_logo_part1">foot</span><span class="footnotes_logo footnotes_logo_part2">notes</span>';
}
}
/**

View file

@ -92,14 +92,14 @@ class Settings {
* @return void
*/
protected function load_dependencies(): void {
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-settings-section.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-settingssection.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-settingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/class-setting.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/general/class-general-settings-section.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/referrers-and-tooltips/class-referrers-and-tooltips-settings-section.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/scope-and-priority/class-scope-and-priority-settings-section.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/custom-css/class-custom-css-settings-section.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/general/class-generalsettingssection.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/referrers-and-tooltips/class-referrersandtooltipssettingssection.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/scope-and-priority/class-scopeandprioritysettingssection.php';
require_once plugin_dir_path( __DIR__ ) . 'includes/settings/custom-css/class-customcsssettingssection.php';
}
/**
@ -116,7 +116,9 @@ class Settings {
foreach ( $this->settings_sections as $settings_section ) {
$setting = $settings_section->get_setting( $setting_key );
if ($setting) return $setting;
if ( $setting ) {
return $setting;
}
}
return null;
@ -137,7 +139,9 @@ class Settings {
foreach ( $this->settings_sections as $settings_section ) {
$setting = $settings_section->get_setting( $setting_key );
if ($setting) return $setting->get_value();
if ( $setting ) {
return $setting->get_value();
}
}
return null;
@ -158,7 +162,9 @@ class Settings {
foreach ( $this->settings_sections as $settings_section ) {
$setting = $settings_section->get_setting( $setting_key );
if ($setting) return $setting->get_default_value();
if ( $setting ) {
return $setting->get_default_value();
}
}
return null;
@ -176,11 +182,13 @@ class Settings {
* @todo This is an _O(n)_ linear search. Explore more scaleable alternatives.
* @todo How to handle settings with a value of `null`?
*/
public function set_setting_value( string $setting_key, mixed $setting_value ): ?bool {
public function set_setting_value( string $setting_key, $setting_value ): ?bool {
foreach ( $this->settings_sections as $settings_section ) {
$setting = $settings_section->get_setting( $setting_key );
if ($setting) return $setting->set_value( $setting_value );
if ( $setting ) {
return $setting->set_value( $setting_value );
}
}
return false;

View file

@ -74,7 +74,7 @@ class Setting {
*
* @since 2.8.0
*/
protected mixed $value;
protected $value;
/**
* Constructs the setting.
@ -256,7 +256,7 @@ class Setting {
'options' => $this->input_options,
'max' => $this->input_max,
'min' => $this->input_min,
'disabled' => $this->is_disabled_or_overridden()
'disabled' => $this->is_disabled_or_overridden(),
);
}
@ -281,14 +281,22 @@ class Setting {
}
if ( isset( $is_enabled ) || isset( $is_overridden ) ) {
if (isset($is_enabled) && !$is_enabled) return true;
if ( isset( $is_enabled ) && ! $is_enabled ) {
return true;
}
if (isset($is_enabled) && $is_enabled && (isset($is_overridden) && !$is_overridden)) return false;
if ( isset( $is_enabled ) && $is_enabled && ( isset( $is_overridden ) && ! $is_overridden ) ) {
return false;
}
if (isset($is_overridden) && $is_overridden) return true;
if ( isset( $is_overridden ) && $is_overridden ) {
return true;
}
return false;
} else return null;
} else {
return null;
}
}
/**
@ -354,7 +362,7 @@ class Setting {
*
* @since 2.8.0
*/
public function set_value(mixed $value): bool {
public function set_value( $value ): bool {
$this->value = $value;
return true;
}

View file

@ -16,6 +16,10 @@ use footnotes\admin\layout\SettingsPage;
/**
* Class defining a group of plugin settings within a section.
*
* NB: the concept of a 'settings group' is just a semantic aide for developers,
* it has no relevance within WordPress itself, which only recognises settings
* sections and options groups.
*
* @package footnotes
* @since 2.8.0
*/
@ -115,7 +119,7 @@ abstract class SettingsGroup {
*
* @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.
@ -157,13 +161,16 @@ abstract class SettingsGroup {
* @todo Remove settings from options group when not found.
*/
protected function load_values( array|false $options ): void {
if ( ! $options ) return;
if ( ! $options ) {
return;
}
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 );
}
}
}
/**
* Adds all the settings fields for this group to the admin. dashboard.
@ -187,17 +194,23 @@ abstract class SettingsGroup {
}
/**
* Retrieve a setting by its key.
*
* @see Settings::get_setting()
*/
public function get_setting( string $setting_key ): ?Setting {
foreach ( $this->settings as $setting ) {
if ($setting->key === $setting_key) return $setting;
if ( $setting->key === $setting_key ) {
return $setting;
}
}
return null;
}
/**
* Creates an options group from the values of the settings in this section.
*
* @see SettingsSection::get_options()
*/
public function get_options(): array {
@ -211,16 +224,23 @@ abstract class SettingsGroup {
}
/**
* Get a setting's value by its key.
*
* @see Settings::get_setting_value()
*/
public function get_setting_value( string $setting_key ) {
$setting = $this->get_setting( $setting_key );
if (! $setting) return null;
else return $setting->value ?? $setting->default_value;
if ( ! $setting ) {
return null;
} else {
return $setting->value ?? $setting->default_value;
}
}
/**
* Set a setting's value by its key.
*
* @see Settings::set_setting_value()
*/
public function set_setting_value( string $setting_key, $value ): bool {

View file

@ -97,7 +97,7 @@ abstract class SettingsSection {
}
public function setting_section_callback(): void {
echo "<hr>";
echo '<hr>';
}
/**
@ -108,7 +108,7 @@ abstract class SettingsSection {
*
* @since 2.8.0
*/
protected abstract function add_settings_groups(): void;
abstract protected function add_settings_groups(): void;
public function get_options_group_slug(): string {
return $this->options_group_slug;
@ -139,7 +139,7 @@ abstract class SettingsSection {
/**
* Gets a settings groups from this section by its ID.
*
* @param string group_id The ID of the settings group.
* @param string $group_id The ID of the settings group.
* @return ?SettingsGroup The section group. 'None' if none found.
*
* @since 2.8.0
@ -149,13 +149,17 @@ abstract class SettingsSection {
}
/**
* Retrieve a setting by its key.
*
* @see Settings::get_setting()
*/
public function get_setting( string $setting_key ): ?Setting {
foreach ( $this->settings_groups as $settings_group ) {
$setting = $settings_group->get_setting( $setting_key );
if ($setting) return $setting;
if ( $setting ) {
return $setting;
}
}
return null;
@ -179,22 +183,32 @@ abstract class SettingsSection {
}
/**
* Retrieve a setting's default value by its key.
*
* @see Settings::get_setting_value()
*/
public function get_setting_value( string $setting_key ) {
$setting = $this->get_setting( $setting_key );
if (! $setting) return null;
else return $setting->value ?? $setting->default_value ?? trigger_error("No default value found for ".$setting_key.".", E_USER_ERROR);
if ( ! $setting ) {
return null;
} else {
return $setting->value ?? $setting->default_value ?? trigger_error( 'No default value found for ' . $setting_key . '.', E_USER_ERROR );
}
}
/**
* Set a setting's value by its key.
*
* @see Settings::set_setting_value()
*/
public function set_setting_value( string $setting_key, $value ): ?bool {
$setting = $this->get_setting( $setting_key );
if (! $setting) return null;
else return $setting->set_value($value);
if ( ! $setting ) {
return null;
} else {
return $setting->set_value( $value );
}
}
}

View file

@ -56,21 +56,8 @@ class CustomCSSSettingsGroup extends SettingsGroup {
);
/**
* Load the required dependencies.
* Add the settings for this settings group.
*
* Include the following files that provide the settings for this plugin:
*
* - {@see SettingsGroup}: defines a group of settings.
*
* @see SettingsGroup::load_dependencies()
*/
protected function load_dependencies(): void {
parent::load_dependencies();
require_once plugin_dir_path( __DIR__ ) . 'class-settings-group.php';
}
/**
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -35,9 +35,9 @@ class CustomCSSSettingsSection extends SettingsSection {
/**
* Constructs the settings section.
*
* @param string options_group_slug The slug of the settings section's options group.
* @param string section_slug The slug of the settings section.
* @param string title The name of the settings section.
* @param string $options_group_slug The slug of the settings section's options group.
* @param string $section_slug The slug of the settings section.
* @param string $title The name of the settings section.
*
* @since 2.8.0
*/
@ -78,12 +78,12 @@ class CustomCSSSettingsSection extends SettingsSection {
protected function load_dependencies(): void {
parent::load_dependencies();
require_once plugin_dir_path( __DIR__ ) . 'class-settings-section.php';
require_once plugin_dir_path( __DIR__ ) . 'custom-css/class-custom-css-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'custom-css/class-customcsssettingsgroup.php';
}
/**
* Add the settings groups for this settings section.
*
* @see SettingsSection::add_settings_groups()
*/
protected function add_settings_groups(): void {

View file

@ -62,6 +62,8 @@ class AMPCompatSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -59,11 +59,13 @@ class ExcerptsSettingsGroup extends SettingsGroup {
'input_options' => array(
'yes' => 'Yes, generate excerpts from posts with effectively processed footnotes and other markup',
'no' => 'No, generate excerpts from posts but remove all footnotes and output plain text',
'manual' => 'Yes but run the process only to display tooltips in manual excerpts with footnote short codes'
'manual' => 'Yes but run the process only to display tooltips in manual excerpts with footnote short codes',
),
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

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

View file

@ -159,6 +159,8 @@ class HardLinksSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -114,6 +114,8 @@ class LoveSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -87,6 +87,8 @@ class NumberingSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -71,7 +71,7 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
'default_value' => 'p',
'type' => 'string',
'input_type' => 'select',
'input_options' => Setting::TEXT_ELEMENT_OPTIONS
'input_options' => Setting::TEXT_ELEMENT_OPTIONS,
);
/**
@ -689,6 +689,8 @@ class ReferenceContainerSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -181,6 +181,8 @@ class ScrollingSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -150,6 +150,8 @@ class ShortcodeSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -66,7 +66,7 @@ class BacklinkSymbolSettingsGroup extends SettingsGroup {
'&#8657;',
'&#8673;',
'&#8679;',
'&#65514;'
'&#65514;',
),
'overridden_by' => self::HYPERLINK_ARROW_USER_DEFINED,
);
@ -89,6 +89,8 @@ class BacklinkSymbolSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -32,9 +32,9 @@ class ReferrersAndTooltipsSettingsSection extends SettingsSection {
/**
* Constructs the settings section.
*
* @param string options_group_slug The slug of the settings section's options group.
* @param string section_slug The slug of the settings section.
* @param string title The name of the settings section.
* @param string $options_group_slug The slug of the settings section's options group.
* @param string $section_slug The slug of the settings section.
* @param string $title The name of the settings section.
*
* @since 2.8.0
*/
@ -84,19 +84,21 @@ class ReferrersAndTooltipsSettingsSection extends SettingsSection {
protected function load_dependencies(): void {
parent::load_dependencies();
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-backlink-symbol-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-referrers-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-referrers-in-labels-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltips-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltip-appearance-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltip-dimensions-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltip-position-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltip-text-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltip-timing-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltip-truncation-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-backlinksymbolsettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-referrerssettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-referrersinlabelssettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltipssettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltipappearancesettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltipdimensionssettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltippositionsettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltiptextsettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltiptimingsettingsgroup.php';
require_once plugin_dir_path( __DIR__ ) . 'referrers-and-tooltips/class-tooltiptruncationsettingsgroup.php';
}
/**
* Add the settings groups for this settings section.
*
* @see SettingsSection::add_settings_groups()
*/
protected function add_settings_groups(): void {

View file

@ -66,11 +66,13 @@ class ReferrersInLabelsSettingsGroup extends SettingsGroup {
'input_options' => array(
'none' => '0. No problem or solved otherwise',
'move' => 'A. Footnotes are moved out and appended after the label\'s end (recommended)',
'disconnect' => 'B. Labels with footnotes are disconnected from input element (discouraged)'
'disconnect' => 'B. Labels with footnotes are disconnected from input element (discouraged)',
),
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -76,7 +76,7 @@ class ReferrersSettingsGroup extends SettingsGroup {
'input_options' => array(
'no' => 'No',
'referrers' => 'Footnote referrers',
'all' => 'All superscript elements'
'all' => 'All superscript elements',
),
);
@ -139,6 +139,8 @@ class ReferrersSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -79,7 +79,7 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
'type' => 'number',
'input_type' => 'number',
'input_max' => 50.0,
'input_min' => 0.0
'input_min' => 0.0,
);
/**
@ -97,7 +97,7 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
'default_value' => 'px',
'type' => 'string',
'input_type' => 'select',
'input_options' => Setting::FONT_SIZE_UNIT_OPTIONS
'input_options' => Setting::FONT_SIZE_UNIT_OPTIONS,
);
/**
@ -218,6 +218,8 @@ class TooltipAppearanceSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -78,6 +78,8 @@ class TooltipDimensionsSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -172,6 +172,8 @@ class TooltipPositionSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -83,6 +83,8 @@ class TooltipsSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -111,6 +111,8 @@ class TooltipTextSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -120,6 +120,8 @@ class TooltipTimingSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -101,6 +101,8 @@ class TooltipTruncationSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -34,9 +34,9 @@ class ScopeAndPrioritySettingsSection extends SettingsSection {
/**
* Constructs the settings section.
*
* @param string options_group_slug The slug of the settings section's options group.
* @param string section_slug The slug of the settings section.
* @param string title The name of the settings section.
* @param string $options_group_slug The slug of the settings section's options group.
* @param string $section_slug The slug of the settings section.
* @param string $title The name of the settings section.
*
* @since 2.8.0
*/
@ -77,10 +77,12 @@ class ScopeAndPrioritySettingsSection extends SettingsSection {
protected function load_dependencies(): void {
parent::load_dependencies();
require_once plugin_dir_path( __DIR__ ) . 'scope-and-priority/class-wordpress-hooks-settings-group.php';
require_once plugin_dir_path( __DIR__ ) . 'scope-and-priority/class-wordpresshookssettingsgroup.php';
}
/**
* Add the settings groups for this settings section.
*
* @see SettingsSection::add_settings_groups()
*/
protected function add_settings_groups(): void {

View file

@ -268,6 +268,8 @@ class WordPressHooksSettingsGroup extends SettingsGroup {
);
/**
* Add the settings for this settings group.
*
* @see SettingsGroup::add_settings()
*/
protected function add_settings( array|false $options ): void {

View file

@ -12,9 +12,7 @@ namespace footnotes\general;
use footnotes\includes\{Footnotes, Convert, Settings};
/**
* @todo Replace with constant imports.
*/
/* TODO Replace with constant imports. */
use footnotes\includes\settings\general\ReferenceContainerSettingsGroup;
use footnotes\includes\settings\general\AMPCompatSettingsGroup;
use footnotes\includes\settings\referrersandtooltips\TooltipsSettingsGroup;

View file

@ -15,9 +15,7 @@ namespace footnotes\general;
use footnotes\includes\{Settings, Config, Convert, Template};
/**
* @todo Replace with constant imports.
*/
/* TODO Replace with constant imports. */
use footnotes\includes\settings\general\{
ExcerptsSettingsGroup,
HardLinksSettingsGroup,
@ -545,7 +543,7 @@ class Parser {
}
// Hard links scroll offset.
// TODO: remove cast
// TODO: remove cast.
self::$hard_links_enabled = (bool) $this->settings->get_setting_value( HardLinksSettingsGroup::FOOTNOTES_HARD_LINKS_ENABLE['key'] );
// Correct hard links enabled status depending on AMP-compatible or alternative reference container enabled status.
@ -820,7 +818,7 @@ class Parser {
$footnote_section_shortcode_length = strlen( $footnote_section_shortcode );
// TODO: Replace with `str_contains()`, but currently breaks Rector downgrade.
// https://github.com/rectorphp/rector/issues/6315
// <https://github.com/rectorphp/rector/issues/6315>.
if ( ! strpos( $content, (string) $footnote_section_shortcode ) ) {
// phpcs:disable WordPress.PHP.YodaConditions.NotYoda
@ -839,7 +837,7 @@ class Parser {
$sections_raw[] = substr( $rest_content, 0, $section_end );
$rest_content = substr( $rest_content, $section_end + $footnote_section_shortcode_length );
// TODO: Replace with `str_contains()`, but currently breaks Rector downgrade.
// https://github.com/rectorphp/rector/issues/6315
// <https://github.com/rectorphp/rector/issues/6315>.
} while ( strpos( $rest_content, (string) $footnote_section_shortcode ) );
$sections_raw[] = $rest_content;
@ -1745,9 +1743,8 @@ class Parser {
// If it is not, check which option is on.
$separator_option = $this->settings->get_setting_value( ReferenceContainerSettingsGroup::BACKLINKS_SEPARATOR_OPTION['key'] );
// TODO: replace with `match` (but currently it breaks the Rector
// downgrade to PHP 7.4.
// https://github.com/rectorphp/rector/issues/6315
// TODO: replace with `match` (but currently it breaks the Rector downgrade to PHP 7.4.
// <https://github.com/rectorphp/rector/issues/6315>.
switch ( $separator_option ) {
case 'comma':
$separator = ',';
@ -1779,9 +1776,8 @@ class Parser {
// If it is not, check which option is on.
$terminator_option = $this->settings->get_setting_value( ReferenceContainerSettingsGroup::BACKLINKS_TERMINATOR_OPTION['key'] );
// TODO: replace with `match` (but currently it breaks the Rector
// downgrade to PHP 7.4.
// https://github.com/rectorphp/rector/issues/6315
// TODO: replace with `match` (but currently it breaks the Rector downgrade to PHP 7.4.
// <https://github.com/rectorphp/rector/issues/6315>.
switch ( $terminator_option ) {
case 'period':
$terminator = '.';
@ -2138,7 +2134,7 @@ class Parser {
}
// Call again for robustness when priority levels don't match any longer.
// TODO: remove cast
// TODO: remove cast.
self::$scroll_offset = (int) $this->settings->get_setting_value( ScrollingSettingsGroup::FOOTNOTES_SCROLL_OFFSET['key'] );
// Streamline.