<?php
// caps
function dropcap($atts, $content = null) {
	return '
<div class="dropcap">'.$content.'</div>';
}
add_shortcode('dropcap', 'dropcap'); 
//colonne
function webtreats_one_third( $atts, $content = null ) {
   return '<div class="one_third">' . do_shortcode($content) . '</div>';
}
add_shortcode('one_third', 'webtreats_one_third');

function webtreats_one_third_last( $atts, $content = null ) {
   return '<div class="one_third last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
}
add_shortcode('one_third_last', 'webtreats_one_third_last');

function webtreats_two_third( $atts, $content = null ) {
   return '<div class="two_third">' . do_shortcode($content) . '</div>';
}
add_shortcode('two_third', 'webtreats_two_third');

function webtreats_two_third_last( $atts, $content = null ) {
   return '<div class="two_third last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
}
add_shortcode('two_third_last', 'webtreats_two_third_last');

function webtreats_one_half( $atts, $content = null ) {
   return '<div class="one_half">' . do_shortcode($content) . '</div>';
}
add_shortcode('one_half', 'webtreats_one_half');

function webtreats_one_half_last( $atts, $content = null ) {
   return '<div class="one_half last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
}
add_shortcode('one_half_last', 'webtreats_one_half_last');

function webtreats_one_fourth( $atts, $content = null ) {
   return '<div class="one_fourth">' . do_shortcode($content) . '</div>';
}
add_shortcode('one_fourth', 'webtreats_one_fourth');

function webtreats_one_fourth_last( $atts, $content = null ) {
   return '<div class="one_fourth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
}
add_shortcode('one_fourth_last', 'webtreats_one_fourth_last');
// fin
function webtreats_three_fourth( $atts, $content = null ) {
   return '<div class="three_fourth">' . do_shortcode($content) . '</div>';
}
add_shortcode('three_fourth', 'webtreats_three_fourth');

function webtreats_three_fourth_last( $atts, $content = null ) {
   return '<div class="three_fourth last">' . do_shortcode($content) . '</div><div class="clearboth"></div>';
}
add_shortcode('three_fourth_last', 'webtreats_three_fourth_last');

// Box
add_shortcode( 'box_grey', 'gpp_base_grey_box' );
add_shortcode( 'box_yellow', 'gpp_base_yellow_box' );
add_shortcode( 'box_green', 'gpp_base_green_box' );
add_shortcode( 'box_red', 'gpp_base_red_box' );
add_shortcode( 'box_black', 'gpp_base_black_box' );
add_shortcode( 'box_blue', 'gpp_base_blue_box' );
	
function gpp_base_grey_box( $atts, $content = null ) {
extract( shortcode_atts(
array(
'largeur' => '95',
'position' =>'centre',
'icon'=> ''
),
$atts ) );
if ($position == 'centre' ) $position_1 = 'margin:0 auto;' ;
if ($position == 'droite' ) $position_1 = 'float:right;' ;
if ($position == 'gauche' ) $position_1 = 'float:left;' ;
   return '<div style=" width:'.$largeur.'%;'.$position_1.'" class="box grey"> <div class="box-icon-'.$icon.'"></div><p>' . do_shortcode( $content ) . '</p></div>';
}

function gpp_base_yellow_box( $atts, $content = null ) {
extract( shortcode_atts(
array(
'largeur' => '95',
'position' =>'centre',
'icon'=> 'info'
),
$atts ) );
if ($position == 'centre' ) $position_1 = 'margin:0 auto;' ;
if ($position == 'droite' ) $position_1 = 'float:right;' ;
if ($position == 'gauche' ) $position_1 = 'float:left;' ;
   return '<div style=" width:'.$largeur.'%;'.$position_1.'" class="box yellow"><div class="box-icon-'.$icon.'"></div><p>' . do_shortcode( $content ) . '</p></div>';
}

function gpp_base_green_box( $atts, $content = null ) {
extract( shortcode_atts(
array(
'largeur' => '95',
'position' =>'centre',
'icon'=> 'info'
),
$atts ) );
if ($position == 'centre' ) $position_1 = 'margin:0 auto;' ;
if ($position == 'droite' ) $position_1 = 'float:right;' ;
if ($position == 'gauche' ) $position_1 = 'float:left;' ;
   return '<div style=" width:'.$largeur.'%;'.$position_1.'" class="box green"><div class="box-icon-'.$icon.'"></div><p>' . do_shortcode( $content ) . '</p></div>';
}

function gpp_base_red_box( $atts, $content = null ) {
extract( shortcode_atts(
array(
'largeur' => '95',
'position' =>'centre',
'icon'=> 'info'
),
$atts ) );
if ($position == 'centre' ) $position_1 = 'margin:0 auto;' ;
if ($position == 'droite' ) $position_1 = 'float:right;' ;
if ($position == 'gauche' ) $position_1 = 'float:left;' ;
   return '<div style=" width:'.$largeur.'%;'.$position_1.'" class="box red"><div class="box-icon-'.$icon.'"></div><p>' . do_shortcode( $content ) . '</p></div>';
}
function gpp_base_black_box( $atts, $content = null ) {
extract( shortcode_atts(
array(
'largeur' => '95',
'position' =>'centre',
'icon'=> 'info'
),
$atts ) );
if ($position == 'centre' ) $position_1 = 'margin:0 auto;' ;
if ($position == 'droite' ) $position_1 = 'float:right;' ;
if ($position == 'gauche' ) $position_1 = 'float:left;' ;
   return '<div style=" width:'.$largeur.'%;'.$position_1.'" class="box black"><div class="box-icon-'.$icon.'"></div><p>' . do_shortcode( $content ) . '</p></div>';
}
function gpp_base_blue_box( $atts, $content = null ) {
extract( shortcode_atts(
array(
'largeur' => '95',
'position' =>'centre',
'icon'=> 'info'
),
$atts ) );
if ($position == 'centre' ) $position_1 = 'margin:0 auto;' ;
if ($position == 'droite' ) $position_1 = 'float:right;' ;
if ($position == 'gauche' ) $position_1 = 'float:left;' ;
   return '<div style=" width:'.$largeur.'%;'.$position_1.'" class="box blue"><div class="box-icon-'.$icon.'"></div><p>' . do_shortcode( $content ) . '</p></div>';
}
// saut de ligne
add_shortcode("br", "br_tag");

function br_tag(){
        return(" <div class='clear-shortcode'></div>");                            
}
// Toggle
function toggle_shortcode( $atts, $content = null )
{
extract( shortcode_atts(
array(
'titre' => 'Cliquez Pour Ouvrir',
'largeur' => '96',
'position' =>'left',
'couleur'=>'blanc'
),
$atts ) );
if ($position == 'centre' ) $var_1= 'margin:0 auto;' ;
if ($position == 'droite' ) $var_4= 'right' ;
if ($position == 'gauche' ) $var_5= 'left' ;
if ($couleur == 'blanc' ) $var_2= 'class="toggle-whirte"' ;
if ($couleur == 'gris' ) $var_3= 'class="toggle-gray"' ;
if ($couleur == 'bleu' ) $var_3= 'class="toggle-bleu"' ;
if ($couleur == 'vert' ) $var_3= 'class="toggle-vert"' ;
return '<div style="width:'.$largeur.'%; float:'.$var_4.''.$var_5.'; '.$var_1.'" class="toggle-resp"> 
  <div class="clear"></div> 
	<ul id="toggle-view">
	<li>
		<h3 '.$var_2.' '.$var_3.''.$var_4.'>'. $titre .'</h3>
		<span></span><p>' . do_shortcode($content) . '</p></li></ul>
</div>';
}
add_shortcode('toggle', 'toggle_shortcode');
// fonction clear div 

function shortcode_clear($atts, $content = null) {
	return '
<div class="clear"></div>
';
}
add_shortcode('clear', 'shortcode_clear');




// Tabs
add_shortcode( 'tabgroup', 'jqtools_tab_group' );
function jqtools_tab_group( $atts, $content ){
$GLOBALS['tab_count'] = 0;
extract(shortcode_atts(array(
'largeur' =>'96'
), $atts));
do_shortcode( $content );

if( is_array( $GLOBALS['tabs'] ) ){
foreach( $GLOBALS['tabs'] as $tab ){
$tabs[] = '<li><a href="#'.$tab['id'].'">'.$tab['title'].'</a></li>';
$panes[] = '<div id="'.$tab['id'].'" class="tab_content" ><p>'.$tab['content'].'</p></div>';
}
$return = "".'<!-- the tabs --><div style=" width:'.$largeur.'%;" class="container-tabs">
								<ul id="tabs">'.implode($tabs ).'</ul>
								<!-- tab "panes" -->
								<div class="tab_container"> '.implode( "", $panes ).'
								</div></div>'."";
}
return $return;
}

add_shortcode( 'tab', 'jqtools_tab' );
function jqtools_tab( $atts, $content ){
extract(shortcode_atts(array(
'title' => 'Tab %d',
'id' => '',
'largeur' =>''
), $atts));

$x = $GLOBALS['tab_count'];
$GLOBALS['tabs'][$x] = array( 'largeur' =>''.$largeur.'' , 'id' =>''.$id.'' , 'title' => sprintf( $title, $GLOBALS['tab_count'] ), 'content' =>  $content );

$GLOBALS['tab_count']++;
}
// Membre
add_shortcode( 'member', 'member_check_shortcode' );
function member_check_shortcode( $atts, $content = null ) {
 if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
 return $content;
 global $post;
 return '

 <div class="member-post">
 <p class="member-code">Il faut être Membre pour accèder a ce contenu</p>
 		<form action="'.get_option('home').'/wp-login.php" method="post">
<fieldset id="inputs">
<p style=" text-align:left; margin-bottom:3px;">Mon identifiant</p>
<input type="text" name="log" id="log" value="'.wp_specialchars(stripslashes($user_login), 1) .'" size="20"/>
<p style=" text-align:left; margin-bottom:3px;">Mon Mot de passe</p>
<input type="password" name="pwd" id="pwd" size="20"/>
</fieldset>
    
       
       <fieldset id="actions">
        <input type="hidden" name="redirect_to" value="'.$_SERVER['REQUEST_URI']. '" />
   		
    	<label style=" width:100%;"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" />Se souvenir de moi</label><br/><br/>
		<input type="submit" name="submit" class="connect_user" value="Connexion" id="submit" />
        </fieldset>
</form>
<br/>
<p style="text-align:center; margin-bottom:5px;"><strong><a href="'.get_option('home').'/wp-login.php?action=register" title="Inscrisption" target="_parent">S&acute;inscrire sur '.get_bloginfo('name').'</a></strong></p>
<p style="text-align:center; margin-bottom:5px;"><strong>Mot de passe perdu ?</strong><a href="'.get_option('home').'/wp-login.php?action=lostpassword">Cliquez ici</a></p>
 </div>
 ';
}

function chart_shortcode( $atts ) {
	extract(shortcode_atts(array(
	    'data' => '',
	    'colors' => '',
	    'size' => '400x200',
	    'bg' => 'ffffff',
	    'title' => '',
	    'labels' => '',
	    'advanced' => '',
	    'type' => 'pie'
	), $atts));
 
	switch ($type) {
		case 'line' :
			$charttype = 'lc'; break;
		case 'xyline' :
			$charttype = 'lxy'; break;
		case 'sparkline' :
			$charttype = 'ls'; break;
		case 'meter' :
			$charttype = 'gom'; break;
		case 'scatter' :
			$charttype = 's'; break;
		case 'venn' :
			$charttype = 'v'; break;
		case 'pie' :
			$charttype = 'p3'; break;
		case 'pie2d' :
			$charttype = 'p'; break;
		default :
			$charttype = $type;
		break;
	}
 
	if ($title) $string .= '&chtt='.$title.'';
	if ($labels) $string .= '&chl='.$labels.'';
	if ($colors) $string .= '&chco='.$colors.'';
	$string .= '&chs='.$size.'';
	$string .= '&chd=t:'.$data.'';
	$string .= '&chf='.$bg.'';
 
	return '<img title="'.$title.'" src="http://chart.apis.google.com/chart?cht='.$charttype.''.$string.$advanced.'" alt="'.$title.'" />';
}
add_shortcode('chart', 'chart_shortcode');
?>
