PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / trunk
Shortcodes and extra features for Phlox theme vtrunk
2.17.21 2.17.20 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / includes / general-shortcodes.php
auxin-elements / includes Last commit date
classes 13 hours ago compatibility 1 month ago elementor 1 day ago elements 1 month ago define.php 13 hours ago general-functions.php 5 months ago general-hooks.php 1 day ago general-shortcodes.php 2 years ago index.php 1 month ago
general-shortcodes.php
415 lines
1 <?php
2
3 /*-----------------------------------------------------------------------------------*/
4 /* Latest from Blog
5 /*-----------------------------------------------------------------------------------*/
6
7 add_shortcode( 'aux_timeline' , 'auxin_shortcode_timeline' );
8
9 function auxin_shortcode_timeline( $atts, $content = null ) {
10
11 // extract attrs to vars
12 extract( shortcode_atts(
13 array(
14 'size' => 100, // section size
15 'title' => '', // widget header title
16 'col' => '33', // one .. six-column
17 'view_more' => 'yes',
18 'more_label' => 'view all',
19 'num' => 5, // fetch num
20 'excerpt_len' => '120',
21 'cat_id' => '', // cat id to display. '' gets all cats
22 'view_thumb' => 'yes', // display thumbnail or not
23 'thumb_mode' => 'left', // 'top': normal thumb on top , 'left': normal thumb on left, 'icon': icon size thumb
24 'date_type' => 'big',
25 'orderby' => '',
26 'order' => '',
27 'layout' => 'center'
28 )
29 , $atts, 'aux_timeline' )
30 );
31
32 // sanitize sql order and orderby
33 $orderby = $orderby ? sanitize_sql_orderby( $orderby ) : 'date';
34 $order = $order ? auxin_sanitize_sql_order( $order ) : 'DESC';
35
36 // validate number fetched items
37 $num = is_numeric( $num ) ? $num : -1;
38
39 // get thumbnail diemntion --------------------------------------
40 $vimeo_height = 273;
41
42 // chane thumbnail size to 60x60 if it is mini mode
43 if($thumb_mode == "mini") {
44 $dimentions[0] = 60;
45 $dimentions[1] = 60;
46 }else{
47 // actual col size
48 // get number of grid column
49 $wrapper_size = empty($size)?100:$size;
50 $col_actual = ($wrapper_size / 100) * (int)$col;
51 $col_num = floor(100 / $col_actual);
52 $col_num = $col_num > 4?4:$col_num; // max column num is 4
53 // get thumbnsil size name
54 $image_size_name = "i".$col_num;
55
56 // get suite thumb size
57 $thumb_size = $image_size_name;
58 $dimentions = auxin_get_image_size( $thumb_size.'_1' );
59
60 // the left mode is half size of top mode, so for making image retina
61 // bigger size is not needed
62 if($thumb_mode == "top"){
63 // retinafy thumbnail
64 $dimentions[0] = 1.5 * $dimentions[0];
65 $dimentions[1] = 1.5 * ($dimentions[1] - 10);
66
67 }else{ // if the image is on left
68 $dimentions[1] -= 10;
69 }
70
71 }
72
73
74 // just view custom taxonomies if tax id is set ----------------
75 $tax_args = array('taxonomy' => 'category', 'terms' => $cat_id );
76 if(empty($cat_id) || $cat_id == "all" ) $tax_args = "";
77
78 // create wp_query to get latest items
79 $args = array(
80 'post_type' => 'post',
81 'orderby' => $orderby,
82 'order' => $order,
83 'post_status' => 'publish',
84 'posts_per_page' => $num,
85 'ignore_sticky_posts'=> 1,
86 'tax_query' => array($tax_args)
87 );
88
89 $th_query = null;
90 $th_query = new WP_Query($args);
91
92
93
94 ob_start();
95 ?>
96
97 <section class="widget-blog widget-container widget-timeline" >
98
99 <?php
100
101 if( ! empty($title) )
102 echo auxin_kses( get_widget_title( $title ) ); ?>
103
104
105 <div class="widget-inner">
106 <div class="aux-timeline aux-<?php echo esc_attr( $layout ); ?>" data-layout="<?php echo esc_attr( $layout ); ?>" >
107
108 <?php if( $th_query->have_posts() ): while ($th_query->have_posts()) : $th_query->the_post(); ?>
109
110
111
112
113 <?php
114 $post_format = get_post_format($th_query->post->ID);
115 $has_attach = FALSE;
116 $the_attach = "";
117 $show_title = true;
118
119 switch ($post_format) {
120 case 'aside':
121
122 break;
123 case 'gallery':
124
125 // if the mode is not mini size
126 if($thumb_mode != "mini") {
127 // if post has featured image, use featured image instead of gallery images
128 $has_attach = has_post_thumbnail($th_query->post->ID);
129 if($has_attach) {
130 $the_attach = auxin_get_the_post_thumbnail($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75);
131
132 $the_media = '<div class="imgHolder">'.
133 '<a href="'.auxin_get_the_attachment_url($th_query->post->ID, "full").'" data-rel="prettyPhoto">'.
134 $the_attach.
135 '</a>'.
136 '</div>';
137
138 // display gallery images as slider if featured image is not set
139 } else {
140
141 $slider = '[flexslider slideshow="no" effect="slide" nav_type="none" easing="easeInOutQuad" ]';
142 $has_attach = false;
143
144 for ($i=1; $i <= 5; $i++) {
145 $img_url = get_post_meta($th_query->post->ID, "axi_gallery_image".$i, true);
146 if(!empty($img_url) ){
147 $has_attach = true;
148 $img_url = auxin_get_the_absolute_image_url($img_url);
149 $slider .= '[simple_slide src="'.auxin_get_the_resized_image_src($img_url, $dimentions[0], $dimentions[1], true, 75 ).'" ]';
150 }
151 }
152
153 $slider .= '[/flexslider]';
154 if(!$has_attach) break;
155
156 $the_media = do_shortcode($slider);
157 }
158
159 break;
160
161 // if thumb mode is mini, just echo small image intead of slider
162 }else {
163 $has_attach = has_post_thumbnail($th_query->post->ID);
164 // if post has featured image, use featured image instead of gallery image
165 if( $has_attach ) {
166 $the_attach = auxin_get_the_post_thumbnail_src($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75);
167
168 // display first gallery image as slider if featured image is not set
169 }else {
170 $the_attach = get_post_meta($th_query->post->ID, "axi_gallery_image1", true);
171 $has_attach = !empty($the_attach);
172 if(!$has_attach) break;
173 $the_attach = auxin_get_the_absolute_image_url($the_attach);
174 }
175
176 $the_media = '<div class="imgHolder">'.
177 '<a href="'.get_permalink().'" >'.
178 '<img src="'.$the_attach.'" alt="" />'.
179 '</a>'.
180 '</div>';
181 break;
182 }
183
184 break;
185 case 'image':
186 $has_attach = has_post_thumbnail();
187 if(!$has_attach) break;
188 $the_attach = auxin_get_the_post_thumbnail($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75);
189
190 $the_media = '<div class="imgHolder">'.
191 '<a href="'.auxin_get_the_attachment_url($th_query->post->ID, "full").'" data-rel="prettyPhoto">'.
192 $the_attach.
193 '</a>'.
194 '</div>';
195 break;
196
197 case 'link':
198 $the_link = get_post_meta($th_query->post->ID, "the_link", true);
199 $show_title = TRUE;
200 $has_attach = false;
201 if(!$has_attach) break;
202 break;
203
204 case 'video':
205 $video_link = get_post_meta($th_query->post->ID, "youtube", true);
206 $mp4 = get_post_meta($th_query->post->ID, "mp4" , true);
207 $ogg = get_post_meta($th_query->post->ID, "ogg" , true);
208 $webm = get_post_meta($th_query->post->ID, "webm", true);
209 $flv = get_post_meta($th_query->post->ID, "flv" , true);
210 $poster = get_post_meta($th_query->post->ID, "poster", true);
211 $skin = get_post_meta($th_query->post->ID, "skin" , true);
212
213 // if it is mini size just display a thumbnail
214 if($thumb_mode == "mini") {
215 if(has_post_thumbnail()){
216 $the_attach = auxin_get_the_post_thumbnail($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75);
217 $the_media = '<div class="imgHolder">'.
218 '<a href="'.get_permalink().'">'.
219 $the_attach.
220 '</a>'.
221 '</div>';
222 }
223 break;
224 }
225
226 // if the feature image is set, display feature image instead
227 $has_attach = has_post_thumbnail();
228 if($has_attach) {
229 $the_attach = auxin_get_the_post_thumbnail($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75);
230
231 $the_media = '<div class="imgHolder">'.
232 '<a href="'.get_permalink().'" >'.
233 $the_attach.
234 '</a>'.
235 '</div>';
236 break;
237 }
238
239 $has_attach = (!empty($video_link) || !empty($mp4) || !empty($ogg) || !empty($webm) || !empty($flv));
240 if(!$has_attach) break;
241
242 $the_attach = do_shortcode('[video_element fit="yes" height="'.$vimeo_height.'" url="'.$video_link.'" mp4="'.$mp4.'" ogg="'.$ogg.'" webm="'.$webm.'" flv="'.$flv.'" poster="'.$poster.'" skin="'.$skin.'" uid="axi_vid'.$th_query->post->ID.'" size="0" ]');
243
244 $the_media = $the_attach;
245 echo '<style type="text/css"> div.jp-video div.jp-jplayer { min-height: '.(($dimentions[1]/2)-75).'px; }</style>';
246 unset($video_link, $mp4,$ogg,$webm,$flv,$poster);
247 break;
248
249 case 'audio':
250 $mp3 = get_post_meta($th_query->post->ID, "mp3" , true);
251 $oga = get_post_meta($th_query->post->ID, "oga" , true);
252 $skin = get_post_meta($th_query->post->ID, "audio_skin" , true);
253 $soundcloud = get_post_meta($th_query->post->ID, "soundcloud" , true);
254
255 if($thumb_mode == "mini") {
256 if(has_post_thumbnail()){
257 $the_attach = auxin_get_the_post_thumbnail($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75);
258 $the_media = '<div class="imgHolder">'.
259 '<a href="'.get_permalink().'">'.
260 $the_attach.
261 '</a>'.
262 '</div>';
263 }
264 break;
265 }
266
267 $has_attach = (!empty($mp3) || !empty($oga) || !empty($soundcloud));
268 if(!$has_attach) break;
269 if(!empty($mp3) || !empty($oga))
270 $the_attach = do_shortcode('[audio mp3="'.$mp3.'" ogg="'.$oga.'" skin="'.$skin.'" uid="axi_au'.$th_query->post->ID.'" size="0" ]');
271 else
272 $the_attach = do_shortcode($soundcloud);
273 $the_media = $the_attach;
274 unset($mp3,$oga,$skin, $soundcloud);
275 break;
276
277
278 case 'quote':
279 $quote = get_the_excerpt();
280 $author = get_post_meta($th_query->post->ID, "the_author", true);
281 $show_title = false;
282 $has_attach = false;
283 $quote = auxin_get_trimmed_string($quote,$excerpt_len, " ...");
284 $quote .= "<br/>- <cite>".$author."</cite>";
285 $the_attach = do_shortcode('[blockquote size="0" indent="no" ]'.$quote.'[/blockquote]');
286 unset($quote);
287 break;
288
289 default:
290 $has_attach = has_post_thumbnail();
291 if(!$has_attach) {
292 $the_attach = auxin_get_first_image_from_string(get_the_content());
293 $has_attach = !empty($the_attach);
294 }else {
295 $the_attach = auxin_get_the_post_thumbnail($th_query->post->ID, $dimentions[0], $dimentions[1], true, 75);
296 }
297
298 if(!$has_attach) break;
299
300 $the_media = '<div class="imgHolder">'.
301 '<a href="'.get_permalink().'">'.
302 $the_attach.
303 '</a>'.
304 '</div>';
305 break;
306 }
307
308 ?>
309
310 <article class="aux-block <?php echo "date-type-". esc_attr( $date_type ) ." "; echo ($thumb_mode != "top")? esc_attr( $thumb_mode ) : "thumb_top" ; ?>">
311 <figure>
312 <?php if ( $has_attach && ($view_thumb == "yes") ) {
313 echo wp_kses_post( $the_media );
314 } ?>
315
316
317 <figcaption>
318 <div class="entry-header">
319 <h4 class="entry-title"><a href="<?php the_permalink(); ?>"><?php echo auxin_kses( get_the_title() ); ?></a></h4>
320 <div class="entry-format">
321 <a href="<?php the_permalink(); ?>" class="post-format format-<?php echo get_post_format(); ?>"> </a>
322 <?php if($date_type == "big") { ?>
323 <div class="cell-date">
324 <em> </em><em> </em>
325 <time datetime="<?php echo get_the_date( DATE_W3C ); ?>" title="<?php echo get_the_date( DATE_W3C ); ?>" >
326 <strong><?php the_time('d')?></strong>
327 <span><?php the_time('M')?></span>
328 </time>
329 </div>
330 <?php } ?>
331 </div>
332 </div>
333
334 <div class="entry-content">
335 <?php if($date_type == "inline" && $post_format != "quote") { ?>
336 <time datetime="<?php echo get_the_date( DATE_W3C ); ?>" title="<?php echo get_the_date( DATE_W3C ); ?>" ><?php the_date(); ?></time>
337 <?php } ?>
338
339 <?php if($post_format == "quote") {
340 echo wp_kses_post( $the_attach );
341 } elseif($excerpt_len > 0) { ?>
342 <p><?php auxin_the_trimmed_string( auxin_kses( get_the_excerpt() ),$excerpt_len); ?></p>
343 <?php } ?>
344 </div>
345 </figcaption>
346 </figure>
347 </article><!-- end-timeline-block -->
348
349 <?php endwhile; endif;
350 wp_reset_query();
351 ?>
352 </div><!-- end-timeline-wrapper -->
353 </div><!-- widget-inner -->
354
355 <?php if($view_more == "yes" ) {
356 $view_all_link = esc_url( auxin_get_option( 'blog_view_all_btn_link', home_url() ) );
357 ?>
358 <a href="<?php echo esc_url( $view_all_link ); ?>" class="more right" ><?php echo auxin_kses( $more_label ); ?></a>
359 <?php } unset( $view_all_link ); ?>
360
361 </section><!-- widget-blog -->
362
363 <?php
364 return ob_get_clean();
365 }
366
367
368 /**
369 * Adds aux_row shortcode for adding row for columns
370 */
371 function auxin_aux_row_shortcode( $atts , $content = null ) {
372
373 if( empty( $atts['tablet-columns'] ) && ! empty( $atts['columns'] ) ){
374 $atts['tablet-columns'] = ceil( (int)$atts['columns'] / 2 );
375 }
376
377 // parse attributes
378 $parsed_atts = shortcode_atts(
379 array(
380 'columns' => 3,
381 'tablet-columns' => '',
382 'mobile-columns' => 1
383 ),
384 $atts,
385 'aux_row'
386 );
387
388 // collect custom layout css classes
389 $classes = '';
390
391 if( $parsed_atts['columns'] ){
392 $classes .= esc_attr( 'aux-col' . $parsed_atts['columns'] ) . ' ';
393 }
394 if( $parsed_atts['tablet-columns'] ){
395 $classes .= esc_attr( 'aux-tb-col' . $parsed_atts['tablet-columns'] ) . ' ';
396 }
397 if( $parsed_atts['mobile-columns'] ){
398 $classes .= esc_attr( 'aux-mb-col' . $parsed_atts['mobile-columns'] ) . ' ';
399 }
400
401 // Return code
402 return '<div class="aux-row '. trim( $classes ) .'">'. do_shortcode( $content ) .'</div>';
403 }
404 add_shortcode( 'aux_row', 'auxin_aux_row_shortcode' );
405
406
407 /**
408 * Adds aux_col shortcode for adding simple column shortcode for layout purposes
409 */
410 function auxin_aux_col_shortcode( $atts , $content = null ) {
411 // Return code
412 return '<div class="aux-col">'. do_shortcode( $content ) .'</div>';
413 }
414 add_shortcode( 'aux_col', 'auxin_aux_col_shortcode' );
415