| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Hooks\Handlers\BlockEditors; |
| 4 |
|
| 5 |
use FluentCart\App\Services\Renderer\CustomerDashboardButtonRenderer; |
| 6 |
use FluentCart\App\Services\Translations\TransStrings; |
| 7 |
use FluentCart\App\Vite; |
| 8 |
|
| 9 |
class CustomerDashboardButtonBlockEditor extends BlockEditor |
| 10 |
{ |
| 11 |
protected static string $editorName = 'customer-dashboard-button'; |
| 12 |
|
| 13 |
public function getScripts(): array |
| 14 |
{ |
| 15 |
return [ |
| 16 |
[ |
| 17 |
'source' => 'admin/BlockEditor/CustomerDashboardButton/CustomerDashboardButtonBlockEditor.jsx', |
| 18 |
'dependencies' => ['wp-blocks', 'wp-components'] |
| 19 |
] |
| 20 |
]; |
| 21 |
} |
| 22 |
|
| 23 |
public function getStyles(): array |
| 24 |
{ |
| 25 |
return [ |
| 26 |
'admin/BlockEditor/CustomerDashboardButton/style/customer-dashboard-button-block-editor.scss' |
| 27 |
]; |
| 28 |
} |
| 29 |
|
| 30 |
public function supports(): array |
| 31 |
{ |
| 32 |
return [ |
| 33 |
'html' => false, |
| 34 |
'typography' => [ |
| 35 |
'fontSize' => true, |
| 36 |
'fontFamily' => true, |
| 37 |
'fontWeight' => true, |
| 38 |
'lineHeight' => true |
| 39 |
], |
| 40 |
'color' => [ |
| 41 |
'text' => true, |
| 42 |
'background' => true |
| 43 |
], |
| 44 |
'spacing' => [ |
| 45 |
'margin' => true, |
| 46 |
'padding' => true |
| 47 |
], |
| 48 |
'__experimentalBorder' => [ |
| 49 |
'color' => true, |
| 50 |
'radius' => true, |
| 51 |
'width' => true, |
| 52 |
'style' => true, |
| 53 |
'__experimentalDefaultControls' => [ |
| 54 |
'color' => true, |
| 55 |
'radius' => true, |
| 56 |
'width' => true |
| 57 |
] |
| 58 |
], |
| 59 |
'border' => [ |
| 60 |
'color' => true, |
| 61 |
'radius' => true, |
| 62 |
'width' => true, |
| 63 |
'style' => true |
| 64 |
], |
| 65 |
'shadow' => true |
| 66 |
]; |
| 67 |
} |
| 68 |
|
| 69 |
public function localizeData(): array |
| 70 |
{ |
| 71 |
return [ |
| 72 |
$this->getLocalizationKey() => [ |
| 73 |
'slug' => $this->slugPrefix, |
| 74 |
'name' => static::getEditorName(), |
| 75 |
'title' => __('Customer Dashboard Button', 'fluent-cart'), |
| 76 |
'description' => __('Display a button or link that navigates to the customer dashboard.', 'fluent-cart'), |
| 77 |
], |
| 78 |
'fluent_cart_block_translation' => TransStrings::blockStrings(), |
| 79 |
]; |
| 80 |
} |
| 81 |
|
| 82 |
public function render(array $shortCodeAttribute, $block = null) |
| 83 |
{ |
| 84 |
$slug = fluentCart()->config->get('app.slug'); |
| 85 |
|
| 86 |
Vite::enqueueStyle( |
| 87 |
$slug . '-customer-dashboard-button', |
| 88 |
'public/customer-dashboard-button/customer-dashboard-button.scss' |
| 89 |
); |
| 90 |
|
| 91 |
$renderer = new CustomerDashboardButtonRenderer(); |
| 92 |
|
| 93 |
ob_start(); |
| 94 |
$renderer->render($shortCodeAttribute); |
| 95 |
return ob_get_clean(); |
| 96 |
} |
| 97 |
} |
| 98 |
|