refactor: refactor widget registration
This commit is contained in:
parent
51f3f92c26
commit
850ab084ff
3 changed files with 25 additions and 19 deletions
|
@ -77,19 +77,6 @@ class Footnotes_Loader {
|
|||
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes all Widgets of the Plugin.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @since 2.8.0 Moved to `Footnotes_Loader` class.
|
||||
*/
|
||||
public function initialize_widgets() {
|
||||
// TODO: This probably shouldn't be necessary here.
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/widget/class-footnotes-widget-reference-container.php';
|
||||
|
||||
register_widget( 'Footnotes_Widget_Reference_Container' );
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility function that is used to register the actions and hooks into a single
|
||||
* collection.
|
||||
|
@ -133,8 +120,6 @@ class Footnotes_Loader {
|
|||
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
||||
}
|
||||
|
||||
add_action( 'widgets_init', array( $this, 'initialize_widgets' ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -194,6 +194,8 @@ class Footnotes {
|
|||
|
||||
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
|
||||
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
|
||||
|
||||
$this->loader->add_action( 'widgets_init', $plugin_public, 'register_widgets' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,13 +36,21 @@ class Footnotes_Public {
|
|||
* @var string $version The current version of this plugin.
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* The reference container widget.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @var Footnotes_Widget_Reference_Container $reference_container_widget The reference container widget
|
||||
*/
|
||||
private $reference_container_widget;
|
||||
|
||||
/**
|
||||
* The Plugin task.
|
||||
* The footnote parser.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @since 2.8.0 Moved from `Footnotes` to `Footnotes_Public` class.
|
||||
* @var Task $task The Plugin task.
|
||||
* @var Footnote_Parser $task The Plugin task.
|
||||
*/
|
||||
public $a_obj_task = null;
|
||||
|
||||
|
@ -123,8 +131,10 @@ class Footnotes_Public {
|
|||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-footnotes-convert.php';
|
||||
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-footnotes-parser.php';
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/widget/class-footnotes-widget-base.php';
|
||||
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/widget/class-footnotes-widget-reference-container.php';
|
||||
|
||||
$this->reference_container_widget = new Footnotes_Widget_Reference_Container($this->plugin_name);
|
||||
|
||||
$this->a_obj_task = new Footnotes_Parser();
|
||||
}
|
||||
|
||||
|
@ -251,6 +261,15 @@ class Footnotes_Public {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register the widget(s) for the public-facing side of the site.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @since 2.8.0 Moved to `Footnotes_Public` class.
|
||||
*/
|
||||
public function register_widgets() {
|
||||
register_widget( $this->reference_container_widget );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue