Convert PHP readfile to WP_Filesystem

Reading a file to send to the user is perfectly safe and does not necessarily need to be converted to the WP_Filesystem methods. Only writing is potentially an issue.

However, if you wanted to do so, this would be the equivalent:

echo $wp_filesystem->get_contents( filename variable here );

Also, note that your filename for “put_contents” is incorrect. Instead of using WP_PLUGIN_DIR, you need to use $wp_filesystem->wp_plugins_dir() because the “remote” directory might not be the same as the “local” directory.

$mySettingsFileLocation = $wp_filesystem->wp_plugins_dir() . '/my-settings/settings.ini';

tech