• Resolved muradko

    (@muradko)


    Hello friends,

    so i have a small plugin where i am creating an admin menu and then directing to another php file that is being shown when i press on the item. inside the php i created a button but i do not know how to make the button do something when being clicked. i tried so much js seems not to be working:

    add_action(‘admin_menu’, ‘my_admin_menu’);

    function my_admin_menu() {
    add_menu_page(
    ‘MyPlugin’,
    ‘MyPlugin’,
    ‘manage_options’,
    plugin_dir_path(FILE) . ‘view.php’,
    null,
    ‘dashicons-saved’,
    15
    );
    }

    function wptuts_scripts_basic()
    {
    // Register the script like this for a theme:
    wp_register_script( ‘custom-script’, plugin_dir_path(FILE) . ‘app.js’ );
    wp_enqueue_script( ‘custom-script’ );
    }

    add_action( ‘wp_enqueue_scripts’, ‘wptuts_scripts_basic’ );

    ——————————-

    app.js :

    document.getElementById(“test”).addEventListener(“click”, function () {
    console.log(“hello”);
    })

    • This topic was modified 2 years, 4 months ago by muradko.
    • This topic was modified 2 years, 4 months ago by muradko.
    • This topic was modified 2 years, 4 months ago by muradko.
    • This topic was modified 2 years, 4 months ago by muradko.
    • This topic was modified 2 years, 4 months ago by muradko.

The topic ‘custom button inside admin menu’ is closed to new replies.