<?php

function button_func( $atts, $content ) {
	extract(shortcode_atts( array(
        'size' => 'medium',
        'url' => '#',
        'new_window' => 'false'
    ), $atts ));

	// Change size to abbriviation (small to sm)

	switch( $size ) {
		case 'small': $size = 'sm'; break;
		case 'medium': $size = 'md'; break;
		case 'large': $size = 'lg'; break;
	}

	// If set, wrap target attribute with HTML target attribute

	$target = '';
	if( $new_window == 'true' || $new_window == 'yes' ) {
		$target = ' target="_blank"';
	}

	// Return button shortcode

	return '<a href="' . $url . '"' . $target . ' class="btn btn-' . $size . '">' . $content . '</a>';
}
add_shortcode( 'button', 'button_func' );