register(new AGRFUXD_Enhanced_Gallery_Widget()); $widgets_manager->register(new AGRFUXD_Enhanced_Repeater_Widget()); } /** * Add widget category */ public function add_widget_category($elements_manager) { $elements_manager->add_category( 'agrfuxd', [ 'title' => __('ACF Gallery & Repeater', 'advanced-gallery-repeater-fields-for-acf'), 'icon' => 'fa fa-plug', ] ); } /** * Enqueue widget styles */ public function enqueue_widget_styles() { wp_enqueue_style( 'agrfuxd-elementor-widgets', AGRFUXD_PLUGIN_URL . 'assets/css/elementor-widgets.css', ['agrfuxd-frontend'], AGRFUXD_VERSION ); } /** * Enqueue widget scripts */ public function enqueue_widget_scripts() { wp_enqueue_script( 'agrfuxd-elementor-widgets', AGRFUXD_PLUGIN_URL . 'assets/js/elementor-widgets.js', ['jquery', 'agrfuxd-frontend'], AGRFUXD_VERSION, true ); } /** * Map ACF field groups for Elementor */ public function map_acf_field_groups($field_groups) { if (is_array($field_groups)) { foreach ($field_groups as &$group) { if (isset($group['fields']) && is_array($group['fields'])) { foreach ($group['fields'] as &$field) { if (isset($field['type']) && $field['type'] === 'enhanced_gallery') { // Tell Elementor this is a gallery field $field['elementor_type'] = 'gallery'; } if (isset($field['type']) && $field['type'] === 'enhanced_repeater') { // Tell Elementor this is a repeater field $field['elementor_type'] = 'repeater'; } } } } } return $field_groups; } /** * Map ACF fields for Elementor widgets */ public function map_acf_fields($fields) { if (!is_array($fields)) { $fields = []; } // Add our field types with proper categorization $fields['enhanced_gallery'] = [ 'type' => 'gallery', 'widget' => 'gallery', ]; $fields['enhanced_repeater'] = [ 'type' => 'repeater', 'widget' => 'repeater', ]; return $fields; } } // Initialize the integration add_action('elementor/init', function() { AGRFUXD_Elementor_Integration::get_instance(); }); // Legacy filters for backward compatibility add_filter('elementor/acf/field_groups', function($field_groups) { if (is_array($field_groups)) { foreach ($field_groups as &$group) { if (isset($group['fields']) && is_array($group['fields'])) { foreach ($group['fields'] as &$field) { if (isset($field['type']) && $field['type'] === 'enhanced_gallery') { $field['elementor_type'] = 'gallery'; } if (isset($field['type']) && $field['type'] === 'enhanced_repeater') { $field['elementor_type'] = 'repeater'; } } } } } return $field_groups; }, 10, 1); add_filter('elementor/widgets/acf/fields', function($fields) { if (!is_array($fields)) { $fields = []; } $fields['enhanced_gallery'] = [ 'type' => 'gallery', 'widget' => 'gallery', ]; $fields['enhanced_repeater'] = [ 'type' => 'repeater', 'widget' => 'repeater', ]; return $fields; }, 10, 1);