Thank you very much for your prompt response.
I’m the author of Freesoul Deactivate Plugins.
I’ve opened this thread because a user of FDP has seen a notification given by my plugin about the rewrite rules.
FDP allows the user to specifically disable other plugins on specific pages.
Imagine on the page sample-page you disable plugin A, B, and C, but you keep them active globally.
If those plugins add some rewrite rules, and your plugin flushes the rewrite rules when someone visits sample-page, the new rewrite rules miss those rules added by plugins A, B, and C. The issue is that after they are regenerated by WordPress they will be saved into the database missing some rules.
To avoid this issue, FDP when detects the flushing of the rewrite rules during a normal page load, it calls the homepage behind the scenes enabling all the plugins and saves the rewrite rules, but this time being careful no rule is missed.
This operation consumes server resources. Because your plugin flushes the rewrite rules at every page load, the issue become more serius.
But it would already be a loss of performance without FDP. There is no reason to flush the rewrite rules during a page request. I would do it on plugin activation, or maybe when the user saves the settings of your plugin if you need it, but not on wp_loaded.
It would be great if you can change your code, but of course, I can’t pretend you do it with the next version. I would be very happy, but you are the owner of your time, and you know when you can do it.
I don’t want to stress you.
For me, if you keep your function in the main file, you could just replace the wp_loaded hook with:
register_activation_hook( __FILE__, 'hsts_plugin_flush_rewrite_rules' );
But of course, you know better than everybody else what is better to do in your code.
Thank you in any case for your prompt response.
Have a great day!
Jose