storefront = $storefront; } /** * Register hooks (only when Elementor is loaded). * * @return void */ public function init() { // Register late so we know whether Elementor is present. add_action( 'elementor/widgets/register', array( $this, 'register_widget' ) ); } /** * Register the Elementor widget. * * @param \Elementor\Widgets_Manager $widgets_manager Elementor widget manager. * @return void */ public function register_widget( $widgets_manager ) { if ( ! did_action( 'elementor/loaded' ) ) { return; } // Load the widget class only when Elementor's base class is available. require_once AISTHETIX_TRYON_PATH . 'includes/class-elementor-widget.php'; // No constructor args: the widget must keep \Elementor\Widget_Base's signature // (Elementor re-instantiates it internally). It resolves the Storefront via // Plugin::instance()->storefront at render time. $widgets_manager->register( new Elementor_Widget() ); } }