From 991599e69e609ade14cee7f5416fbfde902d4d8e Mon Sep 17 00:00:00 2001 From: Tim LSC Date: Wed, 15 Jul 2026 17:58:00 +0300 Subject: [PATCH] =?UTF-8?q?Elementor=20Theme=20Builder=20changes=20do=20no?= =?UTF-8?q?t=20invalidate=20dependent=20page=20cache=20until=20=E2=80=9CPu?= =?UTF-8?q?rge=20All=E2=80=9D=20is=20run?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- thirdparty/elementor.cls.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/thirdparty/elementor.cls.php b/thirdparty/elementor.cls.php index 0da16adc8..865a96cf2 100644 --- a/thirdparty/elementor.cls.php +++ b/thirdparty/elementor.cls.php @@ -34,6 +34,10 @@ public static function preload() { return; } + // Register template-save handling before inspecting the editor request. A + // published save returns early below, but still needs to purge the cache. + add_action( 'elementor/document/after_save', __CLASS__ . '::purge_saved_document' ); + // If user explicitly opened the Elementor editor, disable all LSCWP features. $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( 'elementor' === $action ) { @@ -70,6 +74,37 @@ public static function preload() { add_action( 'elementor/core/files/clear_cache', __CLASS__ . '::regenerate_litespeed_cache' ); } + /** + * Purge all caches after an Elementor library document is saved. + * + * Elementor templates can be rendered across many pages without WordPress + * exposing a complete reverse dependency list, so a full purge guarantees + * that no page keeps stale template output. + * + * @since 7.8.2 + * @param object $document Saved Elementor document. + * @return void + */ + public static function purge_saved_document( $document ) { + if ( ! is_object( $document ) || ! method_exists( $document, 'get_post' ) ) { + do_action( 'litespeed_purge_all', 'Elementor template saved' ); + return; + } + + $post = $document->get_post(); + if ( ! is_object( $post ) || empty( $post->post_type ) ) { + do_action( 'litespeed_purge_all', 'Elementor template saved' ); + return; + } + + // Normal Elementor pages already use WordPress's standard post purge. + if ( 'elementor_library' !== $post->post_type ) { + return; + } + + do_action( 'litespeed_purge_all', 'Elementor template saved' ); + } + /** * Disable LiteSpeed ESI explicitly (kept for backward compatibility if re-enabled). *