Created
May 11, 2020 16:26
-
-
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
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
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
https://deliciousbrains.com/tips-power-users-wp-migrate-db-pro/
https://developer.wordpress.org/cli/commands/media/regenerate/