Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #61205, comment 2


Ignore:
Timestamp:
05/14/2024 04:04:36 AM (14 months ago)
Author:
ramonopoly
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #61205, comment 2

    initial v1  
    88"_links": {
    99    "wp:theme-file-uris": [
    10             {
    11                "href": "http://resolve.uri/path/image.png",
    12                "name": "path/image.png",
    13                "path": [ "style", "blocks", "core/group", "background", "backgroundImage" ]
    14             },
    15       ]
     10        {
     11            "name": "img/budgie3.jpg",
     12            "href": "http://localhost:8888/wp-content/themes/emptytheme/img/budgie3.jpg",
     13            "target": "styles.background.backgroundImage.url",
     14            "type": "image/jpeg"
     15        }
     16    ]
    1617}
    1718}}}
    1819
    19 "href" and "name" are HAL reserved attributes. "path" I added to represent the path in the theme.json tree to the value that needs to be replaced.
     20"href", "type" and "name" are HAL reserved attributes. "target", a valid link attribute, I added to represent the path in the theme.json tree to the value that needs to be replaced.
    2021
    21 However, some responses are collections of global styles objects. For example `WP_REST_Global_Styles_Controller_Gutenberg::get_theme_items` and `WP_REST_Global_Styles_Revisions_Controller::get_items`. Therefore a property can't be added to the top-level response.
     22Some responses are collections of global styles objects. For example `WP_REST_Global_Styles_Controller_Gutenberg::get_theme_items` and `WP_REST_Global_Styles_Revisions_Controller::get_items`. Therefore a property can't be added to the top-level response.
    2223
    23 To get around this I've added `_links` to each item in the collection. I'm not sure that's HAL-friendly, even though HAL is pretty loose and there's no formal spec.
     24To get around this I've added `_links` to each item in the collection.
    2425
    25 I was going to suggest adding another, custom property to the [https://github.com/wordpress/wordpress-develop/blob/3a6cca9ff772c77c86a3cf7c5a69398acc4c2272/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php#L513-L513, global styles object schema] if `_links` aren't allowed in collection items.
     26I was going to suggest adding another, custom property to the [https://github.com/wordpress/wordpress-develop/blob/3a6cca9ff772c77c86a3cf7c5a69398acc4c2272/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php#L513-L513, global styles object schema] if folks think links to image URIs shouldn't live under `_links`. I tend to think that HAL is flexible enough to accommodate, but keen to hear others' thoughts.