Skip to content

Commit e8eae5e

Browse files
Handle cache flushing for Elementor when cloudinary settings are changed
1 parent 8239f2a commit e8eae5e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

php/integrations/class-elementor.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function can_enable() {
6464
*/
6565
public function register_hooks() {
6666
add_action( 'elementor/element/parse_css', array( $this, 'replace_bg_images_in_css' ), 10, 2 );
67+
add_action( 'cloudinary_flush_cache', array( $this, 'clear_elementor_css_cache' ) );
6768
}
6869

6970
/**
@@ -116,4 +117,17 @@ public function replace_bg_images_in_css( $post_css, $element ) {
116117
$post_css->get_stylesheet()->add_rules( $css_selector, $css_rule, $media_query );
117118
}
118119
}
120+
121+
/**
122+
* Clear Elementor CSS cache.
123+
* This is called when Cloudinary cache is flushed, so that any change in media URLs is reflected in Elementor CSS files.
124+
*
125+
* @return void
126+
*/
127+
public function clear_elementor_css_cache() {
128+
if ( class_exists( 'Elementor\Plugin' ) ) {
129+
$elementor = Plugin::instance();
130+
$elementor->files_manager->clear_cache();
131+
}
132+
}
119133
}

0 commit comments

Comments
 (0)