Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks in Customizer: Use temporary fix to make blocks appear #29283

Closed
noisysocks opened this issue Feb 24, 2021 · 0 comments · Fixed by #29365
Closed

Blocks in Customizer: Use temporary fix to make blocks appear #29283

noisysocks opened this issue Feb 24, 2021 · 0 comments · Fixed by #29365
Assignees
Labels
[Feature] Widgets Customizer Ability to add and edit blocks in Customize → Widgets. [Status] In Progress Tracking issues with work in progress [Type] Task Issues or PRs that have been broken down into an individual action to take

Comments

@noisysocks
Copy link
Member

In #28618 the ability to see blocks in Customize -> Widgets was added.

Right now only a JSON representation of the block appears because we can't handle blocks serialization correctly yet. We are using the customizer API to get the contents of the widget, which looks something like:

{
  "id": "block-11",
  "idBase": "block",
  "number": 11,
  "instance": {
    "encoded_serialized_instance": "YToxOntzOjc6ImNvbnRlbnQiO3M6NTQ6IjwhLS0gd3A6cGFyYWdyYXBoIC0tPgo8cD5wMjwvcD4KPCEtLSAvd3A6cGFyYWdyYXBoIC0tPiI7fQ==",
    "title": "",
    "is_widget_customizer_js_value": true,
    "instance_hash_key": "19e32b0073d55e11b26ab957abcf9386"
  }
}

Notice that the content of the widget is a base64-encoded serialized string, which can be unserialize via sanitize_widget_instance. However, there's no equivalent of that in JS. We need to think of another way to do this. Hence, as a fallback, we're just serializing it to string for now.

As a temporary fix that lets us continue work on the Customizer user interface, let's make it so that the Customizer sends the frontend and accepts a non-serialized instance array instead of encoded_serialized_instance.

This would be superseded by a proper fix which accounts for attributes that cannot be JSON serialized, see #28902.

@noisysocks noisysocks added [Type] Task Issues or PRs that have been broken down into an individual action to take [Feature] Widgets Customizer Ability to add and edit blocks in Customize → Widgets. labels Feb 24, 2021
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Widgets Customizer Ability to add and edit blocks in Customize → Widgets. [Status] In Progress Tracking issues with work in progress [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants