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

Update theme.json shape: make settings & style top-level keys #28110

Merged
merged 65 commits into from
Jan 27, 2021
Merged
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
b7f859d
Switch key hierarchy
oandregal Jan 11, 2021
7c4a474
Update docs
oandregal Jan 11, 2021
7e3e2dd
Update tests
oandregal Jan 11, 2021
2db32c6
Filters out invalide top-level keys & block selectors
oandregal Jan 14, 2021
f5241a6
Filters out top-level keys within settings/styles subtrees
oandregal Jan 14, 2021
9eb5f54
Recursively iterate over schema
oandregal Jan 14, 2021
b1318e6
Refactor to compact the code
oandregal Jan 14, 2021
b99380c
Prepare code & test for get_settings
oandregal Jan 14, 2021
bb8af54
Improve test clarity
oandregal Jan 14, 2021
9efc1dc
Fix test_get_settings
oandregal Jan 14, 2021
8fcd1d5
Delete any subtree that is empty
oandregal Jan 14, 2021
1f6ea63
Remove styles & settings if they are not arrays
oandregal Jan 14, 2021
7079ce5
Improve readibility
oandregal Jan 14, 2021
02f6b64
Remove block selectors if they are not arrays
oandregal Jan 14, 2021
c9fa0a3
Remove styles&settinsg if they are empty at the end of the processing
oandregal Jan 14, 2021
ce754eb
Expand test not array
oandregal Jan 14, 2021
252d40b
Improve readibility, add comments
oandregal Jan 14, 2021
1970ba9
Remove unused method
oandregal Jan 14, 2021
d82bbcb
Prepare test
oandregal Jan 14, 2021
ee63972
Rename test
oandregal Jan 15, 2021
6f545aa
Adapt remove insecure props test to new theme.json shape
oandregal Jan 15, 2021
6d56160
Adapt to section/styles being top-level
oandregal Jan 15, 2021
c7332d5
Add failing test to demonstrate bug
oandregal Jan 15, 2021
bafc56b
Simplify merge method
oandregal Jan 15, 2021
5fdf7d0
Fix merge algorithm for leafs that have arrays as values
oandregal Jan 15, 2021
e4aca1b
Uncomment tests
oandregal Jan 15, 2021
50d7c0a
Fix get_stylesheet( css_variables )
oandregal Jan 18, 2021
3120447
Fix get_stylesheet( block_styles )
oandregal Jan 18, 2021
79d400d
Fix get_stylesheet
oandregal Jan 18, 2021
fa14cb5
No need to remove contexts as it was already done by the constructor
oandregal Jan 18, 2021
12c6fb9
Create a escape_styles function
oandregal Jan 18, 2021
2dcdc15
Another tests that can be removed
oandregal Jan 18, 2021
7b1c07a
Remove tests that are duplicated
oandregal Jan 18, 2021
8eb12b6
Create new schema validation test
oandregal Jan 18, 2021
02adbee
Remove style properties that are not supported by the block
oandregal Jan 21, 2021
af15f17
Remove unsafe styles
oandregal Jan 21, 2021
99d237b
Remove unsafe styles sub-properties
oandregal Jan 21, 2021
5162f3e
Fix settings
oandregal Jan 21, 2021
63655ae
Uncomment passing test
oandregal Jan 21, 2021
f27105b
Consolidate back keys
oandregal Jan 21, 2021
ddeb87a
Rename context to block
oandregal Jan 21, 2021
d14d14d
Test for custom css vars as well
oandregal Jan 21, 2021
8b3acf7
Fix custom
oandregal Jan 21, 2021
716c912
Update comments
oandregal Jan 21, 2021
0d41973
Adapt translation logic to new shape
oandregal Jan 22, 2021
138092f
Adapt preset defaults to new shape
oandregal Jan 22, 2021
d863d6c
Adapt preset defaults to new shape
oandregal Jan 22, 2021
a1cb0e4
Protect against theme.json with different shape or empty settings
oandregal Jan 22, 2021
2f395f4
Protect against different theme.json shapes
oandregal Jan 22, 2021
00d5db1
Fix block styles
oandregal Jan 22, 2021
d3195a6
add task/todo
oandregal Jan 25, 2021
523d62d
Update getSetting / setSetting
oandregal Jan 25, 2021
d153174
Update getStyle / setStyle
oandregal Jan 25, 2021
471a19b
Update global styles rendered function
oandregal Jan 25, 2021
2d037ba
Update presets processing
oandregal Jan 25, 2021
9e17373
Pass only the merged settings
oandregal Jan 25, 2021
a6cba44
Format for i18n
oandregal Jan 25, 2021
4ea5f33
Add comment
oandregal Jan 25, 2021
0078b35
Adapt path to new i18-theme.json shape
oandregal Jan 25, 2021
710953a
Fix rebase issues
oandregal Jan 25, 2021
7097e43
Fix rebase issues
oandregal Jan 25, 2021
158491b
fix lint issues in class-wp-theme-json-test.php
oandregal Jan 25, 2021
ba940aa
fix lint issues in class-wp-theme-json.php
oandregal Jan 25, 2021
aaa3edb
fix lint issues in class-wp-theme-json-resolver.php
oandregal Jan 25, 2021
7f99119
Adapt phpunit/class-wp-theme-json-legacy-settings-test.php
oandregal Jan 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove tests that are duplicated
  • Loading branch information
oandregal committed Jan 25, 2021
commit 7b1c07ac7f46efa7e5ff2dca6784609419e401ec
69 changes: 0 additions & 69 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,75 +661,6 @@ function test_remove_insecure_properties_removes_non_preset_settings() {
$this->assertEqualSetsWithIndex( $expected, $result );
}

// This is done in the constructor already.
// No need to test it or do anything code-wise.
function test_remove_insecure_properties_removes_invalid_contexts() {
$theme_json = new WP_Theme_JSON(
array(
'styles' => array(
'global' => array(
'color' => array(
'background' => 'green',
'text' => 'var:preset|color|dark-gray',
),
),
'.my-class' => array(
'color' => array(
'background' => 'green',
'text' => 'var:preset|color|dark-gray',
),
),
),
),
true
);
$theme_json->escape_styles();
$result = $theme_json->get_raw_data();
$expected = array(
'styles' => array(
'global' => array(
'color' => array(
'background' => 'green',
'text' => 'var:preset|color|dark-gray',
),
),
),
);
$this->assertEqualSetsWithIndex( $expected, $result );
}

function test_remove_insecure_properties_removes_invalid_properties() {
$theme_json = new WP_Theme_JSON(
array(
'styles' => array(
'global' => array(
'color' => array(
'gradient' => 'linear-gradient(55deg,rgba(6,147,227,1) 0%,rgb(84,177,218) 54%,rgb(155,81,224) 100%)',
'text' => 'var:preset|color|dark-gray',
),
),
'invalid' => array(
'background' => 'green',
),
),
),
true
);
$theme_json->escape_styles();
$result = $theme_json->get_raw_data();
$expected = array(
'styles' => array(
'global' => array(
'color' => array(
'gradient' => 'linear-gradient(55deg,rgba(6,147,227,1) 0%,rgb(84,177,218) 54%,rgb(155,81,224) 100%)',
'text' => 'var:preset|color|dark-gray',
),
),
),
);
$this->assertEqualSetsWithIndex( $expected, $result );
}

// function test_remove_insecure_properties_removes_unsafe_properties() {
// $theme_json = new WP_Theme_JSON(
// array(
Expand Down