<?php
//Code for the update notice
function callback_un_state($args,$content)
{
	extract(shortcode_atts(array(
		'state' => 'fix'
	), $args));
	$html = '';
	$html = '<li><div';
	if($state == 'fix') {$html .= ' class="gray" ';}
	$html .= '><strong>'.$state.'</strong>'.$content.'</div></li>';
	return $html;	
}
add_shortcode('un_state','callback_un_state');

function callback_unversion($args,$content)
{
	extract(shortcode_atts(array(
		'version' => '1.0'
	), $args));
	$html = '';
	$html .= '<div class="upnum">'.$version.'</div>';	
	$html .= '<ul class="updates">';
	$html .= do_shortcode($content);
	$html .= '</ul>';	
	return $html;	
}
add_shortcode('un_version','callback_unversion');

//update notice shortcode
function callback_update_notice($args,$content= null)
{
	$html = '';
	$html .= '<div class="updates">';
	$html .= do_shortcode($content);;
	$html .= '</div><div class="clear"></div>';
	return $html;
}
add_shortcode('update_notice','callback_update_notice');

function add_update_notice_button() {
   if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
     return;
   if ( get_user_option('rich_editing') == 'true') {
	 add_filter('mce_external_plugins', 'add_update_notice_tinymce_plugin');
     add_filter('mce_buttons', 'register_update_notice_button');
   }
}
/* init*/
add_action('init', 'add_update_notice_button');
function register_update_notice_button($buttons) {
   array_push($buttons, "|", "update_notice");
   return $buttons;
}
function add_update_notice_tinymce_plugin($plugin_array) {
   $plugin_array['update_notice'] = get_template_directory_uri().'/shortcode/update_notice/update_shortcode.js';
   return $plugin_array;
}
?>
