| @@ -1,7 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Core\Base; |
| 3 | 3 | |
| 4 | +use Elementor\Plugin; | |
| 5 | + | |
| 4 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | 7 | exit; // Exit if accessed directly. |
| 6 | 8 | } |
| 7 | 9 | |
| @@ -299,6 +301,32 @@ | ||
| 299 | 301 | * @return string |
| 300 | 302 | */ |
| 301 | 303 | protected function get_assets_relative_url() { |
| 302 | 304 | return 'assets/'; |
| 305 | + } | |
| 306 | + | |
| 307 | + /** | |
| 308 | + * Get the module's associated widgets. | |
| 309 | + * | |
| 310 | + * @return string[] | |
| 311 | + */ | |
| 312 | + protected function get_widgets() { | |
| 313 | + return []; | |
| 314 | + } | |
| 315 | + | |
| 316 | + /** | |
| 317 | + * Initialize the module related widgets. | |
| 318 | + */ | |
| 319 | + public function init_widgets() { | |
| 320 | + $widget_manager = Plugin::instance()->widgets_manager; | |
| 321 | + | |
| 322 | + foreach ( $this->get_widgets() as $widget ) { | |
| 323 | + $class_name = $this->get_reflection()->getNamespaceName() . '\Widgets\\' . $widget; | |
| 324 | + | |
| 325 | + $widget_manager->register_widget_type( new $class_name() ); | |
| 326 | + } | |
| 327 | + } | |
| 328 | + | |
| 329 | + public function __construct() { | |
| 330 | + add_action( 'elementor/widgets/widgets_registered', [ $this, 'init_widgets' ] ); | |
| 303 | 331 | } |
| 304 | 332 | } |