1

I want to move a post in trash but the condition is that simultaneously I need to delete some more posts. Sample Code:

jQuery(function($) {
    $('#delete-action a').unbind();
    $('#delete-action a').click(function(event) {
        event.preventDefault();
    openbox('Trash Child Posts', 1);
        setTimeout(
            function() {
                $('#save-action .spinner').hide();
                $('#publish').removeClass('button-primary-disabled');
            },
            1
        );
    });
});

It pop ups a new popup to delete the child post.

    var trash_blog = $('div#trash-button');
$("#trash-button").click( function()
       {
         TrashBlogs.each(function(){
        var allVals = [];
        $('div#box :checked').each(function() {
          allVals.push($(this).val());
        });

        window.location.replace("post.php?post="+post_id
            +"&action=trash&_wpnonce=20a76fd1e5&blog_id="+allVals);
    });
       }
    );`

Now the problem: How to bypass the nonce value when window.location executes?
After redirection it says 'Are you Sure to do this, Please try again' because nonce value doesn't match.

  • Show how you add the nonce and how you check it. The problem isn't your javascript code. – kaiser Apr 30 '13 at 12:22
  • Still I am not creating the nonce. I want to ask how can we do that so I can pass nonce through java script. – Sumit Apr 30 '13 at 12:53
  • See WordPress Nonces -> Related in Codex – kaiser Apr 30 '13 at 13:34
  • Вo you need additional deletion logic to run in JS? Why not implement it on PHP level, using hooks? – Rarst Apr 30 '13 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.