From fe4188cf9e3792c1f6ef40c2529b236505a91ea9 Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Mon, 19 Jun 2023 10:20:01 +0100 Subject: [PATCH 1/5] Convert theme.json to theme-json.php for better performance. --- Gruntfile.js | 9 +++++++++ src/wp-includes/class-wp-theme-json-resolver.php | 2 +- src/wp-includes/theme-json.php | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/wp-includes/theme-json.php diff --git a/Gruntfile.js b/Gruntfile.js index 2a6d2b9fbaa5..e62a0c164622 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1462,6 +1462,14 @@ module.exports = function(grunt) { ); } ); + grunt.registerTask( 'copy:theme-json', 'Copies theme.json file contents to theme-json.php.', function() { + var themeData = grunt.file.readJSON( SOURCE_DIR + 'wp-includes/theme.json' ); + grunt.file.write( + SOURCE_DIR + 'wp-includes/theme-json.php', + ' 2, 'settings' => array('appearanceTools' => false, 'useRootPaddingAwareAlignments' => false, 'border' => array('color' => false, 'radius' => false, 'style' => false, 'width' => false), 'color' => array('background' => true, 'custom' => true, 'customDuotone' => true, 'customGradient' => true, 'defaultDuotone' => true, 'defaultGradients' => true, 'defaultPalette' => true, 'duotone' => array(array('name' => 'Dark grayscale', 'colors' => array('#000000', '#7f7f7f'), 'slug' => 'dark-grayscale'), array('name' => 'Grayscale', 'colors' => array('#000000', '#ffffff'), 'slug' => 'grayscale'), array('name' => 'Purple and yellow', 'colors' => array('#8c00b7', '#fcff41'), 'slug' => 'purple-yellow'), array('name' => 'Blue and red', 'colors' => array('#000097', '#ff4747'), 'slug' => 'blue-red'), array('name' => 'Midnight', 'colors' => array('#000000', '#00a5ff'), 'slug' => 'midnight'), array('name' => 'Magenta and yellow', 'colors' => array('#c7005a', '#fff278'), 'slug' => 'magenta-yellow'), array('name' => 'Purple and green', 'colors' => array('#a60072', '#67ff66'), 'slug' => 'purple-green'), array('name' => 'Blue and orange', 'colors' => array('#1900d8', '#ffa96b'), 'slug' => 'blue-orange')), 'gradients' => array(array('name' => 'Vivid cyan blue to vivid purple', 'gradient' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', 'slug' => 'vivid-cyan-blue-to-vivid-purple'), array('name' => 'Light green cyan to vivid green cyan', 'gradient' => 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)', 'slug' => 'light-green-cyan-to-vivid-green-cyan'), array('name' => 'Luminous vivid amber to luminous vivid orange', 'gradient' => 'linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)', 'slug' => 'luminous-vivid-amber-to-luminous-vivid-orange'), array('name' => 'Luminous vivid orange to vivid red', 'gradient' => 'linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%)', 'slug' => 'luminous-vivid-orange-to-vivid-red'), array('name' => 'Very light gray to cyan bluish gray', 'gradient' => 'linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%)', 'slug' => 'very-light-gray-to-cyan-bluish-gray'), array('name' => 'Cool to warm spectrum', 'gradient' => 'linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%)', 'slug' => 'cool-to-warm-spectrum'), array('name' => 'Blush light purple', 'gradient' => 'linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%)', 'slug' => 'blush-light-purple'), array('name' => 'Blush bordeaux', 'gradient' => 'linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%)', 'slug' => 'blush-bordeaux'), array('name' => 'Luminous dusk', 'gradient' => 'linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%)', 'slug' => 'luminous-dusk'), array('name' => 'Pale ocean', 'gradient' => 'linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%)', 'slug' => 'pale-ocean'), array('name' => 'Electric grass', 'gradient' => 'linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%)', 'slug' => 'electric-grass'), array('name' => 'Midnight', 'gradient' => 'linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%)', 'slug' => 'midnight')), 'link' => false, 'palette' => array(array('name' => 'Black', 'slug' => 'black', 'color' => '#000000'), array('name' => 'Cyan bluish gray', 'slug' => 'cyan-bluish-gray', 'color' => '#abb8c3'), array('name' => 'White', 'slug' => 'white', 'color' => '#ffffff'), array('name' => 'Pale pink', 'slug' => 'pale-pink', 'color' => '#f78da7'), array('name' => 'Vivid red', 'slug' => 'vivid-red', 'color' => '#cf2e2e'), array('name' => 'Luminous vivid orange', 'slug' => 'luminous-vivid-orange', 'color' => '#ff6900'), array('name' => 'Luminous vivid amber', 'slug' => 'luminous-vivid-amber', 'color' => '#fcb900'), array('name' => 'Light green cyan', 'slug' => 'light-green-cyan', 'color' => '#7bdcb5'), array('name' => 'Vivid green cyan', 'slug' => 'vivid-green-cyan', 'color' => '#00d084'), array('name' => 'Pale cyan blue', 'slug' => 'pale-cyan-blue', 'color' => '#8ed1fc'), array('name' => 'Vivid cyan blue', 'slug' => 'vivid-cyan-blue', 'color' => '#0693e3'), array('name' => 'Vivid purple', 'slug' => 'vivid-purple', 'color' => '#9b51e0')), 'text' => true), 'layout' => array('definitions' => array('default' => array('name' => 'default', 'slug' => 'flow', 'className' => 'is-layout-flow', 'baseStyles' => array(array('selector' => ' > .alignleft', 'rules' => array('float' => 'left', 'margin-inline-start' => '0', 'margin-inline-end' => '2em')), array('selector' => ' > .alignright', 'rules' => array('float' => 'right', 'margin-inline-start' => '2em', 'margin-inline-end' => '0')), array('selector' => ' > .aligncenter', 'rules' => array('margin-left' => 'auto !important', 'margin-right' => 'auto !important'))), 'spacingStyles' => array(array('selector' => ' > *', 'rules' => array('margin-block-start' => '0', 'margin-block-end' => '0')), array('selector' => ' > * + *', 'rules' => array('margin-block-start' => null, 'margin-block-end' => '0')))), 'constrained' => array('name' => 'constrained', 'slug' => 'constrained', 'className' => 'is-layout-constrained', 'baseStyles' => array(array('selector' => ' > .alignleft', 'rules' => array('float' => 'left', 'margin-inline-start' => '0', 'margin-inline-end' => '2em')), array('selector' => ' > .alignright', 'rules' => array('float' => 'right', 'margin-inline-start' => '2em', 'margin-inline-end' => '0')), array('selector' => ' > .aligncenter', 'rules' => array('margin-left' => 'auto !important', 'margin-right' => 'auto !important')), array('selector' => ' > :where(:not(.alignleft):not(.alignright):not(.alignfull))', 'rules' => array('max-width' => 'var(--wp--style--global--content-size)', 'margin-left' => 'auto !important', 'margin-right' => 'auto !important')), array('selector' => ' > .alignwide', 'rules' => array('max-width' => 'var(--wp--style--global--wide-size)'))), 'spacingStyles' => array(array('selector' => ' > *', 'rules' => array('margin-block-start' => '0', 'margin-block-end' => '0')), array('selector' => ' > * + *', 'rules' => array('margin-block-start' => null, 'margin-block-end' => '0')))), 'flex' => array('name' => 'flex', 'slug' => 'flex', 'className' => 'is-layout-flex', 'displayMode' => 'flex', 'baseStyles' => array(array('selector' => '', 'rules' => array('flex-wrap' => 'wrap', 'align-items' => 'center')), array('selector' => ' > *', 'rules' => array('margin' => '0'))), 'spacingStyles' => array(array('selector' => '', 'rules' => array('gap' => null)))))), 'shadow' => array('defaultPresets' => true, 'presets' => array(array('name' => 'Natural', 'slug' => 'natural', 'shadow' => '6px 6px 9px rgba(0, 0, 0, 0.2)'), array('name' => 'Deep', 'slug' => 'deep', 'shadow' => '12px 12px 50px rgba(0, 0, 0, 0.4)'), array('name' => 'Sharp', 'slug' => 'sharp', 'shadow' => '6px 6px 0px rgba(0, 0, 0, 0.2)'), array('name' => 'Outlined', 'slug' => 'outlined', 'shadow' => '6px 6px 0px -3px rgba(255, 255, 255, 1), 6px 6px rgba(0, 0, 0, 1)'), array('name' => 'Crisp', 'slug' => 'crisp', 'shadow' => '6px 6px 0px rgba(0, 0, 0, 1)'))), 'spacing' => array('blockGap' => null, 'margin' => false, 'padding' => false, 'customSpacingSize' => true, 'units' => array('px', 'em', 'rem', 'vh', 'vw', '%'), 'spacingScale' => array('operator' => '*', 'increment' => 1.5, 'steps' => 7, 'mediumStep' => 1.5, 'unit' => 'rem')), 'typography' => array('customFontSize' => true, 'dropCap' => true, 'fontSizes' => array(array('name' => 'Small', 'slug' => 'small', 'size' => '13px'), array('name' => 'Medium', 'slug' => 'medium', 'size' => '20px'), array('name' => 'Large', 'slug' => 'large', 'size' => '36px'), array('name' => 'Extra Large', 'slug' => 'x-large', 'size' => '42px')), 'fontStyle' => true, 'fontWeight' => true, 'letterSpacing' => true, 'lineHeight' => false, 'textDecoration' => true, 'textTransform' => true), 'blocks' => array('core/button' => array('border' => array('radius' => true)), 'core/pullquote' => array('border' => array('color' => true, 'radius' => true, 'style' => true, 'width' => true)))), 'styles' => array('elements' => array('button' => array('color' => array('text' => '#fff', 'background' => '#32373c'), 'spacing' => array('padding' => 'calc(0.667em + 2px) calc(1.333em + 2px)'), 'typography' => array('fontSize' => 'inherit', 'fontFamily' => 'inherit', 'lineHeight' => 'inherit', 'textDecoration' => 'none'), 'border' => array('width' => '0')), 'link' => array('typography' => array('textDecoration' => 'underline'))), 'spacing' => array('blockGap' => '24px', 'padding' => array('top' => '0px', 'right' => '0px', 'bottom' => '0px', 'left' => '0px')))); \ No newline at end of file From 70b99ff5ae6bc6fd6dfc8dd9d608dd57b653e720 Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Mon, 19 Jun 2023 11:49:13 +0100 Subject: [PATCH 2/5] Ignore file. --- phpcs.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 453ef5c79474..f7cff9330f7e 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -121,6 +121,7 @@ /src/wp-includes/ms-deprecated\.php /src/wp-includes/pluggable-deprecated\.php /src/wp-includes/rss\.php + /src/wp-includes/theme-json\.php /src/wp-includes/assets/* /src/wp-includes/blocks/* From 2b806b61f36d6fba4a047b46a55620394c1f651c Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Tue, 20 Jun 2023 12:16:33 +0100 Subject: [PATCH 3/5] Remove file --- Gruntfile.js | 2 +- phpcs.xml.dist | 1 - src/wp-includes/class-wp-theme-json-resolver.php | 2 +- src/wp-includes/theme-json.php | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 src/wp-includes/theme-json.php diff --git a/Gruntfile.js b/Gruntfile.js index e62a0c164622..c6ea925f7758 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1465,7 +1465,7 @@ module.exports = function(grunt) { grunt.registerTask( 'copy:theme-json', 'Copies theme.json file contents to theme-json.php.', function() { var themeData = grunt.file.readJSON( SOURCE_DIR + 'wp-includes/theme.json' ); grunt.file.write( - SOURCE_DIR + 'wp-includes/theme-json.php', + SOURCE_DIR + 'wp-includes/assets/theme-json.php', '/src/wp-includes/ms-deprecated\.php /src/wp-includes/pluggable-deprecated\.php /src/wp-includes/rss\.php - /src/wp-includes/theme-json\.php /src/wp-includes/assets/* /src/wp-includes/blocks/* diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index 08f1572bf31f..b8a2b9b93d47 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -162,7 +162,7 @@ public static function get_core_data() { return static::$core; } - $config = require __DIR__ . '/theme-json.php'; + $config = require __DIR__ . '/assets/theme-json.php'; $config = static::translate( $config ); /** diff --git a/src/wp-includes/theme-json.php b/src/wp-includes/theme-json.php deleted file mode 100644 index f527a767e473..000000000000 --- a/src/wp-includes/theme-json.php +++ /dev/null @@ -1 +0,0 @@ - 2, 'settings' => array('appearanceTools' => false, 'useRootPaddingAwareAlignments' => false, 'border' => array('color' => false, 'radius' => false, 'style' => false, 'width' => false), 'color' => array('background' => true, 'custom' => true, 'customDuotone' => true, 'customGradient' => true, 'defaultDuotone' => true, 'defaultGradients' => true, 'defaultPalette' => true, 'duotone' => array(array('name' => 'Dark grayscale', 'colors' => array('#000000', '#7f7f7f'), 'slug' => 'dark-grayscale'), array('name' => 'Grayscale', 'colors' => array('#000000', '#ffffff'), 'slug' => 'grayscale'), array('name' => 'Purple and yellow', 'colors' => array('#8c00b7', '#fcff41'), 'slug' => 'purple-yellow'), array('name' => 'Blue and red', 'colors' => array('#000097', '#ff4747'), 'slug' => 'blue-red'), array('name' => 'Midnight', 'colors' => array('#000000', '#00a5ff'), 'slug' => 'midnight'), array('name' => 'Magenta and yellow', 'colors' => array('#c7005a', '#fff278'), 'slug' => 'magenta-yellow'), array('name' => 'Purple and green', 'colors' => array('#a60072', '#67ff66'), 'slug' => 'purple-green'), array('name' => 'Blue and orange', 'colors' => array('#1900d8', '#ffa96b'), 'slug' => 'blue-orange')), 'gradients' => array(array('name' => 'Vivid cyan blue to vivid purple', 'gradient' => 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)', 'slug' => 'vivid-cyan-blue-to-vivid-purple'), array('name' => 'Light green cyan to vivid green cyan', 'gradient' => 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)', 'slug' => 'light-green-cyan-to-vivid-green-cyan'), array('name' => 'Luminous vivid amber to luminous vivid orange', 'gradient' => 'linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)', 'slug' => 'luminous-vivid-amber-to-luminous-vivid-orange'), array('name' => 'Luminous vivid orange to vivid red', 'gradient' => 'linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%)', 'slug' => 'luminous-vivid-orange-to-vivid-red'), array('name' => 'Very light gray to cyan bluish gray', 'gradient' => 'linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%)', 'slug' => 'very-light-gray-to-cyan-bluish-gray'), array('name' => 'Cool to warm spectrum', 'gradient' => 'linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%)', 'slug' => 'cool-to-warm-spectrum'), array('name' => 'Blush light purple', 'gradient' => 'linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%)', 'slug' => 'blush-light-purple'), array('name' => 'Blush bordeaux', 'gradient' => 'linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%)', 'slug' => 'blush-bordeaux'), array('name' => 'Luminous dusk', 'gradient' => 'linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%)', 'slug' => 'luminous-dusk'), array('name' => 'Pale ocean', 'gradient' => 'linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%)', 'slug' => 'pale-ocean'), array('name' => 'Electric grass', 'gradient' => 'linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%)', 'slug' => 'electric-grass'), array('name' => 'Midnight', 'gradient' => 'linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%)', 'slug' => 'midnight')), 'link' => false, 'palette' => array(array('name' => 'Black', 'slug' => 'black', 'color' => '#000000'), array('name' => 'Cyan bluish gray', 'slug' => 'cyan-bluish-gray', 'color' => '#abb8c3'), array('name' => 'White', 'slug' => 'white', 'color' => '#ffffff'), array('name' => 'Pale pink', 'slug' => 'pale-pink', 'color' => '#f78da7'), array('name' => 'Vivid red', 'slug' => 'vivid-red', 'color' => '#cf2e2e'), array('name' => 'Luminous vivid orange', 'slug' => 'luminous-vivid-orange', 'color' => '#ff6900'), array('name' => 'Luminous vivid amber', 'slug' => 'luminous-vivid-amber', 'color' => '#fcb900'), array('name' => 'Light green cyan', 'slug' => 'light-green-cyan', 'color' => '#7bdcb5'), array('name' => 'Vivid green cyan', 'slug' => 'vivid-green-cyan', 'color' => '#00d084'), array('name' => 'Pale cyan blue', 'slug' => 'pale-cyan-blue', 'color' => '#8ed1fc'), array('name' => 'Vivid cyan blue', 'slug' => 'vivid-cyan-blue', 'color' => '#0693e3'), array('name' => 'Vivid purple', 'slug' => 'vivid-purple', 'color' => '#9b51e0')), 'text' => true), 'layout' => array('definitions' => array('default' => array('name' => 'default', 'slug' => 'flow', 'className' => 'is-layout-flow', 'baseStyles' => array(array('selector' => ' > .alignleft', 'rules' => array('float' => 'left', 'margin-inline-start' => '0', 'margin-inline-end' => '2em')), array('selector' => ' > .alignright', 'rules' => array('float' => 'right', 'margin-inline-start' => '2em', 'margin-inline-end' => '0')), array('selector' => ' > .aligncenter', 'rules' => array('margin-left' => 'auto !important', 'margin-right' => 'auto !important'))), 'spacingStyles' => array(array('selector' => ' > *', 'rules' => array('margin-block-start' => '0', 'margin-block-end' => '0')), array('selector' => ' > * + *', 'rules' => array('margin-block-start' => null, 'margin-block-end' => '0')))), 'constrained' => array('name' => 'constrained', 'slug' => 'constrained', 'className' => 'is-layout-constrained', 'baseStyles' => array(array('selector' => ' > .alignleft', 'rules' => array('float' => 'left', 'margin-inline-start' => '0', 'margin-inline-end' => '2em')), array('selector' => ' > .alignright', 'rules' => array('float' => 'right', 'margin-inline-start' => '2em', 'margin-inline-end' => '0')), array('selector' => ' > .aligncenter', 'rules' => array('margin-left' => 'auto !important', 'margin-right' => 'auto !important')), array('selector' => ' > :where(:not(.alignleft):not(.alignright):not(.alignfull))', 'rules' => array('max-width' => 'var(--wp--style--global--content-size)', 'margin-left' => 'auto !important', 'margin-right' => 'auto !important')), array('selector' => ' > .alignwide', 'rules' => array('max-width' => 'var(--wp--style--global--wide-size)'))), 'spacingStyles' => array(array('selector' => ' > *', 'rules' => array('margin-block-start' => '0', 'margin-block-end' => '0')), array('selector' => ' > * + *', 'rules' => array('margin-block-start' => null, 'margin-block-end' => '0')))), 'flex' => array('name' => 'flex', 'slug' => 'flex', 'className' => 'is-layout-flex', 'displayMode' => 'flex', 'baseStyles' => array(array('selector' => '', 'rules' => array('flex-wrap' => 'wrap', 'align-items' => 'center')), array('selector' => ' > *', 'rules' => array('margin' => '0'))), 'spacingStyles' => array(array('selector' => '', 'rules' => array('gap' => null)))))), 'shadow' => array('defaultPresets' => true, 'presets' => array(array('name' => 'Natural', 'slug' => 'natural', 'shadow' => '6px 6px 9px rgba(0, 0, 0, 0.2)'), array('name' => 'Deep', 'slug' => 'deep', 'shadow' => '12px 12px 50px rgba(0, 0, 0, 0.4)'), array('name' => 'Sharp', 'slug' => 'sharp', 'shadow' => '6px 6px 0px rgba(0, 0, 0, 0.2)'), array('name' => 'Outlined', 'slug' => 'outlined', 'shadow' => '6px 6px 0px -3px rgba(255, 255, 255, 1), 6px 6px rgba(0, 0, 0, 1)'), array('name' => 'Crisp', 'slug' => 'crisp', 'shadow' => '6px 6px 0px rgba(0, 0, 0, 1)'))), 'spacing' => array('blockGap' => null, 'margin' => false, 'padding' => false, 'customSpacingSize' => true, 'units' => array('px', 'em', 'rem', 'vh', 'vw', '%'), 'spacingScale' => array('operator' => '*', 'increment' => 1.5, 'steps' => 7, 'mediumStep' => 1.5, 'unit' => 'rem')), 'typography' => array('customFontSize' => true, 'dropCap' => true, 'fontSizes' => array(array('name' => 'Small', 'slug' => 'small', 'size' => '13px'), array('name' => 'Medium', 'slug' => 'medium', 'size' => '20px'), array('name' => 'Large', 'slug' => 'large', 'size' => '36px'), array('name' => 'Extra Large', 'slug' => 'x-large', 'size' => '42px')), 'fontStyle' => true, 'fontWeight' => true, 'letterSpacing' => true, 'lineHeight' => false, 'textDecoration' => true, 'textTransform' => true), 'blocks' => array('core/button' => array('border' => array('radius' => true)), 'core/pullquote' => array('border' => array('color' => true, 'radius' => true, 'style' => true, 'width' => true)))), 'styles' => array('elements' => array('button' => array('color' => array('text' => '#fff', 'background' => '#32373c'), 'spacing' => array('padding' => 'calc(0.667em + 2px) calc(1.333em + 2px)'), 'typography' => array('fontSize' => 'inherit', 'fontFamily' => 'inherit', 'lineHeight' => 'inherit', 'textDecoration' => 'none'), 'border' => array('width' => '0')), 'link' => array('typography' => array('textDecoration' => 'underline'))), 'spacing' => array('blockGap' => '24px', 'padding' => array('top' => '0px', 'right' => '0px', 'bottom' => '0px', 'left' => '0px')))); \ No newline at end of file From 3c52be75f22747e7c44aa75568fb8a01b317af3b Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Tue, 20 Jun 2023 13:44:23 +0100 Subject: [PATCH 4/5] Check if file exists. --- src/wp-includes/class-wp-theme-json-resolver.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index b8a2b9b93d47..5dea4d0aa036 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -162,7 +162,13 @@ public static function get_core_data() { return static::$core; } - $config = require __DIR__ . '/assets/theme-json.php'; + $file_path = __DIR__ . '/assets/theme-json.php'; + if ( file_exists( $file_path ) ) { + $config = require $file_path; + } else { + $config = static::read_json_file( __DIR__ . '/theme.json' ); + } + $config = static::translate( $config ); /** From 9fdce4dfe9a68c678cf7cf2348d2b1ba1a5e26b5 Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Tue, 20 Jun 2023 14:48:32 +0100 Subject: [PATCH 5/5] Also convert theme-i18n.json. --- Gruntfile.js | 14 +++++++++----- src/wp-includes/class-wp-theme-json-resolver.php | 9 ++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index c6ea925f7758..a9ab00cb0576 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1463,11 +1463,14 @@ module.exports = function(grunt) { } ); grunt.registerTask( 'copy:theme-json', 'Copies theme.json file contents to theme-json.php.', function() { - var themeData = grunt.file.readJSON( SOURCE_DIR + 'wp-includes/theme.json' ); - grunt.file.write( - SOURCE_DIR + 'wp-includes/assets/theme-json.php', - '