mirror of
https://github.com/Heretek-AI/heretek-control-core.git
synced 2026-10-12 02:03:55 +00:00
39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?php
|
|
/**
|
|
* AI Chat Gutenberg Editor integration.
|
|
*
|
|
* Enqueues the AI Chat floating button in the block editor when enabled.
|
|
*
|
|
* @package EMCP_Tools
|
|
* @since 3.1.0
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
|
|
|
class EMCP_Tools_Gutenberg_Editor {
|
|
|
|
public static function init(): void {
|
|
add_action( 'enqueue_block_editor_assets', array( __CLASS__, 'enqueue' ) );
|
|
}
|
|
|
|
public static function enqueue(): void {
|
|
if ( ! class_exists( 'EMCP_Tools_AI_Chat_Module' ) || ! EMCP_Tools_AI_Chat_Module::is_enabled() ) {
|
|
return;
|
|
}
|
|
|
|
wp_enqueue_style( 'emcp-ai-chat-css', plugins_url( 'assets/css/ai-chat.css', EMCP_TOOLS_BASENAME ), array(), EMCP_TOOLS_VERSION );
|
|
wp_enqueue_script( 'emcp-ai-chat-js', plugins_url( 'assets/js/ai-chat.js', EMCP_TOOLS_BASENAME ), array( 'jquery' ), EMCP_TOOLS_VERSION, true );
|
|
wp_localize_script(
|
|
'emcp-ai-chat-js',
|
|
'emcpAiChat',
|
|
array(
|
|
'endpoint' => rest_url( 'emcp/v1/chat' ),
|
|
'nonce' => wp_create_nonce( 'wp_rest' ),
|
|
'context' => 'gutenberg',
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
EMCP_Tools_Gutenberg_Editor::init();
|