| @@ -5,53 +5,47 @@ | ||
| 5 | 5 | * @package Powerkit |
| 6 | 6 | * @subpackage Templates |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -// Exit if accessed directly. | |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 11 | - exit; | |
| 12 | -} | |
| 13 | - | |
| 14 | 9 | /** |
| 15 | 10 | * Separators |
| 16 | 11 | */ |
| 17 | -add_action( 'init', function () { | |
| 18 | - powerkit_basic_shortcodes_register( array( | |
| 19 | - 'name' => 'separators', | |
| 20 | - 'title' => esc_html__( 'Separators', 'powerkit' ), | |
| 21 | - 'priority' => 10, | |
| 22 | - 'base' => 'powerkit_separator', | |
| 23 | - 'autoregister' => true, | |
| 24 | - 'fields' => array( | |
| 25 | - array( | |
| 26 | - 'type' => 'section', | |
| 27 | - 'label' => esc_html__( 'Options', 'powerkit' ), | |
| 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' ), | |
| 28 | 35 | ), |
| 29 | - array( | |
| 30 | - 'type' => 'radio', | |
| 31 | - 'name' => 'style', | |
| 32 | - 'label' => esc_html__( 'Style', 'powerkit' ), | |
| 33 | - 'style' => 'vertical', | |
| 34 | - 'default' => 'solid', | |
| 35 | - 'options' => array( | |
| 36 | - 'solid' => esc_html__( 'Solid', 'powerkit' ), | |
| 37 | - 'double' => esc_html__( 'Double', 'powerkit' ), | |
| 38 | - 'dotted' => esc_html__( 'Dotted', 'powerkit' ), | |
| 39 | - 'dashed' => esc_html__( 'Dashed', 'powerkit' ), | |
| 40 | - 'blank' => esc_html__( 'Blank (empty space)', 'powerkit' ), | |
| 41 | - ), | |
| 42 | - ), | |
| 43 | - array( | |
| 44 | - 'type' => 'input', | |
| 45 | - 'name' => 'height', | |
| 46 | - 'label' => esc_html__( 'Height', 'powerkit' ), | |
| 47 | - 'default' => '', | |
| 48 | - 'suffix' => ' px', | |
| 49 | - ), | |
| 50 | 36 | ), |
| 51 | - ) ); | |
| 52 | -}); | |
| 37 | + array( | |
| 38 | + 'type' => 'input', | |
| 39 | + 'name' => 'height', | |
| 40 | + 'label' => esc_html__( 'Height', 'powerkit' ), | |
| 41 | + 'default' => '', | |
| 42 | + 'suffix' => ' px', | |
| 43 | + ), | |
| 44 | + ), | |
| 45 | +) ); | |
| 53 | 46 | |
| 47 | + | |
| 54 | 48 | /** |
| 55 | 49 | * Separator Shortcode |
| 56 | 50 | * |
| 57 | 51 | * @param array $output Shortcode HTML. |
| @@ -60,28 +54,18 @@ | ||
| 60 | 54 | * @return string Shortcode result HTML. |
| 61 | 55 | */ |
| 62 | 56 | function powerkit_basic_shortcodes_separator( $output, $atts, $content ) { |
| 63 | 57 | |
| 64 | - // Allowed CSS border-style keywords. The list is wider than the options the | |
| 65 | - // radio field offers, so a hand-written style="groove" keeps working. Any | |
| 66 | - // other value drops the declaration, which is how a browser already treats | |
| 67 | - // an invalid one. | |
| 68 | - $allowed_styles = array( 'none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset' ); | |
| 69 | - | |
| 70 | 58 | if ( 'blank' === $atts['style'] ) { |
| 71 | 59 | $inl_css = sprintf( 'style="height: %dpx;"', absint( $atts['height'] ) ); |
| 72 | 60 | } else { |
| 73 | - $border_style = in_array( $atts['style'], $allowed_styles, true ) | |
| 74 | - ? sprintf( ' border-bottom-style: %s;', $atts['style'] ) | |
| 75 | - : ''; | |
| 76 | - | |
| 77 | - $inl_css = sprintf( 'style="border-bottom-width: %dpx;%s"', absint( $atts['height'] ), $border_style ); | |
| 61 | + $inl_css = sprintf( 'style="border-bottom-width: %dpx; border-bottom-style: %s;"', absint( $atts['height'] ), $atts['style'] ); | |
| 78 | 62 | } |
| 79 | 63 | |
| 80 | 64 | $output = sprintf( |
| 81 | 65 | '<div class="pk-separator" %s>%s</div>', |
| 82 | 66 | $inl_css, |
| 83 | - wp_kses( $content, 'post' ) | |
| 67 | + $content | |
| 84 | 68 | ); |
| 85 | 69 | |
| 86 | 70 | return $output; |
| 87 | 71 | } |