# powerkit/trunk/modules/basic-elements/templates/separators.php

Powerkit – Supercharge your WordPress Site, version trunk. 89 lines.

- Page: https://pluginprobe.com/plugins/powerkit/trunk/code/modules/basic-elements/templates/separators.php
- Raw: https://pluginprobe.com/plugins/powerkit/trunk/raw/modules/basic-elements/templates/separators.php
- Modified: 2026-07-31T07:59:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/powerkit/trunk/code/modules/basic-elements/templates/separators.php#L10-L20`.

```php
<?php
/**
 * Shortcode Separators config
 *
 * @package    Powerkit
 * @subpackage Templates
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Separators
 */
add_action( 'init', function () {
	powerkit_basic_shortcodes_register( array(
		'name'         => 'separators',
		'title'        => esc_html__( 'Separators', 'powerkit' ),
		'priority'     => 10,
		'base'         => 'powerkit_separator',
		'autoregister' => true,
		'fields'       => array(
			array(
				'type'  => 'section',
				'label' => esc_html__( 'Options', 'powerkit' ),
			),
			array(
				'type'    => 'radio',
				'name'    => 'style',
				'label'   => esc_html__( 'Style', 'powerkit' ),
				'style'   => 'vertical',
				'default' => 'solid',
				'options' => array(
					'solid'  => esc_html__( 'Solid', 'powerkit' ),
					'double' => esc_html__( 'Double', 'powerkit' ),
					'dotted' => esc_html__( 'Dotted', 'powerkit' ),
					'dashed' => esc_html__( 'Dashed', 'powerkit' ),
					'blank'  => esc_html__( 'Blank (empty space)', 'powerkit' ),
				),
			),
			array(
				'type'    => 'input',
				'name'    => 'height',
				'label'   => esc_html__( 'Height', 'powerkit' ),
				'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 powerkit_basic_shortcodes_separator( $output, $atts, $content ) {

	// Allowed CSS border-style keywords. The list is wider than the options the
	// radio field offers, so a hand-written style="groove" keeps working. Any
	// other value drops the declaration, which is how a browser already treats
	// an invalid one.
	$allowed_styles = array( 'none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset' );

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

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

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

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

```
