Monday's Work AI Core
Core module for AI-powered WordPress/WooCommerce plugin - MVP architecture with modular AI client integration
by Mondays at Work · github.com/maw-agncy/mondays-work-ai-core · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/maw-agncy/mondays-work-ai-core/archive/refs/heads/main.zipAdvanced AI integration core plugin for WordPress with enterprise-grade security features, encryption, and rate limiting.
🎯 Features
Core Functionality
- 🔐 AES-256-CBC Encryption - Secure encryption for API keys and sensitive data
- ⏱️ Rate Limiting - Built-in rate limiting using WordPress transients
- 🔒 AJAX Security - Automatic nonce validation and capability checks
- 📊 PHPUnit Testing - Comprehensive unit test suite with 20+ tests
- 🎨 WordPress Coding Standards - 100% WPCS compliant code
- 🚀 PSR-4 Autoloading - Modern PHP class autoloading
Security Features
- HMAC authentication for encrypted data
- IP-based and user-based rate limiting
- Automatic request validation
- Secure data storage in WordPress options
- Protection against timing attacks with
hash_equals()
Developer Tools
- GitHub Actions CI/CD pipeline
- PHP CodeSniffer configuration
- PHPUnit bootstrap and test suite
- Automated syntax checking for PHP 7.4-8.3
📋 Requirements
- PHP: 7.4 or higher
- WordPress: 5.8 or higher
- PHP Extensions:
- OpenSSL (required for encryption)
- mbstring
- mysqli
🔧 Installation
Manual Installation
-
Download the plugin:
git clone https://github.com/yourusername/mondays-work-ai-core.git -
Upload to WordPress:
cp -r mondays-work-ai-core /path/to/wordpress/wp-content/plugins/ -
Install dependencies (optional for development):
cd wp-content/plugins/mondays-work-ai-core composer install -
Activate the plugin:
- Go to WordPress Admin → Plugins
- Find "Monday's Work AI Core"
- Click "Activate"
Via WordPress Admin
- Download the plugin ZIP file
- Go to WordPress Admin → Plugins → Add New
- Click "Upload Plugin"
- Choose the ZIP file and click "Install Now"
- Activate the plugin
⚙️ Configuration
Setting Up Encryption Key
For maximum security, add a custom encryption key to your wp-config.php:
define( 'MONDAYS_WORK_AI_ENCRYPTION_KEY', 'your-32-byte-encryption-key-here' );
Generate a secure key:
php -r "echo bin2hex(random_bytes(32));"
Basic Usage
Encrypting Data
use MondaysWork\AI\Core\Security\Encryption;
$encryption = new Encryption();
// Encrypt an API key
$api_key = 'sk-abc123xyz789';
$encrypted = $encryption->encrypt( $api_key );
// Store encrypted data
$encryption->store_encrypted( 'my_api_key', $api_key );
Rate Limiting
use MondaysWork\AI\Core\Security\RateLimiter;
$rate_limiter = new RateLimiter();
// Check if request is allowed (60 requests per minute)
$identifier = RateLimiter::get_request_identifier();
if ( $rate_limiter->is_allowed( $identifier, 'api_call', 60, 60 ) ) {
// Process request
} else {
// Rate limit exceeded
$time_until_reset = $rate_limiter->get_time_until_reset( $identifier, 'api_call' );
wp_send_json_error( "Rate limit exceeded. Try again in {$time_until_reset} seconds." );
}
AJAX Requests
// Frontend JavaScript
jQuery.ajax({
url: mondaysWorkAI.ajaxUrl,
type: 'POST',
data: {
action: 'mondays_work_ai_process',
nonce: mondaysWorkAI.nonce,
input: 'Your data here'
},
success: function(response) {
console.log(response.data);
}
});
📁 Project Structure
mondays-work-ai-core/
├── includes/
│ ├── Core/
│ │ └── Security/
│ │ ├── Encryption.php # AES-256-CBC encryption class
│ │ └── RateLimiter.php # Rate limiting with transients
│ └── Ajax/
│ └── AjaxHandler.php # AJAX request handler
├── tests/
│ ├── bootstrap.php # PHPUnit bootstrap
│ └── Unit/
│ └── EncryptionTest.php # Encryption unit tests
├── .github/
│ └── workflows/
│ └── php-lint.yml # CI/CD pipeline
├── languages/ # Translation files
├── mondays-work-ai-core.php # Main plugin file
├── phpcs.xml # PHP CodeSniffer config
├── composer.json # Composer dependencies
├── README.md # This file
├── CHANGELOG.md # Version history
└── LICENSE # GPL v2 license
🧪 Testing
Running PHPUnit Tests
# Install dependencies
composer install
# Install WordPress test suite
bash bin/install-wp-tests.sh wordpress_test root root localhost latest
# Run tests
composer test
# Run with coverage
composer test -- --coverage-html coverage/
Running Code Standards Check
# Check coding standards
composer phpcs
# Auto-fix issues
composer phpcbf
🔌 Available Hooks
Actions
// Fires when plugin is fully loaded
do_action( 'mondays_work_ai_loaded' );
// Fires when plugin is deactivated
do_action( 'mondays_work_ai_deactivated' );
// Fires when rate limit is exceeded
do_action( 'mondays_work_ai_rate_limit_exceeded', $identifier, $action, $attempts );
Filters
// Filter encryption key
$key = apply_filters( 'mondays_work_ai_encryption_key', $key );
// Filter rate limit settings
$max_attempts = apply_filters( 'mondays_work_ai_rate_limit_max', 60, $action );
$time_window = apply_filters( 'mondays_work_ai_rate_limit_window', 60, $action );
🛠️ Development
Setting Up Development Environment
# Clone repository
git clone https://github.com/yourusername/mondays-work-ai-core.git
cd mondays-work-ai-core
# Install dependencies
composer install
# Set up pre-commit hooks
composer run-script setup-hooks
Code Standards
This project follows WordPress Coding Standards. All code must pass:
- PHP CodeSniffer (PHPCS)
- PHPUnit tests
- PHP compatibility check (7.4+)
🐛 Troubleshooting
Plugin Won't Activate
Error: "Parse error" or syntax error
Solution: Ensure you're running PHP 7.4 or higher:
php -v
OpenSSL Not Available
Error: "OpenSSL extension required"
Solution: Install/enable OpenSSL:
# Ubuntu/Debian
sudo apt-get install php-openssl
# CentOS/RHEL
sudo yum install php-openssl
Rate Limit Issues
Problem: Transients not clearing
Solution: Clean up transients:
$rate_limiter = new RateLimiter();
$rate_limiter->clear_all( 'identifier' );
Encryption Fails
Problem: Data cannot be encrypted/decrypted
Solutions:
- Verify OpenSSL is installed
- Check encryption key is defined
- Verify filesystem permissions for wp-content
📚 Documentation
Full documentation is available in the Wiki:
🤝 Contributing
Contributions are welcome! Please read our Contributing Guide for details on:
- Code of Conduct
- Development process
- Pull request process
- Coding standards
📝 Changelog
See CHANGELOG.md for a list of changes.
📄 License
This project is licensed under the GPL v2 or later - see the LICENSE file for details.
👥 Authors
- Your Name - Initial work - GitHub
🙏 Acknowledgments
- WordPress Core Team
- Anthropic for AI capabilities
- All contributors
📞 Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@layers.tv
🔗 Links
Made with ❤️ for the WordPress community