PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
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 1.2.0 All 47 releases
fluent-cart / app / Modules / Templating / Bricks / Elements / ProductTitle.php

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

140 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace FluentCart\App\Modules\Templating\Bricks\Elements;
3
4 use Bricks\Element;
5
6 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
7
8 class ProductTitle extends Element {
9 public $category = 'fluent-cart';
10 public $name = 'fct-product-title';
11 public $icon = 'ti-text fluent-cart-element-icon';
12 public $tag = 'h1';
13
14 public function get_label() {
15 return esc_html__( 'Product Title', 'fluent-cart' );
16 }
17
18 public function set_controls() {
19 $this->controls['tag'] = [
20 'tab' => 'content',
21 'label' => esc_html__( 'HTML tag', 'fluent-cart' ),
22 'type' => 'select',
23 'options' => [
24 'h1' => 'h1',
25 'h2' => 'h2',
26 'h3' => 'h3',
27 'h4' => 'h4',
28 'h5' => 'h5',
29 'h6' => 'h6',
30 ],
31 'inline' => true,
32 'placeholder' => 'h1',
33 ];
34
35 $this->controls['prefix'] = [
36 'tab' => 'content',
37 'label' => esc_html__( 'Prefix', 'fluent-cart' ),
38 'type' => 'text',
39 'inline' => true,
40 ];
41
42 $this->controls['prefixBlock'] = [
43 'tab' => 'content',
44 'label' => esc_html__( 'Prefix block', 'fluent-cart' ),
45 'type' => 'checkbox',
46 'inline' => true,
47 'required' => [ 'prefix', '!=', '' ],
48 ];
49
50 $this->controls['suffix'] = [
51 'tab' => 'content',
52 'label' => esc_html__( 'Suffix', 'fluent-cart' ),
53 'type' => 'text',
54 'inline' => true,
55 ];
56
57 $this->controls['suffixBlock'] = [
58 'tab' => 'content',
59 'label' => esc_html__( 'Suffix block', 'fluent-cart' ),
60 'type' => 'checkbox',
61 'inline' => true,
62 'required' => [ 'suffix', '!=', '' ],
63 ];
64
65 $this->controls['linkToProduct'] = [
66 'tab' => 'content',
67 'label' => esc_html__( 'Link to product', 'fluent-cart' ),
68 'type' => 'checkbox',
69 ];
70 }
71
72 public function render()
73 {
74 $settings = $this->settings;
75 $post = get_post($this->post_id);
76
77 $prefix = !empty($settings['prefix']) ? $settings['prefix'] : false;
78 $suffix = !empty($settings['suffix']) ? $settings['suffix'] : false;
79 $linkToProduct = isset($settings['linkToProduct']);
80
81 ?>
82 <?php
83 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- render_attributes() handles escaping internally
84 echo "<" . esc_html($this->tag) . " " . $this->render_attributes('_root') . ">";
85 ?>
86 <?php if ($linkToProduct) : ?>
87 <a href="<?php echo esc_url(get_the_permalink($this->post_id)); ?>">
88 <?php endif; ?>
89
90 <?php if ($prefix) : ?>
91 <?php $this->set_attribute('prefix', 'class', ['post-prefix']); ?>
92 <?php if (isset($settings['prefixBlock'])) : ?>
93 <div <?php echo $this->render_attributes('prefix'); ?>>
94 <?php echo wp_kses_post($prefix); ?>
95 </div>
96 <?php else : ?>
97 <span <?php echo $this->render_attributes('prefix'); ?>>
98 <?php echo wp_kses_post($prefix); ?>
99 </span>
100 <?php endif; ?>
101 <?php endif; ?>
102
103 <span><?php echo esc_html($post->post_title); ?></span>
104
105 <?php if ($suffix) : ?>
106 <?php $this->set_attribute('suffix', 'class', ['post-suffix']); ?>
107 <?php if (isset($settings['suffixBlock'])) : ?>
108 <div <?php echo $this->render_attributes('suffix'); ?>>
109 <?php echo wp_kses_post($suffix); ?>
110 </div>
111 <?php else : ?>
112 <span <?php echo $this->render_attributes('suffix'); ?>>
113 <?php echo wp_kses_post($suffix); ?>
114 </span>
115 <?php endif; ?>
116 <?php endif; ?>
117
118 <?php if ($linkToProduct) : ?>
119 </a>
120 <?php endif; ?>
121 <?php echo "</" . esc_html($this->tag) . ">"; ?>
122 <?php
123 }
124
125 public static function render_builder() { ?>
126 <script type="text/x-template" id="tmpl-brxe-product-title">
127 <component :is="tag" class="product-title">
128 <div v-if="settings.prefix && settings.prefixBlock" class="post-prefix" v-html="settings.prefix"></div>
129 <span v-else-if="settings.prefix && !settings.prefixBlock" class="post-prefix" v-html="settings.prefix"></span>
130
131 <span v-html="bricks.wp.post.title"></span>
132
133 <div v-if="settings.suffix && settings.suffixBlock" class="post-suffix" v-html="settings.suffix"></div>
134 <span v-else-if="settings.suffix && !settings.suffixBlock" class="post-suffix" v-html="settings.suffix"></span>
135 </component>
136 </script>
137 <?php
138 }
139 }
140