PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.21
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.21
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 / Hooks / Handlers / BlockEditors / CustomerProfileBlockEditor.php

CustomerProfileBlockEditor.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.3.21, at app/Hooks/Handlers/BlockEditors/CustomerProfileBlockEditor.php

83 lines 2.7 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\Hooks\Handlers\BlockEditors;
4
5 use FluentCart\App\Hooks\Handlers\ShortCodes\CustomerProfileHandler;
6 use FluentCart\Framework\Support\Arr;
7
8
9
10 class CustomerProfileBlockEditor extends BlockEditor
11 {
12 protected static string $editorName = 'customer-profile';
13
14 public function getScripts(): array
15 {
16 return [
17 [
18 'source' => 'admin/BlockEditor/CustomerProfile/CustomerProfileBlockEditor.jsx',
19 'dependencies' => ['wp-blocks', 'wp-components']
20 ]
21 ];
22 }
23
24 public function getStyles(): array
25 {
26 return ['admin/BlockEditor/CustomerProfile/style/customer-profile-block-editor.scss'];
27 }
28
29 public function localizeData(): array
30 {
31 return [
32 $this->getLocalizationKey() => [
33 'slug' => $this->slugPrefix,
34 'name' => static::getEditorName(),
35 'title' => __('Customer Dashboard', 'fluent-cart'),
36 ]
37 ];
38 }
39
40 public function render(array $shortCodeAttribute, $block = null): string
41 {
42 $defaultsTitles = [
43 'purchaseHistory' => __('Purchase History', 'fluent-cart'),
44 'subscriptions' => __('Subscriptions', 'fluent-cart'),
45 'licenses' => __('Licenses', 'fluent-cart'),
46 'downloads' => __('Downloads', 'fluent-cart')
47 ];
48
49 $sectionTitles = Arr::get($shortCodeAttribute, 'sectionTitles', $defaultsTitles);
50 $jsonTitles = wp_json_encode($sectionTitles);
51 $colors = Arr::get($shortCodeAttribute, 'colors', []);
52
53
54
55 $colorStrings = [];
56 // Iterate over each color group (e.g., generalColors)
57 foreach ($colors as $colorGroup) {
58 // Iterate over each color within the color group
59 foreach ($colorGroup as $key => $color) {
60 $value = $color['value'];
61
62 if (is_array($value)) {
63 // Convert box values (like padding/margin) to CSS shorthand string
64 $top = $value['top'] ?? '0';
65 $right = $value['right'] ?? '0';
66 $bottom = $value['bottom'] ?? '0';
67 $left = $value['left'] ?? '0';
68 $value = trim("$top $right $bottom $left");
69 }
70 // Append each color key and its value to the $colorStrings array
71 $colorStrings[] = $key . '=' . $value;
72 }
73 }
74
75 $allColorStrings = implode(', ', $colorStrings);
76
77 return "[" . CustomerProfileHandler::SHORT_CODE .
78 " section_titles='{$jsonTitles}'" .
79 " colors='{$allColorStrings}'" .
80 " ]";
81 }
82 }
83