prefix . 'commentmeta', $wpdb->prefix . 'comments', $wpdb->prefix . 'links', $wpdb->prefix . 'options', $wpdb->prefix . 'postmeta', $wpdb->prefix . 'posts', $wpdb->prefix . 'term_relationships', $wpdb->prefix . 'term_taxonomy', $wpdb->prefix . 'termmeta', $wpdb->prefix . 'terms', $wpdb->prefix . 'usermeta', $wpdb->prefix . 'users', ); // Get all tables with this prefix, including sizes in a single query (R-03). $all_rows = $wpdb->get_results( $wpdb->prepare( 'SELECT table_name AS name, (data_length + index_length) AS size FROM information_schema.TABLES WHERE table_schema = %s AND table_name LIKE %s', DB_NAME, $wpdb->esc_like( $wpdb->prefix ) . '%' ), ARRAY_A ); $all_tables = array(); $size_map = array(); foreach ( $all_rows as $row ) { $all_tables[] = $row['name']; $size_map[ $row['name'] ] = (float) $row['size']; } // Find custom tables. $custom_tables = array(); foreach ( $all_tables as $table ) { if ( ! in_array( $table, $core_tables, true ) ) { $custom_tables[] = array( 'name' => $table, 'size' => static::format_bytes( isset( $size_map[ $table ] ) ? $size_map[ $table ] : 0.0 ), ); } } $custom_count = count( $custom_tables ); $total_count = count( $all_tables ); $details = array( 'total_tables' => $total_count, 'core_tables' => count( array_intersect( $all_tables, $core_tables ) ), 'custom_count' => $custom_count, 'custom_tables' => array_slice( $custom_tables, 0, 10 ), // Show first 10. ); if ( $custom_count > 30 ) { return static::warning( sprintf( /* translators: %d: number of custom tables */ __( 'Your database has %d custom tables (created by plugins or themes). Make sure your export includes all tables, not just core WordPress tables.', '0-day-analytics' ), $custom_count ), __( 'When exporting your database, select all tables or use a complete database dump. Some migration plugins may miss custom tables.', '0-day-analytics' ), $details ); } if ( $custom_count > 10 ) { return static::info( sprintf( /* translators: 1: total tables, 2: custom tables */ __( 'Your database has %1$d tables total, including %2$d custom tables from plugins. Most migration tools will capture these automatically.', '0-day-analytics' ), $total_count, $custom_count ), $details ); } if ( 0 === $custom_count ) { return static::pass( sprintf( /* translators: %d: number of tables */ __( 'Your database has %d tables, all standard WordPress tables. Migration will be straightforward.', '0-day-analytics' ), $total_count ), $details ); } return static::pass( sprintf( /* translators: %d: number of custom tables */ __( 'Your database has %d custom tables, which is minimal. Standard migration tools will handle these without issues.', '0-day-analytics' ), $custom_count ), $details ); } } }