PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.8.1
Shortcodes and extra features for Phlox theme v2.8.1
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 / recent-products.php
auxin-elements / includes / elements Last commit date
about-widget.php 5 years ago accordion-widget.php 5 years ago accordion.php 5 years ago attachment-url.php 5 years ago audio.php 5 years ago before-after.php 5 years ago button.php 5 years ago code.php 5 years ago contact-box.php 5 years ago contact-form.php 5 years ago custom-list.php 5 years ago divider.php 5 years ago dropcap.php 5 years ago facebook.php 5 years ago flickr.php 5 years ago gallery.php 5 years ago general-element-fields.php 5 years ago gmap.php 5 years ago highlight.php 5 years ago image.php 5 years ago instagram-feed.php 5 years ago latest-items.php 5 years ago latest-posts-slider.php 5 years ago popular-posts-widget.php 5 years ago quote.php 5 years ago recent-posts-grid-carousel.php 5 years ago recent-posts-land-style.php 5 years ago recent-posts-masonry.php 5 years ago recent-posts-tiles-carousel.php 5 years ago recent-posts-tiles.php 5 years ago recent-posts-timeline.php 5 years ago recent-posts-widget.php 5 years ago recent-products.php 5 years ago related-posts.php 8 years ago sample-element.php 5 years ago search.php 5 years ago socials-list.php 5 years ago staff.php 5 years ago tab-widget.php 5 years ago tabs.php 5 years ago testimonial.php 5 years ago text.php 5 years ago touch-slider.php 5 years ago video.php 5 years ago
recent-products.php
584 lines
1 <?php
2 /**
3 * Woocommerce Recent Products Element
4 *
5 *
6 * @package Auxin
7 * @license LICENSE.txt
8 * @author averta
9 * @link http://phlox.pro/
10 * @copyright (c) 2010-2021 averta
11 */
12 function auxin_get_the_recent_products_master_array( $master_array ) {
13
14 $master_array['aux_recent_product'] = array(
15 'name' => __("Recent Products", 'auxin-elements' ),
16 'auxin_output_callback' => 'auxin_widget_the_recent_products_callback',
17 'base' => 'aux_recent_product',
18 'description' => __("a Widget for Display Your Store's Products", 'auxin-elements' ),
19 'class' => 'aux-widget-recent-products',
20 'show_settings_on_create' => true,
21 'weight' => 1,
22 'category' => THEME_NAME,
23 'is_so' => true,
24 'is_vc' => true,
25 'is_widget' => true,
26 'is_shortcode' => true,
27 'group' => '',
28 'admin_enqueue_js' => '',
29 'admin_enqueue_css' => '',
30 'front_enqueue_js' => '',
31 'front_enqueue_css' => '',
32 'icon' => 'aux-element aux-pb-icons-grid',
33 'custom_markup' => '',
34 'js_view' => '',
35 'html_template' => '',
36 'deprecated' => '',
37 'content_element' => '',
38 'as_parent' => '',
39 'as_child' => '',
40 'params' => array(
41 array(
42 'heading' => __('Title','auxin-elements' ),
43 'description' => __('Recent products title, leave it empty if you don`t need title.', 'auxin-elements'),
44 'param_name' => 'title',
45 'type' => 'textfield',
46 'value' => '',
47 'holder' => 'textfield',
48 'class' => 'title',
49 'admin_label' => false,
50 'dependency' => '',
51 'weight' => '',
52 'group' => '',
53 'edit_field_class' => ''
54 ),
55 array(
56 'heading' => __('Subtitle','auxin-elements' ),
57 'description' => __('Recent products subtitle, leave it empty if you don`t need title.', 'auxin-elements'),
58 'param_name' => 'subtitle',
59 'type' => 'textfield',
60 'value' => '',
61 'holder' => 'textfield',
62 'class' => 'title',
63 'admin_label' => false,
64 'dependency' => '',
65 'weight' => '',
66 'group' => '',
67 'edit_field_class' => ''
68 ),
69 array(
70 'heading' => __('Categories', 'auxin-elements'),
71 'description' => __('Specifies a category that you want to show posts from it.', 'auxin-elements' ),
72 'param_name' => 'cat',
73 'type' => 'aux_taxonomy',
74 'taxonomy' => 'product_cat',
75 'def_value' => ' ',
76 'holder' => '',
77 'class' => 'cat',
78 'value' => ' ', // should use the taxonomy name
79 'admin_label' => false,
80 'dependency' => '',
81 'weight' => '',
82 'group' => 'Query',
83 'edit_field_class' => ''
84 ),
85 array(
86 'heading' => __('Image aspect ratio', 'auxin-elements'),
87 'description' => '',
88 'param_name' => 'image_aspect_ratio',
89 'type' => 'dropdown',
90 'def_value' => '0.75',
91 'holder' => '',
92 'class' => 'order',
93 'value' =>array (
94 '0.75' => __('Horizontal 4:3' , 'auxin-elements'),
95 '0.56' => __('Horizontal 16:9', 'auxin-elements'),
96 '1.00' => __('Square 1:1' , 'auxin-elements'),
97 '1.33' => __('Vertical 3:4' , 'auxin-elements'),
98 '1.5' => __('Vertical 10:15' , 'auxin-elements'),
99
100 ),
101 'admin_label' => false,
102 'dependency' => '',
103 'weight' => '',
104 'group' => '',
105 'edit_field_class' => ''
106 ),
107 array(
108 'heading' => __('Exclude posts without media','auxin-elements' ),
109 'description' => '',
110 'param_name' => 'exclude_without_media',
111 'type' => 'aux_switch',
112 'value' => '0',
113 'class' => '',
114 'admin_label' => false,
115 'dependency' => '',
116 'weight' => '',
117 'group' => 'Query',
118 'edit_field_class' => ''
119 ),
120 array(
121 'heading' => __('Order by', 'auxin-elements'),
122 'description' => '',
123 'param_name' => 'order_by',
124 'type' => 'dropdown',
125 'def_value' => 'date',
126 'holder' => '',
127 'class' => 'order_by',
128 'value' => array (
129 'date' => __('Date', 'auxin-elements'),
130 'menu_order date' => __('Menu Order', 'auxin-elements'),
131 'title' => __('Title', 'auxin-elements'),
132 'ID' => __('ID', 'auxin-elements'),
133 'rand' => __('Random', 'auxin-elements'),
134 'comment_count' => __('Comments', 'auxin-elements'),
135 'modified' => __('Date Modified', 'auxin-elements'),
136 'author' => __('Author', 'auxin-elements'),
137 'post__in' => __('Inserted Post IDs', 'auxin-elements')
138 ),
139 'admin_label' => false,
140 'dependency' => '',
141 'weight' => '',
142 'group' => 'Query',
143 'edit_field_class' => ''
144 ),
145 array(
146 'heading' => __('Order', 'auxin-elements'),
147 'description' => '',
148 'param_name' => 'order',
149 'type' => 'dropdown',
150 'def_value' => 'DESC',
151 'holder' => '',
152 'class' => 'order',
153 'value' =>array (
154 'DESC' => __('Descending', 'auxin-elements'),
155 'ASC' => __('Ascending', 'auxin-elements'),
156 ),
157 'admin_label' => false,
158 'dependency' => '',
159 'weight' => '',
160 'group' => 'Query',
161 'edit_field_class' => ''
162 ),
163 array(
164 'heading' => __('Only products','auxin-elements' ),
165 'description' => __('If you intend to display ONLY specific products, you should specify the products here. You have to insert the Products IDs that are separated by comma (eg. 53,34,87,25).', 'auxin-elements' ),
166 'param_name' => 'only_products__in',
167 'type' => 'textfield',
168 'value' => '',
169 'holder' => '',
170 'class' => '',
171 'admin_label' => false,
172 'dependency' => '',
173 'weight' => '',
174 'group' => 'Query',
175 'edit_field_class' => ''
176 ),
177 array(
178 'heading' => __('Include products','auxin-elements' ),
179 'description' => __('If you intend to include additional products, you should specify the products here. You have to insert the Products IDs that are separated by comma (eg. 53,34,87,25)', 'auxin-elements' ),
180 'param_name' => 'include',
181 'type' => 'textfield',
182 'value' => '',
183 'holder' => '',
184 'class' => '',
185 'admin_label' => false,
186 'dependency' => '',
187 'weight' => '',
188 'group' => 'Query',
189 'edit_field_class' => ''
190 ),
191 array(
192 'heading' => __('Exclude products','auxin-elements' ),
193 'description' => __('If you intend to exclude specific products from result, you should specify the products here. You have to insert the Products IDs that are separated by comma (eg. 53,34,87,25)', 'auxin-elements' ),
194 'param_name' => 'exclude',
195 'type' => 'textfield',
196 'value' => '',
197 'holder' => '',
198 'class' => '',
199 'admin_label' => false,
200 'dependency' => '',
201 'weight' => '',
202 'group' => 'Query',
203 'edit_field_class' => ''
204 ),
205 array(
206 'heading' => __('Start offset','auxin-elements' ),
207 'description' => __('Number of products to displace or pass over.', 'auxin-elements' ),
208 'param_name' => 'offset',
209 'type' => 'textfield',
210 'value' => '',
211 'holder' => '',
212 'class' => '',
213 'admin_label' => false,
214 'dependency' => '',
215 'weight' => '',
216 'group' => 'Query',
217 'edit_field_class' => ''
218 ),
219 array(
220 'heading' => __('Display products price', 'auxin-elements' ),
221 'param_name' => 'display_price',
222 'type' => 'aux_switch',
223 'def_value' => '',
224 'value' => '1',
225 'holder' => '',
226 'class' => 'display_price',
227 'admin_label' => false,
228 'dependency' => '',
229 'weight' => '',
230 'group' => '',
231 'edit_field_class' => ''
232 ),
233 array(
234 'heading' => __('Display sale badge', 'auxin-elements' ),
235 'param_name' => 'display_sale_badge',
236 'type' => 'aux_switch',
237 'def_value' => '',
238 'value' => '1',
239 'holder' => '',
240 'class' => 'display_sale_badge',
241 'admin_label' => false,
242 'dependency' => '',
243 'weight' => '',
244 'group' => '',
245 'edit_field_class' => ''
246 ),
247 array(
248 'heading' => __('Display product title','auxin-elements' ),
249 'description' => '',
250 'param_name' => 'display_title',
251 'type' => 'aux_switch',
252 'value' => '1',
253 'class' => 'display_title',
254 'admin_label' => false,
255 'dependency' => '',
256 'weight' => '',
257 'group' => '',
258 'edit_field_class' => ''
259 ),
260 array(
261 'heading' => __('Display Categories','auxin-elements' ),
262 'description' => '',
263 'param_name' => 'display_categories',
264 'type' => 'aux_switch',
265 'value' => '1',
266 'holder' => '',
267 'class' => 'display_categories',
268 'admin_label' => false,
269 'weight' => '',
270 'group' => '',
271 'edit_field_class' => ''
272 ),
273 array(
274 'heading' => __('Number of columns', 'auxin-elements'),
275 'description' => '',
276 'param_name' => 'desktop_cnum',
277 'type' => 'dropdown',
278 'def_value' => '4',
279 'holder' => '',
280 'class' => 'num',
281 'value' => array(
282 '1' => '1', '2' => '2', '3' => '3',
283 '4' => '4', '5' => '5', '6' => '6'
284 ),
285 'admin_label' => false,
286 'dependency' => '',
287 'weight' => '',
288 'group' => 'Layout',
289 'edit_field_class' => ''
290 ),
291 array(
292 'heading' => __('Number of columns in tablet size', 'auxin-elements'),
293 'description' => '',
294 'param_name' => 'tablet_cnum',
295 'type' => 'dropdown',
296 'def_value' => 'inherit',
297 'holder' => '',
298 'class' => 'num',
299 'value' => array(
300 'inherit' => 'Inherited from larger',
301 '1' => '1', '2' => '2', '3' => '3',
302 '4' => '4', '5' => '5', '6' => '6'
303 ),
304 'admin_label' => false,
305 'dependency' => '',
306 'weight' => '',
307 'group' => 'Layout',
308 'edit_field_class' => ''
309 ),
310 array(
311 'heading' => __('Number of columns in phone size', 'auxin-elements'),
312 'description' => '',
313 'param_name' => 'phone_cnum',
314 'type' => 'dropdown',
315 'def_value' => '1',
316 'holder' => '',
317 'class' => 'num',
318 'value' => array(
319 '1' => '1', '2' => '2', '3' => '3'
320 ),
321 'admin_label' => false,
322 'dependency' => '',
323 'weight' => '',
324 'group' => 'Layout',
325 'edit_field_class' => ''
326 ),
327 // array(
328 // 'heading' => __('Content layout', 'auxin-elements'),
329 // 'description' => __('Specifies the style of content for each post column.', 'auxin-elements' ),
330 // 'param_name' => 'content_layout',
331 // 'type' => 'dropdown',
332 // 'def_value' => 'default',
333 // 'holder' => '',
334 // 'class' => 'content_layout',
335 // 'value' =>array (
336 // 'default' => __('Full Content', 'auxin-elements'),
337 // 'entry-boxed' => __('Boxed Content', 'auxin-elements')
338 // ),
339 // 'admin_label' => false,
340 // 'dependency' => '',
341 // 'weight' => '',
342 // 'group' => '',
343 // 'edit_field_class' => ''
344 // ),
345 array(
346 'heading' => __('Extra class name','auxin-elements' ),
347 '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' ),
348 'param_name' => 'extra_classes',
349 'type' => 'textfield',
350 'value' => '',
351 'def_value' => '',
352 'holder' => '',
353 'class' => 'extra_classes',
354 'admin_label' => false,
355 'dependency' => '',
356 'weight' => '',
357 'group' => '',
358 'edit_field_class' => ''
359 )
360 )
361 );
362
363 return $master_array;
364 }
365
366 add_filter( 'auxin_master_array_shortcodes', 'auxin_get_the_recent_products_master_array', 10, 1 );
367
368 function auxin_widget_the_recent_products_callback( $atts, $shortcode_content = null ){
369
370 // Defining default attributes
371 $default_atts = array(
372 'title' => '', // header title (required)
373 'subtitle' => '', // header subtitle
374 'cat' => ' ',
375 'num' => '8', // max generated entry
376 'only_products__in' => '', // display only these post IDs. array or string comma separated
377 'include' => '', // include these post IDs in result too. array or string comma separated
378 'exclude' => '', // exclude these post IDs from result. array or string comma separated
379 'offset' => '',
380 'paged' => '',
381 'post_type' => 'product',
382 'taxonomy_name' => 'product_cat', // the taxonomy that we intent to display in post info
383 'tax_args' => '',
384 'order_by' => 'date',
385 'order' => 'DESC',
386 'exclude_without_media' => 0,
387 'display_title' => true,
388 'show_media' => true,
389 'display_categories' => true,
390 'display_button' => true,
391 'preloadable' => false,
392 'preload_preview' => true,
393 'preload_bgcolor' => '',
394 // 'content_layout' => '', // entry-boxed
395 'image_aspect_ratio' => 0.75,
396 'desktop_cnum' => 4,
397 'tablet_cnum' => 'inherit',
398 'phone_cnum' => '1',
399 'display_price' => true,
400 'display_sale_badge' => true,
401 'extra_classes' => '',
402 'template_part_file' => 'recent-products',
403 'extra_template_path' => AUXELS_PUB_DIR . '/templates/woocommerce',
404 'universal_id' => '',
405 'use_wp_query' => false, // true to use the global wp_query, false to use internal custom query
406 'reset_query' => true,
407 'wp_query_args' => array(), // additional wp_query args
408 'custom_wp_query' => '',
409 'base' => 'aux_recent_products',
410 'base_class' => 'aux-widget-recent-products'
411 );
412
413 $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content );
414 extract( $result['parsed_atts'] );
415
416 // get content width
417 global $aux_content_width;
418
419 ob_start();
420
421 if( empty( $cat ) || $cat == " " || ( is_array( $cat ) && in_array( " ", $cat ) ) ) {
422 $tax_args = array();
423 } else {
424 $tax_args = array(
425 array(
426 'taxonomy' => $taxonomy_name,
427 'field' => 'term_id',
428 'terms' => ! is_array( $cat ) ? explode( ",", $cat ) : $cat
429 )
430 );
431 }
432
433 if( $custom_wp_query ){
434 $wp_query = $custom_wp_query;
435
436 } elseif( ! $use_wp_query ){
437
438 // create wp_query to get latest items ---------------------------------
439 $args = array(
440 'post_type' => $post_type,
441 'orderby' => $order_by,
442 'order' => $order,
443 'offset' => $offset,
444 'paged' => $paged,
445 'tax_query' => $tax_args,
446 'post_status' => 'publish',
447 'posts_per_page' => $num,
448 'ignore_sticky_posts' => 1,
449
450 'include_posts__in' => $include, // include posts in this list
451 'posts__not_in' => $exclude, // exclude posts in this list
452 'posts__in' => $only_products__in, // only posts in this list
453
454 'exclude_without_media' => $exclude_without_media,
455 );
456
457 // ---------------------------------------------------------------------
458
459 // add the additional query args if available
460 if( $wp_query_args ){
461 $args = wp_parse_args( $wp_query_args, $args );
462 }
463
464 // pass the args through the auxin query parser
465 $wp_query = new WP_Query( auxin_parse_query_args( $args ) );
466 } else {
467
468 global $wp_query;
469 }
470
471 // widget header ------------------------------
472 echo $result['widget_header'];
473 echo $result['widget_title'];
474 echo '<h4 class="aux-h4 widget-subtitle">' . esc_html( $subtitle ) . '</h4>';
475
476 $phone_break_point = 767;
477 $tablet_break_point = 1025;
478
479 $show_comments = true; // shows comments icon
480 $post_counter = 0;
481 $column_class = '';
482 $item_class = '';
483
484 $columns_custom_styles = '';
485
486 if( ! empty( $loadmore_type ) ) {
487 $item_class .= ' aux-ajax-item';
488 }
489
490 $column_class .= '';
491 $item_class .= ' aux-recent-product-item aux-col';
492
493 // Specifies whether the columns have footer meta or not
494 $column_class .= ' aux-recent-products-wrapper aux-row aux-ajax-view aux-de-col' . $desktop_cnum;
495
496 $tablet_cnum = ('inherit' == $tablet_cnum ) ? $desktop_cnum : $tablet_cnum ;
497 $column_class .= ' aux-tb-col'.$tablet_cnum . ' aux-mb-col'.$phone_cnum;
498
499
500 // automatically calculate the media size if was empty
501 if( empty( $size ) ){
502 $column_media_width = auxin_get_content_column_width( $desktop_cnum, 15, $content_width );
503 $size = array( 'width' => $column_media_width, 'height' => $column_media_width * $image_aspect_ratio );
504 }
505 echo '<div class="'. $column_class .'">';
506
507 $have_posts = $wp_query->have_posts();
508
509 if( $have_posts ){
510
511 while ( $wp_query->have_posts() ) {
512
513 $wp_query->the_post();
514 $post = get_post();
515
516 $post_vars = auxin_get_post_type_media_args(
517 $post,
518 array(
519 'post_type' => $post_type,
520 'request_from' => 'element',
521 'media_width' => $phone_break_point,
522 'media_size' => $size,
523 'upscale_image' => true,
524 'image_from_content' => ! $exclude_without_media, // whether to try to get image from content or not
525 'ignore_media' => ! $show_media,
526 'add_image_hw' => false, // whether add width and height attr or not
527 'preloadable' => $preloadable,
528 'preload_preview' => $preload_preview,
529 'preload_bgcolor' => $preload_bgcolor,
530 'image_sizes' => 'auto',
531 'srcset_sizes' => 'auto'
532 )
533 );
534
535 extract( $post_vars );
536 $the_format = get_post_format( $post );
537
538 // add specific class to current classes for each column
539 $post_classes = $has_attach && $show_media ? 'post column-entry' : 'post column-entry no-media';
540
541 // Generate the markup by template parts
542 if( has_action( $base_class . '-template-part' ) ){
543 do_action( $base_class . '-template-part', $result, $post_vars, $item_class );
544
545 } else {
546 ?>
547 <div <?php wc_product_class( $item_class . ' post-'. $post->ID, $post->ID );?>>
548 <?php
549 include auxin_get_template_file( $template_part_file, '', $extra_template_path );
550 echo '</div>';
551 }
552
553 }
554
555 if( ! $skip_wrappers ) {
556 // End tag for aux-ajax-view wrapper
557 echo '</div>';
558 } else {
559 // Get post counter in the query
560 echo '<span class="aux-post-count hidden">'.$wp_query->post_count.'</span>';
561 echo '<span class="aux-all-posts-count hidden">'.$wp_query->found_posts.'</span>';
562 }
563
564 }
565
566 if( $reset_query ){
567 wp_reset_postdata();
568 }
569
570 // return false if no result found
571 if( ! $have_posts ){
572 ob_get_clean();
573 return false;
574 }
575
576 // widget custom output -----------------------
577
578
579 // widget footer ------------------------------
580 echo $result['widget_footer'];
581
582 return ob_get_clean();
583 }
584