| | 2 | |
| | 3 | |
| | 4 | {{{ |
| | 5 | /** |
| | 6 | * Outputs the REST API link tag into page header. |
| | 7 | * |
| | 8 | * @since 4.4.0 |
| | 9 | * |
| | 10 | * @see get_rest_url() |
| | 11 | */ |
| | 12 | function rest_output_link_wp_head() { |
| | 13 | $api_root = get_rest_url(); |
| | 14 | |
| | 15 | if ( empty( $api_root ) ) { |
| | 16 | return; |
| | 17 | } |
| | 18 | |
| | 19 | printf( '<link rel="https://api.w.org/" href="%s" />', esc_url( $api_root ) ); |
| | 20 | |
| | 21 | $resource = rest_get_queried_resource_route(); |
| | 22 | |
| | 23 | if ( $resource ) { |
| | 24 | printf( '<link rel="alternate" type="application/json" href="%s" />', esc_url( rest_url( $resource ) ) ); |
| | 25 | } |
| | 26 | } |
| | 27 | }}} |
| | 28 | |