Created
January 9, 2023 15:51
-
-
Save mustafauysal/41eef639198e9db7146be21db3c5a0d2 to your computer and use it in GitHub Desktop.
Removes hustle and forminator tables when deleting a blog on multisite installation
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[ | |
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