Editor: Add functionality required for theme export in the site editor

This bring across changes to theme export functionality, and related code, and tests. Relates issue in Gutenberg: https://github.com/WordPress/gutenberg/issues/39889.

Props scruffian, timothyblynjacobs, oandregal, ajlende, zieleadam.
See #55505.



git-svn-id: https://develop.svn.wordpress.org/trunk@53129 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Greg Ziółkowski
2022-04-11 10:36:02 +00:00
parent 43aba3b36f
commit a5a6d0d0e0
8 changed files with 712 additions and 80 deletions

View File

@@ -2173,4 +2173,91 @@ class Tests_Functions extends WP_UnitTestCase {
$this->assertEquals( 111, wp_filesize( $file ) );
}
/**
* @ticket 55505
* @covers ::wp_recursive_ksort
*/
function test_wp_recursive_ksort() {
// Create an array to test.
$theme_json = array(
'version' => 1,
'settings' => array(
'typography' => array(
'fontFamilies' => array(
'fontFamily' => 'DM Sans, sans-serif',
'slug' => 'dm-sans',
'name' => 'DM Sans',
),
),
'color' => array(
'palette' => array(
array(
'slug' => 'foreground',
'color' => '#242321',
'name' => 'Foreground',
),
array(
'slug' => 'background',
'color' => '#FCFBF8',
'name' => 'Background',
),
array(
'slug' => 'primary',
'color' => '#71706E',
'name' => 'Primary',
),
array(
'slug' => 'tertiary',
'color' => '#CFCFCF',
'name' => 'Tertiary',
),
),
),
),
);
// Sort the array.
wp_recursive_ksort( $theme_json );
// Expected result.
$expected_theme_json = array(
'settings' => array(
'color' => array(
'palette' => array(
array(
'color' => '#242321',
'name' => 'Foreground',
'slug' => 'foreground',
),
array(
'color' => '#FCFBF8',
'name' => 'Background',
'slug' => 'background',
),
array(
'color' => '#71706E',
'name' => 'Primary',
'slug' => 'primary',
),
array(
'color' => '#CFCFCF',
'name' => 'Tertiary',
'slug' => 'tertiary',
),
),
),
'typography' => array(
'fontFamilies' => array(
'fontFamily' => 'DM Sans, sans-serif',
'name' => 'DM Sans',
'slug' => 'dm-sans',
),
),
),
'version' => 1,
);
$this->assertEquals( $theme_json, $expected_theme_json );
}
}