在下面的脚本中,我需要将readfile转换为等效的WP\\u文件系统。然而,我在法典中找不到同样的东西。非常感谢您的帮助。
此脚本保存设置。用户桌面/pc的ini文件。
WP_Filesystem();
global $wp_filesystem;
$mySettingsFileLocation = WP_PLUGIN_DIR.\'/my-settings/settings.ini\';
if ( ! $wp_filesystem->put_contents( $mySettingsFileLocation, $mySettings, 0644) ) {
return true;
}
// Define the path to file
$file = WP_PLUGIN_DIR.\'/my-settings/settings.ini\';
if(!$file)
{
// File doesn\'t exist, output error
die(\'file not found\');
}
else
{
// Set headers
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=settings.ini");
header("Content-Type: application/ini");
header("Content-Transfer-Encoding: binary");
// Read the file from disk
readfile($file);
}