Plugin Inactive Feature Implementation
🎯 Overview
This feature provides user-friendly feedback when users try to access WordPress Importer plugin routes while the plugin is inactive, instead of showing a 404 error.
📁 Files Created/Modified
1. Middleware: src/Http/Middleware/CheckPluginActive.php
- Purpose: Checks if a plugin is active before allowing access to routes
- Features:
- Validates plugin status in database
- Shows appropriate inactive message
- Handles different views for different route types
2. Main Inactive View: resources/views/plugin-inactive.blade.php
- Purpose: Shows when users access main import routes while plugin is inactive
- Features:
- Professional design with plugin information
- One-click activation button
- Navigation back to plugins or import page
- Help text and guidance
3. Progress Inactive View: resources/views/plugin-inactive-progress.blade.php
- Purpose: Shows when users access progress/status routes while plugin is inactive
- Features:
- Progress-specific messaging
- Multiple navigation options
- Clear explanation of why progress is unavailable
4. Service Provider: src/WaravelServiceProvider.php
- Modified: Added middleware registration
- Added:
waravel.plugin.activemiddleware alias
5. WordPress Importer Plugin: plugins/WordPressImporter/WordPressImporterPlugin.php
- Modified: Added middleware to route group
- Added:
waravel.plugin.active:WordPress Importermiddleware
🚀 How It Works
1. Route Protection
php
Route::middleware(['web', 'auth:waravel', 'waravel.store.intended', 'waravel.plugin.active:WordPress Importer'])2. Plugin Status Check
php
$plugin = DB::table('waravel_plugins')
->where('name', $pluginName)
->where('active', true)
->first();3. Smart View Selection
php
$isProgressPage = request()->is('*progress*') || request()->is('*stream*') || request()->is('*status*');
$viewName = $isProgressPage ? 'waravel::plugin-inactive-progress' : 'waravel::plugin-inactive';🎨 User Experience
Before (404 Error)
- ❌ User sees generic 404 error
- ❌ No guidance on what to do
- ❌ Confusing experience
- ❌ No way to activate plugin
After (Friendly Message)
- ✅ Professional, informative message
- ✅ Clear explanation of the issue
- ✅ One-click plugin activation
- ✅ Multiple navigation options
- ✅ Help text and guidance
🔧 Features
1. Automatic Plugin Activation
- One-click activation directly from the inactive message
- Loading states during activation
- Success/error feedback
- Automatic redirect after activation
2. Smart Routing
- Different messages for different route types
- Progress-specific messaging for status/progress routes
- Main import messaging for general import routes
3. Professional Design
- Consistent styling with Waravel dashboard
- Clear visual hierarchy
- Responsive design
- Accessible components
4. Navigation Options
- Activate Plugin - One-click activation
- Back to Import - Return to main import page
- Manage Plugins - Go to plugin management
- Back to Plugins - Return to plugin list
🎯 Benefits
For Users
- No more 404 errors when plugin is inactive
- Clear guidance on what to do
- Easy activation process
- Professional experience
For Developers
- Reusable middleware for any plugin
- Consistent user experience across all plugins
- Easy to implement for new plugins
- Maintainable code structure
📋 Usage
For New Plugins
- Add middleware to route group:
php
Route::middleware(['web', 'auth:waravel', 'waravel.plugin.active:Plugin Name'])- Middleware automatically:
- Checks plugin status
- Shows appropriate message
- Handles activation
For Existing Plugins
- Add middleware to existing routes
- No code changes needed in controllers
- Automatic protection for all routes
🚀 Future Enhancements
1. Plugin-Specific Messages
- Custom messages per plugin
- Plugin-specific activation flows
- Branded inactive pages
2. Advanced Features
- Bulk plugin activation
- Plugin dependency checking
- Activation scheduling
3. Analytics
- Track inactive access attempts
- Monitor activation success rates
- User behavior insights
🎉 Result
Users now get a professional, helpful experience instead of confusing 404 errors when trying to access inactive plugin features. The system is extensible and can be easily applied to any plugin in the Waravel ecosystem.