Skip to content

Style variations are saved without $schema #886

Open

Description

@iamtakashi

Description

Style variations created with "Save as style variation" don't get a $schema property. theme.json does: CBT_Theme_JSON_Resolver::export_theme_data() adds $schema and puts it first. CBT_Theme_JSON::add_theme_json_variation_to_local() writes $theme_json->get_data() plus the title, without a schema.

Without $schema, editors can't validate the file or autocomplete keys, and theme validation tools warn about it. The default themes declare it in every variation (for example, Twenty Twenty-Five's styles/01-evening.json).

Steps to reproduce

  1. Activate Twenty Twenty-Five with Create Block Theme.
  2. Create a style variation with Create Block Theme ("Save as style variation"), or call CBT_Theme_JSON::add_theme_json_variation_to_local( 'variation', array( 'name' => 'Schema Test', 'slug' => 'cbt-schema-test' ) ).
  3. Open styles/cbt-schema-test.json.

Expected

The file starts with the same $schema that Create Block Theme writes into theme.json, followed by version.

Actual

{
	"version": 3,
	"title": "Schema Test"
}

Environment

  • Create Block Theme 2.10.2
  • WordPress 7.1.3, Gutenberg 24.2.0

Drafted with AI assistance, reproduced and verified by me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions