
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
<?php
/**
 * Shortcode Separators config
 *
 * @link       https://codesupply.co/plugins/basic-shortcodes/
 * @since      1.0.0
 *
 * @package    Basic Shortcodes
 * @subpackage Templates
 */

/**
 * Separators
 */
bsc_register_shortcode( array(
	'name'			=> 'separators',
	'title'			=> esc_html__( 'Separators', 'basic-shortcodes' ),
	'priority'		=> 10,
	'base'			=> 'bsc_separator',
	'autoregister'	=> true,
	'fields'		=> array(
		array(
			'type'		=> 'section',
			'label'		=> esc_html__( 'Options', 'basic-shortcodes' ),
		),
		array(
			'type'		=> 'radio',
			'name'		=> 'style',
			'label'		=> esc_html__( 'Style', 'basic-shortcodes' ),
			'style'		=> 'vertical',
			'default'	=> 'solid',
			'options'	=> array(
				'solid'		=> esc_html__( 'Solid', 'basic-shortcodes' ),
				'double'	=> esc_html__( 'Double', 'basic-shortcodes' ),
				'dotted'	=> esc_html__( 'Dotted', 'basic-shortcodes' ),
				'dashed'	=> esc_html__( 'Dashed', 'basic-shortcodes' ),
				'blank'		=> esc_html__( 'Blank (empty space)', 'basic-shortcodes' ),
			),
		),
		array(
			'type'		=> 'input',
			'name'		=> 'height',
			'label'		=> esc_html__( 'Height', 'basic-shortcodes' ),
			'default'	=> '',
			'suffix'	=> ' px',
		),
	),
) );


/**
 * Separator 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_separator_shortcode( $output, $atts, $content ) {

	if ( 'blank' === $atts['style'] ) {
		$inl_css = sprintf( 'style="height: %dpx;"', absint( $atts['height'] ) );
	} else {
		$inl_css = sprintf( 'style="border-bottom-width: %dpx; border-bottom-style: %s;"', absint( $atts['height'] ), $atts['style'] );
	}

	$output = sprintf(
		'<div class="bsc-separator" %s>%s</div>',
		$inl_css,
		$content
	);

	return $output;
}
add_filter( 'bsc_separator_shortcode', 'bsc_separator_shortcode', 10, 3 );
