refactor: add strict typing
This commit is contained in:
parent
c1421d1978
commit
9aae69a693
19 changed files with 83 additions and 49 deletions
|
@ -115,7 +115,7 @@ class Admin {
|
||||||
array(),
|
array(),
|
||||||
( PRODUCTION_ENV ) ? $this->version : filemtime(
|
( PRODUCTION_ENV ) ? $this->version : filemtime(
|
||||||
plugin_dir_path(
|
plugin_dir_path(
|
||||||
__FILE__
|
__FILE__
|
||||||
) . 'css/settings.css'
|
) . 'css/settings.css'
|
||||||
),
|
),
|
||||||
'all'
|
'all'
|
||||||
|
|
|
@ -583,7 +583,7 @@ abstract class Engine {
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @todo Refactor HTML generation.
|
* @todo Refactor HTML generation.
|
||||||
*/
|
*/
|
||||||
protected function add_num_box( string $p_str_setting_name, int $p_in_min, int $p_int_max, bool $p_bool_deci = false ): string {
|
protected function add_num_box( string $p_str_setting_name, int $p_in_min, int $p_int_max, bool $p_bool_deci = false ): string {
|
||||||
// Collect data for given settings field.
|
// Collect data for given settings field.
|
||||||
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
$l_arr_data = $this->load_setting( $p_str_setting_name );
|
||||||
|
|
||||||
|
|
|
@ -1231,7 +1231,7 @@ class Settings extends Engine {
|
||||||
* @todo Review in light of admin/public split.
|
* @todo Review in light of admin/public split.
|
||||||
*/
|
*/
|
||||||
public function help(): void {
|
public function help(): void {
|
||||||
$footnotes = new General\General($this->plugin_name, "foo");
|
$footnotes = new General\General( $this->plugin_name, 'foo' );
|
||||||
|
|
||||||
// Load footnotes starting and end tag.
|
// Load footnotes starting and end tag.
|
||||||
$l_arr_footnote_starting_tag = $this->load_setting( \footnotes\includes\Settings::C_STR_FOOTNOTES_SHORT_CODE_START );
|
$l_arr_footnote_starting_tag = $this->load_setting( \footnotes\includes\Settings::C_STR_FOOTNOTES_SHORT_CODE_START );
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace footnotes;
|
namespace footnotes;
|
||||||
|
|
||||||
// If this file is called directly, abort.
|
// If this file is called directly, abort.
|
||||||
|
@ -93,9 +95,10 @@ function deactivate_footnotes(): void {
|
||||||
* Uncaught TypeError: call_user_func_array(): Argument #1 ($function) must be
|
* Uncaught TypeError: call_user_func_array(): Argument #1 ($function) must be
|
||||||
* a valid callback, function "deactivate_footnotes" not found or invalid
|
* a valid callback, function "deactivate_footnotes" not found or invalid
|
||||||
* function name in /srv/www/wordpress-one/public_html/wp-includes/class-wp-hook.php:292
|
* function name in /srv/www/wordpress-one/public_html/wp-includes/class-wp-hook.php:292
|
||||||
|
*
|
||||||
|
* register_activation_hook( __FILE__, 'activate_footnotes' );
|
||||||
|
* register_deactivation_hook( __FILE__, 'deactivate_footnotes' );
|
||||||
*/
|
*/
|
||||||
//register_activation_hook( __FILE__, 'activate_footnotes' );
|
|
||||||
//register_deactivation_hook( __FILE__, 'deactivate_footnotes' );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The core plugin class that defines internationalization, admin-specific and
|
* The core plugin class that defines internationalization, admin-specific and
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace footnotes\includes;
|
namespace footnotes\includes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace footnotes\includes;
|
namespace footnotes\includes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
* rename `class/` sub-directory to `includes/`.
|
* rename `class/` sub-directory to `includes/`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace footnotes\includes;
|
namespace footnotes\includes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +42,7 @@ class Convert {
|
||||||
return self::to_arabic_leading( $p_int_index );
|
return self::to_arabic_leading( $p_int_index );
|
||||||
case 'arabic_plain':
|
case 'arabic_plain':
|
||||||
default:
|
default:
|
||||||
return $p_int_index;
|
return (string) $p_int_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
* Renamed parent `class/` directory to `includes/`.
|
* Renamed parent `class/` directory to `includes/`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace footnotes\includes;
|
namespace footnotes\includes;
|
||||||
|
|
||||||
use footnotes\general as General;
|
use footnotes\general as General;
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace footnotes\includes;
|
namespace footnotes\includes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
* rename `class/` sub-directory to `includes/`.
|
* rename `class/` sub-directory to `includes/`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace footnotes\includes;
|
namespace footnotes\includes;
|
||||||
|
|
||||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-config.php';
|
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-config.php';
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace footnotes\includes;
|
namespace footnotes\includes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
* Renamed parent `class/` directory to `includes/`.
|
* Renamed parent `class/` directory to `includes/`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace footnotes\includes;
|
namespace footnotes\includes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
* rename `class/` sub-directory to `includes/`.
|
* rename `class/` sub-directory to `includes/`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace footnotes\includes;
|
namespace footnotes\includes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,7 +122,7 @@ class Template {
|
||||||
}
|
}
|
||||||
// Iterate through each placeholder and replace it with its value.
|
// Iterate through each placeholder and replace it with its value.
|
||||||
foreach ( $p_arr_placeholders as $l_str_placeholder => $l_str_value ) {
|
foreach ( $p_arr_placeholders as $l_str_placeholder => $l_str_value ) {
|
||||||
$this->a_str_replaced_content = str_replace( '[[' . $l_str_placeholder . ']]', $l_str_value, $this->a_str_replaced_content );
|
$this->a_str_replaced_content = str_replace( '[[' . $l_str_placeholder . ']]', (string) $l_str_value, $this->a_str_replaced_content );
|
||||||
}
|
}
|
||||||
// Success.
|
// Success.
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace footnotes\general;
|
namespace footnotes\general;
|
||||||
|
|
||||||
use footnotes\includes as Includes;
|
use footnotes\includes as Includes;
|
||||||
|
@ -29,7 +31,7 @@ class General {
|
||||||
* @access private
|
* @access private
|
||||||
* @var string $plugin_name The ID of this plugin.
|
* @var string $plugin_name The ID of this plugin.
|
||||||
*/
|
*/
|
||||||
private $plugin_name;
|
private string $plugin_name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The version of this plugin.
|
* The version of this plugin.
|
||||||
|
@ -39,7 +41,7 @@ class General {
|
||||||
* @access private
|
* @access private
|
||||||
* @var string $version The current version of this plugin.
|
* @var string $version The current version of this plugin.
|
||||||
*/
|
*/
|
||||||
private $version;
|
private string $version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The reference container widget.
|
* The reference container widget.
|
||||||
|
@ -48,17 +50,18 @@ class General {
|
||||||
*
|
*
|
||||||
* @var Widget\Reference_Container $reference_container_widget The reference container widget
|
* @var Widget\Reference_Container $reference_container_widget The reference container widget
|
||||||
*/
|
*/
|
||||||
private $reference_container_widget;
|
private Widget\Reference_Container $reference_container_widget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The footnote parser.
|
* The footnote parser.
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @since 2.8.0 Moved from {@see Footnotes} to {@see Includes\Public}.
|
* @since 2.8.0 Moved from {@see Footnotes} to {@see Includes\Public}.
|
||||||
|
* @todo Review null init.
|
||||||
*
|
*
|
||||||
* @var Parser $task The Plugin task.
|
* @var Parser $task The Plugin task.
|
||||||
*/
|
*/
|
||||||
public $a_obj_task = null;
|
public ?Parser $a_obj_task = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag for using tooltips.
|
* Flag for using tooltips.
|
||||||
|
@ -107,7 +110,7 @@ class General {
|
||||||
* @param string $plugin_name The name of this plugin.
|
* @param string $plugin_name The name of this plugin.
|
||||||
* @param string $version The version of this plugin.
|
* @param string $version The version of this plugin.
|
||||||
*/
|
*/
|
||||||
public function __construct( $plugin_name, $version ) {
|
public function __construct( string $plugin_name, string $version ) {
|
||||||
|
|
||||||
$this->plugin_name = $plugin_name;
|
$this->plugin_name = $plugin_name;
|
||||||
$this->version = $version;
|
$this->version = $version;
|
||||||
|
@ -132,7 +135,7 @@ class General {
|
||||||
*
|
*
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
*/
|
*/
|
||||||
private function load_dependencies() {
|
private function load_dependencies(): void {
|
||||||
// TODO: neaten up and document once placements and names are settled.
|
// TODO: neaten up and document once placements and names are settled.
|
||||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-config.php';
|
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-config.php';
|
||||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-settings.php';
|
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-settings.php';
|
||||||
|
@ -156,7 +159,7 @@ class General {
|
||||||
* @since 2.5.5 Change stylesheet schema.
|
* @since 2.5.5 Change stylesheet schema.
|
||||||
* @since 2.8.0 Moved from {@see Footnotes} to {@see Includes\Public}.
|
* @since 2.8.0 Moved from {@see Footnotes} to {@see Includes\Public}.
|
||||||
*/
|
*/
|
||||||
public function enqueue_styles() {
|
public function enqueue_styles(): void {
|
||||||
if ( PRODUCTION_ENV ) {
|
if ( PRODUCTION_ENV ) {
|
||||||
// Set tooltip mode for use in stylesheet name.
|
// Set tooltip mode for use in stylesheet name.
|
||||||
if ( self::$a_bool_tooltips_enabled ) {
|
if ( self::$a_bool_tooltips_enabled ) {
|
||||||
|
@ -204,20 +207,20 @@ class General {
|
||||||
array(),
|
array(),
|
||||||
( PRODUCTION_ENV ) ? $this->version : filemtime(
|
( PRODUCTION_ENV ) ? $this->version : filemtime(
|
||||||
plugin_dir_path(
|
plugin_dir_path(
|
||||||
__FILE__
|
__FILE__
|
||||||
) . "css/footnotes-{$l_str_tooltip_mode_short}brpl{$l_str_layout_mode}.min.css"
|
) . "css/footnotes-{$l_str_tooltip_mode_short}brpl{$l_str_layout_mode}.min.css"
|
||||||
),
|
),
|
||||||
'all'
|
'all'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
foreach (array('amp-tooltips', 'common', 'layout-entry-content', 'layout-main-content', 'layout-reference-container', 'tooltips', 'tooltips-alternative') as $val) {
|
foreach ( array( 'amp-tooltips', 'common', 'layout-entry-content', 'layout-main-content', 'layout-reference-container', 'tooltips', 'tooltips-alternative' ) as $val ) {
|
||||||
wp_enqueue_style(
|
wp_enqueue_style(
|
||||||
"footnotes-$val",
|
"footnotes-$val",
|
||||||
plugin_dir_url( __FILE__ ) . "css/dev-$val.css",
|
plugin_dir_url( __FILE__ ) . "css/dev-$val.css",
|
||||||
array(),
|
array(),
|
||||||
filemtime(
|
filemtime(
|
||||||
plugin_dir_path(
|
plugin_dir_path(
|
||||||
__FILE__
|
__FILE__
|
||||||
) . "css/dev-$val.css"
|
) . "css/dev-$val.css"
|
||||||
),
|
),
|
||||||
'all'
|
'all'
|
||||||
|
@ -235,7 +238,7 @@ class General {
|
||||||
* @since 2.5.6 Add jQuery dependency.
|
* @since 2.5.6 Add jQuery dependency.
|
||||||
* @since 2.8.0 Moved from {@see Footnotes} to {@see Includes\Public}.
|
* @since 2.8.0 Moved from {@see Footnotes} to {@see Includes\Public}.
|
||||||
*/
|
*/
|
||||||
public function enqueue_scripts() {
|
public function enqueue_scripts(): void {
|
||||||
/*
|
/*
|
||||||
* Enqueues the jQuery library registered by WordPress.
|
* Enqueues the jQuery library registered by WordPress.
|
||||||
*
|
*
|
||||||
|
@ -284,7 +287,7 @@ class General {
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @since 2.8.0 Moved from {@see Footnotes} to {@see Includes\Public}.
|
* @since 2.8.0 Moved from {@see Footnotes} to {@see Includes\Public}.
|
||||||
*/
|
*/
|
||||||
public function register_widgets() {
|
public function register_widgets(): void {
|
||||||
register_widget( $this->reference_container_widget );
|
register_widget( $this->reference_container_widget );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
* move from `class/` sub-directory to `public/`.
|
* move from `class/` sub-directory to `public/`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace footnotes\general;
|
namespace footnotes\general;
|
||||||
|
|
||||||
use footnotes\includes as Includes;
|
use footnotes\includes as Includes;
|
||||||
|
@ -284,7 +286,7 @@ class Parser {
|
||||||
* @since 2.1.0 Remove @see 'the_post' support.
|
* @since 2.1.0 Remove @see 'the_post' support.
|
||||||
* @todo Move to {@see General}.
|
* @todo Move to {@see General}.
|
||||||
*/
|
*/
|
||||||
public function register_hooks() {
|
public function register_hooks(): void {
|
||||||
// Get values from settings.
|
// Get values from settings.
|
||||||
$l_int_the_title_priority = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL );
|
$l_int_the_title_priority = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::C_INT_EXPERT_LOOKUP_THE_TITLE_PRIORITY_LEVEL );
|
||||||
$l_int_the_content_priority = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL );
|
$l_int_the_content_priority = (int) Includes\Settings::instance()->get( \footnotes\includes\Settings::C_INT_EXPERT_LOOKUP_THE_CONTENT_PRIORITY_LEVEL );
|
||||||
|
@ -431,7 +433,7 @@ class Parser {
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @todo Refactor to enqueue stylesheets properly in {@see General}.
|
* @todo Refactor to enqueue stylesheets properly in {@see General}.
|
||||||
*/
|
*/
|
||||||
public function footnotes_output_head() {
|
public function footnotes_output_head(): void {
|
||||||
|
|
||||||
// Insert start tag without switching out of PHP.
|
// Insert start tag without switching out of PHP.
|
||||||
echo "\r\n<style type=\"text/css\" media=\"all\">\r\n";
|
echo "\r\n<style type=\"text/css\" media=\"all\">\r\n";
|
||||||
|
@ -746,7 +748,7 @@ class Parser {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function footnotes_output_footer() {
|
public function footnotes_output_footer(): void {
|
||||||
if ( 'footer' === Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_REFERENCE_CONTAINER_POSITION ) ) {
|
if ( 'footer' === Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_REFERENCE_CONTAINER_POSITION ) ) {
|
||||||
echo $this->reference_container();
|
echo $this->reference_container();
|
||||||
}
|
}
|
||||||
|
@ -805,7 +807,7 @@ class Parser {
|
||||||
* @param string $p_str_content Title.
|
* @param string $p_str_content Title.
|
||||||
* @return string $p_str_content Title with replaced footnotes.
|
* @return string $p_str_content Title with replaced footnotes.
|
||||||
*/
|
*/
|
||||||
public function footnotes_in_title( $p_str_content ) {
|
public function footnotes_in_title( string $p_str_content ): string {
|
||||||
// Appends the reference container if set to "post_end".
|
// Appends the reference container if set to "post_end".
|
||||||
return $this->exec( $p_str_content, false );
|
return $this->exec( $p_str_content, false );
|
||||||
}
|
}
|
||||||
|
@ -818,7 +820,7 @@ class Parser {
|
||||||
* @param string $p_str_content Page/Post content.
|
* @param string $p_str_content Page/Post content.
|
||||||
* @return string $p_str_content Content with replaced footnotes.
|
* @return string $p_str_content Content with replaced footnotes.
|
||||||
*/
|
*/
|
||||||
public function footnotes_in_content( $p_str_content ) {
|
public function footnotes_in_content( string $p_str_content ): string {
|
||||||
|
|
||||||
$l_str_ref_container_position = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_REFERENCE_CONTAINER_POSITION );
|
$l_str_ref_container_position = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_REFERENCE_CONTAINER_POSITION );
|
||||||
$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 );
|
||||||
|
@ -864,7 +866,7 @@ class Parser {
|
||||||
* @param string $p_str_excerpt Excerpt content.
|
* @param string $p_str_excerpt Excerpt content.
|
||||||
* @return string $p_str_excerpt Processed or new excerpt.
|
* @return string $p_str_excerpt Processed or new excerpt.
|
||||||
*/
|
*/
|
||||||
public function footnotes_in_excerpt( $p_str_excerpt ) {
|
public function footnotes_in_excerpt( string $p_str_excerpt ): string {
|
||||||
$l_str_excerpt_mode = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_FOOTNOTES_IN_EXCERPT );
|
$l_str_excerpt_mode = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_FOOTNOTES_IN_EXCERPT );
|
||||||
|
|
||||||
if ( 'yes' === $l_str_excerpt_mode ) {
|
if ( 'yes' === $l_str_excerpt_mode ) {
|
||||||
|
@ -891,7 +893,7 @@ class Parser {
|
||||||
* @param string $p_str_content The post.
|
* @param string $p_str_content The post.
|
||||||
* @return string $p_str_content An excerpt of the post.
|
* @return string $p_str_content An excerpt of the post.
|
||||||
*/
|
*/
|
||||||
public function generate_excerpt( $p_str_content ) {
|
public function generate_excerpt( string $p_str_content ): string {
|
||||||
|
|
||||||
// Discard existing excerpt and start on the basis of the post.
|
// Discard existing excerpt and start on the basis of the post.
|
||||||
$p_str_content = get_the_content( get_the_id() );
|
$p_str_content = get_the_content( get_the_id() );
|
||||||
|
@ -936,7 +938,7 @@ class Parser {
|
||||||
* @param string $p_str_content The post.
|
* @param string $p_str_content The post.
|
||||||
* @return string $p_str_content An excerpt of the post.
|
* @return string $p_str_content An excerpt of the post.
|
||||||
*/
|
*/
|
||||||
public function generate_excerpt_with_footnotes( $p_str_content ) {
|
public function generate_excerpt_with_footnotes( string $p_str_content ): string {
|
||||||
|
|
||||||
// Discard existing excerpt and start on the basis of the post.
|
// Discard existing excerpt and start on the basis of the post.
|
||||||
$p_str_content = get_the_content( get_the_id() );
|
$p_str_content = get_the_content( get_the_id() );
|
||||||
|
@ -1037,7 +1039,7 @@ class Parser {
|
||||||
* @param string $p_str_content Widget content.
|
* @param string $p_str_content Widget content.
|
||||||
* @return string $p_str_content Content with replaced footnotes.
|
* @return string $p_str_content Content with replaced footnotes.
|
||||||
*/
|
*/
|
||||||
public function footnotes_in_widget_title( $p_str_content ) {
|
public function footnotes_in_widget_title( string $p_str_content ): string {
|
||||||
// Appends the reference container if set to "post_end".
|
// Appends the reference container if set to "post_end".
|
||||||
return $this->exec( $p_str_content, false );
|
return $this->exec( $p_str_content, false );
|
||||||
}
|
}
|
||||||
|
@ -1050,7 +1052,7 @@ class Parser {
|
||||||
* @param string $p_str_content Widget content.
|
* @param string $p_str_content Widget content.
|
||||||
* @return string $p_str_content Content with replaced footnotes.
|
* @return string $p_str_content Content with replaced footnotes.
|
||||||
*/
|
*/
|
||||||
public function footnotes_in_widget_text( $p_str_content ) {
|
public function footnotes_in_widget_text( string $p_str_content ): string {
|
||||||
// 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".
|
||||||
return $this->exec( $p_str_content, 'post_end' === Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_REFERENCE_CONTAINER_POSITION ) );
|
return $this->exec( $p_str_content, 'post_end' === Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_REFERENCE_CONTAINER_POSITION ) );
|
||||||
|
@ -1067,7 +1069,7 @@ class Parser {
|
||||||
* @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
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function exec( $p_str_content, $p_bool_output_references = false, $p_bool_hide_footnotes_text = false ) {
|
public function exec( string $p_str_content, bool $p_bool_output_references = false, bool $p_bool_hide_footnotes_text = false ): string {
|
||||||
|
|
||||||
// Process content.
|
// Process content.
|
||||||
$p_str_content = $this->search( $p_str_content, $p_bool_hide_footnotes_text );
|
$p_str_content = $this->search( $p_str_content, $p_bool_hide_footnotes_text );
|
||||||
|
@ -1122,7 +1124,7 @@ class Parser {
|
||||||
*
|
*
|
||||||
* @param string $p_str_content The footnote, including delimiters.
|
* @param string $p_str_content The footnote, including delimiters.
|
||||||
*/
|
*/
|
||||||
public function unify_delimiters( $p_str_content ) {
|
public function unify_delimiters( string $p_str_content ): string {
|
||||||
|
|
||||||
// Get footnotes start and end tag short codes.
|
// Get footnotes start and end tag short codes.
|
||||||
$l_str_starting_tag = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_FOOTNOTES_SHORT_CODE_START );
|
$l_str_starting_tag = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_FOOTNOTES_SHORT_CODE_START );
|
||||||
|
@ -1184,12 +1186,13 @@ class Parser {
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @todo Refactor to parse DOM rather than using RegEx.
|
* @todo Refactor to parse DOM rather than using RegEx.
|
||||||
|
* @todo Decompose.
|
||||||
*
|
*
|
||||||
* @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
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function search( $p_str_content, $p_bool_hide_footnotes_text ) {
|
public function search( string $p_str_content, bool $p_bool_hide_footnotes_text ): string {
|
||||||
|
|
||||||
// Get footnote delimiter shortcodes and unify them.
|
// Get footnote delimiter shortcodes and unify them.
|
||||||
$p_str_content = self::unify_delimiters( $p_str_content );
|
$p_str_content = self::unify_delimiters( $p_str_content );
|
||||||
|
@ -1701,7 +1704,7 @@ class Parser {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function reference_container() {
|
public function reference_container(): string {
|
||||||
|
|
||||||
// No footnotes have been replaced on this page.
|
// No footnotes have been replaced on this page.
|
||||||
if ( empty( self::$a_arr_footnotes ) ) {
|
if ( empty( self::$a_arr_footnotes ) ) {
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace footnotes\general\Widget;
|
namespace footnotes\general\Widget;
|
||||||
|
|
||||||
use footnotes\includes as Includes;
|
use footnotes\includes as Includes;
|
||||||
|
@ -36,7 +38,7 @@ abstract class Base extends \WP_Widget {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
abstract protected function get_id();
|
abstract protected function get_id(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Public name of child Widget to be displayed in the Configuration page.
|
* Returns the Public name of child Widget to be displayed in the Configuration page.
|
||||||
|
@ -46,7 +48,7 @@ abstract class Base extends \WP_Widget {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
abstract protected function get_name();
|
abstract protected function get_name(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Description of the child widget.
|
* Returns the Description of the child widget.
|
||||||
|
@ -56,7 +58,7 @@ abstract class Base extends \WP_Widget {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
abstract protected function get_description();
|
abstract protected function get_description(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the width of the Widget. Default width is 250 pixel.
|
* Returns the width of the Widget. Default width is 250 pixel.
|
||||||
|
@ -65,7 +67,7 @@ abstract class Base extends \WP_Widget {
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
protected function get_widget_width() {
|
protected function get_widget_width(): int {
|
||||||
return 250;
|
return 250;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO: Disabled pending WPWidget AP review.
|
||||||
|
/* declare(strict_types=1); */
|
||||||
|
|
||||||
namespace footnotes\general\Widget;
|
namespace footnotes\general\Widget;
|
||||||
|
|
||||||
use footnotes\includes as Includes;
|
use footnotes\includes as Includes;
|
||||||
|
@ -34,7 +37,7 @@ class Reference_Container extends Base {
|
||||||
* @see Includes\Footnotes::$plugin_name
|
* @see Includes\Footnotes::$plugin_name
|
||||||
* @var string $plugin_name The ID of this plugin.
|
* @var string $plugin_name The ID of this plugin.
|
||||||
*/
|
*/
|
||||||
private $plugin_name;
|
private string $plugin_name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the class and set its properties.
|
* Initialize the class and set its properties.
|
||||||
|
@ -43,9 +46,9 @@ class Reference_Container extends Base {
|
||||||
*
|
*
|
||||||
* @param string $plugin_name The name of this plugin.
|
* @param string $plugin_name The name of this plugin.
|
||||||
*/
|
*/
|
||||||
public function __construct( $plugin_name ) {
|
public function __construct( string $plugin_name ) {
|
||||||
parent::__construct();
|
|
||||||
$this->plugin_name = $plugin_name;
|
$this->plugin_name = $plugin_name;
|
||||||
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +59,7 @@ class Reference_Container extends Base {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function get_id() {
|
protected function get_id(): string {
|
||||||
return 'footnotes_widget';
|
return 'footnotes_widget';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +71,7 @@ class Reference_Container extends Base {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function get_name() {
|
protected function get_name(): string {
|
||||||
return $this->plugin_name;
|
return $this->plugin_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +83,7 @@ class Reference_Container extends Base {
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function get_description() {
|
protected function get_description(): string {
|
||||||
return __( 'The widget defines the position of the reference container if set to “widget area”.', 'footnotes' );
|
return __( 'The widget defines the position of the reference container if set to “widget area”.', 'footnotes' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
// If uninstall not called from WordPress, then exit.
|
// If uninstall not called from WordPress, then exit.
|
||||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||||
exit;
|
exit;
|
||||||
|
|
Reference in a new issue