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 mustafauysal/41eef639198e9db7146be21db3c5a0d2 to your computer and use it in GitHub Desktop.
Save mustafauysal/41eef639198e9db7146be21db3c5a0d2 to your computer and use it in GitHub Desktop.
Removes hustle and forminator tables when deleting a blog on multisite installation
<?php[
add_filter( 'wpmu_drop_tables', function ( $tables, $blog_id ) {
global $wpdb;
$hustle = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->get_blog_prefix( $blog_id ) . 'hustle' ) . '%' ), ARRAY_A );
if ( ! empty( $hustle ) ) {
foreach ( $hustle as $hustle_table ) {
$hustle_table = array_values( $hustle_table );
$hustle_table = $hustle_table[0];
$tables[] = $hustle_table;
}
}
$forminator = $wpdb->get_results( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->get_blog_prefix( $blog_id ) . 'frmt' ) . '%' ), ARRAY_A );
if ( ! empty( $forminator ) ) {
foreach ( $forminator as $forminator_table ) {
$forminator_table = array_values( $forminator_table );
$forminator_table = $forminator_table[0];
$tables[] = $forminator_table;
}
}
return $tables;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment