chore: lint code

This commit is contained in:
Ben Goldsworthy 2021-05-01 19:22:41 +01:00
parent 7ad975c389
commit f0c6b07a84
17 changed files with 257 additions and 269 deletions

View file

@ -208,6 +208,7 @@ class Footnotes_Layout_Settings extends Footnotes_Layout_Engine {
'semicolon' => __( 'SEMICOLON', 'footnotes' ), 'semicolon' => __( 'SEMICOLON', 'footnotes' ),
'en_dash' => __( 'EN DASH', 'footnotes' ), 'en_dash' => __( 'EN DASH', 'footnotes' ),
); );
/* /*
* Options for the terminating punctuation after backlinks. * Options for the terminating punctuation after backlinks.
* The Unicode name of RIGHT PARENTHESIS was originally more accurate because. * The Unicode name of RIGHT PARENTHESIS was originally more accurate because.

View file

@ -10,7 +10,6 @@
* @package footnotes * @package footnotes
* @license GPL-3.0-only * @license GPL-3.0-only
* @copyright 2021 Mark Cheret (email: mark@cheret.de) * @copyright 2021 Mark Cheret (email: mark@cheret.de)
*
* @since 1.0.0 * @since 1.0.0
* *
* @wordpress-plugin * @wordpress-plugin
@ -34,48 +33,56 @@ if ( ! defined( 'WPINC' ) ) {
} }
/** /**
* The current plugin version. * The plugin version.
* *
* @link https://github.com/markcheret/footnotes/wiki/Versioning Versioning Guide * @link https://github.com/markcheret/footnotes/wiki/Versioning Versioning Guide
* *
* @global string PLUGIN_VERSION
*
* @since 2.1.4 * @since 2.1.4
* @todo Draw from envfile rather than hard-coding.
* @var string PLUGIN_VERSION The version of this instance of the plugin.
*/ */
define( 'PLUGIN_VERSION', '2.8.0d' ); define( 'PLUGIN_VERSION', '2.8.0d' );
/** /**
* The current environment ('development' or 'production'). * The environment that the plugin is configured for.
* *
* This primarily affects whether minified or unminified files are requested. * This primarily affects whether minified or unminified CSS/JS files are
* * requested.
* @global bool PRODUCTION_ENV
* *
* @since 2.5.5 * @since 2.5.5
* @todo Draw from envfile rather than hard-coding.
* @todo Replace with string for >2 environment options.
* @var bool PRODUCTION_ENV Whether the plugin is running in production mode or not. Default `false`.
*/ */
define( 'PRODUCTION_ENV', false ); define( 'PRODUCTION_ENV', false );
/** /**
* Triggers during plugin activation. * Handles the activation of the plugin.
*
* @uses Footnotes_Activator::activate() Method called on plugin activation.
* *
* @since 2.8.0 * @since 2.8.0
* @see Footnotes_Activator::activate()
*/ */
function activate_footnotes() { function activate_footnotes() {
/**
* Provides plugin activation functionality.
*/
require_once plugin_dir_path( __FILE__ ) . 'includes/class-footnotes-activator.php'; require_once plugin_dir_path( __FILE__ ) . 'includes/class-footnotes-activator.php';
Footnotes_Activator::activate(); Footnotes_Activator::activate();
} }
/** /**
* Triggers during plugin deactivation. * Handles the deactivation of the plugin.
*
* @uses Footnotes_Deactivator::deactivate() Method called on plugin deactivation.
* *
* @since 2.8.0 * @since 2.8.0
* @see Footnotes_Deactivator::deactivate()
*/
function deactivate_footnotes() {
/**
* Provides plugin deactivation functionality.
*/ */
function deactivate_plugin_name() {
require_once plugin_dir_path( __FILE__ ) . 'includes/class-footnotes-deactivator.php'; require_once plugin_dir_path( __FILE__ ) . 'includes/class-footnotes-deactivator.php';
Footnotes_Deactivator::deactivate(); Footnotes_Deactivator::deactivate();
} }
@ -83,8 +90,8 @@ register_activation_hook( __FILE__, 'activate_footnotes' );
register_deactivation_hook( __FILE__, 'deactivate_footnotes' ); register_deactivation_hook( __FILE__, 'deactivate_footnotes' );
/** /**
* The core plugin class that is used to define internationalization, * The core plugin class that defines internationalization, admin-specific and
* admin-specific hooks, and public-facing site hooks. * public-facing site hooks and functionality.
*/ */
require plugin_dir_path( __FILE__ ) . 'includes/class-footnotes.php'; require plugin_dir_path( __FILE__ ) . 'includes/class-footnotes.php';

View file

@ -788,7 +788,7 @@ class Footnotes_Settings {
* *
* This must be `false` if its setting is contained in the container to be hidden * This must be `false` if its setting is contained in the container to be hidden
* because when saving, all missing constants are emptied, and {@see * because when saving, all missing constants are emptied, and {@see
Footnotes_Convert::to_bool()} converts empty to `false`. * Footnotes_Convert::to_bool()} converts empty to `false`.
* *
* @var string * @var string
* *
@ -806,7 +806,6 @@ class Footnotes_Settings {
* @var string * @var string
* *
* @since 2.2.5 * @since 2.2.5
*
*/ */
const C_STR_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION = 'footnotes_inputfield_alternative_mouse_over_box_position'; const C_STR_FOOTNOTES_ALTERNATIVE_MOUSE_OVER_BOX_POSITION = 'footnotes_inputfield_alternative_mouse_over_box_position';

View file

@ -2,7 +2,6 @@
/** /**
* File providing the `Footnotes_Template` class. * File providing the `Footnotes_Template` class.
* *
*
* @package footnotes * @package footnotes
* @subpackage includes * @subpackage includes
* *

View file

@ -5,12 +5,10 @@
* A class definition that includes attributes and functions used across both the * A class definition that includes attributes and functions used across both the
* public-facing side of the site and the admin area. * public-facing side of the site and the admin area.
* *
* @package footnotes * @package footnotes\includes
* @subpackage includes
*
* @since 1.5.0 * @since 1.5.0
* @since 2.8.0 Rename file from `wysiwyg.php` to `class-footnotes-wysiwyg.php`, * @since 2.8.0 Rename file from `init.php` to `class-footnotes.php`, rename
* rename `class/` sub-directory to `includes/`. * `class/` sub-directory to `includes/`.
*/ */
/** /**
@ -19,21 +17,17 @@
* This is used to define internationalization, admin-specific hooks, and * This is used to define internationalization, admin-specific hooks, and
* public-facing site hooks. * public-facing site hooks.
* @package footnotes * @package footnotes\includes
* @subpackage includes
*
* @since 1.5.0 * @since 1.5.0
* @since 2.8.0
*/ */
class Footnotes { class Footnotes {
/** /**
* The loader that's responsible for maintaining and registering all hooks that power * The loader that's responsible for maintaining and registering all hooks that power
* the plugin. * the plugin.
* *
* @access protected
* @var Footnotes_Loader $loader Maintains and registers all hooks for the plugin.
*
* @since 2.8.0 * @since 2.8.0
*
* @var Footnotes_Loader $loader Maintains and registers all hooks for the plugin.
*/ */
protected $loader; protected $loader;
@ -41,7 +35,7 @@ class Footnotes {
* The unique identifier of this plugin * The unique identifier of this plugin
* *
* @since 2.8.0 * @since 2.8.0
* @access protected *
* @var string $plugin_name The string used to uniquely identify this plugin. * @var string $plugin_name The string used to uniquely identify this plugin.
*/ */
protected $plugin_name; protected $plugin_name;
@ -50,7 +44,8 @@ class Footnotes {
* The current version of the plugin. * The current version of the plugin.
* *
* @since 2.8.0 * @since 2.8.0
* @access protected * @see PLUGIN_VERSION
*
* @var string $version The current version of the plugin. * @var string $version The current version of the plugin.
*/ */
protected $version; protected $version;
@ -62,9 +57,10 @@ class Footnotes {
* plugin. Load the dependencies, define the locale, and set the hooks for * plugin. Load the dependencies, define the locale, and set the hooks for
* the admin area and the public-facing side of the site. * the admin area and the public-facing side of the site.
* *
* @uses PLUGIN_VERSION The plugin version constant.
*
* @since 1.0.0 * @since 1.0.0
* @see PLUGIN_VERSION The plugin version constant.
*
* @return void
*/ */
public function __construct() { public function __construct() {
if ( defined( 'PLUGIN_VERSION' ) ) { if ( defined( 'PLUGIN_VERSION' ) ) {
@ -78,7 +74,6 @@ class Footnotes {
$this->set_locale(); $this->set_locale();
$this->define_admin_hooks(); $this->define_admin_hooks();
$this->define_public_hooks(); $this->define_public_hooks();
} }
/** /**
@ -86,22 +81,21 @@ class Footnotes {
* *
* Includes the following files that make up the plugin: * Includes the following files that make up the plugin:
* *
* - `Footnotes_Loader`. Orchestrates the hooks of the plugin. * - {@see Footnotes_Loader}: orchestrates the hooks of the plugin;
* - `Footnotes_i18n`. Defines internationalization functionality. * - {@see Footnotes_i18n}: defines internationalization functionality;
* - `Footnotes_Config`. Defines plugin details. * - {@see Footnotes_Config}: defines plugin details;
* - `Footnotes_Convert`. Provides conversion methods. * - {@see Footnotes_Convert}: provides conversion methods;
* - `Footnotes_Settings`. Defines customisable plugin settings. * - {@see Footnotes_Settings}: defines customisable plugin settings;
* - `Footnotes_Template`. Handles template rendering. * - {@see Footnotes_Template}: handles template rendering;
* - `Footnotes_Admin`. Defines all hooks for the admin area. * - {@see Footnotes_Admin}: defines all hooks for the admin area; and
* - `Footnotes_Public`. Defines all hooks for the public side of the site. * - {@see Footnotes_Public}: defines all hooks for the public side of the site.
* *
* Creates an instance of the loader which will be used to register the hooks * Creates an instance of the loader which will be used to register the hooks
* with WordPress. * with WordPress.
* *
* @access private
* @uses Footnotes_Loader Loads plugin dependencies.
*
* @since 2.8.0 * @since 2.8.0
*
* @return void
*/ */
private function load_dependencies() { private function load_dependencies() {
@ -143,13 +137,13 @@ class Footnotes {
/** /**
* Define the locale for this plugin for internationalization. * Define the locale for this plugin for internationalization.
* *
* Uses the {@see Footnotes_i18n} class in order to set the domain and to * Uses {@see Footnotes_i18n} in order to set the domain and to
* register the hook with WordPress. * register the hook with WordPress.
* *
* @access private * @since 2.8.0
* @uses Footnotes_i18n Handles initialization functions. * @uses Footnotes_i18n Handles initialization functions.
* *
* @since 2.8.0 * @return void
*/ */
private function set_locale() { private function set_locale() {
@ -163,11 +157,11 @@ class Footnotes {
* Register all of the hooks related to the admin area functionality of the * Register all of the hooks related to the admin area functionality of the
* plugin. * plugin.
* *
* @access private
* @uses Footnotes_Admin Defines admin functionality.
*
* @since 1.5.0 * @since 1.5.0
* @since 2.8.0 Moved hook registrations from various classes into `Footnotes_Admin`. * @since 2.8.0 Moved hook registrations from various classes into `Footnotes_Admin`.
* @uses Footnotes_Admin Defines admin functionality.
*
* @return void
*/ */
private function define_admin_hooks() { private function define_admin_hooks() {
@ -195,10 +189,10 @@ class Footnotes {
* Register all of the hooks related to the public-facing functionality of * Register all of the hooks related to the public-facing functionality of
* the plugin. * the plugin.
* *
* @access private * @since 2.8.0
* @uses Footnotes_Admin Defines public-facing functionality. * @uses Footnotes_Admin Defines public-facing functionality.
* *
* @since 2.8.0 * @return void
*/ */
private function define_public_hooks() { private function define_public_hooks() {
@ -214,6 +208,8 @@ class Footnotes {
* Runs the loader to execute all of the hooks with WordPress. * Runs the loader to execute all of the hooks with WordPress.
* *
* @since 1.5.0 * @since 1.5.0
*
* @return void
*/ */
public function run() { public function run() {
$this->loader->run(); $this->loader->run();
@ -223,33 +219,27 @@ class Footnotes {
* Gets the name of the plugin used to uniquely identify it within the * Gets the name of the plugin used to uniquely identify it within the
* context of WordPress and to define internationalization functionality. * context of WordPress and to define internationalization functionality.
* *
* @return string The name of the plugin.
*
* @since 2.8.0 * @since 2.8.0
*/ */
public function get_plugin_name() { public function get_plugin_name(): string {
return $this->plugin_name; return $this->plugin_name;
} }
/** /**
* Returns a reference to the class that orchestrates the hooks with the plugin. * Returns a reference to the class that orchestrates the hooks with the plugin.
* *
* @return Footnotes_Loader Orchestrates the hooks of the plugin.
*
* @since 2.8.0 * @since 2.8.0
*/ */
public function get_loader() { public function get_loader(): Footnotes_Loader {
return $this->loader; return $this->loader;
} }
/** /**
* Gets the version number of the plugin. * Gets the version number of the plugin.
* *
* @return string The version number of the plugin.
*
* @since 2.8.0 * @since 2.8.0
*/ */
public function get_version() { public function get_version(): string {
return $this->version; return $this->version;
} }
} }

View file

@ -316,6 +316,7 @@ class Footnotes_Parser {
* article status. * article status.
* For this to happen, WordPress' built-in partial HTML blocker needs to * For this to happen, WordPress' built-in partial HTML blocker needs to
* be disabled. * be disabled.
*
* @link https://docs.woocommerce.com/document/allow-html-in-term-category-tag-descriptions/ * @link https://docs.woocommerce.com/document/allow-html-in-term-category-tag-descriptions/
* *
* @since 2.5.0 * @since 2.5.0
@ -556,7 +557,6 @@ class Footnotes_Parser {
// Tooltip position, dimensions and timing. // Tooltip position, dimensions and timing.
if ( ! Footnotes_Public::$a_bool_alternative_tooltips_enabled && ! Footnotes_Public::$a_bool_amp_enabled ) { if ( ! Footnotes_Public::$a_bool_alternative_tooltips_enabled && ! Footnotes_Public::$a_bool_amp_enabled ) {
/* /*
* Dimensions of jQuery tooltips. * Dimensions of jQuery tooltips.
* *
@ -830,6 +830,7 @@ class Footnotes_Parser {
* Generates excerpt on the basis of the post. * Generates excerpt on the basis of the post.
* *
* Applies full WordPress excerpt processing. * Applies full WordPress excerpt processing.
*
* @link https://developer.wordpress.org/reference/functions/wp_trim_excerpt/ * @link https://developer.wordpress.org/reference/functions/wp_trim_excerpt/
* @link https://developer.wordpress.org/reference/functions/wp_trim_words/ * @link https://developer.wordpress.org/reference/functions/wp_trim_words/
* *
@ -873,6 +874,7 @@ class Footnotes_Parser {
* Generates excerpt with footnotes on the basis of the post. * Generates excerpt with footnotes on the basis of the post.
* *
* Does not apply full WordPress excerpt processing. * Does not apply full WordPress excerpt processing.
*
* @see self::generate_excerpt() * @see self::generate_excerpt()
* Uses information and some code from Advanced Excerpt. * Uses information and some code from Advanced Excerpt.
* @link https://wordpress.org/plugins/advanced-excerpt/ * @link https://wordpress.org/plugins/advanced-excerpt/
@ -1461,16 +1463,7 @@ class Footnotes_Parser {
$l_str_excerpt_text .= '>'; $l_str_excerpt_text .= '>';
/** // Configurable read-on button label.
* Configurable read-on button label.
*
* - Adding: Tooltips: Read-on button: Label: configurable instead of localizable, thanks to @rovanov example provision.
*
* @reporter @rovanov
* @link https://wordpress.org/support/topic/offset-x-axis-and-offset-y-axis-does-not-working/
*
* @since 2.1.0
*/
$l_str_excerpt_text .= Footnotes_Settings::instance()->get( Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL ); $l_str_excerpt_text .= Footnotes_Settings::instance()->get( Footnotes_Settings::C_STR_FOOTNOTES_TOOLTIP_READON_LABEL );
$l_str_excerpt_text .= self::$a_bool_hard_links_enabled ? '</a>' : '</span>'; $l_str_excerpt_text .= self::$a_bool_hard_links_enabled ? '</a>' : '</span>';
@ -1505,7 +1498,7 @@ class Footnotes_Parser {
$l_str_footnote_link_argument .= $l_int_index; $l_str_footnote_link_argument .= $l_int_index;
$l_str_footnote_link_argument .= '" class="footnote_hard_link"'; $l_str_footnote_link_argument .= '" class="footnote_hard_link"';
/** /*
* Compose fragment ID anchor with offset, for use in reference container. * Compose fragment ID anchor with offset, for use in reference container.
* Empty span, child of empty span, to avoid tall dotted rectangles in browser. * Empty span, child of empty span, to avoid tall dotted rectangles in browser.
*/ */
@ -1516,7 +1509,6 @@ class Footnotes_Parser {
$l_str_referrer_anchor_element .= '" class="footnote_referrer_anchor"></span></span>'; $l_str_referrer_anchor_element .= '" class="footnote_referrer_anchor"></span></span>';
} else { } else {
/* /*
* Initialize hard link variables when hard links are disabled. * Initialize hard link variables when hard links are disabled.
* *
@ -1538,6 +1530,7 @@ class Footnotes_Parser {
// Determine tooltip content. // Determine tooltip content.
if ( Footnotes_Public::$a_bool_tooltips_enabled ) { if ( Footnotes_Public::$a_bool_tooltips_enabled ) {
$l_str_tooltip_content = $l_bool_has_tooltip_text ? $l_str_tooltip_text : $l_str_excerpt_text; $l_str_tooltip_content = $l_bool_has_tooltip_text ? $l_str_tooltip_text : $l_str_excerpt_text;
/* /*
* Ensures paragraph separation * Ensures paragraph separation
* *
@ -1878,7 +1871,6 @@ class Footnotes_Parser {
$l_str_hard_link_address = ''; $l_str_hard_link_address = '';
if ( self::$a_bool_hard_links_enabled ) { if ( self::$a_bool_hard_links_enabled ) {
/* /*
* Use-Backbutton-Hint tooltip, optional and configurable. * Use-Backbutton-Hint tooltip, optional and configurable.
* *