| @@ -21,14 +21,23 @@ | ||
| 21 | 21 | FLUENT_SUPPORT_VERSION, |
| 22 | 22 | true |
| 23 | 23 | ); |
| 24 | 24 | |
| 25 | + wp_register_style( | |
| 26 | + 'fluent-support/customer-portal-block-style', | |
| 27 | + $assets . 'block-editor/css/fs_block.css', | |
| 28 | + array(), | |
| 29 | + FLUENT_SUPPORT_VERSION | |
| 30 | + ); | |
| 31 | + | |
| 25 | 32 | wp_localize_script('fluent-support/customer-portal', 'fluent_support_vars', [ |
| 26 | 33 | 'rest' => $this->getRestInfo(), |
| 27 | 34 | ]); |
| 28 | 35 | |
| 29 | 36 | register_block_type('fluent-support/customer-portal', array( |
| 37 | + 'api_version' => 3, | |
| 30 | 38 | 'editor_script' => 'fluent-support/customer-portal', |
| 39 | + 'editor_style' => 'fluent-support/customer-portal-block-style', | |
| 31 | 40 | 'render_callback' => array($this, 'renderBlock'), |
| 32 | 41 | 'attributes' => BlockAttributes::CustomerPortalAttributes(), |
| 33 | 42 | )); |
| 34 | 43 | } |
| @@ -50,8 +59,12 @@ | ||
| 50 | 59 | } |
| 51 | 60 | |
| 52 | 61 | public function renderBlock($attributes) |
| 53 | 62 | { |
| 63 | + if (defined('REST_REQUEST') && REST_REQUEST) { | |
| 64 | + return ''; | |
| 65 | + } | |
| 66 | + | |
| 54 | 67 | $param = ''; |
| 55 | 68 | |
| 56 | 69 | if (Arr::get($attributes, 'showLogoutButton')) { |
| 57 | 70 | $param = "show_logout=yes"; |
| @@ -60,9 +73,9 @@ | ||
| 60 | 73 | if ($selectedMailbox = Arr::get($attributes, 'selectedMailbox')) { |
| 61 | 74 | $param .= " business_box_id='" . esc_attr($selectedMailbox) . "'"; |
| 62 | 75 | } |
| 63 | 76 | |
| 64 | - $param .= " attributes='" . esc_attr(json_encode($attributes)) . "'"; | |
| 77 | + $param .= " attributes='" . esc_attr( base64_encode( wp_json_encode( $attributes, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ) ) . "'"; | |
| 65 | 78 | |
| 66 | 79 | return do_shortcode("[fluent_support_portal $param]"); |
| 67 | 80 | } |
| 68 | 81 | } |