
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
<?php

/* ======= Automatic Shortcode Registration ( 'autoregister' => true ) ======= */

/**
 * Button Shortcode
 *
 * @param array  $output    Shortcode HTML.
 * @param array  $atts      User defined attributes in shortcode tag.
 * @param string $content   Shorcode tag content.
 * @return string           Shortcode result HTML.
 */
function bsc_button_shortcode( $output, $atts, $content ) {
	$nofollow  = ( 'true' === $atts['nofollow'] ) ? 'rel="nofollow"' : '';

	$output = sprintf(
		'<a class="bsc-button btn btn-%s btn-%s" href="%s" target="%s" %s>
			%s
		</a>',
		$atts['size'],
		$atts['style'],
		$atts['url'],
		$atts['target'],
		$nofollow,
		$atts['title']
	);

	return $output;
}
add_filter( 'bsc_button_shortcode', 'bsc_button_shortcode', 10, 3 );

/* ======= Manual Shortcode Registration ( 'autoregister' => false ) ======= */

/**
 * Button Shortcode
 *
 * @param array  $atts      User defined attributes in shortcode tag.
 * @param string $content   Shorcode tag content.
 * @return string           Shortcode result HTML.
 */
function bsc_button_test( $atts, $content = '' ) {
	$atts = shortcode_atts( array(
		'size'		=> 'sm',
		'style'		=> 'vertical',
		'title'		=> 'Button',
		'url'		=> '/',
		'target'	=> '_self',
		'nofollow'	=> 'false',
	), $atts );

	$nofollow  = ( 'true' === $atts['nofollow'] ) ? 'rel="nofollow"' : '';

	$output = sprintf(
		'<a class="bsc-button btn btn-%s btn-%s" href="%s" target="%s" %s>
			%s
		</a>',
		$atts['size'],
		$atts['style'],
		$atts['url'],
		$atts['target'],
		$nofollow,
		$atts['title']
	);

	return $output;
}
add_shortcode( 'bsc_button', 'bsc_button_test' );
