How to write to the plugin’s directory?

  1. First ask yourself if this is really necessary.

  2. Use wp-content/uploads

  3. Use the Filesystem API