PluginProbe
Powerkit – Supercharge your WordPress Site / 3.0.4
Powerkit – Supercharge your WordPress Site v3.0.4
3.1.1 3.1.0 3.0.9 3.0.8 trunk 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 All 87 releases
powerkit / modules / basic-elements / templates / separators.php

separators.php in Powerkit – Supercharge your WordPress Site 3.0.4, at modules/basic-elements/templates/separators.php

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