heyfletch
3/1/2019 - 10:23 PM

Clear Elementor Cache After a WP Migrate DB Pro Migration - Must Use Plugin (mu-plugins)

Clear Elementor Cache After a WP Migrate DB Pro Migration - Must Use Plugin (mu-plugins)

<?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();
	}
}