Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 自定义文件下载wordpress管理插件_Php_Wordpress - Fatal编程技术网

Php 自定义文件下载wordpress管理插件

Php 自定义文件下载wordpress管理插件,php,wordpress,Php,Wordpress,我想向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

我想向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

我建议用这个钩子

使用添加菜单页面函数的返回值


load-$页面类似于管理员页面的init hook。

确保在发送任何输出之前调用头函数。我说的是wordpress插件。这里是我的插件下载页面的调用方式。如果混合使用HTML和PHP,在一些HTML代码之后的php代码中,您不应该调用header…您可能必须更改调用header的方式,或者如果您无法尝试使用ob_start和ob_flush。可能的重复