refactor: rename Hooks, update docblocks
This commit is contained in:
parent
571b6bf74f
commit
3af81c01b9
3 changed files with 30 additions and 72 deletions
|
@ -1,9 +1,9 @@
|
||||||
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName, WordPress.Security.EscapeOutput.OutputNotEscaped
|
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName, WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||||
/**
|
/**
|
||||||
* Handles all WordPress hooks of this Plugin.
|
* Hooks class
|
||||||
*
|
*
|
||||||
* @filesource
|
|
||||||
* @package footnotes
|
* @package footnotes
|
||||||
|
* @subpackage WPDashboard
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
class MCI_Footnotes_Hooks {
|
class Hooks {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers all WordPress hooks.
|
* Registers all WordPress hooks.
|
||||||
|
@ -20,13 +20,15 @@ class MCI_Footnotes_Hooks {
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public static function register_hooks() {
|
public static function register_hooks() {
|
||||||
register_activation_hook( dirname( __FILE__ ) . '/../footnotes.php', array( 'MCI_Footnotes_Hooks', 'activate_plugin' ) );
|
register_activation_hook( dirname( __FILE__ ) . '/../footnotes.php', array( 'Hooks', 'activate_plugin' ) );
|
||||||
register_deactivation_hook( dirname( __FILE__ ) . '/../footnotes.php', array( 'MCI_Footnotes_Hooks', 'deactivate_plugin' ) );
|
register_deactivation_hook( dirname( __FILE__ ) . '/../footnotes.php', array( 'Hooks', 'deactivate_plugin' ) );
|
||||||
register_uninstall_hook( dirname( __FILE__ ) . '/../footnotes.php', array( 'MCI_Footnotes_Hooks', 'uninstall_plugin' ) );
|
register_uninstall_hook( dirname( __FILE__ ) . '/../footnotes.php', array( 'Hooks', 'uninstall_plugin' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executed when the Plugin gets activated.
|
* Executes when the Plugin is activated.
|
||||||
|
*
|
||||||
|
* Currently a no-op placeholder.
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@ -35,7 +37,9 @@ class MCI_Footnotes_Hooks {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executed when the Plugin gets deactivated.
|
* Executes when the Plugin is deactivated.
|
||||||
|
*
|
||||||
|
* Currently a no-op placeholder.
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
@ -44,41 +48,20 @@ class MCI_Footnotes_Hooks {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executed when the Plugin gets uninstalled.
|
* Appends the Plugin links for display in the dashboard “Plugins” page.
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*
|
* @param array $plugin_links The WP-default set of links to display.
|
||||||
* @since 2.2.0 this function is not called any longer when deleting the plugin.
|
* @return string[] The full set of links to display.
|
||||||
* Note: clear_all() didn't actually work.
|
|
||||||
* @see class/settings.php
|
|
||||||
*/
|
*/
|
||||||
public static function uninstall_plugin() {
|
public static function get_plugin_links( array $plugin_links ): array {
|
||||||
// WordPress User has to be logged in.
|
|
||||||
if ( ! is_user_logged_in() ) {
|
|
||||||
wp_die( __( 'You must be logged in to run this script.', 'footnotes' ) );
|
|
||||||
}
|
|
||||||
// WordPress User needs the permission to (un)install plugins.
|
|
||||||
if ( ! current_user_can( 'install_plugins' ) ) {
|
|
||||||
wp_die( __( 'You do not have permission to run this script.', 'footnotes' ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add Links to the Plugin in the "installed Plugins" page.
|
|
||||||
*
|
|
||||||
* @since 1.5.0
|
|
||||||
* @param array $p_arr_links Current Links.
|
|
||||||
* @param string $p_str_plugin_file_name Plugins init file name.
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function plugin_links( $p_arr_links, $p_str_plugin_file_name ) {
|
|
||||||
// Append link to the WordPress Plugin page.
|
// Append link to the WordPress Plugin page.
|
||||||
$p_arr_links[] = sprintf( '<a href="https://wordpress.org/support/plugin/footnotes" target="_blank">%s</a>', __( 'Support', 'footnotes' ) );
|
$plugin_links[] = sprintf( '<a href="https://wordpress.org/support/plugin/footnotes" target="_blank">%s</a>', __( 'Support', 'footnotes' ) );
|
||||||
// Append link to the settings page.
|
// Append link to the settings page.
|
||||||
$p_arr_links[] = sprintf( '<a href="%s">%s</a>', admin_url( 'options-general.php?page=footnotes' ), __( 'Settings', 'footnotes' ) );
|
$plugin_links[] = sprintf( '<a href="%s">%s</a>', admin_url( 'options-general.php?page=footnotes' ), __( 'Settings', 'footnotes' ) );
|
||||||
// Append link to the PayPal donate function.
|
// Append link to the PayPal donate function.
|
||||||
$p_arr_links[] = sprintf( '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6Z6CZDW8PPBBJ" target="_blank">%s</a>', __( 'Donate', 'footnotes' ) );
|
$plugin_links[] = sprintf( '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6Z6CZDW8PPBBJ" target="_blank">%s</a>', __( 'Donate', 'footnotes' ) );
|
||||||
// Return new links.
|
// Return new links.
|
||||||
return $p_arr_links;
|
return $plugin_links;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,59 +1,34 @@
|
||||||
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName
|
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName
|
||||||
/**
|
/**
|
||||||
* Includes the main Class of the Plugin.
|
* Footnotes class
|
||||||
*
|
*
|
||||||
* @filesource
|
|
||||||
* @package footnotes
|
* @package footnotes
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*
|
|
||||||
* @since 1.6.5 Bugfix: Improve widgets registration, thanks to @felipelavinz code contribution.
|
|
||||||
* @since 1.6.5 Update: Fix for deprecated PHP function create_function(), thanks to @psykonevro @daliasued bug reports, thanks to @felipelavinz code contribution.
|
|
||||||
* @since 2.0.0 Update: Tooltips: fix disabling bug by loading jQuery UI library, thanks to @rajinderverma @ericcorbett2 @honlapdavid @mmallett bug reports, thanks to @vonpiernik code contribution.
|
|
||||||
*
|
|
||||||
* @since 2.0.3 add versioning of public.css for cache busting
|
|
||||||
* @since 2.0.4 add jQuery UI from WordPress
|
|
||||||
* @since 2.1.4 automate passing version number for cache busting
|
|
||||||
* @since 2.1.4 optionally enqueue an extra stylesheet
|
|
||||||
*
|
|
||||||
* @since 2.5.5 Update: Stylesheets: increase speed and energy efficiency by tailoring stylesheets to the needs of the instance, thanks to @docteurfitness design contribution.
|
|
||||||
* @since 2.5.5 Bugfix: Stylesheets: minify to shrink the carbon footprint, increase speed and implement best practice, thanks to @docteurfitness issue report.
|
|
||||||
* @since 2.5.5 Bugfix: Libraries: optimize processes by loading external and internal scripts only if needed, thanks to @docteurfitness issue report.
|
|
||||||
* @since 2.5.6 Bugfix: Reference container: optional alternative expanding and collapsing without jQuery for use with hard links, thanks to @hopper87it @pkverma99 issue reports.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry point of the Plugin. Loads the Dashboard and executes the Task.
|
* Provides an entry point to the Plugin.
|
||||||
|
*
|
||||||
|
* Loads the dashboard and executes the task.
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
class MCI_Footnotes {
|
class MCI_Footnotes {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to the Plugin Task object.
|
* The Plugin task.
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @var null|MCI_Footnotes_Task
|
* @var Task $task The Plugin task.
|
||||||
*/
|
*/
|
||||||
public $a_obj_task = null;
|
public $a_obj_task = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows to determine whether tooltips are enabled.
|
* Flag for using tooltips.
|
||||||
* The actual value of these properties is configurable.
|
|
||||||
*
|
|
||||||
* - Bugfix: Templates: optimize template load and processing based on settings, thanks to @misfist code contribution.
|
|
||||||
*
|
*
|
||||||
* @since 2.4.0
|
* @since 2.4.0
|
||||||
*
|
*
|
||||||
* @contributor Patrizia Lutz @misfist
|
* @var bool $tooltips_enabled Whether tooltips are enabled or not.
|
||||||
* @link https://wordpress.org/support/topic/template-override-filter/#post-13864301
|
|
||||||
* @link https://github.com/misfist/footnotes/releases/tag/2.4.0d3 repository
|
|
||||||
* @link https://github.com/misfist/footnotes/compare/2.4.0%E2%80%A62.4.0d3 diff
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*
|
|
||||||
* Template process and script / stylesheet load optimization.
|
|
||||||
* Streamline process depending on tooltip enabled status.
|
|
||||||
* Load tooltip inline script only if jQuery tooltips are enabled.
|
|
||||||
*/
|
*/
|
||||||
public static $a_bool_tooltips_enabled = false;
|
public static $a_bool_tooltips_enabled = false;
|
||||||
|
|
||||||
|
@ -134,7 +109,7 @@ class MCI_Footnotes {
|
||||||
// Register Button hooks.
|
// Register Button hooks.
|
||||||
MCI_Footnotes_WYSIWYG::register_hooks();
|
MCI_Footnotes_WYSIWYG::register_hooks();
|
||||||
// Register general hooks.
|
// Register general hooks.
|
||||||
MCI_Footnotes_Hooks::register_hooks();
|
Hooks::register_hooks();
|
||||||
|
|
||||||
// Initialize the Plugin Dashboard.
|
// Initialize the Plugin Dashboard.
|
||||||
$this->initialize_dashboard();
|
$this->initialize_dashboard();
|
||||||
|
|
|
@ -109,7 +109,7 @@ require_once dirname( __FILE__ ) . '/includes.php';
|
||||||
|
|
||||||
// Add Plugin Links to the "installed plugins" page.
|
// Add Plugin Links to the "installed plugins" page.
|
||||||
$l_str_plugin_file = 'footnotes/footnotes.php';
|
$l_str_plugin_file = 'footnotes/footnotes.php';
|
||||||
add_filter( "plugin_action_links_{$l_str_plugin_file}", array( 'MCI_Footnotes_Hooks', 'plugin_links' ), 10, 2 );
|
add_filter( "plugin_action_links_{$l_str_plugin_file}", array( 'Hooks', 'get_plugin_links' ), 10, 2 );
|
||||||
|
|
||||||
// Initialize the Plugin.
|
// Initialize the Plugin.
|
||||||
$g_obj_mci_footnotes = new MCI_Footnotes();
|
$g_obj_mci_footnotes = new MCI_Footnotes();
|
||||||
|
|
Reference in a new issue