<?php
/*
Plugin Name: Simplicy Shortcode insert
Plugin URI: http://www.naxialis.com/
Description: ajout de boutons shortcode.
Version: 1.0
Author: @naxialis
Author URI: http://www.naxialis.com/
*/
require_once(dirname(__FILE__).'/shortcodes.php');
wp_enqueue_style('shortcode', '/wp-content/plugins/sp_insert_shorcodes/css/shortcode.css');
class SP_Insert_Shortcode {
	
	function SP_Insert_Shortcode(){
		if(is_admin()){
			if ( current_user_can('edit_posts') && current_user_can('edit_pages') && get_user_option('rich_editing') == 'true')
			{
				add_filter('tiny_mce_version', array(&$this, 'tiny_mce_version') );
				add_filter("mce_external_plugins", array(&$this, "mce_external_plugins"));
				add_filter('mce_buttons_2', array(&$this, 'mce_buttons'));
			}
		}
	}
	function mce_buttons($buttons) {
		array_push($buttons, "separator", "lineBreak", "Members", "2cols","3cols","4cols","2cols1small","2colsrightsmall", "drop","charts3d","charts2d" );
		return $buttons;
	}
	function mce_external_plugins($plugin_array) {
		$plugin_array['sp_insert_shorcodes']  =  plugins_url('/sp_insert_shorcodes/sp_insert_shorcodes.js');
		return $plugin_array;
	}
	function tiny_mce_version($version) {
		return ++$version;
	}
}
add_action('init', 'SP_Insert_Shortcode');
function SP_Insert_Shortcode(){
	global $SP_Insert_Shortcode;
	$SP_Insert_Shortcode = new SP_Insert_Shortcode();
}
// adds the jQuery code toggle
function insert_toggle_js() {
?>
<script type="text/javascript"> 
 
$(document).ready(function() {
 
	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul#tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	
	//On Click Event
	$("ul#tabs li").click(function() {
		$("ul#tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
 
});
</script> 
  <script type="text/javascript">

$(document).ready(function () {
	
	$('#toggle-view li').click(function () {

		var text = $(this).children('p');

		if (text.is(':hidden')) {
			text.slideDown('200');
			$(this).children('span').html('<div class="toggle-moin"><div>');		
		} else {
			text.slideUp('200');
			$(this).children('span').html('<div class="toggle-plus"><div>');		
		}
		
	});

});

</script>
<?php
}
add_action( 'wp_head', 'insert_toggle_js' );
?>