-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshortcode
39 lines (32 loc) · 956 Bytes
/
shortcode
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
// Shortcode Function
<?php
// Test Shortcodes For Alert
function stock_alert_shortcode($atts, $content = null) {
extract(shortcode_atts(
array (
'type' => 'success',
'text' => ''
),
$atts
));
return '<div class="alert alert-'.esc_attr($type).'" role="alert">'. esc_html($text).'</div>';
// Conditional Shortcode
extract(shortcode_atts(
array (
'city' => ''
),
$atts
));
if( $city == 'Dhaka'){
$message = (''.esc_html($city).' is the most populated city');
} elseif( $city == 'Sylhet') {
$message = (''.esc_html($city).'Sylhet is the most beutiful country');
} else {
$message = ('you do not added a city');
}
return $message;
}
add_shortcode( alert, stock_alert_shortcode );
// Shortcodes in text editor
[alert type="warning" text="Hello I am learning shortcode"]
[alert city="sylhet"]