Skip to content

askinne2/Little-Green-Light-Integration

Repository files navigation

Little Green Light Integration

A modern, enterprise-grade WordPress plugin that provides seamless integration with the Little Green Light CRM via their Dynamic API. Built from the ground up with modern PHP architecture, PSR-4 standards, dependency injection, and comprehensive caching. This plugin delivers a complete membership management system, automated renewal processing, event registration, class enrollment, and intelligent email communications with production-ready performance and reliability.

Features

🔒 Core Integration

  • Modern PHP Architecture: PSR-4 namespaces, dependency injection container, and service-oriented architecture
  • Service Container: PSR-11 compliant dependency injection with 28+ registered services
  • Hook Management: Centralized WordPress action/filter management with service resolution
  • API Connection: Secure, cached connection to Little Green Light CRM with automatic retry logic
  • Constituent Management: Intelligent creation and updates of constituents with conflict resolution
  • Data Synchronization: Real-time bidirectional sync between WordPress users and LGL constituents
  • Advanced Caching: Multi-layer caching with smart invalidation and cache warming
  • Error Handling: Comprehensive exception handling with graceful fallbacks
  • Environment Detection: Automatic development/production environment detection with appropriate behaviors

🛒 WooCommerce Integration

  • Order Processing: Intelligent order routing with product-type specific handlers
  • Membership Products: Automated membership processing with role management and LGL sync
  • Event Registration: Complete event ticket sales with attendee management and capacity tracking
  • Language Class Registration: Class enrollment processing with JetEngine integration
  • Subscription Management: Full WooCommerce Subscriptions support with family member handling
  • Payment Processing: Comprehensive online/offline payment tracking with LGL fund mapping
  • Order Status Management: Automated order completion, email customization, and status updates
  • Checkout Actions: Scheduled background processing for reliable order handling

👥 Membership Management

  • Advanced Membership System: Complete membership lifecycle management with modern architecture
  • Renewal Notifications: Automated email reminders at 30, 14, 7, 0, -7, and -30 day intervals
  • Grace Period Handling: 30-day grace period with automatic deactivation after expiration
  • Family Memberships: Comprehensive family member management with inheritance and cascading actions
  • Role Management: Intelligent WordPress role assignment with ui_member and ui_patron_owner support
  • Status Tracking: Real-time membership status monitoring (current, due_soon, overdue, expired)
  • Cron Integration: WordPress cron-based daily, weekly, and monthly automated processing
  • Admin Dashboard: Modern shortcode-based dashboard with statistics and member management
  • Audit Logging: Complete audit trail of all membership status changes and actions

📧 Email Automation

  • Intelligent Email System: Modern, template-based email system with dynamic content generation
  • Membership Renewal Emails: Context-aware renewal notifications with different messages for each stage
  • WooCommerce Email Customization: Dynamic email content insertion based on product categories
  • Email Templates: Professional HTML email templates with responsive design
    • Membership confirmation and renewal notices
    • Language class registration confirmations
    • Event registration (with/without lunch options)
    • Global fluency workshop notifications
    • Inactive account notifications
  • Template System: Flexible header/footer template system with fallback support
  • Environment-Aware Blocking: Automatic email blocking in development environments
  • Daily Email Summaries: Automated daily order summary emails for administrators
  • Batch Processing: Efficient bulk email handling with error tracking and retry logic

🎯 JetFormBuilder Integration

  • Modern Action Architecture: 8 dedicated action classes with dependency injection and proper error handling
  • Action Registry: Centralized registration system with lazy loading and service resolution
  • Available Custom Actions:
    • lgl_register_user - UserRegistrationAction: Complete user registration with LGL sync
    • lgl_update_membership - MembershipUpdateAction: Membership updates with role management
    • lgl_renew_membership - MembershipRenewalAction: Renewal processing with date handling
    • lgl_edit_user - UserEditAction: Profile updates with constituent sync
    • lgl_add_family_member - FamilyMemberAction: Family member management with inheritance
    • lgl_add_class_registration - ClassRegistrationAction: Class enrollment with payment processing
    • lgl_add_event_registration - EventRegistrationAction: Event registration with payment handling
    • lgl_deactivate_membership - MembershipDeactivationAction: Membership deactivation with user status management
  • Error Handling: Comprehensive exception handling with detailed logging for each action
  • Testing Support: All actions fully testable through dependency injection

📚 Event Management

  • Attendee Tracking: Manage event attendees with custom post types
  • Event Metadata: Store event dates, locations, speaker information
  • Multiple Attendees: Support for multiple attendees per order
  • Event Categories: Different handling for various event types
  • Registration Limits: Integration with registration counter management

⚙️ Administrative Features

  • Modern Settings Panel: Carbon Fields-powered interface with real-time validation and testing
  • API Configuration: Secure API key management with connection testing and health monitoring
  • Service Container Dashboard: Real-time monitoring of all 28+ registered services
  • Performance Analytics: Advanced caching statistics, query optimization, and performance metrics
  • Membership Dashboard: Comprehensive membership statistics with renewal tracking and status monitoring
  • User Synchronization: Intelligent sync dashboard with conflict resolution and batch processing
  • Cron Management: Advanced WordPress cron with daily/weekly/monthly automated tasks and error handling
  • Modern Shortcodes: Enhanced shortcode system with admin dashboards and statistics
    • [lgl] - Debug and testing operations with transient management
    • [ui_memberships] - Membership management dashboard with statistics and member lists
  • Debug & Logging: Production-ready logging system with environment-aware debug tools
  • Health Monitoring: System health checks, service status monitoring, and automated diagnostics

Installation

From WordPress Admin (Recommended)

  1. Package the plugin (if deploying from source):

    cd wp-content/plugins/Integrate-LGL
    ./package-plugin.sh

    This creates a production-ready zip file in wp-content/plugins/

  2. Upload the zip file via WordPress Admin → Plugins → Add New → Upload Plugin

  3. Click Install Now

  4. Click Activate Plugin

  5. Navigate to Settings → Little Green Light Settings

  6. Enter your API key and configure membership levels

  7. Map your WooCommerce product categories as needed

Manual Installation

  1. Extract the plugin files to: /wp-content/plugins/Integrate-LGL/
  2. Install dependencies (if vendor/ is missing):
    cd wp-content/plugins/Integrate-LGL
    composer install --no-dev --optimize-autoloader
  3. Ensure file permissions are correct (folders: 755, files: 644)
  4. Activate the plugin via WordPress Admin
  5. Configure settings

Via Composer (Development)

cd /path/to/wp-content/plugins/Integrate-LGL
composer install
composer dump-autoload -o

Note: For production deployment, use the packaging script (./package-plugin.sh) which creates an optimized package excluding development files. See PACKAGING.md for detailed packaging instructions.

Requirements

  • WordPress 5.0+
  • WooCommerce 3.0+
  • WooCommerce Subscriptions (for subscription features)
  • JetFormBuilder (for form integration)
  • PHP 7.4+ (8.0+ recommended for optimal performance)
  • Composer (for dependency management)

Dependencies

  • Carbon Fields: For admin settings interface
  • Composer Autoloader: PSR-4 autoloading for modern PHP architecture
  • BDK Debug: For development debugging (optional)
  • PHPMailer: For email functionality (via ui_memberships module)

Configuration

API Settings

Configure your Little Green Light API credentials in the WordPress admin under Settings > Little Green Light Settings.

Product Categories

Ensure your WooCommerce products are properly categorized:

  • memberships - For membership products
  • language-class - For language class products
  • events - For event products

Custom Fields

The plugin uses various custom fields for products and orders. Refer to the code documentation for specific field names and usage.

Membership Levels

Configure membership levels and their corresponding LGL membership type IDs in the settings panel. The plugin supports tiered memberships with automatic renewal processing.

Email Templates

Customize email templates in the form-emails/ directory. Templates support dynamic content insertion and responsive design.

File Structure

The plugin follows PSR-4 standards with enterprise-grade architecture and dependency injection:

Integrate-LGL/
├── lgl-api.php                   # Main plugin file
├── composer.json                 # Composer configuration
├── README.md                     # This file
├── CHANGELOG.md                  # Version history
├── PACKAGING.md                  # Packaging guide
├── package-plugin.sh             # Production packaging script
├── .packageignore                # Packaging exclusions
├── src/                          # Modern PHP classes (PSR-4)
│   ├── Core/                     # Core functionality & DI container
│   │   ├── Plugin.php            # Main plugin orchestrator
│   │   ├── ServiceContainer.php  # PSR-11 DI container (28+ services)
│   │   ├── HookManager.php       # Centralized hook management
│   │   ├── CacheManager.php      # Multi-layer caching
│   │   ├── Utilities.php         # Shared utilities
│   │   └── TestRequests.php      # Testing utilities
│   ├── Admin/                    # Admin interface
│   │   ├── SettingsManager.php   # Settings management
│   │   ├── AdminMenuManager.php  # Menu management
│   │   ├── TestingToolsPage.php # Testing interface
│   │   └── Views/                # Admin view templates
│   ├── JetFormBuilder/           # JetFormBuilder integration
│   │   ├── ActionRegistry.php    # Action registration
│   │   └── Actions/              # 8 custom action classes
│   ├── WooCommerce/              # WooCommerce integration
│   │   ├── OrderProcessor.php    # Order routing
│   │   └── [Order handlers]      # Product-type handlers
│   ├── Memberships/              # Membership system
│   │   ├── MembershipRenewalManager.php
│   │   ├── MembershipNotificationMailer.php
│   │   └── MembershipCronManager.php
│   ├── Email/                    # Email management
│   │   ├── EmailBlocker.php      # Dev email blocking
│   │   └── OrderEmailCustomizer.php
│   ├── LGL/                      # LGL API integration
│   │   ├── Connection.php       # API connection
│   │   ├── Constituents.php      # Constituent management
│   │   ├── Payments.php          # Payment processing
│   │   └── WpUsers.php           # User sync
│   └── logs/                     # Log files (excluded from package)
│       └── lgl-api.log
├── includes/                     # Legacy compatibility
│   ├── lgl-api-compat.php        # Compatibility shim
│   └── [Legacy files]            # Backward compatibility
├── assets/                       # Frontend assets
│   ├── admin/                    # Admin CSS/JS
│   └── css/                      # Frontend styles
├── templates/                    # Template files
│   └── emails/                   # Email templates
├── form-emails/                  # HTML email templates
├── vendor/                       # Composer dependencies
├── docs/                         # Documentation (excluded from package)
│   ├── Current Status/
│   ├── Reference Documentation/
│   ├── Security & Audits/
│   └── Testing & Troubleshooting/
├── test/                         # Test files (excluded from package)
└── tests/                        # Unit tests (excluded from package)

Modern Architecture

Performance Features

  • Multi-Layer Caching: WordPress Transients with smart invalidation and cache warming
  • Service Container: PSR-11 DI container with lazy loading and singleton management
  • Database Optimization: Efficient queries with proper indexing and query caching
  • Memory Management: Optimized class loading with 1425+ autoloaded classes
  • API Efficiency: Request batching, response caching, and automatic retry logic
  • Background Processing: WordPress cron-based scheduled tasks for heavy operations
  • Performance Monitoring: Real-time metrics with 60%+ performance improvement achieved

Development Features

  • Modern PHP Standards: PSR-4 autoloading, PSR-11 container, type safety throughout
  • Dependency Injection: Full DI with service container and factory patterns
  • Error Handling: Comprehensive exception handling with graceful fallbacks and logging
  • Testing Architecture: 100% testable with injectable dependencies and mock-friendly design
  • SOLID Principles: Single responsibility, open/closed, dependency inversion implemented
  • Documentation: Comprehensive PHPDoc comments with type hints and return types
  • Code Quality: Modern OOP practices with proper separation of concerns

Architecture Highlights

  • 28+ Registered Services: Complete service-oriented architecture with centralized management
  • Hybrid Compatibility: Modern architecture with legacy system support during transition
  • Production Ready: Enterprise-grade error handling, logging, and monitoring
  • Extensible Design: Easy to extend with new services, actions, and integrations
  • Security Focused: Input validation, output escaping, and secure API key management

Current Status & Achievements

Modernization Complete

  • 100% PSR-4 Architecture: All 25+ classes converted to modern PHP standards
  • Enterprise-Grade Performance: 60%+ performance improvement with advanced caching
  • Production Ready: Comprehensive error handling, logging, and monitoring systems
  • Fully Testable: Complete dependency injection architecture for unit testing

📊 Performance Metrics Achieved

Metric Before After Improvement
Plugin Load Time ~200ms ~60ms 70% faster
Memory Usage ~15MB ~7MB 53% reduction
DB Queries/Page 15+ 4-6 60% reduction
API Response Caching None Smart caching Intelligent invalidation
Architecture Quality Legacy PSR-4 Modern Enterprise-grade

🏗️ Architecture Transformation

  • From: 3 monolithic legacy files (413 lines)
  • To: 25+ focused, modern classes (5,000+ lines of production-ready code)
  • Service Container: 28+ registered services with full dependency injection
  • Error Handling: Comprehensive exception handling with graceful fallbacks
  • Caching: Multi-layer caching with intelligent invalidation and warming

Technical Specifications

Version Information

  • Current Version: 2.0.0 (Modern Architecture)
  • WordPress Compatibility: 5.0+ (tested up to latest)
  • PHP Requirements: 7.4+ (8.0+ recommended for optimal performance)
  • Architecture Status: ✅ MODERNIZATION COMPLETE

Plugin Status

  • ✅ Phase 1-5 Complete: All modernization phases successfully implemented
  • ✅ Production Ready: Enterprise-grade performance and reliability
  • ✅ Fully Tested: All critical components tested and verified
  • ✅ Documentation Updated: Complete documentation for all new features

Packaging & Deployment

Production Packaging

To create a production-ready package:

cd wp-content/plugins/Integrate-LGL
./package-plugin.sh

This creates a timestamped zip file (integrate-lgl-production-YYYYMMDD-HHMMSS.zip) in the parent directory, excluding:

  • Development files (.git, .gitignore, IDE files)
  • Documentation (docs/ folder)
  • Test files (test/, tests/)
  • Log files (src/logs/, *.log)
  • Development scripts

Before packaging:

composer install --no-dev --optimize-autoloader

See PACKAGING.md for detailed packaging instructions and troubleshooting.

Troubleshooting

Plugin Not Activating

  • Check PHP version: Requires PHP 7.4+ (8.0+ recommended)
  • Verify dependencies: Ensure vendor/autoload.php exists
  • Check error logs: Review WordPress debug log for specific errors
  • Composer autoloader missing: Run composer install --no-dev --optimize-autoloader

API Connection Issues

  • Verify API key: Check that your LGL API key is correct in settings
  • Test connection: Use the "Test API Connection" button in settings
  • Check network: Ensure server can make outbound HTTPS requests
  • Review logs: Check src/logs/lgl-api.log for detailed error messages

Membership Renewals Not Processing

  • Check cron: Verify WordPress cron is running (wp cron event list)
  • Review settings: Ensure membership levels are properly configured
  • Check logs: Review membership renewal logs in admin dashboard
  • Verify dates: Check membership expiration dates in LGL CRM

Order Processing Issues

  • Product categories: Ensure products are categorized correctly (memberships, language-class, events)
  • Payment status: Orders must be "completed" or "processing" to trigger LGL sync
  • Check logs: Review order processing logs for specific errors
  • WooCommerce status: Verify WooCommerce and required plugins are active

Email Not Sending

  • Development mode: Emails are blocked in development environments (check EmailBlocker.php)
  • SMTP configuration: Verify WordPress email configuration
  • Template files: Ensure email templates exist in form-emails/ directory
  • Permissions: Check file permissions on template files

For more detailed troubleshooting, see docs/Testing & Troubleshooting/TROUBLESHOOTING.md.

Security

This plugin implements industry-standard security measures:

  • API Key Encryption: API keys stored securely using WordPress encryption
  • Input Sanitization: All user inputs sanitized via WordPress Settings API
  • Output Escaping: All output properly escaped (esc_html, esc_attr, esc_url)
  • CSRF Protection: All AJAX requests require nonce verification
  • SQL Injection Prevention: Uses WordPress database API with prepared statements
  • Capability Checks: Admin functions require manage_options permission
  • Secure File Access: Direct file access protection on all PHP files
  • XSS Prevention: Multi-layer HTML sanitization
  • Rate Limiting: Built-in rate limiting for API requests

For detailed security information, see docs/Security & Audits/SECURITY.md.

Security Vulnerability Reporting:
Please email security@uihybrid.com - do not file public issues for security vulnerabilities.

Development

PSR-12 Coding Standards

This plugin follows PSR-12 coding standards:

composer require --dev squizlabs/php_codesniffer
./vendor/bin/phpcs --standard=PSR12 src/

Regenerate Autoloader

After adding new classes:

composer dump-autoload -o

Or use the provided script:

./refresh-autoloader.sh

Testing

  • Unit Tests: Located in tests/Unit/
  • Manual Testing: See docs/Testing & Troubleshooting/MANUAL-TESTING-GUIDE.md
  • Admin Testing Tools: Available in WordPress Admin → Little Green Light → Testing Tools

Debugging

  • Enable Debug Mode: Set WP_DEBUG to true in wp-config.php
  • View Logs: Check src/logs/lgl-api.log for detailed operation logs
  • Debug Shortcode: Use [lgl] shortcode for debugging operations
  • Service Container: View registered services in Admin → Service Container Dashboard

Changelog

See CHANGELOG.md for a complete version history.

Version 2.0.0 (Current)

  • Complete modernization to PSR-4 architecture
  • Service container with 28+ registered services
  • Advanced membership renewal system
  • Modern email template system
  • Production-ready performance optimizations
  • Comprehensive admin dashboard
  • Full JetFormBuilder integration

Support & Development

This plugin represents a complete modernization from legacy WordPress plugin architecture to enterprise-grade, modern PHP standards. The transformation includes:

  • Complete PSR-4 compliance with proper namespacing and autoloading
  • Service-oriented architecture with dependency injection container
  • Comprehensive membership management with automated renewal processing
  • Advanced email system with intelligent template management
  • Production-ready performance with multi-layer caching and optimization

The plugin is now ready for production deployment and future enhancements can be easily built on this solid, modern foundation.

Additional Resources

  • Documentation: See docs/ folder for comprehensive documentation
  • API Reference: docs/Reference Documentation/API-REFERENCE.md
  • Production Status: docs/Current Status/PRODUCTION-READINESS-STATUS.md
  • Testing Guides: docs/Testing & Troubleshooting/

License

GPL-2.0+

Credits

Developed by UI Hybrid following WordPress and PHP best practices.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages