Making WordPress.org


Ignore:
Timestamp:
03/22/2017 11:18:25 PM (7 years ago)
Author:
iandunn
Message:

WordCamp JSON API: Add a deprecation notice to V1 endpoints

The endpoints will be deactivated after 2018-04-01.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-json-api.php

    r3770 r5164  
    1818add_filter( 'json_prepare_post',           'wcorg_json_embed_related_posts',             999, 3 );   // after `wcorg_json_expose_additional_post_data()`
    1919add_action( 'wp_json_server_before_serve', 'wcorg_json_avoid_nested_callback_conflicts', 11     );    // after the default endpoints are added in `json_api_default_filters()`
     20
     21add_filter( 'json_prepare_post',        'deprecate_v1_endpoints' );
     22add_filter( 'json_prepare_page',        'deprecate_v1_endpoints' );
     23add_filter( 'json_prepare_attachment',  'deprecate_v1_endpoints' );
     24add_filter( 'json_prepare_revision',    'deprecate_v1_endpoints' );
     25add_filter( 'json_prepare_wcb_speaker', 'deprecate_v1_endpoints' );
     26add_filter( 'json_prepare_wcb_session', 'deprecate_v1_endpoints' );
     27add_filter( 'json_prepare_wcb_sponsor', 'deprecate_v1_endpoints' );
     28add_filter( 'json_prepare_mes',         'deprecate_v1_endpoints' );
     29add_filter( 'json_prepare_taxonomy',    'deprecate_v1_endpoints' );
     30add_filter( 'json_prepare_term',        'deprecate_v1_endpoints' );
     31add_filter( 'json_prepare_user',        'deprecate_v1_endpoints' );
    2032
    2133// Allow some routes to skip the JSON REST API v1 plugin.
     
    378390    }
    379391}
     392
     393/**
     394 * Add a deprecation notice to objects in the response
     395 *
     396 * @param array $response_data
     397 *
     398 * @return array
     399 */
     400function deprecate_v1_endpoints( $response_data ) {
     401    $response_data = array_merge(
     402        array( '_WARNING_DEPRECATED' => 'All v1 endpoints have been deprecated, and will be deactivated after 2018-04-01. Please switch to the v2 endpoints by then, in order to ensure that your application continues to function. If you have any questions, join the #meta-wordcamp channel on Slack or email ' . EMAIL_CENTRAL_SUPPORT ),
     403        $response_data
     404    );
     405
     406    return $response_data;
     407}
Note: See TracChangeset for help on using the changeset viewer.