wordpress plugin shortcodes buffer

My developed wordpress plugin which is activated with a shortcode is breaking my admin area saying that header cannot be modified. Digging a bit deeper I got to know that if the function is getting echoed than I have this problem if I use return than is ok. But the problem with return is: that I use ajax to retrieve html and in this case no output is generated.

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();

Related posts

Leave a Reply