$addon) { // Only get pro elements if (empty($addon['is_pro']) || $addon['is_pro'] !== true) { continue; } $widget_data = [ 'title' => $addon['title'] ?? '', 'name' => $key, 'icon' => 'jltma-icon eicon-lock', // Default fallback icon 'categories' => '["master-addons"]', // Default category ]; $icon_found = false; // Method 1: Try to get icon from the widget class if it exists if (!empty($addon['class']) && class_exists($addon['class'])) { try { $widget_instance = new $addon['class'](); if (method_exists($widget_instance, 'get_icon')) { $widget_data['icon'] = $widget_instance->get_icon(); $icon_found = true; } if (method_exists($widget_instance, 'get_categories')) { $categories = $widget_instance->get_categories(); $widget_data['categories'] = json_encode($categories); } } catch (\Exception $e) { // Silently fail } } // Method 2: If class doesn't exist, extract icon from addon file if (!$icon_found) { $file_icon = $this->get_icon_from_file($key, $addon); if ($file_icon) { $widget_data['icon'] = $file_icon; } } // Add pro widget class for styling $widget_data['icon'] .= ' jltma-pro-widget'; $pro_widgets[] = $widget_data; } return $pro_widgets; } /** * Promote Pro Addons in Elementor Editor * * @param array $config Elementor localize settings config * @return array Modified config */ public function promote_pro_addons($config) { $promotion_widgets = []; if (isset($config['promotionWidgets'])) { $promotion_widgets = $config['promotionWidgets']; } // Get pro elements dynamically $pro_elements = $this->get_pro_elements(); if (!empty($pro_elements)) { $promotion_widgets = array_merge($promotion_widgets, $pro_elements); } $config['promotionWidgets'] = $promotion_widgets; return $config; } }