$template_parts =
get_block_templates( array
(), 'wp_template_part'
);
foreach ( $template_parts as $template_part ) { $zip->
addFromString( 'parts/' .
$template_part->slug . '.html',
$template_part->content
);
} // Load theme.json into the zip file.
$tree = WP_Theme_JSON_Resolver::
get_theme_data( array
(), array
( 'with_supports' => false
) );
// Merge with user data.
$tree->
merge( WP_Theme_JSON_Resolver::
get_user_data() );
$theme_json_raw =
$tree->
get_data();
// If a version is defined, add a schema.
if ( $theme_json_raw['version'
] ) { $theme_json_version = 'wp/' .
substr( $wp_version, 0, 3
);
$schema = array
( '$schema' => 'https://schemas.wp.org/' .
$theme_json_version . '/theme.json'
);
$theme_json_raw =
array_merge( $schema,
$theme_json_raw );
} // Convert to a string.
$theme_json_encoded =
wp_json_encode( $theme_json_raw, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
);