widget = $widget; } public function hook() { add_action('widgets_init', [$this, 'register_widgets']); } public function register_widgets() { global $wp_widget_factory; $wp_widget_factory->widgets[ get_class($this->widget) ] = $this->widget; } }