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.

4
  • Show how you add the nonce and how you check it. The problem isn't your javascript code.
    – kaiser
    Apr 30, 2013 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.
    – Xing Lee
    Apr 30, 2013 at 12:53
  • See WordPress Nonces -> Related in Codex
    – kaiser
    Apr 30, 2013 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, 2013 at 16:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.