How to append_contents using WP_Filesystem?

WP_Filesystem abstraction is primarily meant for performing plugin/theme/core updates, especially in environments with restricted writes.

As such it doesn’t really implement full range of possible file operations, as you noted there is no ability to write to the end of file in declared API. More so some possible implementations (depending on file system) might not even be capable of writing to the end of file.

In a nutshell you’ll have to take care of this logic yourself and it would depend a lot on it being private/public code and how widely compatible you want it to be. If you stick with uploads destination in WP context it has the maximum chances of being writable with direct filesystem access (which WP core itself still uses for many operations).

tech