Closed mennolui closed 6 years ago
Possible solutions..
1. Trigger through register_activation_hook and loop over all blogs to flush permalinks
https://jeremyfelt.com/2015/07/17/flushing-rewrite-rules-in-wordpress-multisite-for-fun-and-profit/
Does however not solve the edge case where new sites are added to a multisite network with the plugin network activated.
Even less elegant:
https://surniaulula.com/2013/10/24/wordpress-multisite-activate-deactivate-and-uninstall/ https://wordpress.stackexchange.com/questions/181141/how-to-run-an-activation-function-when-plugin-is-network-activated-on-multisite
2. Check against version option in db on plugins_loaded and add action on init to flush permalinks
Solves multisite pretty permalink issues and uses the existing Foyer_Updater code to detect if the plugin was updated (or freshly installed).
Minor draw back is the rules are not flushed at activation but rather at the first page load after activation. Should work fine (unless redirecting to a pretty permalink directly after activation).
Major draw back: will not flush permalinks after deactivating and then activating. Between deactivating and activating other plugins or the user could have flushed our rules.
3. Loop over all blogs at register_activation_hook and set a flush option, flush when present on init
Minor draw back is the rules are not flushed at activation but rather at the first page load after activation. Should work fine (unless redirecting to a pretty permalink directly after activation).
Minor draw back: Deactivation is harder: our code is no longer present on init.
https://andrezrv.com/2014/08/12/efficiently-flush-rewrite-rules-plugin-activation/
Almost solved this issue in release/1.5.3. Implemented a combination between 1 and 2.
Remaining problem: When network activated, then network deactivated and later network activated again the rewrite rules are not flushed. In this situation displays could become inaccessible (404 Not Found) for all sites other than the primary site. For example when other plugins flushed the rewrite rules between deactivation and activation.
I'll add a separate issue for that.
When Foyer is network activated, viewing a display on its pretty permalink, eg. http://demo.foyer.tv/foyer/display-above-bar/, results in a 404 Not Found. For all sites in the multisite network, except for the primary site where pretty permalinks work fine.
Cause: When Foyer is network activated, rewrite rules are not flushed for each site in the multisite network at plugin activation / update. Also when Foyer is network activated, rewrite rules are not flushed when a new site is added to the multisite network.