add_category( 'surecart-elementor-layout', [ 'title' => esc_html__( 'SureCart Layout', 'surecart' ), 'icon' => 'fa fa-plug', ] ); $elements_manager->add_category( 'surecart-elementor-elements', [ 'title' => esc_html__( 'SureCart Elements', 'surecart' ), 'icon' => 'fa fa-plug', ] ); $elements_manager->add_category( 'surecart-elementor-checkout', [ 'title' => esc_html__( 'SureCart Checkout Page', 'surecart' ), 'icon' => 'fa fa-plug', ] ); } /** * Register the widgets. * * @param \Elementor\Widgets_Manager $widget_manager Widget manager. * * @return void */ public function registerWidgets( $widget_manager ) { if ( ! class_exists( '\Elementor\Widget_Base' ) ) { return; } foreach ( glob( __DIR__ . '/Widgets/*.php' ) as $file ) { if ( ! is_readable( $file ) ) { continue; } // pro is not active and the widget is not in the free widgets array. if ( ! $this->is_pro_active() && ! in_array( basename( $file, '.php' ), $this->free_widgets, true ) ) { continue; } require_once $file; $get_declared_classes = get_declared_classes(); $widget_class_name = end( $get_declared_classes ); $widget_manager->register( new $widget_class_name() ); } } /** * Check if Elementor Pro is active. * * @return bool */ protected function is_pro_active(): bool { return class_exists( '\ElementorPro\Plugin' ); } }