PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.9.22
Shortcodes and extra features for Phlox theme v2.9.22
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 / elements / latest-posts-slider.php
auxin-elements / includes / elements Last commit date
about-widget.php 4 years ago accordion-widget.php 4 years ago accordion.php 4 years ago attachment-url.php 4 years ago audio.php 4 years ago before-after.php 4 years ago button.php 4 years ago code.php 4 years ago contact-box.php 4 years ago contact-form.php 4 years ago custom-list.php 4 years ago divider.php 4 years ago dropcap.php 4 years ago facebook.php 4 years ago flickr.php 4 years ago gallery.php 4 years ago general-element-fields.php 4 years ago gmap.php 4 years ago highlight.php 4 years ago image.php 4 years ago instagram-feed.php 4 years ago latest-items.php 4 years ago latest-posts-slider.php 4 years ago popular-posts-widget.php 4 years ago products-grid.php 4 years ago quote.php 4 years ago recent-posts-grid-carousel.php 3 years ago recent-posts-land-style.php 4 years ago recent-posts-masonry.php 4 years ago recent-posts-tiles-carousel.php 3 years ago recent-posts-tiles.php 4 years ago recent-posts-timeline.php 4 years ago recent-posts-widget.php 4 years ago recent-products.php 3 years ago related-posts.php 8 years ago sample-element.php 4 years ago search.php 4 years ago socials-list.php 4 years ago staff.php 4 years ago tab-widget.php 4 years ago tabs.php 4 years ago testimonial.php 4 years ago text.php 3 years ago touch-slider.php 4 years ago video.php 4 years ago
latest-posts-slider.php
563 lines
1 <?php
2 /**
3 * Latest Post slider element
4 *
5 *
6 * @package Auxin
7 * @license LICENSE.txt
8 * @author averta
9 * @link http://phlox.pro/
10 * @copyright (c) 2010-2022 averta
11 */
12 function auxin_get_post_slider_master_array( $master_array ) {
13
14 $master_array['aux_latest_posts_slider'] = array(
15 'name' => __('Latest Posts Slider ', 'auxin-elements' ),
16 'auxin_output_callback' => 'auxin_latest_posts_slider_callback',
17 'base' => 'aux_latest_posts_slider',
18 'description' => __('Slider for latest posts.', 'auxin-elements' ),
19 'class' => 'aux-widget-post-slider',
20 'show_settings_on_create' => true,
21 'weight' => 1,
22 'is_widget' => true,
23 'is_shortcode' => true,
24 'is_vc' => true,
25 'category' => THEME_NAME,
26 'group' => '',
27 'admin_enqueue_js' => '',
28 'admin_enqueue_css' => '',
29 'front_enqueue_js' => '',
30 'front_enqueue_css' => '',
31 'icon' => 'aux-element aux-pb-icons-post-slider',
32 'custom_markup' => '',
33 'js_view' => '',
34 'html_template' => '',
35 'deprecated' => '',
36 'content_element' => '',
37 'as_parent' => '',
38 'as_child' => '',
39 'params' => array(
40 array(
41 'heading' => __('Title','auxin-elements' ),
42 'description' => __('Latest post slider title, leave it empty if you don`t need title.', 'auxin-elements'),
43 'param_name' => 'title',
44 'type' => 'textfield',
45 'value' => '',
46 'holder' => '',
47 'class' => 'title',
48 'admin_label' => false,
49 'dependency' => '',
50 'weight' => '',
51 'group' => '' ,
52 'edit_field_class' => ''
53 ),
54 array(
55 'heading' => __('Create slides from','auxin-elements' ),
56 'description' => '',
57 'param_name' => 'post_type',
58 'type' => 'dropdown',
59 'def_value' => 'post',
60 'value' => array(
61 'post' => __('Posts', 'auxin-elements' ),
62 'page' => __('Pages', 'auxin-elements' ),
63 ),
64 'holder' => '',
65 'class' => 'border',
66 'admin_label' => true,
67 'dependency' => '',
68 'weight' => '',
69 'group' => __( 'Query', 'auxin-elements' ),
70 'edit_field_class' => ''
71 ),
72 array(
73 'heading' => __('Slides number','auxin-elements' ),
74 'description' => __('Specifies maximum number of slides in slider.', 'auxin-elements' ),
75 'param_name' => 'slides_num',
76 'type' => 'textfield',
77 'value' => '10',
78 'holder' => '',
79 'class' => '',
80 'admin_label' => false,
81 'dependency' => '',
82 'weight' => '',
83 'group' => __( 'Query', 'auxin-elements' ),
84 'edit_field_class' => ''
85 ),
86 array(
87 'heading' => __('Exclude posts','auxin-elements' ),
88 'description' => __('Post IDs separated by comma (eg. 53,34,87,25).', 'auxin-elements' ),
89 'param_name' => 'exclude',
90 'type' => 'textfield',
91 'value' => '',
92 'holder' => '',
93 'class' => '',
94 'admin_label' => false,
95 'dependency' => '',
96 'weight' => '',
97 'group' => __( 'Query', 'auxin-elements' ),
98 'edit_field_class' => ''
99 ),
100 array(
101 'heading' => __('Include posts','auxin-elements' ),
102 'description' => __('Post IDs separated by comma (eg. 53,34,87,25).', 'auxin-elements' ),
103 'param_name' => 'include',
104 'type' => 'textfield',
105 'value' => '',
106 'holder' => '',
107 'class' => '',
108 'admin_label' => false,
109 'dependency' => '',
110 'weight' => '',
111 'group' => __( 'Query', 'auxin-elements' ),
112 'edit_field_class' => ''
113 ),
114 array(
115 'heading' => __('Start offset','auxin-elements' ),
116 'description' => __('Number of post to displace or pass over.', 'auxin-elements' ),
117 'param_name' => 'offset',
118 'type' => 'textfield',
119 'value' => '',
120 'holder' => '',
121 'class' => '',
122 'admin_label' => false,
123 'dependency' => '',
124 'weight' => '',
125 'group' => __( 'Query', 'auxin-elements' ),
126 'edit_field_class' => ''
127 ),
128 array(
129 'heading' => __('Order by','auxin-elements' ),
130 'description' => '',
131 'param_name' => 'order_by',
132 'type' => 'dropdown',
133 'def_value' => 'date',
134 'value' => array(
135 'date' => __('Date', 'auxin-elements' ),
136 'menu_order date' => __('Menu Order', 'auxin-elements' ),
137 'title' => __('Title', 'auxin-elements' ),
138 'ID' => __('ID', 'auxin-elements' ),
139 'rand' => __('Random', 'auxin-elements' ),
140 'comment_count' => __('Comments', 'auxin-elements' ),
141 'modified' => __('Date Modified', 'auxin-elements' ),
142 'author' => __('Author', 'auxin-elements' ),
143 ),
144 'holder' => '',
145 'class' => 'border',
146 'admin_label' => false,
147 'dependency' => '',
148 'weight' => '',
149 'group' => __( 'Query', 'auxin-elements' ),
150 'edit_field_class' => ''
151 ),
152 array(
153 'heading' => __('Order direction','auxin-elements' ),
154 'description' => '',
155 'param_name' => 'order_dir',
156 'type' => 'dropdown',
157 'def_value' => 'DESC',
158 'value' => array(
159 'DESC' => __('Descending', 'auxin-elements' ),
160 'ASC' => __('Ascending', 'auxin-elements' ),
161 ),
162 'holder' => '',
163 'class' => 'border',
164 'admin_label' => false,
165 'dependency' => '',
166 'weight' => '',
167 'group' => __( 'Query', 'auxin-elements' ),
168 'edit_field_class' => ''
169 ),
170 array(
171 'heading' => __('Slider skin','auxin-elements' ),
172 'description' => '',
173 'param_name' => 'skin',
174 'type' => 'dropdown',
175 'def_value' => 'aux-light-skin',
176 'value' => array(
177 'aux-light-skin' => __('Light and boxed', 'auxin-elements' ),
178 'aux-dark-skin' => __('Dark and boxed', 'auxin-elements' ),
179 'aux-full-light-skin' => __('Light overlay', 'auxin-elements' ),
180 'aux-full-dark-skin' => __('Dark overlay', 'auxin-elements' ),
181 ),
182 'holder' => '',
183 'class' => 'border',
184 'admin_label' => false,
185 'dependency' => '',
186 'weight' => '',
187 'group' => '' ,
188 'edit_field_class' => ''
189 ),
190 array(
191 'heading' => __('Insert post title','auxin-elements' ),
192 'description' => '',
193 'param_name' => 'add_title',
194 'type' => 'aux_switch',
195 'value' => '1',
196 'class' => '',
197 'admin_label' => false,
198 'dependency' => '',
199 'weight' => '',
200 'group' => '' ,
201 'edit_field_class' => ''
202 ),
203 array(
204 'heading' => __('Insert post meta','auxin-elements' ),
205 'description' => '',
206 'param_name' => 'add_meta',
207 'type' => 'aux_switch',
208 'value' => '1',
209 'class' => '',
210 'dependency' => array(
211 'element' => 'add_title',
212 'value' => '1'
213 ),
214 'admin_label' => false,
215 'weight' => '',
216 'group' => '' ,
217 'edit_field_class' => ''
218 ),
219
220 array(
221 'heading' => __('Grab the image from','auxin-elements' ),
222 'description' => '',
223 'param_name' => 'image_from',
224 'type' => 'dropdown',
225 'def_value' => 'auto',
226 'value' => array(
227 'auto' => __('Auto select', 'auxin-elements' ),
228 'featured' => __('Featured image', 'auxin-elements' ),
229 'first' => __('First image in post', 'auxin-elements' ),
230 'custom' => __('Custom image', 'auxin-elements' ),
231 ),
232 'holder' => '',
233 'class' => 'border',
234 'admin_label' => false,
235 'dependency' => '',
236 'weight' => '',
237 'group' => __( 'Query', 'auxin-elements' ),
238 'edit_field_class' => ''
239 ),
240 array(
241 'heading' => __('Background image','auxin-elements' ),
242 'description' => '',
243 'param_name' => 'custom_image',
244 'type' => 'attach_image',
245 'value' => '',
246 'class' => '',
247 'admin_label' => false,
248 'dependency' => array(
249 'element' => 'image_from',
250 'value' => 'custom'
251 ),
252 'weight' => '',
253 'group' => '' ,
254 'edit_field_class' => ''
255 ),
256 array(
257 'heading' => __('Exclude posts without image','auxin-elements' ),
258 'description' => '',
259 'param_name' => 'exclude_without_image',
260 'type' => 'aux_switch',
261 'value' => '1',
262 'class' => '',
263 'admin_label' => false,
264 'dependency' => '',
265 'weight' => '',
266 'group' => '' ,
267 'edit_field_class' => ''
268 ),
269
270
271 array(
272 'heading' => __('Slider image width','auxin-elements' ),
273 'param_name' => 'width',
274 'type' => 'textfield',
275 'value' => '960',
276 'holder' => '',
277 'class' => '',
278 'admin_label' => false,
279 'dependency' => '',
280 'weight' => '',
281 'group' => '' ,
282 'edit_field_class' => ''
283 ),
284 array(
285 'heading' => __('Slider image height','auxin-elements' ),
286 'param_name' => 'height',
287 'type' => 'textfield',
288 'value' => '560',
289 'holder' => '',
290 'class' => '',
291 'admin_label' => false,
292 'dependency' => '',
293 'weight' => '',
294 'group' => '' ,
295 'edit_field_class' => ''
296 ),
297 array(
298 'heading' => __('Arrow navigation','auxin-elements' ),
299 'description' => '',
300 'param_name' => 'arrows',
301 'type' => 'aux_switch',
302 'value' => '0',
303 'class' => '',
304 'admin_label' => false,
305 'dependency' => '',
306 'weight' => '',
307 'group' => '' ,
308 'edit_field_class' => ''
309 ),
310 array(
311 'heading' => __('Space between slides','auxin-elements' ),
312 'param_name' => 'space',
313 'type' => 'textfield',
314 'value' => '5',
315 'holder' => '',
316 'class' => '',
317 'admin_label' => false,
318 'dependency' => '',
319 'weight' => '',
320 'group' => '' ,
321 'edit_field_class' => ''
322 ),
323 array(
324 'heading' => __('Looped navigation','auxin-elements' ),
325 'description' => '',
326 'param_name' => 'loop',
327 'type' => 'aux_switch',
328 'value' => '1',
329 'class' => '',
330 'admin_label' => false,
331 'dependency' => '',
332 'weight' => '',
333 'group' => '' ,
334 'edit_field_class' => ''
335 ),
336 array(
337 'heading' => __('Slideshow','auxin-elements' ),
338 'description' => '',
339 'param_name' => 'slideshow',
340 'type' => 'aux_switch',
341 'value' => '0',
342 'class' => '',
343 'admin_label' => false,
344 'dependency' => '',
345 'weight' => '',
346 'group' => '' ,
347 'edit_field_class' => ''
348 ),
349 array(
350 'heading' => __('Slideshow delay in seconds','auxin-elements' ),
351 'param_name' => 'slideshow_delay',
352 'type' => 'textfield',
353 'value' => '2',
354 'holder' => '',
355 'class' => '',
356 'admin_label' => false,
357 'dependency' => array(
358 'element' => 'slideshow',
359 'value' => '1'
360 ),
361 'weight' => '',
362 'group' => '' ,
363 'edit_field_class' => ''
364 ),
365 array(
366 'heading' => __('Extra class name','auxin-elements'),
367 'description' => __('If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.', 'auxin-elements'),
368 'param_name' => 'extra_classes',
369 'type' => 'textfield',
370 'value' => '',
371 'def_value' => '',
372 'holder' => '',
373 'class' => 'extra_classes',
374 'admin_label' => false,
375 'dependency' => '',
376 'weight' => '',
377 'group' => '' ,
378 'edit_field_class' => ''
379 )
380 )
381 );
382
383 return $master_array;
384 }
385
386 add_filter( 'auxin_master_array_shortcodes', 'auxin_get_post_slider_master_array', 10, 1 );
387
388 /**
389 * Dynamic element with result in columns
390 * The front-end output of this element is returned by the following function
391 *
392 * @param array $atts The array containing the parsed values from shortcode
393 * containing widget info too
394 * @param string $shortcode_content The shorcode content
395 * @return string The output of element markup
396 */
397 function auxin_latest_posts_slider_callback( $atts, $shortcode_content = null ){
398
399 // Defining default attributes
400 $default_atts = array(
401 'title' => '',
402 'slides_num' => '10',
403 'order_by' => 'date',
404 'order_dir' => 'DESC',
405 'post_type' => 'post',
406 'add_title' => '1',
407 'add_meta' => '1',
408 'image_from' => 'auto',
409 'offset' => '',
410 'include' => '',
411 'exclude_without_image' => '1',
412 'exclude' => '',
413 'custom_image' => '',
414 'skin' => 'aux-light-skin',
415 'width' => '960',
416 'height' => '560',
417 'loop' => '1',
418 'space' => '5',
419 'slideshow' => '0',
420 'slideshow_delay' => '2',
421 'arrows' => '0',
422
423 'extra_classes' => '', // custom css class names for this element
424 'custom_el_id' => '', // custom id attribute for this element
425 'base_class' => 'aux-widget-post-slider' // base class name for container
426 );
427
428 $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content );
429 extract( $result['parsed_atts'] );
430
431 // query --------------------------------------
432
433 // Create wp_query to get pages
434 $query_args = array(
435 'post_type' => $post_type,
436 'orderby' => $order_by,
437 'order' => $order_dir,
438 'offset' => $offset,
439 'posts__not_in' => $exclude,
440 'include_posts__in' => $include,
441 'post_status' => 'publish',
442 'posts_per_page' => $slides_num, // -1 causes ignoring offset
443 'ignore_sticky_posts' => 1
444 );
445
446 $post_counter = 0;
447
448 $query_res = null;
449 $query_res = new WP_Query( auxin_parse_query_args( $query_args ) );
450
451 // skip building slider if no post results found
452 if( ! $query_res->have_posts() ){
453 return '';
454 }
455
456 ob_start();
457
458 // widget header ------------------------------
459 echo wp_kses_post( $result['widget_header'] );
460 echo wp_kses_post( $result['widget_title'] );
461
462 echo '<div class="master-carousel-slider aux-latest-posts-slider aux-no-js '.esc_attr( $skin ).'" data-empty-height="'.esc_attr( $height ).'" data-navigation="peritem" data-space="'.esc_attr( $space ).'" data-auto-height="true" data-delay="'.esc_attr( $slideshow_delay ).'" data-loop="'.esc_attr( $loop ).'" data-autoplay="'.esc_attr( $slideshow ).'">';
463
464 // widget custom output -----------------------
465
466
467 if( $query_res->have_posts() ): while ( $query_res->have_posts() ) : $query_res->the_post();
468
469 // break the loop if it is reached to the limit
470 if ( $exclude_without_image && $post_counter == $slides_num ) {
471 break;
472 } else {
473 $post_counter ++;
474 }
475
476 $slide_image = '';
477
478 // get image
479 if ( 'custom' == $image_from && !empty( $custom_image ) ) {
480 $slide_image = auxin_get_the_resized_image( $custom_image, $width, $height, true , 100 );
481 } else {
482 // $slide_image = auxin_get_auto_post_thumbnail( $query_res->post->ID, $image_from, $width, $height, true, 100, true );
483 $slide_image = auxin_get_the_post_responsive_thumbnail(
484 $query_res->post->ID,
485 array(
486 'size' => array( 'width' => $width, 'height' => $height ),
487 'add_hw' => false,
488 'preloadable' => false,
489 'preload_preview' => true,
490 'image_sizes' => 'auto',
491 'srcset_sizes' => 'auto',
492 )
493 );
494 }
495
496 //skip if post doesn't have image
497 if ( $exclude_without_image && empty( $slide_image ) ) {
498 $post_counter --;
499 continue;
500 }
501 ?>
502 <div class="aux-mc-item" >
503 <div class="aux-slide-media">
504 <div class="aux-media-frame aux-media-image">
505 <?php echo wp_kses_post( $slide_image ); ?>
506 </div>
507 </div>
508 <?php if( $add_title ) { ?>
509 <section class="aux-info-container">
510 <div class="aux-slide-title">
511 <h3><a href="<?php the_permalink(); ?>"><?php echo auxin_get_trimmed_string( get_the_title(), 70, '...'); ?></a></h3>
512 </div>
513 <div class="aux-slide-info">
514 <?php if ( $add_meta ) { ?>
515 <time datetime="<?php echo get_the_date( DATE_W3C ); ?>" title="<?php echo get_the_date( DATE_W3C ); ?>" ><?php echo get_the_date(); ?></time>
516 <span class="entry-tax">
517 <?php // the_category(' '); we can use this template tag, but customizable way is needed! ?>
518 <?php $tax_name = 'category';
519 if( $cat_terms = wp_get_post_terms( $query_res->post->ID, $tax_name ) ){
520 foreach( $cat_terms as $term ){
521 echo '<a href="'. esc_url( get_term_link( $term->slug, $tax_name ) ) .'" title="'.esc_attr__("View all posts in ", 'auxin-elements' ). esc_attr( $term->name ) .'" rel="category" >'. esc_html( $term->name ) .'</a>';
522 }
523 }
524 ?>
525 </span>
526 <?php } ?>
527 </div>
528 </section>
529 <?php } ?>
530 </div>
531
532 <?php endwhile;
533
534 // skip building slider if no slide is generated
535 if( ! $post_counter ){
536 ob_get_clean();
537 return '';
538 }
539
540 if ( $arrows ) { ?>
541 <div class="aux-next-arrow aux-arrow-nav aux-white aux-round aux-hover-slide">
542 <span class="aux-overlay"></span>
543 <span class="aux-svg-arrow aux-medium-right"></span>
544 <span class="aux-hover-arrow aux-svg-arrow aux-medium-right"></span>
545 </div>
546 <div class="aux-prev-arrow aux-arrow-nav aux-white aux-round aux-hover-slide">
547 <span class="aux-overlay"></span>
548 <span class="aux-svg-arrow aux-medium-left"></span>
549 <span class="aux-hover-arrow aux-svg-arrow aux-medium-left"></span>
550 </div>
551 <?php
552 }
553 endif;
554 wp_reset_query();
555
556 // widget footer ------------------------------
557 echo '</div><!-- aux-col-wrapper -->';
558
559 echo wp_kses_post( $result['widget_footer'] );
560
561 return ob_get_clean();
562 }
563