Skip to content

Commit 4cd4600

Browse files
authored
JSON Schemas: fix menu_icon property in Options Pages schema (#274)
1 parent c83b060 commit 4cd4600

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

schemas/ui-options-page.schema.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,29 +89,30 @@
8989
},
9090
"menu_icon": {
9191
"oneOf": [
92-
{
93-
"type": "string",
94-
"description": "Icon as string: Dashicon name (e.g. 'dashicons-admin-generic') or full URL to image file"
95-
},
9692
{
9793
"type": "object",
9894
"properties": {
9995
"type": {
10096
"type": "string",
10197
"enum": [ "dashicons", "url", "media_library" ],
102-
"description": "Icon source type: 'dashicons' for WordPress dashicons, 'url' for custom image URL, 'media_library' for media library attachment"
98+
"description": "Icon source type: 'dashicons' for WordPress dashicons, 'url' for custom image URL, 'media_library' for media library attachment ID"
10399
},
104100
"value": {
105101
"type": [ "string", "integer" ],
106-
"description": "The icon value: dashicon class name, image URL, or media library attachment ID"
102+
"description": "The icon value: dashicon class name (e.g. 'dashicons-admin-generic'), image URL, or media library attachment ID"
107103
}
108104
},
109105
"required": [ "type", "value" ],
110106
"additionalProperties": false,
111-
"description": "[SCF] SCF icon object format: {\"type\": \"dashicons\", \"value\": \"dashicons-admin-generic\"}"
107+
"description": "[SCF] Object with type and value properties specifying the icon source and identifier."
108+
},
109+
{
110+
"type": "array",
111+
"maxItems": 0,
112+
"description": "Empty array representing unset/default state (no icon configured)."
112113
}
113114
],
114-
"description": "The menu icon. Can be a string (URL or dashicon name) or SCF object format with type and value properties."
115+
"description": "The menu icon displayed in the admin menu. Accepts object format with type/value properties, or empty array when no icon is configured."
115116
},
116117
"position": {
117118
"type": [ "integer", "string", "null" ],

tests/php/schemas/UIOptionsPageSchemaTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,6 @@ public function validEntitiesProvider(): array {
120120
),
121121
'Parent page with menu_icon object should be valid',
122122
),
123-
'menu_icon as string' => array(
124-
array(
125-
'key' => 'ui_options_page_settings',
126-
'title' => 'Settings',
127-
'menu_slug' => 'settings',
128-
'menu_icon' => 'dashicons-admin-generic',
129-
),
130-
'Options page with menu_icon as string should be valid',
131-
),
132123
'menu_icon with url type' => array(
133124
array(
134125
'key' => 'ui_options_page_settings',
@@ -153,6 +144,15 @@ public function validEntitiesProvider(): array {
153144
),
154145
'Options page with menu_icon media_library type should be valid',
155146
),
147+
'menu_icon as empty array' => array(
148+
array(
149+
'key' => 'ui_options_page_settings',
150+
'title' => 'Settings',
151+
'menu_slug' => 'settings',
152+
'menu_icon' => array(),
153+
),
154+
'Options page with empty menu_icon array (default state when no icon configured) should be valid',
155+
),
156156
'child page with parent_slug' => array(
157157
array(
158158
'key' => 'ui_options_page_child',

0 commit comments

Comments
 (0)