PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.25
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.25
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
fluent-cart / app / Modules / Templating / Bricks / BricksHelper.php

BricksHelper.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.3.25, at app/Modules/Templating/Bricks/BricksHelper.php

66 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Modules\Templating\Bricks;
4
5 use Bricks\Frontend;
6 use FluentCart\Framework\Support\Arr;
7
8 class BricksHelper
9 {
10
11 static public $forcedPost = null;
12
13 public static function getFormCurrentPost()
14 {
15 return self::$forcedPost;
16 }
17
18 public static function setFormCurrentPost($post)
19 {
20 self::$forcedPost = $post;
21 }
22
23 public static function getCategoriesOptions()
24 {
25 $categories = get_terms(array(
26 'taxonomy' => 'product-categories',
27 'hide_empty' => false,
28 'orderby' => 'name'
29 ));
30
31 $options = [];
32 if (!is_wp_error($categories) && !empty($categories)) {
33 foreach ($categories as $category) {
34 $options[$category->term_id] = $category->name;
35 }
36 }
37
38 return $options;
39 }
40
41 public static function renderCollectionCard($settings, $post, $post_index = 1, $uid = '')
42 {
43 $content = Frontend::get_content_wrapper($settings, Arr::get($settings, 'fields', []), $post);
44
45 if ($post_index === 1) {
46 echo "<div data-fluent-client-id='" . esc_attr($uid) . "' data-template-provider='bricks' data-fct-product-card class='fct-product-card repeater-item'>";
47 } else {
48 echo "<div data-fct-product-card class='fct-product-card repeater-item'>";
49 }
50
51 $linkedProduct = isset($settings['linkProduct']) ? $settings['linkProduct'] : false;
52
53 if ($linkedProduct && strpos($content, '<a ') === false) {
54 echo '<a href="' . esc_attr(get_the_permalink($post)) . '">';
55 }
56
57 echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
58
59 if ($linkedProduct && strpos($content, '<a ') === false) {
60 echo '</a>';
61 }
62
63 echo '</div>';
64 }
65 }
66