Skip to content

Commit d614a4b

Browse files
committed
chore: ensure cache-busting for otter-blocks and elementor
1 parent 76c3d32 commit d614a4b

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

inc/media_rename/attachment_edit.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function init() {
2323
add_action('submenu_file', [$this, 'hide_sub_menu']);
2424

2525
add_action( 'edit_attachment', [ $this, 'save_attachment_filename' ] );
26-
add_action( 'optml_attachment_renamed', [$this, 'bust_cached_assets'], 10, 2 );
26+
add_action( 'optml_after_attachment_url_replace', [$this, 'bust_cached_assets'], 10, 3 );
2727
}
2828

2929
public function add_metabox( string $post_type, \WP_Post $post ) {
@@ -282,8 +282,25 @@ public function save_attachment_filename( $post_id ) {
282282
$renamer->rename();
283283
}
284284

285-
public function bust_cached_assets() {
285+
/**
286+
* Bust cached assets
287+
*
288+
* @param int $attachment_id The attachment ID
289+
* @param string $new_guid The new GUID
290+
* @param string $old_guid The old GUID
291+
*/
292+
public function bust_cached_assets( $attachment_id, $new_guid, $old_guid ) {
293+
if (
294+
class_exists('\ThemeIsle\GutenbergBlocks\Server\Dashboard_Server') &&
295+
is_callable(['\ThemeIsle\GutenbergBlocks\Server\Dashboard_Server', 'regenerate_styles'])
296+
) {
297+
\ThemeIsle\GutenbergBlocks\Server\Dashboard_Server::regenerate_styles();
298+
}
286299

287-
300+
if ( did_action( 'elementor/loaded' ) ) {
301+
if ( class_exists( '\Elementor\Plugin' ) ) {
302+
\Elementor\Plugin::instance()->files_manager->clear_cache();
303+
}
304+
}
288305
}
289306
}

0 commit comments

Comments
 (0)