| 1 |
<?php |
| 2 |
/** |
| 3 |
* Shortcode Separators config |
| 4 |
* |
| 5 |
* @package Powerkit |
| 6 |
* @subpackage Templates |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* Separators |
| 11 |
*/ |
| 12 |
powerkit_basic_shortcodes_register( array( |
| 13 |
'name' => 'separators', |
| 14 |
'title' => esc_html__( 'Separators', 'powerkit' ), |
| 15 |
'priority' => 10, |
| 16 |
'base' => 'powerkit_separator', |
| 17 |
'autoregister' => true, |
| 18 |
'fields' => array( |
| 19 |
array( |
| 20 |
'type' => 'section', |
| 21 |
'label' => esc_html__( 'Options', 'powerkit' ), |
| 22 |
), |
| 23 |
array( |
| 24 |
'type' => 'radio', |
| 25 |
'name' => 'style', |
| 26 |
'label' => esc_html__( 'Style', 'powerkit' ), |
| 27 |
'style' => 'vertical', |
| 28 |
'default' => 'solid', |
| 29 |
'options' => array( |
| 30 |
'solid' => esc_html__( 'Solid', 'powerkit' ), |
| 31 |
'double' => esc_html__( 'Double', 'powerkit' ), |
| 32 |
'dotted' => esc_html__( 'Dotted', 'powerkit' ), |
| 33 |
'dashed' => esc_html__( 'Dashed', 'powerkit' ), |
| 34 |
'blank' => esc_html__( 'Blank (empty space)', 'powerkit' ), |
| 35 |
), |
| 36 |
), |
| 37 |
array( |
| 38 |
'type' => 'input', |
| 39 |
'name' => 'height', |
| 40 |
'label' => esc_html__( 'Height', 'powerkit' ), |
| 41 |
'default' => '', |
| 42 |
'suffix' => ' px', |
| 43 |
), |
| 44 |
), |
| 45 |
) ); |
| 46 |
|
| 47 |
|
| 48 |
/** |
| 49 |
* Separator Shortcode |
| 50 |
* |
| 51 |
* @param array $output Shortcode HTML. |
| 52 |
* @param array $atts User defined attributes in shortcode tag. |
| 53 |
* @param string $content Shorcode tag content. |
| 54 |
* @return string Shortcode result HTML. |
| 55 |
*/ |
| 56 |
function powerkit_basic_shortcodes_separator( $output, $atts, $content ) { |
| 57 |
|
| 58 |
if ( 'blank' === $atts['style'] ) { |
| 59 |
$inl_css = sprintf( 'style="height: %dpx;"', absint( $atts['height'] ) ); |
| 60 |
} else { |
| 61 |
$inl_css = sprintf( 'style="border-bottom-width: %dpx; border-bottom-style: %s;"', absint( $atts['height'] ), $atts['style'] ); |
| 62 |
} |
| 63 |
|
| 64 |
$output = sprintf( |
| 65 |
'<div class="pk-separator" %s>%s</div>', |
| 66 |
$inl_css, |
| 67 |
$content |
| 68 |
); |
| 69 |
|
| 70 |
return $output; |
| 71 |
} |
| 72 |
add_filter( 'powerkit_separator_shortcode', 'powerkit_basic_shortcodes_separator', 10, 3 ); |
| 73 |
|