Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Embarrassingly big hole in my understanding!

When I've finished editing a post and click the big blue "Update" button, what happens next? In particular, how does the 'pre-post-update' hook (which, being php, exists only on the server) manage to intercept my request?

I imagine that either there's something clever going on with Ajax, or - more likely? - that the button action reloads the page, giving the hook a chance to do its thing.

The practical application is as follows:

I have a metabox where (amongst other things) I allow the user to re-order the rows of a table using jQuery UI Sortable. Rather than update the database every time the user re-orders the table or by having a separate "Save changes" button, I'd prefer to have the updating happen when the blue WordPress "Update" button is pressed.

The names of some of the WordPress hooks ('save_post', 'pre_post_update') seduced me into thinking I could use them to capture this client-side data - but if the page has to reload before they're called, this is presumably not possible.

The nearest I've got to an answer is in this impressive labour of love: http://humanshell.net/2011/08/14/wordpress-initialization/ Now, if someone could do the same sort of explanation for what happens when the "Update" button is pressed...

Many thanks if you can help to put me out of my ignorance!

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Yes, the page reloads. The form data is sent as a POST request to the server for processing. Whatever your jQuery script does needs to be reflected in some sort of input field(s) so that data can be passed to the server and intercepted by your save_post action.

share|improve this answer
    
OK Thanks. I'll try that –  Bill Phelps Mar 19 '13 at 15:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.