Prevent unsafe flush_rewrite_rules() to avoid WPML 404 issues
Miikka
One of our clients is running a multilingual WooCommerce store with Flatsome + WPML.
We’ve run into a recurring problem where Flatsome (or related theme code) triggers flush_rewrite_rules() at times that cause WPML language directories to break. After this, translated pages often return 404 errors until we manually resave permalinks.
Why this matters:
It breaks translated shop/product URLs (major impact for SEO and sales).
It forces site admins to do manual fixes after updates or settings changes.
It adds instability in production environments with WPML.
Suggested solution:
Only call flush_rewrite_rules() on safe hooks (e.g. after theme switch, on Permalink save), never on front-end requests.
Optionally provide a theme setting to disable automatic flushes.
Ömer Faruk
I've been dealing with this for a week. You've identified the problem. Yes, an urgent solution is needed.