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


Implementation Overview

  1. PHP Side

    • Output a checkbox and set it to ON by default using checked().

  2. JavaScript Side

    • Execute $('#save-map-button').trigger('click') every 5 minutes using setInterval().
    • Directly invoke the button’s normal click handler to perform an Ajax save.


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!