refactor: move hook registration to Footnotes_Admin
This commit is contained in:
parent
4bcd8991ca
commit
6fb2b20424
3 changed files with 39 additions and 23 deletions
|
@ -36,6 +36,14 @@ class Footnotes_Admin {
|
||||||
* @var string $version The current version of this plugin.
|
* @var string $version The current version of this plugin.
|
||||||
*/
|
*/
|
||||||
private $version;
|
private $version;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The WYSIWYG editor integration object.
|
||||||
|
*
|
||||||
|
* @since 2.8.0
|
||||||
|
* @var Footnotes_WYSIWYG $wysiwyg The WYSIWYG editor integration object.
|
||||||
|
*/
|
||||||
|
public $wysiwyg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the class and set its properties.
|
* Initialize the class and set its properties.
|
||||||
|
@ -71,6 +79,8 @@ class Footnotes_Admin {
|
||||||
*/
|
*/
|
||||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-footnotes-wysiwyg.php';
|
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-footnotes-wysiwyg.php';
|
||||||
|
|
||||||
|
$this->wysiwyg = new Footnotes_WYSIWYG($this->plugin_name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class responsible for constructing the plugin dashboard page(s).
|
* The class responsible for constructing the plugin dashboard page(s).
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,33 +16,26 @@
|
||||||
class Footnotes_WYSIWYG {
|
class Footnotes_WYSIWYG {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers Button hooks.
|
* The ID of this plugin.
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 2.8.0
|
||||||
*
|
* @access private
|
||||||
* - Bugfix: Editor buttons: debug button by reverting name change in PHP file while JS file and HTML template remained unsynced, thanks to @gova bug report.
|
* @var string $plugin_name The ID of this plugin.
|
||||||
*
|
|
||||||
* @reporter @gova
|
|
||||||
* @link https://wordpress.org/support/topic/back-end-footnotes-not-working-400-bad-erro/
|
|
||||||
*
|
|
||||||
* @since 2.6.5
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public static function register_hooks() {
|
private $plugin_name;
|
||||||
add_filter( 'mce_buttons', array( 'Footnotes_WYSIWYG', 'new_visual_editor_button' ) );
|
|
||||||
add_action( 'admin_print_footer_scripts', array( 'Footnotes_WYSIWYG', 'new_plain_text_editor_button' ) );
|
/**
|
||||||
|
* Initialize the class and set its properties.
|
||||||
|
*
|
||||||
|
* @since 2.8.0
|
||||||
|
* @param string $plugin_name The name of this plugin.
|
||||||
|
*/
|
||||||
|
public function __construct( $plugin_name ) {
|
||||||
|
|
||||||
add_filter( 'mce_external_plugins', array( 'Footnotes_WYSIWYG', 'include_scripts' ) );
|
$this->plugin_name = $plugin_name;
|
||||||
|
|
||||||
// phpcs:disable
|
|
||||||
// 'footnotes_getTags' must match its instance in wysiwyg-editor.js.
|
|
||||||
// 'footnotes_getTags' must match its instance in editor-button.html.
|
|
||||||
add_action( 'wp_ajax_nopriv_footnotes_getTags', array( 'Footnotes_WYSIWYG', 'ajax_callback' ) );
|
|
||||||
add_action( 'wp_ajax_footnotes_getTags', array( 'Footnotes_WYSIWYG', 'ajax_callback' ) );
|
|
||||||
// phpcs:enable
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append a new Button to the WYSIWYG editor of Posts and Pages.
|
* Append a new Button to the WYSIWYG editor of Posts and Pages.
|
||||||
*
|
*
|
||||||
|
|
|
@ -155,8 +155,9 @@ class Footnotes {
|
||||||
* Register all of the hooks related to the admin area functionality
|
* Register all of the hooks related to the admin area functionality
|
||||||
* of the plugin.
|
* of the plugin.
|
||||||
*
|
*
|
||||||
* @since 2.8.0
|
* @since 1.5.0
|
||||||
* @access private
|
* @since 2.8.0 Moved registrating from various classes into `Footnotes_Admin`.
|
||||||
|
* @access private
|
||||||
*/
|
*/
|
||||||
private function define_admin_hooks() {
|
private function define_admin_hooks() {
|
||||||
|
|
||||||
|
@ -166,6 +167,18 @@ class Footnotes {
|
||||||
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
|
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
|
||||||
|
|
||||||
$this->loader->add_filter( 'plugin_action_links_footnotes/footnotes.php', $plugin_admin, 'footnotes_action_links' );
|
$this->loader->add_filter( 'plugin_action_links_footnotes/footnotes.php', $plugin_admin, 'footnotes_action_links' );
|
||||||
|
|
||||||
|
$this->loader->add_filter( 'mce_buttons', $plugin_admin->wysiwyg, 'new_visual_editor_button' );
|
||||||
|
$this->loader->add_action( 'admin_print_footer_scripts', $plugin_admin->wysiwyg, 'new_plain_text_editor_button' );
|
||||||
|
|
||||||
|
$this->loader->add_filter( 'mce_external_plugins', $plugin_admin->wysiwyg, 'include_scripts' );
|
||||||
|
|
||||||
|
// phpcs:disable
|
||||||
|
// 'footnotes_getTags' must match its instance in wysiwyg-editor.js.
|
||||||
|
// 'footnotes_getTags' must match its instance in editor-button.html.
|
||||||
|
$this->loader->add_action( 'wp_ajax_nopriv_footnotes_getTags', $plugin_admin->wysiwyg, 'ajax_callback' );
|
||||||
|
$this->loader->add_action( 'wp_ajax_footnotes_getTags', $plugin_admin->wysiwyg, 'ajax_callback' );
|
||||||
|
// phpcs:enable
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Reference in a new issue