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 / BlockTemplates / ProductModalTemplate.php

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

83 lines 2.1 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\BlockTemplates;
4
5 /**
6 * ProductCategoryTemplate class.
7 *
8 */
9 class ProductModalTemplate
10 {
11
12 /**
13 * The slug of the template.
14 *
15 * @var string
16 */
17 const SLUG = 'fct-single-product-modal';
18
19 /**
20 * Initialization method.
21 */
22 public function init()
23 {
24 register_block_template('fluent-cart//fct-single-product-modal', [
25 'title' => $this->getTitle(),
26 'description' => $this->getDescription(),
27 'content' => $this->getDefaultTemplate(),
28 ]);
29 }
30
31 /**
32 * Returns the title of the template.
33 *
34 * @return string
35 */
36 public function getTitle()
37 {
38 return _x('Single Product Modal', 'Template name', 'fluent-cart');
39 }
40
41 /**
42 * Returns the description of the template.
43 *
44 * @return string
45 */
46 public function getDescription()
47 {
48 return __('Template for Single Product Modal.', 'fluent-cart');
49 }
50
51
52 public function getDefaultTemplate()
53 {
54 ob_start();
55 ?>
56 <!-- wp:group {"tagName":"main","templateLock":"contentOnly","lock":{"move":false,"remove":false},"className":"alignfull is-style-default","layout":{"type":"default"}} -->
57 <main class="wp-block-group alignfull is-style-default">
58 <!-- wp:group {"lock":{"move":false,"remove":false},"align":"wide","layout":{"type":"default"}} -->
59 <div class="wp-block-group alignwide"><!-- wp:shortcode -->[fluent_cart_product_header]
60 <!-- /wp:shortcode --></div>
61 <!-- /wp:group --></main>
62 <!-- /wp:group -->
63 <?php
64 return ob_get_clean();
65 }
66
67 /**
68 * Render the template with custom content if modified by user
69 *
70 * @return string
71 */
72 public function render()
73 {
74 $templates = get_block_templates(['slug__in' => [self::SLUG]]);
75 if (!empty($templates) && isset($templates[0]->content)) {
76 $content = $templates[0]->content;
77 return do_shortcode(do_blocks($content));
78 }
79
80 return do_shortcode(do_blocks($this->getDefaultTemplate()));
81 }
82 }
83