This repository was archived by the owner on Dec 16, 2022. It is now read-only.
Send values to JS via js_value(); use setting json method if available #163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an issue whereby:
The reason for the secondary refresh of the featured image is because I incorrectly used
WP_Customize_Setting::value()as opposed toWP_Customize_Setting::js_value(). For postmeta containing post IDs for media controls like Featured Image, this is particularly important because all scalar postmeta (e.g. numbers and bools) get saved as strings (since ameta_valueis aTEXTfield). We implement ajs_valueto cast the underlying string attachment ID from a string to an integer for JS. Since I didn't do this, when the Customizer saves and it sends back the sanitized saved values to update in the JS models, any integer post IDs get replaced with string post IDs. The result is the secondary partial refresh.If, on the other hand, a
refreshis done due to there not being a partial (and so falling back to refesh), the resulting behavior at saving is an infinite reload, since the Customizer keeps trying to sync a string value into the preview where there is an integer value already exported, triggering a change on that setting value.To prevent partial refresh from causing an infinite reload this patch should also be applied to core (see #37032), as it prevents any setting changes from triggering a partial refresh until
activehas been received (after the initial settingsync):