get_results( "SELECT blog_id FROM {$wpdb->blogs} LIMIT $offset, $limit", ARRAY_A ) ) { if ( $blogs ) { foreach ( $blogs as $blog ) { switch_to_blog( $blog['blog_id'] ); delete_metadata( $meta_type, null, $meta_key, $meta_value, $delete_all ); delete_metadata( $meta_type, null, 'wp-smush-lossy', '', $delete_all ); delete_metadata( $meta_type, null, 'wp-smush-resize_savings', '', $delete_all ); delete_metadata( $meta_type, null, 'wp-smush-original_file', '', $delete_all ); delete_metadata( $meta_type, null, 'wp-smush-pngjpg_savings', '', $delete_all ); foreach ( $smushit_keys as $key ) { $key = 'wp-smush-' . $key; delete_option( $key ); delete_site_option( $key ); } //Delete Cache data foreach ( $cache_keys as $key ) { wp_cache_delete( $key ); } foreach ( $cache_smush_group as $s_key ) { wp_cache_delete( $s_key, 'smush' ); } foreach ( $cache_nextgen_group as $n_key ) { wp_cache_delete( $n_key, 'nextgen' ); } } restore_current_blog(); } $offset += $limit; } } else { delete_metadata( $meta_type, null, $meta_key, $meta_value, $delete_all ); delete_metadata( $meta_type, null, 'wp-smush-lossy', '', $delete_all ); delete_metadata( $meta_type, null, 'wp-smush-resize_savings', '', $delete_all ); delete_metadata( $meta_type, null, 'wp-smush-original_file', '', $delete_all ); delete_metadata( $meta_type, null, 'wp-smush-pngjpg_savings', '', $delete_all ); } //Delete Directory smush table global $wpdb; $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}smush_dir_images" ); // Delete directory scan data. delete_option( 'wp-smush-scan-step' ); //@todo: Add procedure to delete backup files //@todo: Update NextGen Metadata to remove Smush stats on plugin deletion