Opened 11 years ago
Closed 10 years ago
#29098 closed enhancement (fixed)
Send JSON success for customize_save and allow response to be filtered
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.2 | Priority: | normal |
Severity: | normal | Version: | 3.4 |
Component: | Customize | Keywords: | early needs-patch |
Focuses: | javascript | Cc: |
Description
In my development on the Customize Posts plugin, and on the work celloexpressions is doing on Menu Customizer, there is a need to create pseudo posts in the preview experience which don't correspond to actual posts in the DB. In other words, the IDs used are placeholders which aren't finalized until the Customizer settings are saved. Upon saving, we need to obtain the IDs that were generated by the DB and then pass them back to the frontend so that the model can be updated to utilize the new IDs. This currently is difficult because the customize_save Ajax action terminates with a die
without providing a mechanism for returning data which plugins can filter to attach any additional information resulting from the save. So I suggest that the save
method return with something like:
$response = apply_filters( 'wp_customize_save_response', array(), $this->manager ); wp_send_json_success( $response );
Another key use for this filter would be to send back the PHP-sanitized settings and to update the JS models so that they match what was saved to the DB.
Attachments (4)
Change History (12)
#2
@
11 years ago
+1
Menu Customizer currently sidesteps this by saving and updating clones to the DB, then hooking into the customizer saved
action to trigger new clones. While I don't foresee this changing there for scaling purposes, this would be really useful for a lot of other situations.
#3
@
10 years ago
- Keywords early added
- Milestone changed from Future Release to 4.2
- Owner set to ocean90
- Status changed from new to reviewing
In 29098.2.diff:
- Refresh patch
- Bump
@since
to 4.2.0 - Use
wp.ajax.post()
and the promisefail
callback since we're usingwp_send_json_success()
andwp_send_json_error()
.
Having this in place is a prerequisite for things that I need to do for Menu Customizer, and it will also be useful for #30028.
This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.
10 years ago
#6
follow-up:
↓ 7
@
10 years ago
- Keywords needs-patch added; has-patch removed
- Resolution fixed deleted
- Status changed from closed to reopened
In [31062] the parameter description for $data
was missed in the hook doc for the new customize_save_response
filter.
Initial patch. PR: https://github.com/x-team/wordpress-develop/pull/27