Hi everyone,
Do you know the pop-up that appears when clicking on the “Delete” button of a listing, the one saying “Are you sure you want to permanently delete this listing”?.
I am currently trying to create a similar pop-up that would appear after the listing is deleted (so preferably after the user clicks on “Yes” in the first, default pop-up), but I can’t target the right action to get it triggered. This is the code I tried so far as a test:
add_action('wp_footer', function() {
?>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
// Select the delete buttons inside listings
document.querySelectorAll(".hp-listing__delete").forEach(function(button) {
button.addEventListener("click", function(event) {
event.preventDefault(); // Stop the default delete action for testing
alert("Delete button clicked!");
// Uncomment the next line in the final version to allow deletion
// this.closest("form").submit();
});
});
});
</script>
<?php
});
However, it fails to display when a listing is delete, so I can only assume it’s not targeting the right thing. Any ideas what selector would be right in this case?
Also, if this doesn’t work, can you tell me if it would be possible to modify the default pop-up using the child-theme (so it’s resistant to updated)?
Thanks a lot!