Developer Overview
This guide introduces developers to extending Million Dollar Script. Whether you're building custom features for your site or creating shareable extensions, MDS provides hooks, filters, and patterns to integrate seamlessly.
Architecture Overview
MDS follows WordPress conventions and best practices:
- Hooks and filters for extensibility at key points
- Proper capability checks before rendering admin content
- Nonce verification for all form submissions
- Input sanitization and output escaping
- Translation-ready strings using WordPress i18n functions
The plugin is built around a modular class structure with namespaced PHP (PSR-4) and Composer autoloading.
Key Concepts
Text Domains
- Core plugin:
milliondollarscript-two - Extensions: Each extension uses its own text domain (e.g.,
mds-translation,mds-fields)
Always use the appropriate text domain for translatable strings.
Database
MDS uses WordPress database conventions:
- Database operations use
$wpdbdirectly - Custom tables use
{$wpdb->prefix}mds_*naming - Plugin options are stored in the WordPress options table
- The
mds-pixelcustom post type stores pixel/advertiser data
Admin Integration
Extensions integrate with MDS admin in several ways:
mds_main_menu_extensions_submenu- Add items to the Extensions dropdown (recommended)mds_main_menu_admin_submenu- Add items to the Admin dropdownmds_main_menu_top- Add top-level hero menu items
See Hooks Reference for complete documentation.
Getting Started
Recommended Reading
- Hooks Reference - Available actions and filters
- Extension Development - Building your own extension
- List Page Customization - Extending the advertiser list
Example Extensions
Two example extensions demonstrate MDS development patterns:
- MDS Sample Greeter - Basic extension with admin page, shortcode, and AJAX
- MDS Skeleton - Clean boilerplate for scaffolding new extensions
Both are available in the MDS extensions repository and can serve as starting points.
Development Environment
Recommended setup:
- Local WordPress installation (Local by Flywheel, DDEV, or Docker)
- PHP 8.1+ with debugging enabled
- WordPress debug constants in
wp-config.php:define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false); - Million Dollar Script core plugin installed and activated
- Code editor with PHP support (VS Code, PhpStorm)
Quick Test
To verify your environment is ready for MDS development:
- Activate MDS and confirm the admin menu appears
- Check
wp-content/debug.logexists and is writable - Test a simple hook:
add_action('mds_main_menu_extensions_submenu', function () { if (current_user_can('manage_options')) { echo '<li><a href="#">Dev Test</a></li>'; } }); - Verify "Dev Test" appears in the Extensions menu
Coding Standards
MDS follows WordPress Coding Standards:
- PHP: WordPress PHP Coding Standards
- JavaScript: WordPress JavaScript Coding Standards
- CSS: WordPress CSS Coding Standards
Key practices:
- Use meaningful, descriptive names for functions, classes, and variables
- Prefix all function names, classes, and global variables with your extension's unique prefix
- Always escape output (
esc_html(),esc_attr(),esc_url()) - Always sanitize input (
sanitize_text_field(),absint(), etc.) - Use nonces for form verification (
wp_nonce_field(),wp_verify_nonce()) - Check capabilities before performing privileged actions (
current_user_can())
Requirements
Extensions should declare their requirements in the plugin header:
/**
* Plugin Name: My MDS Extension
* Requires at least: 6.7
* Requires PHP: 8.1
*/
Minimum requirements for MDS compatibility:
- WordPress 6.7+
- PHP 8.1+
- Million Dollar Script core plugin (active)
Support Resources
- GitHub Issues - Report bugs or request features
- Discord Community - Developer discussions
- This Documentation - Reference guides and examples