delete( $wpdb->prefix . $table, array( 'cal_id' => $cal_id ), array( '%d' ) ); } self::purge_options( $cal_id ); } /** * Remove the per-event options (attachments and featured image). */ public static function purge_options( int $cal_id ): void { delete_option( 'webcal_attachments_' . $cal_id ); delete_option( 'webcal_featured_image_' . $cal_id ); } /** * Purge every event a calendar owns. Call it before deleting them in * bulk (EventRepository::deleteByCreator), while the ids can still be * listed. */ public static function purge_creator( string $login ): void { global $wpdb; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Ids of rows about to be deleted. $ids = $wpdb->get_col( $wpdb->prepare( 'SELECT cal_id FROM %i WHERE cal_create_by = %s', $wpdb->prefix . 'webcal_entry', $login ) ); foreach ( $ids as $id ) { self::purge( (int) $id ); } } }