esc_html__('Chat Instances', 'ai-chatbot-builder'), 'singular_name' => esc_html__('Chat Instance', 'ai-chatbot-builder'), 'menu_name' => esc_html__('Chat Instances', 'ai-chatbot-builder'), 'name_admin_bar' => esc_html__('Chat Instance', 'ai-chatbot-builder'), 'add_new' => esc_html__('Add New', 'ai-chatbot-builder'), 'add_new_item' => esc_html__('Add New Chat Instance', 'ai-chatbot-builder'), 'new_item' => esc_html__('New Chat Instance', 'ai-chatbot-builder'), 'edit_item' => esc_html__('Edit Chat Instance', 'ai-chatbot-builder'), 'view_item' => esc_html__('View Chat Instance', 'ai-chatbot-builder'), 'all_items' => esc_html__('All Chat Instances', 'ai-chatbot-builder'), 'search_items' => esc_html__('Search Chat Instances', 'ai-chatbot-builder'), 'parent_item_colon' => esc_html__('Parent Chat Instances:', 'ai-chatbot-builder'), 'not_found' => esc_html__('No chat instances found.', 'ai-chatbot-builder'), 'not_found_in_trash' => esc_html__('No chat instances found in Trash.', 'ai-chatbot-builder'), ); $args = array( 'labels' => $labels, 'public' => false, 'publicly_queryable' => false, 'show_ui' => true, 'show_in_menu' => 'aichatbotbuilder_settings', 'query_var' => true, 'rewrite' => array('slug' => 'aichatbotbuilder-chat'), 'capability_type' => 'post', 'has_archive' => false, 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title'), ); register_post_type('aichatbot_chat', $args); } /** * Adds meta boxes for chat settings. */ public function add_meta_boxes(): void { add_meta_box( 'aichatbot_chat_settings', __('Chat Settings', 'ai-chatbot-builder'), array($this, 'render_meta_box'), 'aichatbot_chat', 'normal', 'high' ); } /** * Enqueues WP color picker assets and admin script for meta box. * * @param string $hook Current admin page hook. */ public function enqueue_admin_scripts(string $hook): void { global $post; if (in_array($hook, array('post.php', 'post-new.php'), true) && isset($post) && $post->post_type === 'aichatbot_chat') { wp_enqueue_style('wp-color-picker'); wp_enqueue_script('wp-color-picker'); wp_enqueue_script('aichatbotbuilder-admin', AICHATBOTBUILDER_URL . 'assets/js/aichatbotbuilder-admin.js', array('wp-color-picker', 'jquery'), AICHATBOTBUILDER_VERSION, true); } } /** * Renders meta box fields. * * @param \WP_Post $post The current post object. */ public function render_meta_box($post): void { wp_nonce_field('aichatbot_chat_settings_nonce', 'aichatbot_chat_settings_nonce'); $shortcode = sprintf('[aichatbot_chat id="%d"]', $post->ID); $prompt = get_post_meta($post->ID, 'aichatbotbuilder_initial_prompt', true); $bg = get_post_meta($post->ID, 'aichatbotbuilder_bg_color', true); $user_color = get_post_meta($post->ID, 'aichatbotbuilder_user_color', true); $bot_color = get_post_meta($post->ID, 'aichatbotbuilder_bot_color', true); $position = get_post_meta($post->ID, 'aichatbotbuilder_position', true); $z_index = get_post_meta($post->ID, 'aichatbotbuilder_z_index', true); $z_index = $z_index ?: 9999; $container_border_color = get_post_meta($post->ID, 'aichatbotbuilder_container_border_color', true); $container_border_width = get_post_meta($post->ID, 'aichatbotbuilder_container_border_width', true); $container_border_radius = get_post_meta($post->ID, 'aichatbotbuilder_container_border_radius', true); $container_max_width = get_post_meta($post->ID, 'aichatbotbuilder_container_max_width', true); $container_max_width = $container_max_width ?: 400; $container_min_height = get_post_meta($post->ID, 'aichatbotbuilder_container_min_height', true); $container_min_height = $container_min_height ?: 450; $input_bg_color = get_post_meta($post->ID, 'aichatbotbuilder_input_bg_color', true); $input_text_color = get_post_meta($post->ID, 'aichatbotbuilder_input_text_color', true); $input_border_color = get_post_meta($post->ID, 'aichatbotbuilder_input_border_color', true); $input_border_radius = get_post_meta($post->ID, 'aichatbotbuilder_input_border_radius', true); $input_border_width = get_post_meta($post->ID, 'aichatbotbuilder_input_border_width', true); $button_bg_color = get_post_meta($post->ID, 'aichatbotbuilder_button_bg_color', true); $button_text_color = get_post_meta($post->ID, 'aichatbotbuilder_button_text_color', true); $button_border_color = get_post_meta($post->ID, 'aichatbotbuilder_button_border_color', true); $button_border_radius = get_post_meta($post->ID, 'aichatbotbuilder_button_border_radius', true); $button_border_width = get_post_meta($post->ID, 'aichatbotbuilder_button_border_width', true); $placeholder_text = get_post_meta($post->ID, 'aichatbotbuilder_placeholder_text', true); $send_button_text = get_post_meta($post->ID, 'aichatbotbuilder_send_button_text', true); $clear_button_text = get_post_meta($post->ID, 'aichatbotbuilder_clear_button_text', true); $clear_bg_color = get_post_meta($post->ID, 'aichatbotbuilder_clear_bg_color', true); $clear_text_color = get_post_meta($post->ID, 'aichatbotbuilder_clear_text_color', true); $clear_border_color = get_post_meta($post->ID, 'aichatbotbuilder_clear_border_color', true); $clear_border_width = get_post_meta($post->ID, 'aichatbotbuilder_clear_border_width', true); $clear_border_radius = get_post_meta($post->ID, 'aichatbotbuilder_clear_border_radius', true); $style_preset = get_post_meta($post->ID, 'aichatbotbuilder_style_preset', true); $style_preset = $style_preset ?: 'apple'; $greeting_message = get_post_meta($post->ID, 'aichatbotbuilder_greeting_message', true); $greeting_message = $greeting_message ?: __('How can we help you?', 'ai-chatbot-builder'); $greeting_bg_color = get_post_meta($post->ID, 'aichatbotbuilder_greeting_bg_color', true); $greeting_text_color = get_post_meta($post->ID, 'aichatbotbuilder_greeting_text_color', true); $greeting_border_color = get_post_meta($post->ID, 'aichatbotbuilder_greeting_border_color', true); $greeting_border_width = get_post_meta($post->ID, 'aichatbotbuilder_greeting_border_width', true); $greeting_border_radius = get_post_meta($post->ID, 'aichatbotbuilder_greeting_border_radius', true); $typing_color = get_post_meta($post->ID, 'aichatbotbuilder_typing_color', true); $typing_color = $typing_color ?: ''; // Apply default values if empty $bg = $bg ?: '#ffffff'; $user_color = $user_color ?: '#e1ffc7'; $bot_color = $bot_color ?: '#f1f1f1'; $container_border_color = $container_border_color ?: '#ccc'; $container_border_width = $container_border_width ?: 1; $container_border_radius = $container_border_radius ?: 0; $input_bg_color = $input_bg_color ?: '#ffffff'; $input_text_color = $input_text_color ?: '#000000'; $input_border_color = $input_border_color ?: '#ccc'; $input_border_radius = $input_border_radius ?: 4; $input_border_width = $input_border_width ?: 1; $button_bg_color = $button_bg_color ?: '#0073aa'; $button_text_color = $button_text_color ?: '#ffffff'; $button_border_color = $button_border_color ?: '#0073aa'; $button_border_radius = $button_border_radius ?: 4; $button_border_width = $button_border_width ?: 1; $clear_bg_color = $clear_bg_color ?: '#f1f1f1'; $clear_text_color = $clear_text_color ?: '#000000'; $clear_border_color = $clear_border_color ?: '#ccc'; $clear_border_width = $clear_border_width ?: 1; $clear_border_radius = $clear_border_radius ?: 4; $placeholder_text = $placeholder_text ?: esc_html__('Type a message...', 'ai-chatbot-builder'); $send_button_text = $send_button_text ?: esc_html__('Send', 'ai-chatbot-builder'); $clear_button_text = $clear_button_text ?: esc_html__('Clear', 'ai-chatbot-builder'); $greeting_bg_color = $greeting_bg_color ?: '#f1f1f1'; $greeting_text_color = $greeting_text_color ?: '#000000'; $greeting_border_color = $greeting_border_color ?: '#ccc'; $greeting_border_width = $greeting_border_width ?: 1; $greeting_border_radius = $greeting_border_radius ?: 4; // Launcher enabled toggle and button meta $launcher_enabled = get_post_meta($post->ID, 'aichatbotbuilder_launcher_enabled', true); $launcher_enabled = '' === $launcher_enabled ? '1' : $launcher_enabled; // Launcher button meta and defaults $launcher_icon_color = get_post_meta($post->ID, 'aichatbotbuilder_launcher_icon_color', true); $launcher_bg_color = get_post_meta($post->ID, 'aichatbotbuilder_launcher_bg_color', true); $launcher_animation = get_post_meta($post->ID, 'aichatbotbuilder_launcher_animation', true); $launcher_position = get_post_meta($post->ID, 'aichatbotbuilder_launcher_position', true); $launcher_position = $launcher_position ?: 'above'; // Set defaults for launcher button $launcher_icon_color = $launcher_icon_color ?: '#ffffff'; $launcher_bg_color = $launcher_bg_color ?: '#0073aa'; $launcher_animation = $launcher_animation ?: 'fade'; // Header title and subtitle $header_title = get_post_meta($post->ID, 'aichatbotbuilder_header_title', true); $header_title = $header_title ?: __('Send a message', 'ai-chatbot-builder'); $header_subtitle = get_post_meta($post->ID, 'aichatbotbuilder_header_subtitle', true); $header_subtitle = $header_subtitle ?: __('Online and ready to help', 'ai-chatbot-builder'); ?>



ID, 'aichatbotbuilder_memory_enabled', true); $memory_enabled = '' === $memory_enabled ? '1' : $memory_enabled; $memory_length = get_post_meta($post->ID, 'aichatbotbuilder_memory_length', true); $memory_length = '' === $memory_length ? 10 : absint($memory_length); ?>






























/>