This is my first attempt at creating my own plugin and everything was working just fine until I tried to add or update a page through wp-admin. If I deactivate the plugin, the sites works as it should. I get an error about headers already being sent by my file and I'm not sure how to get around this. Like I said, this is my first attempt.
Here is my very simple plugin file:
include(plugin_dir_path( __FILE__ ) . 'ndmr-plugin.php');
add_shortcode('small_ndmr_buttons_sc','small_ndmr_buttons');
add_action('init', 'small_ndmr_buttons_plugin');
function small_ndmr_buttons_plugin() {
add_action('wp_enqueue_scripts', 'ndmr_plugin_stylesheet');
function ndmr_plugin_stylesheet() {
wp_register_style('ndmr-plugin-style', plugins_url('style.css', __FILE__), array() );
wp_enqueue_style('ndmr-plugin-style');
wp_register_script('ndmr-plugin-jquery', plugins_url('ndmr-plugin-javascript.js', __FILE__), array() );
wp_enqueue_script('ndmr-plugin-jquery');
}
}
And this is the file that renders the shortcode:
function small_ndmr_buttons(){
return '
<div class="small-ndmr-buttons">
<div>
<p>search</p>
<ul>'.
wp_list_pages('title_li=&child_of=25&echo=0')
.'</ul>
</div>
<div>
<p>social</p>
<ul>'.
wp_list_pages('title_li=&child_of=27&echo=0')
.'</ul>
</div>
<div>
<p>design</p>
<ul>'.
wp_list_pages('title_li=&child_of=29&echo=0')
.'</ul>
</div>
<div>
<p>tv/radio</p>
<ul>'.
wp_list_pages('title_li=&child_of=31&echo=0')
.'</ul>
</div>
<div>
<p>yellow pages</p>
<ul>'.
wp_list_pages('title_li=&child_of=33&echo=0')
.'</ul>
</div>
<div>
<p>billboard</p>
<ul>'.
wp_list_pages('title_li=&child_of=35&echo=0')
.'</ul>
</div>
<span class="clear"></span>
</div>
';
}
The file that renders the shortcode is where I'm getting the error Cannot modify header information - headers already sent by
I tried using ob_start();
, but that just echo's the text in the file and kills the wordpress back end entirely. Am I missing something having to do with the plugin?
Thank you for any help you might have.