# fluent-support/1.10.2/app/Hooks/Handlers/BlockEditorHandler.php

Fluent Support – Helpdesk &amp; Customer Support Ticket System, version 1.10.2. 69 lines.

- Page: https://pluginprobe.com/plugins/fluent-support/1.10.2/code/app/Hooks/Handlers/BlockEditorHandler.php
- Raw: https://pluginprobe.com/plugins/fluent-support/1.10.2/raw/app/Hooks/Handlers/BlockEditorHandler.php
- Modified: 2025-11-06T15:00:16+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-support/1.10.2/code/app/Hooks/Handlers/BlockEditorHandler.php#L10-L20`.

```php
<?php

namespace FluentSupport\App\Hooks\Handlers;

use FluentSupport\App\App;
use FluentSupport\Framework\Support\Arr;
use FluentSupport\App\Services\Blocks\BlockAttributes;

class BlockEditorHandler
{
    public function init()
    {
        $app = App::getInstance();

        $assets = $app['url.assets'];

        wp_register_script(
            'fluent-support/customer-portal',
            $assets . 'block-editor/js/fs_block.js',
            array('wp-blocks', 'wp-components', 'wp-block-editor', 'wp-element'),
            FLUENT_SUPPORT_VERSION,
            true
        );

        wp_localize_script('fluent-support/customer-portal', 'fluent_support_vars', [
            'rest' => $this->getRestInfo(),
        ]);

        register_block_type('fluent-support/customer-portal', array(
            'editor_script'   => 'fluent-support/customer-portal',
            'render_callback' => array($this, 'renderBlock'),
            'attributes'      => BlockAttributes::CustomerPortalAttributes(),
        ));
    }

    protected function getRestInfo()
    {
        $app = App::getInstance();

        $ns = $app->config->get('app.rest_namespace');
        $v = $app->config->get('app.rest_version');

        return [
            'base_url'  => esc_url_raw(rest_url()),
            'url'       => rest_url($ns . '/' . $v),
            'nonce'     => wp_create_nonce('wp_rest'),
            'namespace' => $ns,
            'version'   => $v
        ];
    }

    public function renderBlock($attributes)
    {
        $param = '';

        if (Arr::get($attributes, 'showLogoutButton')) {
            $param = "show_logout=yes";
        }

        if ($selectedMailbox = Arr::get($attributes, 'selectedMailbox')) {
            $param .= " business_box_id='" . esc_attr($selectedMailbox) . "'";
        }

        $param .= " attributes='" . esc_attr(json_encode($attributes)) . "'";

        return do_shortcode("[fluent_support_portal $param]");
    }
}

```
