<?php 
/* ------------------------------------------------------------------------ */
/* TinyMce Editor Custom Shortcode Buttons
/* ------------------------------------------------------------------------ */


function slant_myplugin_addbuttons() {
   // Don't bother doing this stuff if the current user lacks permissions
   global $typenow;
    // check user permissions
    if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) {
   	return;
    }
 
   // verify the post type
    if( ! in_array( $typenow, array( 'post', 'page' ) ) )
        return;
		
	// check if WYSIWYG is enabled
	if ( get_user_option('rich_editing') == 'true') {
		add_filter("mce_external_plugins", "slant_add_myplugin_tinymce_plugin");
		add_filter('mce_buttons', 'slant_register_myplugin_button');
	}
}
 
function slant_register_myplugin_button($buttons) {
   array_push($buttons, 'kb_button');
   return $buttons;
}



 
// Load the TinyMCE plugin : editor_plugin.js (wp2.5)
function slant_add_myplugin_tinymce_plugin($plugin_array) {
	// this plugin file will work the magic of our button
   $plugin_array['kb_button'] = KP_THEME_DIRECTORY . '/framework/shortcode/tinymce/tinymce_codes.js';
   return $plugin_array;
}



 
// init process for button Appear and control
add_action('admin_head', 'slant_myplugin_addbuttons');


?>