refactor: upgrade to PHP 8.0
This commit is contained in:
parent
4afbb94003
commit
39871b6cd0
7 changed files with 42 additions and 92 deletions
|
@ -28,26 +28,6 @@ use footnotes\includes as Includes;
|
||||||
*/
|
*/
|
||||||
class Admin {
|
class Admin {
|
||||||
|
|
||||||
/**
|
|
||||||
* The ID of this plugin.
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @since 2.8.0
|
|
||||||
* @see Includes\Footnotes::$plugin_name
|
|
||||||
* @var string $plugin_name The ID of this plugin.
|
|
||||||
*/
|
|
||||||
private string $plugin_name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The version of this plugin.
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @since 2.8.0
|
|
||||||
* @see Includes\Footnotes::$version
|
|
||||||
* @var string $version The current version of this plugin.
|
|
||||||
*/
|
|
||||||
private string $version;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The WYSIWYG editor integration object.
|
* The WYSIWYG editor integration object.
|
||||||
*
|
*
|
||||||
|
@ -58,16 +38,26 @@ class Admin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the class and set its properties.
|
* Initialize the class and set its properties.
|
||||||
|
|
||||||
* @param string $plugin_name The name of this plugin.
|
|
||||||
* @param string $version The version of this plugin.
|
|
||||||
*
|
*
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
*/
|
*/
|
||||||
public function __construct( string $plugin_name, string $version ) {
|
public function __construct( /**
|
||||||
|
* The ID of this plugin.
|
||||||
$this->plugin_name = $plugin_name;
|
*
|
||||||
$this->version = $version;
|
* @access private
|
||||||
|
* @since 2.8.0
|
||||||
|
* @see Includes\Footnotes::$plugin_name
|
||||||
|
* @var string $plugin_name The ID of this plugin.
|
||||||
|
*/
|
||||||
|
private string $plugin_name, /**
|
||||||
|
* The version of this plugin.
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @since 2.8.0
|
||||||
|
* @see Includes\Footnotes::$version
|
||||||
|
* @var string $version The current version of this plugin.
|
||||||
|
*/
|
||||||
|
private string $version ) {
|
||||||
|
|
||||||
$this->load_dependencies();
|
$this->load_dependencies();
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,6 @@ abstract class Engine {
|
||||||
* Returns a Priority index. Lower numbers have a higher priority.
|
* Returns a Priority index. Lower numbers have a higher priority.
|
||||||
*
|
*
|
||||||
* @abstract
|
* @abstract
|
||||||
* @return int
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@ -76,7 +75,6 @@ abstract class Engine {
|
||||||
*
|
*
|
||||||
* @abstract
|
* @abstract
|
||||||
* @access protected
|
* @access protected
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@ -87,7 +85,6 @@ abstract class Engine {
|
||||||
*
|
*
|
||||||
* @abstract
|
* @abstract
|
||||||
* @access protected
|
* @access protected
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@ -98,7 +95,6 @@ abstract class Engine {
|
||||||
*
|
*
|
||||||
* @abstract
|
* @abstract
|
||||||
* @access protected
|
* @access protected
|
||||||
* @return array
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@ -109,7 +105,6 @@ abstract class Engine {
|
||||||
*
|
*
|
||||||
* @abstract
|
* @abstract
|
||||||
* @access protected
|
* @access protected
|
||||||
* @return array
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@ -387,7 +382,6 @@ abstract class Engine {
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $p_str_text Message to be surrounded with `<span>` tags.
|
* @param string $p_str_text Message to be surrounded with `<span>` tags.
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @todo Refactor HTML generation.
|
* @todo Refactor HTML generation.
|
||||||
|
@ -402,7 +396,6 @@ abstract class Engine {
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $p_str_setting_name Settings key.
|
* @param string $p_str_setting_name Settings key.
|
||||||
* @param string $p_str_caption Label caption.
|
* @param string $p_str_caption Label caption.
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @todo Refactor HTML generation.
|
* @todo Refactor HTML generation.
|
||||||
|
@ -434,7 +427,6 @@ abstract class Engine {
|
||||||
* @param int $p_str_max_length Maximum length of the input. Default length 999 chars.
|
* @param int $p_str_max_length Maximum length of the input. Default length 999 chars.
|
||||||
* @param bool $p_bool_readonly Set the input to be read only. Default `false`.
|
* @param bool $p_bool_readonly Set the input to be read only. Default `false`.
|
||||||
* @param bool $p_bool_hidden Set the input to be hidden. Default `false`.
|
* @param bool $p_bool_hidden Set the input to be hidden. Default `false`.
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @todo Refactor HTML generation.
|
* @todo Refactor HTML generation.
|
||||||
|
@ -462,7 +454,6 @@ abstract class Engine {
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $p_str_setting_name Setting key.
|
* @param string $p_str_setting_name Setting key.
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @todo Refactor HTML generation.
|
* @todo Refactor HTML generation.
|
||||||
|
@ -484,7 +475,6 @@ abstract class Engine {
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $p_str_setting_name Setting key.
|
* @param string $p_str_setting_name Setting key.
|
||||||
* @param array $p_arr_options Possible options.
|
* @param array $p_arr_options Possible options.
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @todo Refactor HTML generation.
|
* @todo Refactor HTML generation.
|
||||||
|
@ -519,7 +509,6 @@ abstract class Engine {
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $p_str_setting_name Setting key.
|
* @param string $p_str_setting_name Setting key.
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @todo Refactor HTML generation.
|
* @todo Refactor HTML generation.
|
||||||
|
@ -541,7 +530,6 @@ abstract class Engine {
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $p_str_setting_name Setting key.
|
* @param string $p_str_setting_name Setting key.
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
* @since 1.5.6
|
* @since 1.5.6
|
||||||
* @todo Refactor HTML generation.
|
* @todo Refactor HTML generation.
|
||||||
|
@ -566,7 +554,6 @@ abstract class Engine {
|
||||||
* @param int $p_in_min Minimum value.
|
* @param int $p_in_min Minimum value.
|
||||||
* @param int $p_int_max Maximum value.
|
* @param int $p_int_max Maximum value.
|
||||||
* @param bool $p_bool_deci `true` if float, `false` if integer. Default `false`.
|
* @param bool $p_bool_deci `true` if float, `false` if integer. Default `false`.
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @todo Refactor HTML generation.
|
* @todo Refactor HTML generation.
|
||||||
|
|
|
@ -27,16 +27,6 @@ use footnotes\includes as Includes;
|
||||||
*/
|
*/
|
||||||
class Init {
|
class Init {
|
||||||
|
|
||||||
/**
|
|
||||||
* The ID of this plugin.
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @var string $plugin_name The ID of this plugin.
|
|
||||||
*
|
|
||||||
* @since 2.8.0
|
|
||||||
*/
|
|
||||||
private string $plugin_name;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Slug for the Plugin main menu.
|
* Slug for the Plugin main menu.
|
||||||
*
|
*
|
||||||
|
@ -58,14 +48,19 @@ class Init {
|
||||||
/**
|
/**
|
||||||
* Initializes all WordPress hooks for the Plugin Settings.
|
* Initializes all WordPress hooks for the Plugin Settings.
|
||||||
*
|
*
|
||||||
* @param string $plugin_name The name of the plugin.
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @since 2.8.0 Added `$plugin_name` parameter.
|
* @since 2.8.0 Added `$plugin_name` parameter.
|
||||||
*/
|
*/
|
||||||
public function __construct( string $plugin_name ) {
|
public function __construct( /**
|
||||||
$this->plugin_name = $plugin_name;
|
* The ID of this plugin.
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @var string $plugin_name The ID of this plugin.
|
||||||
|
*
|
||||||
|
* @since 2.8.0
|
||||||
|
*/
|
||||||
|
private string $plugin_name ) {
|
||||||
$this->load_dependencies();
|
$this->load_dependencies();
|
||||||
|
|
||||||
$this->settings_page = new Settings( $this->plugin_name );
|
$this->settings_page = new Settings( $this->plugin_name );
|
||||||
|
|
|
@ -177,7 +177,7 @@ class Convert {
|
||||||
* @todo Review.
|
* @todo Review.
|
||||||
* @todo Single return type.
|
* @todo Single return type.
|
||||||
*/
|
*/
|
||||||
public static function get_arrow( int $p_int_index = -1 ) {
|
public static function get_arrow( int $p_int_index = -1 ): string|array {
|
||||||
// Define all possible arrows.
|
// Define all possible arrows.
|
||||||
$l_arr_arrows = array( '↑', '↥', '↟', '↩', '↲', '↵', '⇑', '⇡', '⇧', '↑' );
|
$l_arr_arrows = array( '↑', '↥', '↟', '↩', '↲', '↵', '⇑', '⇡', '⇧', '↑' );
|
||||||
// Convert index to an integer.
|
// Convert index to an integer.
|
||||||
|
|
|
@ -1344,7 +1344,6 @@ class Settings {
|
||||||
/**
|
/**
|
||||||
* Returns a singleton of this class.
|
* Returns a singleton of this class.
|
||||||
*
|
*
|
||||||
* @return Settings
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @todo Remove?
|
* @todo Remove?
|
||||||
|
@ -1432,7 +1431,6 @@ class Settings {
|
||||||
*
|
*
|
||||||
* @param int $p_int_index Index of the Setting Container.
|
* @param int $p_int_index Index of the Setting Container.
|
||||||
* @param array $p_arr_new_values The new Settings value(s).
|
* @param array $p_arr_new_values The new Settings value(s).
|
||||||
* @return bool
|
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -180,7 +180,7 @@ class Template {
|
||||||
* @param string $p_str_extension The file extension of the template.
|
* @param string $p_str_extension The file extension of the template.
|
||||||
* @return string|bool `false` or the template path
|
* @return string|bool `false` or the template path
|
||||||
*/
|
*/
|
||||||
public function get_template( string $p_str_file_type, string $p_str_file_name, string $p_str_extension = 'html' ) {
|
public function get_template( string $p_str_file_type, string $p_str_file_name, string $p_str_extension = 'html' ): string|bool {
|
||||||
$located = false;
|
$located = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -792,7 +792,7 @@ class Parser {
|
||||||
$l_str_footnote_section_shortcode = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_FOOTNOTE_SECTION_SHORTCODE );
|
$l_str_footnote_section_shortcode = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_FOOTNOTE_SECTION_SHORTCODE );
|
||||||
$l_int_footnote_section_shortcode_length = strlen( $l_str_footnote_section_shortcode );
|
$l_int_footnote_section_shortcode_length = strlen( $l_str_footnote_section_shortcode );
|
||||||
|
|
||||||
if ( strpos( $p_str_content, (string) $l_str_footnote_section_shortcode ) === false ) {
|
if ( !str_contains( $p_str_content, (string) $l_str_footnote_section_shortcode ) ) {
|
||||||
|
|
||||||
// phpcs:disable WordPress.PHP.YodaConditions.NotYoda
|
// phpcs:disable WordPress.PHP.YodaConditions.NotYoda
|
||||||
// Appends the reference container if set to "post_end".
|
// Appends the reference container if set to "post_end".
|
||||||
|
@ -809,7 +809,7 @@ class Parser {
|
||||||
$l_int_section_end = strpos( $l_str_rest_content, (string) $l_str_footnote_section_shortcode );
|
$l_int_section_end = strpos( $l_str_rest_content, (string) $l_str_footnote_section_shortcode );
|
||||||
$l_arr_sections_raw[] = substr( $l_str_rest_content, 0, $l_int_section_end );
|
$l_arr_sections_raw[] = substr( $l_str_rest_content, 0, $l_int_section_end );
|
||||||
$l_str_rest_content = substr( $l_str_rest_content, $l_int_section_end + $l_int_footnote_section_shortcode_length );
|
$l_str_rest_content = substr( $l_str_rest_content, $l_int_section_end + $l_int_footnote_section_shortcode_length );
|
||||||
} while ( strpos( $l_str_rest_content, (string) $l_str_footnote_section_shortcode ) !== false );
|
} while ( str_contains( $l_str_rest_content, (string) $l_str_footnote_section_shortcode ) );
|
||||||
$l_arr_sections_raw[] = $l_str_rest_content;
|
$l_arr_sections_raw[] = $l_str_rest_content;
|
||||||
|
|
||||||
foreach ( $l_arr_sections_raw as $l_str_section ) {
|
foreach ( $l_arr_sections_raw as $l_str_section ) {
|
||||||
|
@ -1033,7 +1033,6 @@ class Parser {
|
||||||
* @param string $p_str_content Any string that may contain footnotes to be replaced.
|
* @param string $p_str_content Any string that may contain footnotes to be replaced.
|
||||||
* @param bool $p_bool_output_references Appends the Reference Container to the output if set to true, default true.
|
* @param bool $p_bool_output_references Appends the Reference Container to the output if set to true, default true.
|
||||||
* @param bool $p_bool_hide_footnotes_text Hide footnotes found in the string.
|
* @param bool $p_bool_hide_footnotes_text Hide footnotes found in the string.
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public function exec( string $p_str_content, bool $p_bool_output_references = false, bool $p_bool_hide_footnotes_text = false ): string {
|
public function exec( string $p_str_content, bool $p_bool_output_references = false, bool $p_bool_hide_footnotes_text = false ): string {
|
||||||
|
|
||||||
|
@ -1156,7 +1155,6 @@ class Parser {
|
||||||
*
|
*
|
||||||
* @param string $p_str_content Any content to be parsed for footnotes.
|
* @param string $p_str_content Any content to be parsed for footnotes.
|
||||||
* @param bool $p_bool_hide_footnotes_text Hide footnotes found in the string.
|
* @param bool $p_bool_hide_footnotes_text Hide footnotes found in the string.
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public function search( string $p_str_content, bool $p_bool_hide_footnotes_text ): string {
|
public function search( string $p_str_content, bool $p_bool_hide_footnotes_text ): string {
|
||||||
|
|
||||||
|
@ -1667,8 +1665,6 @@ class Parser {
|
||||||
* Generates the reference container.
|
* Generates the reference container.
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public function reference_container(): string {
|
public function reference_container(): string {
|
||||||
|
|
||||||
|
@ -1717,24 +1713,16 @@ class Parser {
|
||||||
*/
|
*/
|
||||||
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_SEPARATOR_ENABLED ) ) ) {
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_SEPARATOR_ENABLED ) ) ) {
|
||||||
|
|
||||||
// Check if it is input-configured.
|
|
||||||
$l_str_separator = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_SEPARATOR_CUSTOM );
|
|
||||||
|
|
||||||
if ( empty( $l_str_separator ) ) {
|
if ( empty( $l_str_separator ) ) {
|
||||||
|
|
||||||
// If it is not, check which option is on.
|
// If it is not, check which option is on.
|
||||||
$l_str_separator_option = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_SEPARATOR_OPTION );
|
$l_str_separator_option = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_SEPARATOR_OPTION );
|
||||||
switch ( $l_str_separator_option ) {
|
$l_str_separator = match ($l_str_separator_option) {
|
||||||
case 'comma':
|
'comma' => ',',
|
||||||
$l_str_separator = ',';
|
'semicolon' => ';',
|
||||||
break;
|
'en_dash' => ' –',
|
||||||
case 'semicolon':
|
default => Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_SEPARATOR_CUSTOM ),
|
||||||
$l_str_separator = ';';
|
};
|
||||||
break;
|
|
||||||
case 'en_dash':
|
|
||||||
$l_str_separator = ' –';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -1748,24 +1736,16 @@ class Parser {
|
||||||
*/
|
*/
|
||||||
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_TERMINATOR_ENABLED ) ) ) {
|
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_TERMINATOR_ENABLED ) ) ) {
|
||||||
|
|
||||||
// Check if it is input-configured.
|
|
||||||
$l_str_terminator = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_TERMINATOR_CUSTOM );
|
|
||||||
|
|
||||||
if ( empty( $l_str_terminator ) ) {
|
if ( empty( $l_str_terminator ) ) {
|
||||||
|
|
||||||
// If it is not, check which option is on.
|
// If it is not, check which option is on.
|
||||||
$l_str_terminator_option = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_TERMINATOR_OPTION );
|
$l_str_terminator_option = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_TERMINATOR_OPTION );
|
||||||
switch ( $l_str_terminator_option ) {
|
$l_str_terminator = match ($l_str_terminator_option) {
|
||||||
case 'period':
|
'period' => '.',
|
||||||
$l_str_terminator = '.';
|
'parenthesis' => ')',
|
||||||
break;
|
'colon' => ':',
|
||||||
case 'parenthesis':
|
default => Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_TERMINATOR_CUSTOM ),
|
||||||
$l_str_terminator = ')';
|
};
|
||||||
break;
|
|
||||||
case 'colon':
|
|
||||||
$l_str_terminator = ':';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
Reference in a new issue