I am new in WordPress plugin development. how can I call to function on button click with wordPRess shortcode?
<?php
/**
*
*Plugin Name: Testing
*Description:
**/
function showMessage(){
echo '<script>alert("Welcome to custom plugin") </script>';
}
function callFun(){
$button1 = "<button type='button' onclick='showMessage()'>Click to Alert</button>";
return $button1;
}
add_shortcode('example','callFun');
?>