advanced
7 months ago
basic
7 months ago
choice
7 months ago
content
7 months ago
layout
7 months ago
relational
7 months ago
field-base.schema.json
7 months ago
field-base.schema.json
431 lines
| 1 | { |
| 2 | "$schema": "http://json-schema.org/draft-07/schema#", |
| 3 | "$id": "https://raw.githubusercontent.com/WordPress/secure-custom-fields/trunk/schemas/field-fragments/field-base.schema.json", |
| 4 | "title": "SCF Field Base", |
| 5 | "description": "Base field schema with shared properties and definitions. Used by the generation script to compose field.schema.json.", |
| 6 | "$comment": "WordPress doesn't support 'allOf', so we use '$ref' with explicit 'required' arrays. Since PHP's array_merge() replaces (not merges) nested arrays, we must redeclare all required fields from the definition plus 'parent'.", |
| 7 | "oneOf": [ |
| 8 | { |
| 9 | "description": "Single field object with required parent", |
| 10 | "$ref": "#/definitions/field", |
| 11 | "required": [ |
| 12 | "key", |
| 13 | "label", |
| 14 | "name", |
| 15 | "type", |
| 16 | "parent" |
| 17 | ] |
| 18 | }, |
| 19 | { |
| 20 | "description": "Array of field objects with required parent", |
| 21 | "type": "array", |
| 22 | "items": { |
| 23 | "$ref": "#/definitions/field", |
| 24 | "required": [ |
| 25 | "key", |
| 26 | "label", |
| 27 | "name", |
| 28 | "type", |
| 29 | "parent" |
| 30 | ] |
| 31 | }, |
| 32 | "minItems": 1 |
| 33 | } |
| 34 | ], |
| 35 | "definitions": { |
| 36 | "field": { |
| 37 | "type": "object", |
| 38 | "required": [ |
| 39 | "key", |
| 40 | "label", |
| 41 | "name", |
| 42 | "type" |
| 43 | ], |
| 44 | "additionalProperties": true, |
| 45 | "properties": { |
| 46 | "key": { |
| 47 | "type": "string", |
| 48 | "pattern": "^field_.+$", |
| 49 | "minLength": 1, |
| 50 | "description": "Unique identifier for the field with field_ prefix (e.g. 'field_abc123')" |
| 51 | }, |
| 52 | "label": { |
| 53 | "type": "string", |
| 54 | "minLength": 1, |
| 55 | "description": "The label displayed for this field" |
| 56 | }, |
| 57 | "name": { |
| 58 | "type": "string", |
| 59 | "pattern": "^[a-zA-Z0-9_-]*$", |
| 60 | "description": "The field name/meta_key used to save and load data (empty for layout fields like tab, accordion)" |
| 61 | }, |
| 62 | "aria-label": { |
| 63 | "type": "string", |
| 64 | "description": "Accessible label for screen readers" |
| 65 | }, |
| 66 | "type": { |
| 67 | "type": "string", |
| 68 | "enum": [ |
| 69 | "text", |
| 70 | "textarea", |
| 71 | "number", |
| 72 | "range", |
| 73 | "email", |
| 74 | "url", |
| 75 | "password", |
| 76 | "image", |
| 77 | "file", |
| 78 | "wysiwyg", |
| 79 | "oembed", |
| 80 | "gallery", |
| 81 | "select", |
| 82 | "checkbox", |
| 83 | "radio", |
| 84 | "button_group", |
| 85 | "true_false", |
| 86 | "link", |
| 87 | "post_object", |
| 88 | "page_link", |
| 89 | "relationship", |
| 90 | "taxonomy", |
| 91 | "user", |
| 92 | "google_map", |
| 93 | "date_picker", |
| 94 | "date_time_picker", |
| 95 | "time_picker", |
| 96 | "color_picker", |
| 97 | "icon_picker", |
| 98 | "message", |
| 99 | "accordion", |
| 100 | "tab", |
| 101 | "group", |
| 102 | "repeater", |
| 103 | "flexible_content", |
| 104 | "clone", |
| 105 | "nav_menu", |
| 106 | "separator", |
| 107 | "output" |
| 108 | ], |
| 109 | "description": "The type of field" |
| 110 | }, |
| 111 | "instructions": { |
| 112 | "type": "string", |
| 113 | "description": "Instructions for content editors" |
| 114 | }, |
| 115 | "required": { |
| 116 | "type": [ |
| 117 | "boolean", |
| 118 | "integer" |
| 119 | ], |
| 120 | "default": false, |
| 121 | "description": "Whether the field is required" |
| 122 | }, |
| 123 | "conditional_logic": { |
| 124 | "type": [ |
| 125 | "boolean", |
| 126 | "integer", |
| 127 | "string", |
| 128 | "array" |
| 129 | ], |
| 130 | "default": 0, |
| 131 | "description": "Conditional logic rules for field visibility. False/0/empty string to disable, or array of rule groups." |
| 132 | }, |
| 133 | "wrapper": { |
| 134 | "type": "object", |
| 135 | "additionalProperties": false, |
| 136 | "properties": { |
| 137 | "width": { |
| 138 | "type": "string", |
| 139 | "description": "Width of the field wrapper (e.g. '50' for 50%)" |
| 140 | }, |
| 141 | "class": { |
| 142 | "type": "string", |
| 143 | "description": "CSS class(es) for the field wrapper" |
| 144 | }, |
| 145 | "id": { |
| 146 | "type": "string", |
| 147 | "description": "HTML ID for the field wrapper" |
| 148 | } |
| 149 | }, |
| 150 | "description": "Wrapper element settings" |
| 151 | }, |
| 152 | "menu_order": { |
| 153 | "type": "integer", |
| 154 | "description": "Order of the field within its parent" |
| 155 | }, |
| 156 | "parent": { |
| 157 | "type": [ |
| 158 | "string", |
| 159 | "integer" |
| 160 | ], |
| 161 | "description": "Parent field or field group key/ID" |
| 162 | }, |
| 163 | "parent_layout": { |
| 164 | "type": "string", |
| 165 | "description": "Parent layout key for flexible content sub-fields" |
| 166 | } |
| 167 | } |
| 168 | }, |
| 169 | "conditionalLogicGroup": { |
| 170 | "type": "array", |
| 171 | "items": { |
| 172 | "$ref": "#/definitions/conditionalLogicRule" |
| 173 | }, |
| 174 | "minItems": 1, |
| 175 | "description": "Group of conditional logic rules (AND logic within group)" |
| 176 | }, |
| 177 | "conditionalLogicRule": { |
| 178 | "type": "object", |
| 179 | "required": [ |
| 180 | "field", |
| 181 | "operator" |
| 182 | ], |
| 183 | "additionalProperties": false, |
| 184 | "properties": { |
| 185 | "field": { |
| 186 | "type": "string", |
| 187 | "pattern": "^field_.+$", |
| 188 | "description": "Field key to check" |
| 189 | }, |
| 190 | "operator": { |
| 191 | "type": "string", |
| 192 | "enum": [ |
| 193 | "==", |
| 194 | "!=", |
| 195 | "!==", |
| 196 | "==empty", |
| 197 | "!=empty", |
| 198 | "==pattern", |
| 199 | "==contains", |
| 200 | "!=contains", |
| 201 | "<", |
| 202 | ">" |
| 203 | ], |
| 204 | "description": "Comparison operator" |
| 205 | }, |
| 206 | "value": { |
| 207 | "type": "string", |
| 208 | "description": "Value to compare against (not required for ==empty and !=empty operators)" |
| 209 | } |
| 210 | } |
| 211 | }, |
| 212 | "default_value": { |
| 213 | "type": "string", |
| 214 | "default": "", |
| 215 | "description": "Default value for the field" |
| 216 | }, |
| 217 | "default_value_numeric": { |
| 218 | "type": [ |
| 219 | "string", |
| 220 | "number" |
| 221 | ], |
| 222 | "default": "", |
| 223 | "description": "Default value for numeric fields (string for empty, number for value)" |
| 224 | }, |
| 225 | "default_value_multi": { |
| 226 | "type": [ |
| 227 | "string", |
| 228 | "array" |
| 229 | ], |
| 230 | "default": "", |
| 231 | "description": "Default value(s) for multi-select fields (string for single, array for multiple)" |
| 232 | }, |
| 233 | "placeholder": { |
| 234 | "type": "string", |
| 235 | "default": "", |
| 236 | "description": "Placeholder text shown when field is empty" |
| 237 | }, |
| 238 | "prepend": { |
| 239 | "type": "string", |
| 240 | "default": "", |
| 241 | "description": "Text or HTML displayed before the input" |
| 242 | }, |
| 243 | "append": { |
| 244 | "type": "string", |
| 245 | "default": "", |
| 246 | "description": "Text or HTML displayed after the input" |
| 247 | }, |
| 248 | "maxlength": { |
| 249 | "type": [ |
| 250 | "integer", |
| 251 | "string" |
| 252 | ], |
| 253 | "default": "", |
| 254 | "description": "Maximum character length (empty string for unlimited)" |
| 255 | }, |
| 256 | "rows": { |
| 257 | "type": [ |
| 258 | "integer", |
| 259 | "string" |
| 260 | ], |
| 261 | "default": "", |
| 262 | "description": "Number of rows for textarea display" |
| 263 | }, |
| 264 | "new_lines": { |
| 265 | "type": "string", |
| 266 | "enum": [ |
| 267 | "wpautop", |
| 268 | "br", |
| 269 | "" |
| 270 | ], |
| 271 | "default": "", |
| 272 | "description": "How to handle new lines in output (wpautop, br, or none)" |
| 273 | }, |
| 274 | "return_format_media": { |
| 275 | "type": "string", |
| 276 | "enum": [ |
| 277 | "array", |
| 278 | "url", |
| 279 | "id" |
| 280 | ], |
| 281 | "default": "array", |
| 282 | "description": "How the media value is returned (array of data, URL string, or attachment ID)" |
| 283 | }, |
| 284 | "library": { |
| 285 | "type": "string", |
| 286 | "enum": [ |
| 287 | "all", |
| 288 | "uploadedTo" |
| 289 | ], |
| 290 | "default": "all", |
| 291 | "description": "Media library source (all media or uploaded to current post only)" |
| 292 | }, |
| 293 | "mime_types": { |
| 294 | "type": "string", |
| 295 | "default": "", |
| 296 | "description": "Comma-separated list of allowed MIME types (e.g., 'image/png, image/jpeg')" |
| 297 | }, |
| 298 | "preview_size": { |
| 299 | "type": "string", |
| 300 | "default": "medium", |
| 301 | "description": "Image size for preview display in admin" |
| 302 | }, |
| 303 | "min_width": { |
| 304 | "type": "integer", |
| 305 | "default": 0, |
| 306 | "description": "Minimum image width in pixels (0 for no limit)" |
| 307 | }, |
| 308 | "min_height": { |
| 309 | "type": "integer", |
| 310 | "default": 0, |
| 311 | "description": "Minimum image height in pixels (0 for no limit)" |
| 312 | }, |
| 313 | "max_width": { |
| 314 | "type": "integer", |
| 315 | "default": 0, |
| 316 | "description": "Maximum image width in pixels (0 for no limit)" |
| 317 | }, |
| 318 | "max_height": { |
| 319 | "type": "integer", |
| 320 | "default": 0, |
| 321 | "description": "Maximum image height in pixels (0 for no limit)" |
| 322 | }, |
| 323 | "min_size": { |
| 324 | "type": "integer", |
| 325 | "default": 0, |
| 326 | "description": "Minimum file size in MB (0 for no limit)" |
| 327 | }, |
| 328 | "max_size": { |
| 329 | "type": "integer", |
| 330 | "default": 0, |
| 331 | "description": "Maximum file size in MB (0 for no limit)" |
| 332 | }, |
| 333 | "choices": { |
| 334 | "type": [ |
| 335 | "object", |
| 336 | "array" |
| 337 | ], |
| 338 | "default": {}, |
| 339 | "description": "Available choices as value:label pairs (object when populated, array when empty)" |
| 340 | }, |
| 341 | "allow_null": { |
| 342 | "type": "integer", |
| 343 | "default": 0, |
| 344 | "description": "Allow a null/empty value to be selected (1 for yes, 0 for no)" |
| 345 | }, |
| 346 | "multiple": { |
| 347 | "type": "integer", |
| 348 | "default": 0, |
| 349 | "description": "Allow multiple values to be selected (1 for yes, 0 for no)" |
| 350 | }, |
| 351 | "return_format_choice": { |
| 352 | "type": "string", |
| 353 | "enum": [ |
| 354 | "value", |
| 355 | "label", |
| 356 | "array" |
| 357 | ], |
| 358 | "default": "value", |
| 359 | "description": "Value returned (value, label, or both as array)" |
| 360 | }, |
| 361 | "layout_choice": { |
| 362 | "type": "string", |
| 363 | "enum": [ |
| 364 | "vertical", |
| 365 | "horizontal" |
| 366 | ], |
| 367 | "default": "vertical", |
| 368 | "description": "Layout direction for choices (default varies by field type)" |
| 369 | }, |
| 370 | "min": { |
| 371 | "type": "integer", |
| 372 | "default": 0, |
| 373 | "description": "Minimum number of items required (0 for no minimum)" |
| 374 | }, |
| 375 | "max": { |
| 376 | "type": "integer", |
| 377 | "default": 0, |
| 378 | "description": "Maximum number of items allowed (0 for no limit)" |
| 379 | }, |
| 380 | "post_type": { |
| 381 | "type": "array", |
| 382 | "default": [], |
| 383 | "description": "Limit selection to specific post types (empty for all)" |
| 384 | }, |
| 385 | "taxonomy_filter": { |
| 386 | "type": "array", |
| 387 | "default": [], |
| 388 | "description": "Limit selection to posts with specific taxonomy terms" |
| 389 | }, |
| 390 | "bidirectional_target": { |
| 391 | "type": "array", |
| 392 | "default": [], |
| 393 | "description": "Target fields for bidirectional relationships" |
| 394 | }, |
| 395 | "first_day": { |
| 396 | "type": "integer", |
| 397 | "default": 1, |
| 398 | "description": "Week start day (0 = Sunday, 1 = Monday, etc.)" |
| 399 | }, |
| 400 | "default_to_current_date": { |
| 401 | "type": "integer", |
| 402 | "default": 0, |
| 403 | "description": "Set current date/time as default value (1 for yes, 0 for no)" |
| 404 | }, |
| 405 | "sub_fields": { |
| 406 | "type": "array", |
| 407 | "default": [], |
| 408 | "description": "Nested fields within this field" |
| 409 | }, |
| 410 | "layout_display": { |
| 411 | "type": "string", |
| 412 | "enum": [ |
| 413 | "block", |
| 414 | "table", |
| 415 | "row" |
| 416 | ], |
| 417 | "description": "Visual layout style for rendering fields" |
| 418 | }, |
| 419 | "button_label": { |
| 420 | "type": "string", |
| 421 | "default": "", |
| 422 | "description": "Text label for the add row button" |
| 423 | }, |
| 424 | "endpoint": { |
| 425 | "type": "integer", |
| 426 | "default": 0, |
| 427 | "description": "Define an endpoint for the previous accordion/tab group" |
| 428 | } |
| 429 | } |
| 430 | } |
| 431 |