PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
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 / SearchBarBlockEditor.php

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

60 lines 2.0 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\SearchBarShortCode;
6 use FluentCart\App\Services\Translations\TransStrings;
7 use FluentCart\App\Vite;
8 use FluentCart\Framework\Support\Arr;
9
10 class SearchBarBlockEditor extends BlockEditor
11 {
12 protected static string $editorName = 'fluent-products-search-bar';
13
14 public function getScripts(): array
15 {
16 return [
17 [
18 'source' => 'admin/BlockEditor/SearchBar/SearchBarBlockEditor.jsx',
19 'dependencies' => ['wp-blocks', 'wp-components']
20 ]
21 ];
22 }
23
24 public function getStyles(): array
25 {
26 return ['admin/BlockEditor/SearchBar/style/searchbar-block-editor.css'];
27 }
28
29 public function localizeData(): array
30 {
31 return [
32 $this->getLocalizationKey() => [
33 'slug' => $this->slugPrefix,
34 'name' => static::getEditorName(),
35 'title' => __('Product Search', 'fluent-cart'),
36 ],
37 'fluent_cart_block_editor_asset' => [
38 'placeholder_image' => Vite::getAssetUrl('images/placeholder.svg'),
39 ],
40 'fluent_cart_block_translation' => TransStrings::blockStrings()
41 ];
42 }
43
44 public function render(array $shortCodeAttribute, $block = null): string
45 {
46 $urlMode = Arr::get($shortCodeAttribute, 'url_mode');
47 $categoryMode = Arr::get($shortCodeAttribute, 'category_mode');
48 $linkWithShopApp = Arr::get($shortCodeAttribute, 'link_with_shop_app');
49 $showThumbnail = Arr::get($shortCodeAttribute, 'show_thumbnail', true);
50
51 return SearchBarShortCode::make([
52 'url_mode' => !empty($urlMode) ? $urlMode : 'new-tab',
53 'category_mode' => !empty($categoryMode) ? $categoryMode : '',
54 'link_with_shop_app' => !empty($linkWithShopApp) ? $linkWithShopApp : '',
55 'show_thumbnail' => $showThumbnail,
56 ])->renderShortcode($block);
57 }
58
59 }
60