prefix . 'a360_insights_events', $wpdb->prefix . 'a360_insights_views', // Legacy table name used by early builds. ); foreach ( $tables as $table_name ) { $table_name = esc_sql( $table_name ); $wpdb->query( "DROP TABLE IF EXISTS `{$table_name}`" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Required during uninstall to remove plugin tables when the user opted in. } // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Deletes plugin post meta during uninstall when explicitly enabled. $wpdb->delete( $wpdb->postmeta, array( 'meta_key' => '_a360_insights_total_views' ), array( '%s' ) ); if ( function_exists( 'wp_cache_flush_group' ) ) { wp_cache_flush_group( 'a360_insights' ); } else { wp_cache_delete( 'admin_counts', 'a360_insights' ); wp_cache_delete( 'dashboard_summary', 'a360_insights' ); } delete_option( 'a360_insights_settings' ); delete_option( 'a360_insights_db_version' ); } /** * Check whether this plugin is network active. * * @return bool */ function a360_insights_is_network_active() { if ( ! is_multisite() ) { return false; } $active_sitewide_plugins = get_site_option( 'active_sitewide_plugins', array() ); return isset( $active_sitewide_plugins['a360-insights/a360-insights.php'] ); } if ( is_multisite() && a360_insights_is_network_active() ) { $a360_insights_site_ids = get_sites( array( 'fields' => 'ids', 'number' => 0, ) ); foreach ( $a360_insights_site_ids as $a360_insights_site_id ) { switch_to_blog( (int) $a360_insights_site_id ); a360_insights_uninstall_site_cleanup(); restore_current_blog(); } } else { a360_insights_uninstall_site_cleanup(); }