- Timestamp:
- 08/03/2016 08:07:42 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-json-api.php
r3104 r3770 18 18 add_filter( 'json_prepare_post', 'wcorg_json_embed_related_posts', 999, 3 ); // after `wcorg_json_expose_additional_post_data()` 19 19 add_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 add_filter( 'wp_cache_eof_tags', 'wcorg_json_cache_requests' );21 20 22 21 // Allow some routes to skip the JSON REST API v1 plugin. … … 315 314 316 315 /** 317 * Tell WP Super Cache to cache API endpoints318 *319 * @param string $eof_pattern320 *321 * @return string322 */323 function wcorg_json_cache_requests( $eof_pattern ) {324 global $wp_super_cache_comments;325 326 $api_request = ( defined( 'JSON_REQUEST' ) && JSON_REQUEST ) || ( defined( 'REST_REQUEST' ) && REST_REQUEST );327 328 if ( $api_request ) {329 // Accept a JSON-formatted string as an end-of-file marker, so that the page will be cached330 $json_object_pattern = '^[{].*[}]$';331 $json_collection_pattern = '^[\[].*[\]]$';332 333 /* disabling until can set correct header334 $eof_pattern = str_replace(335 '<\?xml',336 sprintf( '<\?xml|%s|%s', $json_object_pattern, $json_collection_pattern ),337 $eof_pattern338 );339 */340 341 // Don't append HTML comments to the JSON output, because that would invalidate it342 $wp_super_cache_comments = false;343 }344 345 return $eof_pattern;346 }347 348 /**349 316 * JSON REST API v1 and Core/v2 compatibility. 350 317 *
Note: See TracChangeset
for help on using the changeset viewer.