Asking popup for delete post in WordPress [closed]

Yes, it’s possible.

You have to create a JavaScript File and enqueue this file for admin use.

This hook is to add files for the backend:

add_action( 'admin_enqueue_scripts', 'your_function_name' );

This hook is to add files for the frontend:

add_action( 'wp_enqueue_scripts', 'your_function_name' );

So we need to use the admin_enqueue_scripts hook and create our function:

function your_function_name() {
    wp_enqueue_script( 'script', get_template_directory_uri() . '/path/to/admin.js', array( 'jquery' ), 1.1, true );
}

Next create your admin.js file in your template directory. In my case it’s dist/css/admin.js (in the example above path/to/admin.js)

jQuery(function ($) {
  console.log('load admin.js');
})

You will see the console log as logged in user in your wordpress backend in the developer tools.

Add the following content in the admin.js file:

jQuery(function ($) {
    $('.submitdelete').each(function(e) {
        $(this).on('click', function(e) {      
            if( ! confirm("You really want to delete the post?") ) {
                e.preventDefault();
                return;
            }          
        })
    })
})

I looked for the class of the “Trash” link. In my case the trash link has the class=”submitdelete”.

I create click event which will triggered if the user submit the confirmation form.