An educational tutorial repository that teaches developers how to create custom modals for Divi 5 Visual Builder. Learn through hands-on examples, complete code implementations, and step-by-step guidance for building professional modal-based extensions.
- How to structure modal components with WrapperContainer, Header, and Body
- Implementing drag, resize, expand, and snap capabilities for professional UX
- Error handling patterns with ErrorBoundary integration
- Creating custom Redux stores that integrate seamlessly with Divi 5
- Building reactive data patterns using useSelect and useEffect hooks
- Implementing persistent storage with app preferences and fallback strategies
- Managing real-time UI updates without performance issues
- WordPress hooks mastery: How to use
divi.modalLibrary.addModule.moduleList - Plugin architecture patterns for maintainable third-party extensions
- Module filtering systems that work with Divi's Insert Module dialog
- Effects patterns for data persistence without complex middleware
- Modern build processes with webpack and proper external dependencies
- PHP-JavaScript integration following WordPress and Divi standards
- Development-to-production optimization strategies
- Testing and debugging techniques for modal-based extensions
- Clone this educational repository to your local WordPress development environment
- Install dependencies:
npm install(in module-visibility-manager/) - Build the tutorial example:
npm run build - Activate in WordPress Admin โ Plugins to see it in action
- Open Divi Visual Builder on any page to begin exploring
- Find the "Module Visibility" button in the builder toolbar
- Click to open the modal and see the tutorial in action
- Live module discovery - See how the code dynamically finds all available modules
- Interactive controls - Toggle module visibility and watch real-time updates
- Persistent state - Learn how data survives page refreshes
- Professional UI - Study the modal structure and user experience patterns
d5-extension-example-modals/
โโโ d5-extension-example-modals.php
โโโ module-visibility-manager/
โโโ d5-extension-example-modal-module-visibility.php
โโโ package.json
โโโ webpack.config.js
โโโ src/
โ โโโ index.jsx
โ โโโ add-bar-builder-buttons.js
โ โโโ custom-store.js
โ โโโ hooks/
โ โ โโโ index.js
โ โ โโโ use-reactive-module-filter.js
โ โโโ modal/
โ โโโ component.jsx
โ โโโ module-visibility-list.jsx
โโโ build/
โโโ bundle.js
โโโ add-bar-builder-buttons.js
const store = createReduxStore('divi/custom-test', {
reducer: customReducer,
actions: customActions,
selectors: customSelectors,
});export const useReactiveModuleFilter = () => {
return useSelect(select => {
return select('divi/custom-test').getItems();
}, []);
};export const ModuleVisibilityManagerModal = (props) => (
<ErrorBoundary>
<WrapperContainer draggable resizable expandable snappable>
<Header name={__('Module Visibility Manager', 'et_builder')} />
<BodyContainer>
<PanelContainer id="module-visibility-manager" opened>
<ModuleVisibilityList />
</PanelContainer>
</BodyContainer>
</WrapperContainer>
</ErrorBoundary>
);// Create custom store
const myStore = createReduxStore('my-plugin/data', {
reducer: myReducer,
actions: myActions,
selectors: mySelectors,
});
// Register with WordPress
register(myStore);// Register your modal
addFilter('divi.modalLibrary.modalMapping', 'my-plugin', modals => ({
...modals,
myCustomModal: MyModalComponent,
}));// Add module filter
addFilter('divi.modalLibrary.addModule.moduleList', 'my-plugin',
(modules) => modules.filter(module => myFilterLogic(module))
);- Always use ErrorBoundary to prevent modal crashes
- Implement reactive patterns with useSelect and useEffect
- Use proper Redux patterns for state management
- Handle empty states gracefully with helpful messaging
- Test with real data in Visual Builder environment
- Store Registration: Use
register()after store creation - Reactive Updates: Use
useSelectfor automatic re-renders - Filter Integration: Use WordPress hooks for module filtering
- Persistent Storage: Combine app preferences with localStorage fallback
All build commands are now available from the root directory for better plugin architecture and scalability:
# Development
npm run start
# Production build
npm run build
# Development build
npm run build:dev
# Create distribution package
npm run zipNote: The build commands delegate to the module-visibility-manager/ subdirectory internally, but can be run from the root level for convenience.
For better scalability when adding more modals, consider this structure:
d5-extension-example-modals/
โโโ package.json (with all build commands)
โโโ webpack.config.js (root-level build config)
โโโ src/
โ โโโ module-visibility-manager/
โ โ โโโ component.jsx
โ โ โโโ ...
โ โโโ future-modal/
โ โโโ component.jsx
โ โโโ ...
โโโ build/
โโโ module-visibility-manager/
โโโ future-modal/
This would allow:
- Single
npm run startandnpm run buildcommands from root - Centralized build configuration
- Easier addition of new modals
- Consistent development workflow
To create a distribution-ready zip file of the plugin:
npm run zipThis command will:
- Create a
d5-extension-example-modals.zipfile - Exclude development files (
node_modules/,src/,.git/, etc.) - Include only production-ready plugin files
- Ready for distribution or installation
The zip command automatically excludes:
- Development dependencies (
node_modules/) - Source files (
src/) - Git files (
.git/,.gitignore) - Build configuration files (
gulpfile.js,package.json, etc.) - IDE and system files (
.vscode/,.DS_Store, etc.)
- Check that plugin is activated
- Verify build completed successfully
- Check browser console for JavaScript errors
- Ensure store is registered before modal opens
- Check Redux DevTools for store state
- Verify useSelect dependencies are correct
- Check filter hook registration timing
- Verify filter function returns valid array
- Test with browser console logging
- Divi 5 Modal Components: GitHub Repository
- Redux Store Architecture: WordPress data module patterns
- WordPress Hooks API: Filter and action integration
This implementation provides a working foundation for custom modal development with:
- โ Complete modal structure with proper Divi 5 integration
- โ Custom Redux store with reactive patterns
- โ Module filtering system with WordPress hooks
- โ Persistent data storage across sessions
- โ Professional build process for development and production
This example provides a solid foundation. For enhanced features:
- Server-side persistence ๐ Coming Soon: Replace localStorage with WordPress options/user meta
- Advanced UI features ๐ Coming Soon: Add search, categories, bulk operations
- โ Enhanced error handling: Comprehensive validation and user feedback
- โ Performance optimization: Lazy loading and caching strategies
A working example of custom modal integration with Divi 5 Visual Builder demonstrating store patterns, reactive filtering, and professional development practices.