I'm trying to build my first WordPress plugin, and have admin menu labels already created using the add_menu_page() and content with a callable function in my functions.php file. For the life of me, I can't seem to add any javascript functions, or link to an external php page in the same plugin directory.
Has anyone else been able to do this?
Thanks!
Here's a code example. The code is a bit clunky, and I was wondering if there's a way to improve this/
function mt_sublevel_page() {
echo "<h2>" . __( 'Welcome', 'menu-test' ) . "</h2>";
echo '<div class="wrap">';
echo '<input type="button" value="Text Button" onclick="demo()" style="background-color:blue;">';
echo '</div>';
echo '<p class="test"></p>';
echo '<script>';
echo 'function demo() {var x = "Hello";document.getElementId("test").innerHTML=x;}';
echo '<script>';
}