Mind Elixir × Custom WordPress Plugin: Adding a 5-Minute Auto-Save Feature
This article explains the steps to add an auto-save feature to the “Mind Elixir Admin" plugin, which integrates mind maps into the WordPress dashboard. We will introduce how to set up an “Enable Auto-Save" checkbox on the PHP side, and have JavaScript automatically click the existing save button (#save-map-button) every 5 minutes.
Introduction
-
Background & Objectives
-
To improve the usability of the previously created mind map plugin for the WordPress dashboard, we want to implement an auto-save feature.
I tried making a plugin to jot down article ideas using mind maps in the WordPress dashboard (Japanese)
I tried expanding the plugin to save, switch, and delete multiple mind maps in the WordPress dashboard (Japanese) -
By automatically calling the same processing as manual saves, we reduce user effort and prevent data loss.
-
Implementation Overview
-
PHP Side
-
Output a checkbox and set it to ON by default using
checked().
-
-
JavaScript Side
- Execute
$('#save-map-button').trigger('click')every 5 minutes usingsetInterval(). -
Directly invoke the button’s normal click handler to perform an Ajax save.
- Execute
Code Explanation Highlights
-
Simple Reuse
By reusing the same save button click event for both manual and automatic saves, maintainability is improved. -
Reflecting User Settings
Control the flag via a checkbox, allowing easy ON/OFF toggling on the JS side.
Code
The code is publicly available on GitHub.
Add auto-save feature every 5 minutes · bomura/wp-mind-elixir-admin@638433f
Summary & Future Expansion Ideas
-
With this method, mind maps can now be saved automatically every 5 minutes.
-
Expansion Ideas
-
Allow the save interval to be configurable from the dashboard
-
Change save completion notifications to toast alerts
-
Combine with local storage backup
-
Feel free to use this implementation as a base to build a more comfortable mind map editing environment!