Lesson 2 – Creating a Basic MainWP Add-on
Creating a basic MainWP add-on involves several steps, primarily focusing on developing custom functionality that integrates seamlessly with the MainWP Dashboard.
Here’s a simplified outline of the steps you will need to be familiar with:
- Understand MainWP Add-on Architecture: Familiarize yourself with MainWP’s add-on development guidelines and architecture. MainWP provides documentation and resources to help you understand how add-ons work within its ecosystem.
- Plan Your Add–on: Clearly define the purpose and functionality of your MainWP add-on. Decide what features it will add to the MainWP dashboard and how it will interact with connected child sites.
- Create a New WordPress Plugin: Begin by creating a new WordPress plugin for your MainWP add-on. Set up the necessary files and folder structure according to WordPress plugin development standards. To simplify this process, we have provided a starting point for you that has the basic structure already in place. You can freely download that here: https://github.com/mainwp/mainwp-development-extension Once downloaded simply install just like a regular WordPress Plugin & you should be able to start developing right away. As this is just an outline of what to expect, we will get more into renaming files & folders for your add-on a bit later in the lesson so you may want to hold off on installing just yet but you can just so you know what to expect.
- Database Architecture & Optimization: The architecture of the database holds significant importance and should not be overlooked, especially when considering add-ons that may lead to the expansion of database data and scalability. Thus, meticulous planning of database aspects becomes crucial. It should be best practice to assign each add-on a dedicated database table and minimize the utilization of wp_options or any other database table whenever feasible.
- Integrate with MainWP APIs: Utilize MainWP’s APIs and hooks to integrate your add-on with the MainWP Dashboard. This may include adding custom menu items, widgets, settings pages, or other UI elements.
- Implement Core Functionality: Develop the core functionality of your add-on. This could involve tasks such as adding new site management features, enhancing site monitoring capabilities, or integrating with third-party services.
- Testing: Thoroughly test your add-on to ensure it functions as expected. Test various scenarios, including different MainWP configurations and child site setups. Laragon’s local environment allows for easy testing and debugging. This could include testing different PHP versions or Plugin / Add-on versions.
- Refinement and Optimization: Refine your add-on code for performance, security, and user experience. Optimize queries, implement caching mechanisms, and ensure proper error handling.
- Documentation: Write documentation for your add-on, including installation instructions, usage guidelines, and troubleshooting tips. Clear documentation helps users understand how to use your add-on effectively.
- Publish and Share: Once your MainWP add-on is ready, consider sharing it with the community. You can publish it on the WordPress plugin repository or distribute it through other channels. Sharing your add-on allows other MainWP users to benefit from your work. These are just a few ways to get your plugin out in the wild, but we will leave the final decision up to you as the developer.
By following these steps, you can create a basic MainWP add-on that enhances the functionality of the MainWP Dashboard and provides value to users managing multiple WordPress sites.
In the next lesson, we will be diving a bit deeper into the provided MainWP Development Add-on framework & going over renaming any files & folders needed before installing the add-on for development.
Add-on Development Guide
Lesson 1 – Setting up a MainWP Development EnvironmentLesson 2 – Creating a Basic MainWP Add-onLesson 3 - The MainWP Development Add-on
Lesson 3 - Main FileLesson 3 - Admin ClassLesson 3 - Database ClassLesson 3 - Utility ClassLesson 3 - Overview ClassLesson 3 - Individual ClassLesson 3 - Ajax ClassLesson 3 - Widget Class
Lesson 4 – Building intuitive admin interfaces for MainWP Add-onsLesson 5 – Storing and retrieving data with a WordPress PluginLesson 6 – How to use MainWP Actions & FiltersLesson 7 – Debugging common issues in MainWP Add-onsLesson 8 – Packaging and distributing your Add-onLesson 9 – Writing Clean & Maintainable MainWP Code: Best Practices