自定义文件下载wordpress管理插件
custom file download wordpress admin plugin
我想为 wordpress 插件添加功能以下载自定义文件。
这是我的代码。
add_action('admin_menu','function_name');
这里是下载代码。
header("Content-Disposition: attachment; filename=map.html");
header("Content-Length: ".strlen($content));
echo $content;
exit;
但是,我遇到了错误。
[22-Feb-2015 00:00:00 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /path/to/wp/wp-admin/includes/template.php:1877) in /path/to/wp/wp-content/plugins/plugin-name/lib/model.php on line 99
我是这样提出请求的
http://www.website.com/wp-admin/admin.php?page=file-download&fileid=10
我建议使用这个钩子
http://codex.wordpress.org/Plugin_API/Action_Reference/load-%28page%29
使用 add_menu_page 函数的 return 值。
load-$page 就像管理页面的初始化挂钩。
我想为 wordpress 插件添加功能以下载自定义文件。 这是我的代码。
add_action('admin_menu','function_name');
这里是下载代码。
header("Content-Disposition: attachment; filename=map.html");
header("Content-Length: ".strlen($content));
echo $content;
exit;
但是,我遇到了错误。
[22-Feb-2015 00:00:00 UTC] PHP Warning: Cannot modify header information - headers already sent by (output started at /path/to/wp/wp-admin/includes/template.php:1877) in /path/to/wp/wp-content/plugins/plugin-name/lib/model.php on line 99
我是这样提出请求的
http://www.website.com/wp-admin/admin.php?page=file-download&fileid=10
我建议使用这个钩子
http://codex.wordpress.org/Plugin_API/Action_Reference/load-%28page%29
使用 add_menu_page 函数的 return 值。
load-$page 就像管理页面的初始化挂钩。