'defer')
);
wp_enqueue_script('camhdk-chatbot-script');
break; // No need to check further, stop if the page matches
}
}
}
add_action('wp_enqueue_scripts', 'camhdk_chatbot_enqueue_scripts');
// Step 3: Add chatbot HTML to the footer on specified pages
function camhdk_chatbot_html() {
// Get the user-defined page slugs/IDs from the options table
$selected_pages = get_option('camhdk_chatbot_pages');
// If no pages are defined, don't add the chatbot
if (empty($selected_pages)) {
return;
}
// Convert the entered pages into an array
$pages = explode(',', $selected_pages);
// Trim whitespace from the page slugs/IDs
$pages = array_map('trim', $pages);
// Check if the current page matches any of the selected pages
foreach ($pages as $page) {
// Check if the page exists (valid slug or ID)
if (is_page($page)) {
?>