diff --git a/src/includes/class-footnotes-loader.php b/src/includes/class-footnotes-loader.php index bf0628c..e49b7f9 100644 --- a/src/includes/class-footnotes-loader.php +++ b/src/includes/class-footnotes-loader.php @@ -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' ) ); - } } diff --git a/src/includes/class-footnotes.php b/src/includes/class-footnotes.php index c122fb1..d3defa2 100644 --- a/src/includes/class-footnotes.php +++ b/src/includes/class-footnotes.php @@ -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' ); } /** diff --git a/src/public/class-footnotes-public.php b/src/public/class-footnotes-public.php index 3d48b37..bfcb2f0 100644 --- a/src/public/class-footnotes-public.php +++ b/src/public/class-footnotes-public.php @@ -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 ); + } }