Making WordPress.org

Ticket #1459: 1459.patch

File 1459.patch, 1.3 KB (added by SergeyBiryukov, 9 years ago)
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-json-api.php

     
    7373add_filter( 'json_endpoints', 'wcorg_json_whitelist_endpoints', 999 );
    7474
    7575/**
     76 * Map the oEmbed REST API route to WordPress core infrastructure.
     77 *
     78 * Version 1.x of the WP-API plugin does not support the WordPress 4.4 embed functionality,
     79 * so the oEmbed API endpoint needs to be handled by WordPress core.
     80 *
     81 * @param array $query_vars The array of requested query variables.
     82 *
     83 * @return array
     84 */
     85function wcorg_json_map_embed_route_to_core_api( $query_vars ) {
     86        if ( isset( $query_vars['json_route'] ) && '/oembed/1.0/embed' === $query_vars['json_route'] ) {
     87                $query_vars['rest_route'] = $query_vars['json_route'];
     88                unset( $query_vars['json_route'] );
     89        }
     90
     91        return $query_vars;
     92}
     93add_filter( 'request', 'wcorg_json_map_embed_route_to_core_api' );
     94
     95/**
    7696 * Expose a whitelisted set of meta data to unauthenticated JSON API requests
    7797 *
    7898 * Note: Some additional fields are added in `wcorg_json_expose_additional_post_data()`