Add javascript confirmation popup on “Move to Trash” link

I want to open javascript error message when some one clicks on “Move to Trash” link in Publish box in wp-admin

Related posts

Leave a Reply

1 comment

  1. Put the following in your functions.php:

    if (! empty($GLOBALS['pagenow']) && 'post.php' === $GLOBALS['pagenow'])
        add_action('admin_footer', 'trash_click_error');
    function trash_click_error() {
        echo <<<JQUERY
    <script>
        jQuery(function($) {
            $('#delete-action a').unbind();
            $('#delete-action a').click(function(event) {
                event.preventDefault();
                alert('Error!');
                setTimeout(
                    function() {
                        $('#save-action .spinner').hide();
                        $('#publish').removeClass('button-primary-disabled');
                    },
                    1
                );
            });
        });
    </script>
    JQUERY;
    }