Skip to content

Commit 90b6128

Browse files
authored
Merge branch 'WordPress:trunk' into trunk
2 parents 66313ed + c45d184 commit 90b6128

2 files changed

Lines changed: 15 additions & 11 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ public function register( $icon_name, $icon_properties ) {
9292
return false;
9393
}
9494

95-
if ( ! preg_match( '/^[a-z0-9][a-z0-9_-]*$/', $unqualified_name ) ) {
95+
if ( ! preg_match( '/^[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?$/', $unqualified_name ) ) {
9696
_doing_it_wrong(
9797
__METHOD__,
98-
__( 'Icon names must start with a lowercase letter or digit and contain only lowercase letters, digits, hyphens, and underscores.' ),
98+
__( 'Icon names must start and end with a lowercase letter or digit and contain only lowercase letters, digits, hyphens, and underscores.' ),
9999
'7.1.0'
100100
);
101101
return false;

tests/phpunit/tests/icons/wpIconsRegistry.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,22 @@ private function create_temp_icon_file( $contents, $extension = 'svg' ) {
7575
}
7676

7777
/**
78-
* Provides valid namespaced icon names, including names that contain or
79-
* start with digits, as well as underscores.
78+
* Provides valid namespaced icon names, including names that contain,
79+
* start or end with digits, as well as underscores and hyphens.
8080
*
8181
* @return array<string, array{0: string}>
8282
*/
8383
public function data_valid_icon_names() {
8484
return array(
85-
'simple name' => array( 'test-collection/my-icon' ),
86-
'digit at the start' => array( 'test-collection/1-icon' ),
87-
'digit in the name' => array( 'test-collection/my-1-icon' ),
88-
'digit at the end' => array( 'test-collection/icon1' ),
89-
'underscore in the name' => array( 'test-collection/my_icon' ),
90-
'underscore at the end' => array( 'test-collection/my-icon_' ),
91-
'hyphen at the end' => array( 'test-collection/my-icon-' ),
85+
'single character' => array( 'test-collection/a' ),
86+
'simple name' => array( 'test-collection/icon' ),
87+
'digit at the start' => array( 'test-collection/1icon' ),
88+
'digit in the name' => array( 'test-collection/my1icon' ),
89+
'digit at the end' => array( 'test-collection/icon1' ),
90+
'underscore in the name' => array( 'test-collection/my_icon' ),
91+
'hyphen in the name' => array( 'test-collection/my-icon' ),
92+
'digit adjacent to a hyphen' => array( 'test-collection/my-1-icon' ),
93+
'digit adjacent to an underscore' => array( 'test-collection/my_1_icon' ),
9294
);
9395
}
9496

@@ -125,7 +127,9 @@ public function data_invalid_icon_names() {
125127
'uppercase in the name' => array( 'test-collection/my-Icon' ),
126128
'uppercase at the end' => array( 'test-collection/my-iconX' ),
127129
'underscore at the start' => array( 'test-collection/_my-icon' ),
130+
'underscore at the end' => array( 'test-collection/my-icon_' ),
128131
'hyphen at the start' => array( 'test-collection/-my-icon' ),
132+
'hyphen at the end' => array( 'test-collection/my-icon-' ),
129133
);
130134
}
131135

0 commit comments

Comments
 (0)