I am working on a plugin that registers custom new endpoints in every update and we need to Flush Rewrite Rules after every update of the plugin.
Flushing Rewrite Rules are easy after activation of the plugin and there is a lot of tutorials out there about this
But in the case of Flushing Rewrite Rules after Update I can't find any solution
I am working on a plugin that registers custom new endpoints in every update and we need to Flush Rewrite Rules after every update of the plugin.
Flushing Rewrite Rules are easy after activation of the plugin and there is a lot of tutorials out there about this
But in the case of Flushing Rewrite Rules after Update I can't find any solution
Share Improve this question edited Dec 24, 2019 at 6:41 Kaperto 4783 silver badges10 bronze badges asked Dec 23, 2019 at 8:24 mir.moezimir.moezi 1013 bronze badges 2- 1 you can save the plugin version in an option and when the version change, you flush the cache. – Kaperto Commented Dec 23, 2019 at 9:23
- thank you your comment was the answer – mir.moezi Commented Dec 30, 2019 at 5:06
2 Answers
Reset to default 2Your answer above was close but is should be
add_action( 'upgrader_process_complete', 'wp_answ_355114' );
not
do_action( 'upgrader_process_complete', 'wp_answ_355114' );
noting that this is only the case when a plugin is updated view WP plugin updates.
I haven't verified this but you could try the upgrader_process_complete hook. More information on that hook.
like follows
function wp_answ_355114() {
flush_rewrite_rules();
}
do_action( 'upgrader_process_complete', 'wp_answ_355114' );