PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 1.10.5
Fluent Support – Helpdesk & Customer Support Ticket System v1.10.5
2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 68 releases
fluent-support / app / Hooks / Handlers / BlockEditorHandler.php

BlockEditorHandler.php in Fluent Support – Helpdesk & Customer Support Ticket System 1.10.5, at app/Hooks/Handlers/BlockEditorHandler.php

69 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\App\Hooks\Handlers;
4
5 use FluentSupport\App\App;
6 use FluentSupport\Framework\Support\Arr;
7 use FluentSupport\App\Services\Blocks\BlockAttributes;
8
9 class BlockEditorHandler
10 {
11 public function init()
12 {
13 $app = App::getInstance();
14
15 $assets = $app['url.assets'];
16
17 wp_register_script(
18 'fluent-support/customer-portal',
19 $assets . 'block-editor/js/fs_block.js',
20 array('wp-blocks', 'wp-components', 'wp-block-editor', 'wp-element'),
21 FLUENT_SUPPORT_VERSION,
22 true
23 );
24
25 wp_localize_script('fluent-support/customer-portal', 'fluent_support_vars', [
26 'rest' => $this->getRestInfo(),
27 ]);
28
29 register_block_type('fluent-support/customer-portal', array(
30 'editor_script' => 'fluent-support/customer-portal',
31 'render_callback' => array($this, 'renderBlock'),
32 'attributes' => BlockAttributes::CustomerPortalAttributes(),
33 ));
34 }
35
36 protected function getRestInfo()
37 {
38 $app = App::getInstance();
39
40 $ns = $app->config->get('app.rest_namespace');
41 $v = $app->config->get('app.rest_version');
42
43 return [
44 'base_url' => esc_url_raw(rest_url()),
45 'url' => rest_url($ns . '/' . $v),
46 'nonce' => wp_create_nonce('wp_rest'),
47 'namespace' => $ns,
48 'version' => $v
49 ];
50 }
51
52 public function renderBlock($attributes)
53 {
54 $param = '';
55
56 if (Arr::get($attributes, 'showLogoutButton')) {
57 $param = "show_logout=yes";
58 }
59
60 if ($selectedMailbox = Arr::get($attributes, 'selectedMailbox')) {
61 $param .= " business_box_id='" . esc_attr($selectedMailbox) . "'";
62 }
63
64 $param .= " attributes='" . esc_attr(json_encode($attributes)) . "'";
65
66 return do_shortcode("[fluent_support_portal $param]");
67 }
68 }
69