add_category( 'convertkit', array( 'title' => __( 'ConvertKit', 'convertkit' ), 'icon' => 'fa fa-plug', ) ); } /** * Registers Blocks as Elementor Widgets. * * @since 1.9.7.2 * * @param Elementor\Widgets_Manager $widgets_manager Widgets Manager, used to register/unregister Elementor Widgets. */ public function register_widgets( $widgets_manager ) { // Get blocks. $blocks = convertkit_get_blocks(); // Bail if no blocks are available. if ( ! is_array( $blocks ) || ! count( $blocks ) ) { return; } // Load widget class here, as we know that Elementor is active. require_once CONVERTKIT_PLUGIN_PATH . '/includes/integrations/elementor/class-convertkit-elementor-widget.php'; // Iterate through blocks, registering them. foreach ( $blocks as $block => $properties ) { // Skip if this block doesn't have an Elementor Widget class. if ( ! file_exists( CONVERTKIT_PLUGIN_PATH . '/includes/integrations/elementor/class-convertkit-elementor-widget-' . $block . '.php' ) ) { continue; } // Load widget class for this block. require_once CONVERTKIT_PLUGIN_PATH . '/includes/integrations/elementor/class-convertkit-elementor-widget-' . $block . '.php'; // Register Widget. $class_name = 'ConvertKit_Elementor_Widget_' . str_replace( '-', '_', $block ); $widgets_manager->register_widget_type( new $class_name() ); } } }