Skip to content

Instantly share code, notes, and snippets.

@annelyse
Created January 17, 2020 12:03
Show Gist options
  • Save annelyse/f2b01036d6d2b672bc147db66b0f13d9 to your computer and use it in GitHub Desktop.
Save annelyse/f2b01036d6d2b672bc147db66b0f13d9 to your computer and use it in GitHub Desktop.
function btn_clone(){
$btn_link = get_sub_field('btn_link');
$btn_position = get_sub_field('btn_position');
$btn_color = get_sub_field('btn_color');
$btn_deco = get_sub_field('btn_deco');
$force_line = get_sub_field('btn-force-line');
//----- alignement bouton
$row_align = "";
$col_offset = "";
$offset_size = "";
switch ($btn_position) {
case "left":
$row_align = "justify-content-start";
break;
case "center":
$row_align = "justify-content-center";
break;
case "right":
$row_align = "justify-content-end";
break;
case "offset-1":
$row_align = "justify-content-start";
$offset_size = "offset-lg-1";
break;
case "offset-2":
$row_align = "justify-content-start";
$offset_size = "offset-lg-2";
break;
}
$btn_styles = "btn-outline-dark"; //default
switch ($btn_color) {
case "light":
$btn_styles = "btn-outline-light";
break;
case "full-light":
$btn_styles = "btn-outline-light btn-hover-light" ;
break;
case "dark":
$btn_styles = "btn-outline-dark";
break;
case "primary":
$btn_styles = "btn-outline-primary";
break;
case "dark-primary":
$btn_styles = "btn-outline-dark-primary";
break;
}
if( $btn_deco == true ){
$btn_styles .= " btn-line";
if($force_line === true){
$btn_styles .= " btn-force-line";
}
}
if( empty( $btn_link['target'] )){
$target = '_self';
}else{
$target = $btn_link['target'];
}
?>
<div class="bloc_btn row <?php echo $row_align; ?>">
<div class="col-auto <?php echo $offset_size; ?>">
<a href="<?php echo $btn_link['url']; ?>" class="btn <?php echo $btn_styles ?>" title="<?php echo $btn_link['title'];?>" target="<?php echo $target;?>">
<?php echo $btn_link['title'];?>
</a>
</div>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment