You will need the MailChimp API by Drew McLellan. If you’re managing your project with composer (which you should) it’s as simple as running:
composer require drewm/mailchimp-api
Be careful not to commit your MailChimp API credentials to your code repository. Credentials belong into a database or an environment configuration file. Since I want to keep the code here minimal, lets define 2 globals.
If you use dotenv or some kind of environment configuration, you’ll know where to put these, if not, wp-config.php will work.
3. Ajax endpoint for MailChimp subscription
The code below is a fully functional plugin. While it can be used as is, you should ideally integrate it into your own codebase.
Place the following into wp-content/plugins/smc/smc.php:
4. Front-end form submission
Place the following into wp-content/plugins/smc/mailchimp.js:
5. The HTML markup
You can simply translate everything as you would with any another plugin. Create a sub-directory called languages and fill it with localisations. Below is the English template from the above files:
That’s all. A fully functional replica of MailChimp for WP in less than 200 lines of code. Should be tiny and to the point so you can expand on it and adapt it to your needs. Don’t waste time trying to wrap your head around some plugin that needs extra plugins just to get some basic functionality going.