我开发的wordpress插件使用短代码激活,打破了我的管理区域,说无法修改标头。深入挖掘我知道,如果我使用return
而不是正常,如果函数得到回应而不是我有这个问题。但返回的问题是:我使用ajax来检索html,在这种情况下没有生成输出。
message Cannot modify header information - headers already sent by (output started at /var/www.... web/wordpress/wp-admin/admin-header.php
MyClass{
public function __construct()
public $data;
{
require_once(dirname(__FILE__) . '/class/class.another.php');
$this->data = new Another();
add_action( 'init', array( &$this, 'init' ) );
}
public function init()
{
add_shortcode( 'my_shortcode', array ($this, 'shortcode') );
if(isset($_POST['id'])){
$param = $this->data->output_ajax_html($_POST['id']);
echo $this->shortcode_html_extended($param);
//this part breaks the buffer without echo is working but the contertn won't show up
}
}
public function shortcode()
{
add_shortcode( 'my_shortcode', array ($this, 'shortcode_html') );
}
public function shortcode_html()
{
$html = "";
$html .="";
return $html;
}
public function shortcode_html_extended($param)
{
$html = "";
//mixed with php
$html .="";
return $html;
}
}
$test = new MyClass();