Skip to content

Commit 19bef0e

Browse files
committed
Build/Test Tools: Move icon library SVG files to wp-includes/images.
This makes several changes to the build script to place the icon library files into more appropriate locations. - The icon library SVG files are now copied into the `wp-includes/images/icon-library` directory instead of `wp-includes/icons`. - The name of the `manifest.php` file has changed to `icon-library-manifest.php` and is now copied to `wp-includes/assets`. - An unnecessary `trailingslashit()` has been removed. - The `gutenberg-` prefix for the corresponding `grunt copy` tasks has been removed. These values are merged into the `script-loader-packages.php` file during a `build`, so the original PHP files are not required. Props mcsf, desrosj. See #64393. git-svn-id: https://develop.svn.wordpress.org/trunk@62077 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 0af3431 commit 19bef0e

4 files changed

Lines changed: 32 additions & 26 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ wp-tests-config.php
3939
/src/wp-includes/css/*-rtl.css
4040
/src/wp-includes/blocks/*
4141
!/src/wp-includes/blocks/index.php
42-
/src/wp-includes/icons
42+
/src/wp-includes/images/icon-library
4343
/src/wp-includes/build
4444
/src/wp-includes/theme.json
4545
/packagehash.txt

Gruntfile.js

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ module.exports = function(grunt) {
5555
'wp-includes/css/dist',
5656
'wp-includes/blocks/**/*',
5757
'!wp-includes/blocks/index.php',
58+
'wp-includes/images/icon-library',
59+
// Old location kept temporarily to ensure they are cleaned up.
5860
'wp-includes/icons',
5961
],
6062

@@ -682,31 +684,35 @@ module.exports = function(grunt) {
682684
},
683685
],
684686
},
685-
'gutenberg-icons': {
687+
'icon-library-images': {
688+
files: [ {
689+
expand: true,
690+
cwd: 'gutenberg/packages/icons/src/library',
691+
src: '*.svg',
692+
dest: WORKING_DIR + 'wp-includes/images/icon-library',
693+
} ],
694+
},
695+
'icon-library-manifest': {
686696
options: {
687-
process: function( content, srcpath ) {
688-
// Remove the 'gutenberg' text domain from _x() calls in manifest.php.
689-
if ( path.basename( srcpath ) === 'manifest.php' ) {
690-
return content.replace(
697+
process: function( content ) {
698+
return content
699+
// Remove the 'gutenberg' text domain from _x() calls.
700+
.replace(
691701
/_x\(\s*([^,]+),\s*([^,]+),\s*['"]gutenberg['"]\s*\)/g,
692702
'_x( $1, $2 )'
703+
)
704+
// Strip the 'library/' prefix from filePath values so they
705+
// resolve correctly relative to wp-includes/images/icon-library/.
706+
.replace(
707+
/'filePath' => 'library\//g,
708+
'\'filePath\' => \''
693709
);
694-
}
695-
return content;
696710
}
697711
},
698-
files: [
699-
{
700-
src: 'gutenberg/packages/icons/src/manifest.php',
701-
dest: WORKING_DIR + 'wp-includes/icons/manifest.php',
702-
},
703-
{
704-
expand: true,
705-
cwd: 'gutenberg/packages/icons/src/library',
706-
src: '*.svg',
707-
dest: WORKING_DIR + 'wp-includes/icons/library/',
708-
},
709-
],
712+
files: [ {
713+
src: 'gutenberg/packages/icons/src/manifest.php',
714+
dest: WORKING_DIR + 'wp-includes/assets/icon-library-manifest.php',
715+
} ],
710716
},
711717
},
712718
sass: {
@@ -2059,7 +2065,8 @@ module.exports = function(grunt) {
20592065
'copy:gutenberg-modules',
20602066
'copy:gutenberg-styles',
20612067
'copy:gutenberg-theme-json',
2062-
'copy:gutenberg-icons',
2068+
'copy:icon-library-images',
2069+
'copy:icon-library-manifest',
20632070
] );
20642071

20652072
grunt.registerTask( 'build', function() {

src/wp-includes/class-wp-icons-registry.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ class WP_Icons_Registry {
4141
* registry is loaded with those icons listed in the manifest.
4242
*/
4343
protected function __construct() {
44-
$icons_directory = __DIR__ . '/icons/';
45-
$icons_directory = trailingslashit( $icons_directory );
46-
$manifest_path = $icons_directory . 'manifest.php';
44+
$icons_directory = __DIR__ . '/images/icon-library/';
45+
$manifest_path = __DIR__ . '/assets/icon-library-manifest.php';
4746

4847
if ( ! is_readable( $manifest_path ) ) {
4948
wp_trigger_error(

src/wp-includes/rest-api/endpoints/class-wp-rest-icons-controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
/**
1212
* Controller which provides a REST endpoint for the editor to read registered
1313
* icons. For the time being, only core icons are available, which are defined
14-
* in a single manifest file (wp-includes/icons/manifest.php). Icons are
15-
* comprised of their SVG source, a name and a translatable label.
14+
* in a single manifest file (wp-includes/assets/icon-library-manifest.php).
15+
* Icons are comprised of their SVG source, a name and a translatable label.
1616
*
1717
* @since 7.0.0
1818
*

0 commit comments

Comments
 (0)