Make WordPress Core

Changeset 51973


Ignore:
Timestamp:
11/02/2021 12:46:01 PM (3 years ago)
Author:
hellofromTonya
Message:

REST API: Add URL Details endpoint.

Adds a new REST API endpoint (/wp-block-editor/v1/url-details) for retrieving information from an external URL.

Information retrieved:

  • Title: content of the <title> element
  • Icon: favicon image link
  • Description: content of the description or og:description meta element
  • Image: OG image link

This endpoint is used by the block editor for link previews.

Props get_dave, aduth, andraganescu, beaulebens, hellofromTonya, kevin940726, mamaduka, marekhrabe, mnelson4, noisysocks, obenland, ocean90, retrofox, shaunandrews, spacedmonkey, swissspidy, timothyblynjacobs, xknown, youknowriad.
Fixes #54358.

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api.php

    r51964 r51973  
    337337    $site_health = WP_Site_Health::get_instance();
    338338    $controller  = new WP_REST_Site_Health_Controller( $site_health );
     339    $controller->register_routes();
     340
     341    // URL Details.
     342    $controller = new WP_REST_URL_Details_Controller();
    339343    $controller->register_routes();
    340344}
  • trunk/src/wp-settings.php

    r51056 r51973  
    277277require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-widgets-controller.php';
    278278require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-templates-controller.php';
     279require ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-url-details-controller.php';
    279280require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-meta-fields.php';
    280281require ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-comment-meta-fields.php';
  • trunk/tests/qunit/fixtures/wp-api-generated.js

    r51964 r51973  
    1616        "oembed/1.0",
    1717        "wp/v2",
    18         "wp-site-health/v1"
     18        "wp-site-health/v1",
     19        "wp-block-editor/v1"
    1920    ],
    2021    "authentication": [],
     
    75397540                ]
    75407541            }
     7542        },
     7543        "/wp-block-editor/v1": {
     7544            "namespace": "wp-block-editor/v1",
     7545            "methods": [
     7546                "GET"
     7547            ],
     7548            "endpoints": [
     7549                {
     7550                    "methods": [
     7551                        "GET"
     7552                    ],
     7553                    "args": {
     7554                        "namespace": {
     7555                            "default": "wp-block-editor/v1",
     7556                            "required": false
     7557                        },
     7558                        "context": {
     7559                            "default": "view",
     7560                            "required": false
     7561                        }
     7562                    }
     7563                }
     7564            ],
     7565            "_links": {
     7566                "self": [
     7567                    {
     7568                        "href": "http://example.org/index.php?rest_route=/wp-block-editor/v1"
     7569                    }
     7570                ]
     7571            }
     7572        },
     7573        "/wp-block-editor/v1/url-details": {
     7574            "namespace": "wp-block-editor/v1",
     7575            "methods": [
     7576                "GET"
     7577            ],
     7578            "endpoints": [
     7579                {
     7580                    "methods": [
     7581                        "GET"
     7582                    ],
     7583                    "args": {
     7584                        "url": {
     7585                            "description": "The URL to process.",
     7586                            "type": "string",
     7587                            "format": "uri",
     7588                            "required": true
     7589                        }
     7590                    }
     7591                }
     7592            ],
     7593            "_links": {
     7594                "self": [
     7595                    {
     7596                        "href": "http://example.org/index.php?rest_route=/wp-block-editor/v1/url-details"
     7597                    }
     7598                ]
     7599            }
    75417600        }
    75427601    },
Note: See TracChangeset for help on using the changeset viewer.