【发布时间】:2012-06-26 12:22:15
【问题描述】:
我正在编写一个插件并尝试获取文本文件的内容。这是有效的:
$ipn_log = WP_PLUGIN_DIR."/plugin-folder/filename.txt";
$log_contents = file_get_contents($ipn_log);
然而,Wordpress Codex 表示插件不应使用 WP_PLUGIN_DIR,而应使用 plugins_url 函数:http://codex.wordpress.org/Determining_Plugin_and_Content_Directories
所以,我尝试这样做:
$ipn_log = plugins_url( 'filename.txt', __FILE__ );
$log_contents = file_get_contents($ipn_log);
当我使用plugins_url 时,我收到 403 禁止错误。知道为什么吗?我不应该使用WP_PLUGIN_DIR 来执行此操作吗?
谢谢
【问题讨论】:
标签: php wordpress file-get-contents