' . $message . '
';
}
$atts = shortcode_atts(
array(
'title' => $settings['business_name'] ?? __( 'Ask me anything', 'aiohm-knowledge-assistant' ),
'placeholder' => __( 'Type your question here...', 'aiohm-knowledge-assistant' ),
'height' => '400',
'width' => '100%',
'theme' => 'ohm-green',
'position' => 'inline',
'show_branding' => 'true',
'welcome_message' => $settings['welcome_message'] ?? 'Hey there! I am your AI assistant. I can help answer questions about our services and content. Ask me anything!',
'max_height' => '600',
),
$atts,
'aiohm_chat'
);
static $chat_counter = 0;
++$chat_counter;
$chat_id = 'aiohm-chat-' . $chat_counter;
wp_enqueue_script( 'aiohm-chat-shortcode' );
wp_enqueue_style( 'aiohm-chat' );
// Prepare chat configuration
$chat_config = array(
'chat_id' => $chat_id,
'ajax_url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'aiohm_chat_nonce' ),
'chat_action' => 'aiohm_frontend_chat',
'strings' => array(
'error' => __( 'Sorry, something went wrong. Please try again.', 'aiohm-knowledge-assistant' ),
),
'settings' => $settings,
);
$output = '';
// Output configuration script right at the start
$output .= '';
$output .= '
';
$output .= '
';
$output .= '';
$output .= '' . __( 'Ready', 'aiohm-knowledge-assistant' ) . '';
$output .= '
';
$output .= '
';
$output .= '
';
if ( ! empty( $atts['welcome_message'] ) ) {
$output .= '
';
if ( ! empty( $settings['ai_avatar'] ) ) {
$output .= '
' . AIOHM_KB_Core_Init::render_image(
$settings['ai_avatar'],
__( 'AI Avatar', 'aiohm-knowledge-assistant' ),
array( 'style' => 'width:100%; height:100%; border-radius:50%; object-fit: cover;' )
) . '
';
} else {
$output .= '
';
}
$output .= '
' . esc_html( $atts['welcome_message'] ) . '
';
$output .= '
';
}
$output .= '
';
$output .= '
';
if ( $atts['show_branding'] === 'true' ) {
$branding_text = '
' . __( 'Powered by', 'aiohm-knowledge-assistant' ) . ' AIOHM';
$meeting_url = $settings['meeting_button_url'] ?? '';
if ( ! empty( $meeting_url ) ) {
$output .= '
' . __( 'Book a Meeting', 'aiohm-knowledge-assistant' ) . '';
} else {
$output .= '
' . $branding_text . '
';
}
}
$output .= '
'; // aiohm-chat-container
$output .= ''; // aiohm-chat-wrapper
return $output;
}
}