PluginProbe
Powerkit – Supercharge your WordPress Site / 2.4.4
Powerkit – Supercharge your WordPress Site v2.4.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 2.4.4, at modules/basic-elements/templates/alerts.php

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