MC Functionality
A file-based code snippet system for WordPress. Load and execute PHP files from the /code-snippets/ directory with better performance and security than database-stored snippets.
by Matt Cromwell · github.com/mathetos/mc-functionality · 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/mathetos/mc-functionality/archive/refs/heads/main.zipReadme
MC Functionality
A file-based code snippet system for WordPress that loads and executes PHP files with better performance and security than database-stored snippets.
🚀 Why MC Functionality?
Performance Benefits
- File-based storage - No database queries for snippet loading
- Early loading - Snippets available before themes and plugins
- Caching friendly - Files don't change frequently, perfect for caching
- Zero database overhead - Snippets stored as PHP files
Developer Experience
- In-browser editor with CodeMirror syntax highlighting
- Real-time validation and error checking
- Enable/disable snippets without deleting files
- Template system for quick snippet creation
- Comprehensive error handling and logging
Security Features
- Path traversal protection
- File validation before loading
- Restricted execution to
.phpfiles only - Error logging when WP_DEBUG is enabled
📦 Installation
- Upload the plugin to
/wp-content/plugins/mc-functionality/ - Activate the plugin through the WordPress admin
- Access "Site Functions" under the Plugins menu
- Create your first snippet in the
/code-snippets/directory
🛠️ Quick Start
Creating Your First Snippet
- Go to Plugins → Site Functions in your WordPress admin
- Click "Create New Snippet"
- Write your PHP code:
<?php
// Add a custom shortcode
add_shortcode( 'hello_world', function( $atts ) {
return '<div>Hello from MC Functionality!</div>';
} );
// Hook into WordPress actions
add_action( 'wp_footer', function() {
echo '<!-- Custom footer content -->';
} );
- Save and your snippet is immediately active!
File-Based Snippets
Place PHP files in the /code-snippets/ directory:
wp-content/plugins/mc-functionality/code-snippets/
├── custom-shortcodes.php
├── theme-modifications.php
├── admin-customizations.php
└── performance-optimizations.php
🎯 Use Cases
- Custom shortcodes and functions
- Theme modifications and customizations
- Admin interface enhancements
- Performance optimizations
- Security hardening measures
- Third-party integrations
🔧 Features
- ✅ File-based snippet storage
- ✅ In-browser code editor
- ✅ Enable/disable snippets
- ✅ Syntax highlighting
- ✅ Error validation
- ✅ Template system
- ✅ Security protection
- ✅ Performance optimized
🤝 Contributing
We welcome contributions! Here's how you can help:
Reporting Issues
- 🐛 Bug reports - Help us improve the plugin
- 💡 Feature requests - Suggest new functionality
- 📚 Documentation - Help improve our docs
Submitting Pull Requests
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Guidelines
- Follow WordPress coding standards
- Add proper documentation
- Include tests for new features
- Update README if needed
📄 License
This project is licensed under the GPL v2 or later - see the LICENSE.txt file for details.
🙏 Support
- Documentation: Plugin Wiki
- Issues: GitHub Issues
- Author: Matt Cromwell
⭐ Star This Repository
If you find this plugin useful, please consider giving it a star on GitHub. It helps others discover the project!
Built with ❤️ for the WordPress community