When I activate the plugin I have been trying my hand at making for WordPress which is essentially a chat bot in a modal on the page, WordPress presents the following error:
the plugin generated 1 character of unexpected output during activation. if you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
I have tried to debug this by taking out some lines of code and making sure there are no unexpected outputs in the PHP script, Here is my code:
function my_modal_enqueue_scripts() {
wp_enqueue_style( 'my-modal-styles', plugin_dir_url( __FILE__ ) . 'Modal.css' );
wp_enqueue_script( 'my-modal-script', plugin_dir_url( __FILE__ ) . 'Modal.js', array( 'jquery' ), '', true );
}
add_action( 'wp_enqueue_scripts', 'my_modal_enqueue_scripts' );
function your_plugin_enqueue_google_fonts() {
wp_enqueue_style(
'material-symbols-outlined',
'https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0'
);
wp_enqueue_style(
'material-symbols-rounded',
'https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@48,400,1,0'
);
}
add_action('wp_enqueue_scripts', 'your_plugin_enqueue_google_fonts');
// Function to output the chatbot HTML
function chatbot_output_html() {
?>
<button id="chatbotPlaceholder"></button>
<?php
}
add_action('wp_footer', 'chatbot_output_html');
?>