Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukecav/f03d6ce0768ac5b0cfaf237cfd826454 to your computer and use it in GitHub Desktop.
Save lukecav/f03d6ce0768ac5b0cfaf237cfd826454 to your computer and use it in GitHub Desktop.
Regenerate media using a WP-CLI command once a WP Migrate DB Pro migration is complete
add_action( 'wpmdb_migration_complete', 'regen_media_migration_complete', 2, 20 );
function regen_media_migration_complete ( $action, $url ) {
$wp = "/chroot/home/a80f149d/no-install.com/html"; //full path to the WP-CLI command
global $wp_current_filter;
$is_remote = strstr($wp_current_filter[0], 'nopriv') ? true : false;
if ( ( 'push' == $action && $is_remote ) ||
( 'pull' == $action && ! $is_remote ) )
{
exec( "$wp media regenerate --yes /dev/null 2>/dev/null &" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment