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 / alerts.php

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

103 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shortcode Alerts config
4 *
5 * @package Powerkit
6 * @subpackage Templates
7 */
8
9 /**
10 * Alerts
11 */
12 add_action( 'init', function () {
13 powerkit_basic_shortcodes_register( array(
14 'name' => 'alerts',
15 'title' => esc_html__( 'Alerts', 'powerkit' ),
16 'priority' => 30,
17 'base' => 'powerkit_alert',
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' => 'type',
27 'label' => esc_html__( 'Type', 'powerkit' ),
28 'style' => 'vertical',
29 'default' => 'info',
30 'options' => array(
31 'danger' => esc_html__( 'Danger', 'powerkit' ),
32 'info' => esc_html__( 'Info', 'powerkit' ),
33 'link' => esc_html__( 'Link', 'powerkit' ),
34 'success' => esc_html__( 'Success', 'powerkit' ),
35 'warning' => esc_html__( 'Warning', 'powerkit' ),
36 ),
37 ),
38 array(
39 'type' => 'checkbox',
40 'name' => 'dismissible',
41 'label' => esc_html__( 'Display close button', 'powerkit' ),
42 'default' => false,
43 ),
44 array(
45 'type' => 'checkbox',
46 'name' => 'multiline',
47 'label' => esc_html__( 'Multiline', 'powerkit' ),
48 'default' => false,
49 ),
50 array(
51 'type' => 'section',
52 'label' => esc_html__( 'Content', 'powerkit' ),
53 ),
54 array(
55 'type' => 'content',
56 'name' => 'content',
57 'label' => esc_html__( 'Content', 'powerkit' ),
58 'default' => '',
59 'attrs' => array(
60 'class' => 'widefat',
61 'rows' => 6,
62 ),
63 ),
64 ),
65 ) );
66 } );
67
68 /**
69 * Alert Shortcode
70 *
71 * @param array $output Shortcode HTML.
72 * @param array $atts User defined attributes in shortcode tag.
73 * @param string $content Shorcode tag content.
74 * @return string Shortcode result HTML.
75 */
76 function powerkit_basic_shortcodes_alert( $output, $atts, $content ) {
77 $dm_class = __return_empty_string();
78 $dm_button = __return_empty_string();
79
80 if ( 'true' === $atts['dismissible'] ) {
81 $dm_class .= ' pk-alert-dismissible';
82 $dm_button .= '
83 <button type="button" class="pk-close" data-dismiss="alert" aria-label="' . esc_attr__( 'Close', 'powerkit' ) . '">
84 <i class="pk-icon-x"></i>
85 </button>';
86 }
87
88 if ( 'true' === $atts['multiline'] ) {
89 $dm_class .= ' pk-alert-multiline';
90 }
91
92 $output = sprintf(
93 '<div class="pk-alert pk-alert-%s%s" role="alert" >%s%s</div>',
94 esc_attr( $atts['type'] ),
95 esc_attr( $dm_class ),
96 wp_kses( $dm_button, 'post' ),
97 wp_kses( $content, 'post' )
98 );
99
100 return $output;
101 }
102 add_filter( 'powerkit_alert_shortcode', 'powerkit_basic_shortcodes_alert', 10, 3 );
103