-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_shortcode.php
More file actions
246 lines (176 loc) · 6.72 KB
/
add_shortcode.php
File metadata and controls
246 lines (176 loc) · 6.72 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?php
//LWHH
function philosophy_button( $attributes ) {
$default = array(
'type'=>'primary',
'title'=>__("Button",'philosophy'),
'url'=>'',
);
$button_attributes = shortcode_atts($default,$attributes);
return sprintf( '<a target="_blank" class="btn btn--%s full-width" href="%s">%s</a>',
$button_attributes['type'],
$button_attributes['url'],
$button_attributes['title']
);
}
add_shortcode( 'button', 'philosophy_button' );
//Sample
function philosophy_uppercase($attributes, $content=''){
return strtoupper(do_shortcode($content));
}
add_shortcode('uc','philosophy_uppercase');
// $content ke obosshoy do_shortcode($content)); diye return korte hobe
// Google map sortcode
function philosophy_google_map($attributes){
$default = array(
'place'=>'Dhaka Museum',
'width'=>'800',
'height'=>'500',
'zoom'=>'14'
);
$params = shortcode_atts($default,$attributes);
$map = <<<EOD
<div>
<div>
<iframe width="{$params['width']}" height="{$params['height']}"
src="https://maps.google.com/maps?q={$params['place']}&t=&z={$params['zoom']}&ie=UTF8&iwloc=&output=embed"
frameborder="0" scrolling="no" marginheight="0" marginwidth="0">
</iframe>
</div>
</div>
EOD;
return $map;
}
add_shortcode('gmap','philosophy_google_map');
// Shortcode impliment sample
echo do_shortcode('[contact-form-7 id='5']');
//Shortcode Starting Demo
function custom_active_slide($para, $content){
$para = shortcode_atts(array(
'' => ''
), $para );
ob_start(); ?>
<!-- shortcode e ja dekhabe aikhane add kora jete pare like HTML codes -->
<?php return ob_get_clean();
}
add_shortcode( 'active_slider', 'custom_active_slide' );
/*implement*/
echo do_shortcode( '[active_slider]' );
//OR
[active_slider]
//Shortcode Starting Demo
function my_slider(){
}
add_shortcode('shortcode_name','my_slider');
/*Use shortcode like below: [shortcode_name]*/
// Shortcode example ebit
function my_slide($para, $content){
$para = shortcode_atts(array(
'color' => 'red',
'font-size' => '30px'
), $para); ob_start(); ?>
echo '<h2 style="color:'.$para['color']'">'. $content .'</h2>'
<?php return ob_get_clean(); }
add_shortcode('myslider_shortcode','my_slide');
// Shortcode sample
add_shortcode( 'feature_box', 'feature_box_callback' );
function feature_box_callback( $attr, $content = null ) {
$params = wp_parse_args( $attr, array(
'title' => 'Your Feature',
'icon' => 'flaticon-vector-design',
'shadow' => 'true'
) );
ob_start();
?>
<div class="services">
<div class="service-part <?php echo $params['shadow'] !== 'true'?'no-shadow': '';?>"><i class="<?php echo $params['icon']; ?> animate fadeInLeft" data-wow-delay="0.4s"></i>
<?php
if ( ! empty( $params['title'] ) ) {
echo '<h4>' . $params['title'] . '</h4>';
}
echo $content;
?>
</div>
</div>
<?php
$output = ob_get_contents();
ob_get_clean();
return $output;
}
function counter_callback( $attr ){
$default = array(
'icon' => 'icon-target',
'number' => '1500+',
'text' => 'Creative Template'
);
$params = wp_parse_args ( $attr, $default );
$html = '<span class="milestone counters">';
$html .= '<i class="'.$params['icon'].' animate fadeInDown animated" data-wow-delay="0.4s" style="visibility: visible; animation-delay: 0.4s;"></i>';
$html .= '<span class="counter">'.$params['number'].'</span>';
$html .= '<p>'.$params['text'].'</p>';
$html .= '</span>';
return $html;
}
add_shortcode('counter', 'counter_callback');
// Slider shortcode by eBit
function custom_active_slide($atts){
$para = shortcode_atts(
array(
'id' => '1'
), $atts );
ob_start(); ?>
<!-- Begin #carousel-section -->
<section id="carousel-section" class="section-global-wrapper">
<div class="container-fluid-kamn">
<div class="row">
<div id="carousel-<?php echo $para['id']; ?>" class="carousel slide">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<?php
$slider_query = null;
$slider_query = new WP_Query( array(
'post_type' => 'slider',
'posts_per_page' => -1,
) );
$pre = '_office_master_';
$x = 0;
while ( $slider_query->have_posts() ) {
$slider_query->the_post();
$x++;
$slider_caption = get_post_meta( get_the_ID(), $pre.'slider_caption', true );
?>
<!-- Begin Slide 1 -->
<div class="item <?php if ( $x == 1 ) {
echo 'active';
} ?>">
<?php the_post_thumbnail('slider-pic'); ?>
<div class="carousel-caption">
<h3 class="carousel-title hidden-xs"> <?php the_title(); ?> </h3>
<p class="carousel-body"> <?php echo $slider_caption; ?> </p>
</div>
</div>
<!-- End Slide 1 -->
<?php } ?>
</div>
<!-- Indicators -->
<ol class="carousel-indicators visible-lg">
<?php for ($i=0; $i < $x ; $i++) { ?>
<li data-target="#carousel-<?php echo $para['id']; ?>" data-slide-to="<?php echo $i; ?>" class="<?php if ($i==0) { echo 'active'; } ?>"> </li>
<?php } ?>
</ol>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-<?php echo $para['id']; ?>" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-<?php echo $para['id']; ?>" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
</div>
</section>
<!-- End #carousel-section -->
<?php
return ob_get_clean();
}
add_shortcode( 'active_slider', 'custom_active_slide' );