wordpress插件短代码缓冲区

时间:2013-03-21 10:46:17

标签: wordpress wordpress-plugin buffer

我开发的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();

0 个答案:

没有答案