Last active
February 14, 2022 14:14
-
-
Save heyfletch/769c64ad1fab8679032b076433afafd1 to your computer and use it in GitHub Desktop.
Clear Elementor Cache After a WP Migrate DB Pro Migration - Must Use Plugin (mu-plugins)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: FD Clear Elementor Cache After WP Migrate DB Migration | |
Plugin URI: https://gist.github.com/heyfletch/769c64ad1fab8679032b076433afafd1 | |
Description: Deletes CSS in uploads/elementor/css, which auto-regenerates on pageload. This clears the cache locally and remotely. Must-use plugin (mu-plugin). | |
Author: Fletcher Digital | |
Version: 0.1.1 | |
Author URI: https://fletcherdigital.com | |
*/ | |
// Whitelist Elementor to load during a migration (avoids Migrate DB Pro's Compatibility mode) | |
add_filter( 'wpmdb_compatibility_plugin_whitelist', function ( $plugins ) { | |
$plugins[] = 'elementor'; | |
return $plugins; | |
} ); | |
add_action( 'wpmdb_migration_complete', 'fd_clear_elementor_cache' ); | |
function fd_clear_elementor_cache() { | |
// Check if Elementor installed and activated | |
if ( did_action( 'elementor/loaded' ) ) { | |
// clear Elementor cache | |
\Elementor\Plugin::instance()->files_manager->clear_cache(); | |
} | |
} |
Thanks! Works like a charm.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@damashe, glad you could use it. I'm not sure you'd need to upload the folder. I believe simply visiting the pages that had changed should generate the css files. I know it does if they don't exist, but I can't remember if it will regenerate existing files. But then you could just go to Regenerate CSS from the Elementor > Tools menu.