Skip to content

tudor-constantin/ai-comment-guard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Comment Guard

WordPress Plugin Version WordPress Tested PHP Version License

πŸ€– AI-powered comment moderation for WordPress - Protect your WordPress site from spam with intelligent, customizable AI analysis.

🌟 Features

  • πŸ”Œ Multiple AI Providers: OpenAI (GPT-4/GPT-3.5), Anthropic (Claude), OpenRouter
  • ⚑ Automatic Processing: Real-time comment analysis and moderation
  • 🎯 Smart Classification: Auto-approve, reject, hold, or mark as spam
  • πŸ“Š Confidence Thresholds: Customizable confidence levels for actions
  • ✏️ Custom Prompts: Tailor AI behavior to your needs
  • πŸ“ˆ Comprehensive Logging: Track all decisions with detailed statistics
  • πŸ”’ Secure Integration: Encrypted API key storage
  • 🌍 i18n Ready: Fully translatable
  • βš™οΈ Easy Setup: Intuitive admin interface

πŸ“‹ Requirements

  • WordPress 5.0+
  • PHP 7.2+
  • API key from supported provider
  • SSL certificate (recommended)

πŸš€ Installation

From WordPress Admin

  1. Navigate to Plugins > Add New
  2. Search for "AI Comment Guard"
  3. Click Install Now then Activate
  4. Go to Settings > AI Comment Guard

Manual Installation

  1. Download the latest release
  2. Upload to /wp-content/plugins/ai-comment-guard/
  3. Activate through the Plugins menu
  4. Configure at Settings > AI Comment Guard

βš™οΈ Configuration

  1. Choose Provider: Select OpenAI, Anthropic, or OpenRouter
  2. Add API Key: Enter your provider's API key
  3. Test Connection: Verify the connection works
  4. Set Thresholds: Configure confidence levels
  5. Customize Prompts: Tailor AI analysis criteria
  6. Enable Logging: Track moderation decisions (optional)

πŸ”‘ API Providers

OpenAI

  • Get your key at platform.openai.com
  • Supports GPT-4 and GPT-3.5 models
  • Excellent for nuanced content analysis

Anthropic

OpenRouter

  • Get your key at openrouter.ai
  • Access to multiple AI models
  • Flexible pricing options

πŸ“Š Usage Examples

Basic Setup

// The plugin works automatically once configured
// Comments are processed before being saved to database

Custom Threshold Example

  • Spam Threshold: 0.7 (70% confidence = mark as spam)
  • Approval Threshold: 0.3 (30% confidence = auto-approve)
  • Between thresholds: Hold for manual review

Custom Prompt Example

Analyze this comment for spam, inappropriate content, or legitimate discussion.
Consider: relevance, tone, promotional content, and value to discussion.
Respond with JSON: {"analysis": "approved|rejected|spam", "confidence": 0.0-1.0, "reason": "explanation"}

πŸ›‘οΈ Security Features

  • Nonce Verification: All AJAX requests protected
  • Capability Checks: Admin-only access to settings
  • Data Sanitization: All inputs properly sanitized
  • SQL Injection Protection: Prepared statements used
  • XSS Prevention: Output properly escaped
  • HTTPS Only: API communications encrypted

🌐 Internationalization

The plugin is fully translatable with .pot file included. Available text domains:

  • ai-comment-guard

To translate:

  1. Use the included .pot file
  2. Create your .po and .mo files
  3. Place in /wp-content/languages/plugins/

πŸ“ˆ Performance

  • Async Processing: Non-blocking comment analysis
  • Database Indexes: Optimized query performance
  • Caching: Configuration cached for efficiency
  • Cleanup Cron: Automatic old log removal
  • Minimal Overhead: < 50ms average processing time

πŸ”§ Development

File Structure

ai-comment-guard/
β”œβ”€β”€ admin/              # Admin interface assets
β”‚   β”œβ”€β”€ css/           # Admin styles
β”‚   └── js/            # Admin scripts
β”œβ”€β”€ includes/          # Core PHP classes
β”‚   β”œβ”€β”€ AI/           # AI provider implementations
β”‚   β”œβ”€β”€ Admin/        # Admin functionality
β”‚   β”œβ”€β”€ Comments/     # Comment processing
β”‚   β”œβ”€β”€ Core/         # Core plugin files
β”‚   β”œβ”€β”€ Database/     # Database operations
β”‚   └── Utils/        # Utility classes
β”œβ”€β”€ languages/         # Translation files
β”œβ”€β”€ ai-comment-guard.php  # Main plugin file
β”œβ”€β”€ readme.txt         # WordPress.org readme
β”œβ”€β”€ README.md          # This file
└── uninstall.php      # Clean uninstall handler

Coding Standards

  • PSR-4 Autoloading: Modern PHP namespace structure
  • WordPress Coding Standards: Following WP guidelines
  • PHPDoc Comments: Complete documentation
  • Security Best Practices: OWASP guidelines followed
  • Design Patterns: Singleton, Factory, Strategy patterns

Hooks & Filters

// Filter comment approval status
add_filter('pre_comment_approved', 'your_function', 10, 2);

// Action after AI analysis
do_action('aicog_after_analysis', $comment_data, $analysis);

// Filter AI prompt
add_filter('aicog_prompt', 'customize_prompt', 10, 2);

πŸ§ͺ Testing

Manual Testing Checklist

  • Install and activate plugin
  • Configure API provider
  • Test connection
  • Submit test comment
  • Verify AI analysis
  • Check logs (if enabled)
  • Test threshold adjustments
  • Verify uninstall cleanup

πŸ“ Changelog

For detailed version history and release notes, see the changelog in readme.txt or visit the WordPress.org plugin page.

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a pull request

Reporting Issues

Please report issues with:

  • WordPress version
  • PHP version
  • Error messages
  • Steps to reproduce

πŸ“œ License

AI Comment Guard is licensed under GPL v2 or later.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

πŸ‘¨β€πŸ’» Author

Tudor Constantin

πŸ™ Acknowledgments

  • WordPress Community for feedback and support
  • Contributors and testers
  • AI provider teams for excellent APIs

πŸ“ž Support

For support, please:

  1. Check the FAQ section
  2. Visit the support forum
  3. Contact via LinkedIn

⭐ If you find this plugin useful, please consider leaving a 5-star review on WordPress.org!

About

AI-powered comment moderation for WordPress - Protect your WordPress site from spam with intelligent, customizable AI analysis.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors