I've written a plugin to manually (admin button push) delete several hundred posts that are created by another plugin. That other plugin creates posts based on an external API.
I'm running into a situation where occasionally the API plugin is starting to creating new posts midway through the deletion.
I'm wondering if there is a way to use WP's core maintenance mode for just a few seconds to pause everything else on the site from running while the delete runs?
I've looked at update-core.php and update.php but it wasn't quite obvious to me what it was doing to initiate and terminate maintenance mode. I was kind of hoping there was a function to set maintenance mode and another to clear maintenance mode, but I'm not seeing it. Open to other ways to avoid this race condition as well.