This repository was archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 544
Expand file tree
/
Copy pathshortcodes.php
More file actions
135 lines (105 loc) · 2.86 KB
/
shortcodes.php
File metadata and controls
135 lines (105 loc) · 2.86 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
<?php
// shortcodes
// Buttons
function buttons( $atts, $content = null ) {
extract( shortcode_atts( array(
'type' => 'default', /* primary, default, info, success, danger, warning, inverse */
'size' => 'default', /* mini, small, default, large */
'url' => '',
'text' => '',
), $atts ) );
if($type == "default"){
$type = "";
}
else{
$type = "btn-" . $type;
}
if($size == "default"){
$size = "";
}
else{
$size = "btn-" . $size;
}
$output = '<a href="' . $url . '" class="btn '. $type . ' ' . $size . '">';
$output .= $text;
$output .= '</a>';
return $output;
}
add_shortcode('button', 'buttons');
// Alerts
function alerts( $atts, $content = null ) {
extract( shortcode_atts( array(
'type' => 'alert-info', /* alert-info, alert-success, alert-error */
'close' => 'false', /* display close link */
'text' => '',
), $atts ) );
$output = '<div class="fade in alert alert-'. $type . '">';
if($close == 'true') {
$output .= '<a class="close" data-dismiss="alert">×</a>';
}
$output .= $text . '</div>';
return $output;
}
add_shortcode('alert', 'alerts');
// Block Messages
function block_messages( $atts, $content = null ) {
extract( shortcode_atts( array(
'type' => 'alert-info', /* alert-info, alert-success, alert-error */
'close' => 'false', /* display close link */
'text' => '',
), $atts ) );
$output = '<div class="fade in alert alert-block alert-'. $type . '">';
if($close == 'true') {
$output .= '<a class="close" data-dismiss="alert">×</a>';
}
$output .= '<p>' . $text . '</p></div>';
return $output;
}
add_shortcode('block-message', 'block_messages');
// Block Messages
function blockquotes( $atts, $content = null ) {
extract( shortcode_atts( array(
'float' => '', /* left, right */
'cite' => '', /* text for cite */
), $atts ) );
$output = '<blockquote';
if($float == 'left') {
$output .= ' class="pull-left"';
}
elseif($float == 'right'){
$output .= ' class="pull-right"';
}
$output .= '><p>' . $content . '</p>';
if($cite){
$output .= '<small>' . $cite . '</small>';
}
$output .= '</blockquote>';
return $output;
}
add_shortcode('blockquote', 'blockquotes');
function rows($atts, $content = null) {
extract( shortcode_atts( array(
'id' => ''
), $atts));
return "<div id='" . $id . "' class='row'>" . do_shortcode($content) . "</div>";
}
add_shortcode('row', 'rows');
function cols($atts, $content = null) {
extract( shortcode_atts( array(
'id' => '',
'size' => 'md', /* xs, sm, md, lg */
'span' => '6' /* 1-12 */
), $atts ));
if($span > 12 || $span < 1) {
$span = 6;
}
if(!preg_match('/xs|sm|md|lg/', $size)) {
$size = "md";
}
$output = "<div id='" . $id . "' class='col-" . $size . "-" . $span . "'>";
$output .= $content;
$output .= "</div>";
return $output;
}
add_shortcode('col', 'cols');
?>