alert.php
5.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?php
/**
* LearnDash LD30 Displays a custom alert message
*
* This file contains the wrapper for a custom alert message
*
* @since 3.0.0
*
* @package LearnDash\Templates\LD30
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Filters custom alert type.
*
* @since 3.1.4
*
* @param string $type Alert message type.
*/
$type = apply_filters(
'ld-alert-type',
( ( isset( $type ) ) && ( ! empty( $type ) ) ? $type : '' )
);
/**
* Filters custom alert icon CSS class.
*
* @since 3.0.0
*
* @param string $alert_class List of alert Icon CSS classes.
* @param string $type Alert message type.
* @param string $icon List of alert icon CSS classes.
*/
$icon = apply_filters(
'ld-alert-icon',
'ld-alert-icon ld-icon' . ( ( isset( $icon ) ) && ( ! empty( $icon ) ) ? ' ld-icon-' . $icon : '' ),
( ! empty( $type ) ? $type : '' ),
( ( isset( $icon ) ) && ( ! empty( $icon ) ) ? $icon : '' )
);
/**
* Filters custom alert message CSS class.
*
* @since 3.0.0
*
* @param string $alert_class List of alert CSS classes.
* @param string $type Alert message type.
* @param string $icon List of alert icon CSS classes.
*/
$class = apply_filters(
'ld-alert-class',
'ld-alert ' . ( ! empty( $type ) ? 'ld-alert-' . $type : '' ),
( ! empty( $type ) ? $type : '' ),
( ! empty( $icon ) ? $icon : '' )
);
/**
* Filters LearnDash custom alert message text.
*
* @since 3.0.0
*
* @param string $message Alert message text.
* @param string $type Alert message type.
* @param string $icon List of alert icon CSS classes.
*/
$message = apply_filters(
'learndash_alert_message',
$message,
( ! empty( $type ) ? $type : '' ),
( ! empty( $icon ) ? $icon : '' )
);
if ( ( isset( $message ) ) && ( ! empty( $message ) ) ) :
/**
* Fires before an alert.
*
* @since 3.0.0
*
* @param string $class List of alert CSS classes.
* @param string $icon List of alert icon CSS classes.
* @param string $message Alert message text.
* @param string $type Alert message type.
*/
do_action( 'learndash-alert-before', $class, $icon, $message, $type ); ?>
<div class="<?php echo esc_attr( $class ); ?>">
<div class="ld-alert-content">
<?php
/**
* Fires before an alert icon.
*
* @since 3.0.0
*
* @param string $class List of alert CSS classes.
* @param string $icon List of alert icon CSS classes.
* @param string $message Alert message text.
* @param string $type Alert message type.
*/
do_action( 'learndash-alert-icon-before', $class, $icon, $message, $type );
if ( ! empty( $icon ) ) :
?>
<div class="<?php echo esc_attr( $icon ); ?>"></div>
<?php
endif;
/**
* Fires after an alert icon.
*
* @since 3.0.0
*
* @param string $class List of alert CSS classes.
* @param string $icon List of alert icon CSS classes.
* @param string $message Alert message text.
* @param string $type Alert message type.
*/
do_action( 'learndash-alert-icon-after', $class, $icon, $message, $type );
?>
<div class="ld-alert-messages">
<?php
echo wp_kses_post( $message );
?>
</div>
<?php
/**
* Fires after an alert message.
*
* @since 3.0.0
*
* @param string $class List of alert CSS classes.
* @param string $icon List of alert icon CSS classes.
* @param string $message Alert message text.
* @param string $type Alert message type.
*/
do_action( 'learndash-alert-message-after', $class, $icon, $message, $type );
?>
</div>
<?php
/**
* Fires between alert message and button
*
* @since 3.0.0
*
* @param string $class List of alert CSS classes.
* @param string $icon List of alert icon CSS classes.
* @param string $message Alert message text.
* @param string $type Alert message type.
*/
do_action( 'learndash-alert-between-message-button', $class, $icon, $message, $type );
/**
* Filters alert button data.
*
* @since 3.1.4
*
* @param array $button An array of alert button data.
*/
$button = apply_filters(
'ld-alert-button',
( ( isset( $button ) ) && ( ! empty( $button ) ) ? $button : array() )
);
if ( is_array( $button ) && ! empty( $button ) ) :
$button_target = ( ( isset( $button['target'] ) ) && ( ! empty( $button['target'] ) ) ? 'target="' . esc_attr( $button['target'] ) . '"' : '' );
$button_class = 'class="ld-button' . ( ( isset( $button['class'] ) ) && ( ! empty( $button['class'] ) ) ? ' ' . esc_attr( $button['class'] ) : '' ) . '"';
$button_url = ( ( isset( $button['url'] ) ) && ( ! empty( $button['url'] ) ) ? 'href="' . esc_url( $button['url'] ) . '"' : '' );
$button_label = ( ( isset( $button['label'] ) ) && ( ! empty( $button['label'] ) ) ? esc_html( $button['label'] ) : '' );
$button_icon = ( ( isset( $button['icon'] ) ) && ( ! empty( $button['icon'] ) ) ? '<span class="ld-icon ld-icon-' . esc_attr( $button['icon'] ) . '"></span>' : '' );
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped above
?>
<a <?php echo $button_class; ?> <?php echo $button_url; ?> <?php echo $button_target; ?>>
<?php echo $button_icon; ?>
<?php echo $button_label; ?>
</a>
<?php
// phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
endif;
/**
* Fires after an alert button
*
* @since 3.0.0
*
* @param string $class List of alert CSS classes.
* @param string $icon List of alert icon CSS classes.
* @param string $message Alert message text.
* @param string $type Alert message type.
*/
do_action( 'learndash-alert-content-after', $class, $icon, $message, $type );
?>
</div>
<?php
/**
* Fires after an alert.
*
* @since 3.0.0
*
* @param string $class List of alert CSS classes.
* @param string $icon List of alert icon CSS classes.
* @param string $message Alert message text.
* @param string $type Alert message type.
*/
do_action( 'learndash-alert-after', $class, $icon, $message, $type );
endif; ?>