Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Strip null values from styles when saving to theme.json

Open Beginner friendly
#885 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, php
Domain
backend

Research direction

Start with CBT_Theme_JSON_Resolver::export_theme_data( 'all' ) in the plugin's PHP, where the global styles are assembled before being written to theme.json, and find the point where styles.blocks is built. Check that the null-stripping also covers style variations. Done when exporting the core/quote border example from the issue produces no null keys in theme.json.

Written by the indexing model from the issue text.

Description

Description

When the user's global styles contain null values, "Save Changes to Theme" writes them into theme.json as they are. The theme.json schema rejects null here, and WordPress ignores these keys, so they're only noise that theme authors have to remove by hand.

The editor currently saves such nulls when border sides are unlinked in Global Styles (WordPress/gutenberg#84814), for example:

"core/quote": {
  "border": {
    "color": null,
    "style": null,
    "width": null,
    "left": { "color": "currentColor", "style": "solid", "width": "4px" }
  }
}
Steps to reproduce
  1. Activate Twenty Twenty-Five with Create Block Theme.
  2. Site Editor → Styles → Blocks → Quote → Borders: click "Unlink sides", set the left width to 4px, save.
  3. Save Changes to Theme (or call CBT_Theme_JSON_Resolver::export_theme_data( 'all' )).
Expected

null values are dropped from the exported theme.json (and style variations).

Actual

styles.blocks["core/quote"].border in the export has "color":null, "style":null and "width":null.

Environment
  • Create Block Theme 2.10.2
  • WordPress 7.1.3, Gutenberg 24.2.0

Drafted with AI assistance, reproduced and verified by me.

Dominant language
JavaScript
Stars
424
Forks
69
Avg merge
18h 59m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WordPress/create-block-theme

All issues in WordPress/create-block-theme

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.