- Timestamp:
- 05/09/2016 12:55:30 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-json-api.php
r3098 r3101 25 25 // Allow users to read new post statuses. 26 26 add_filter( 'json_check_post_read_permission', 'wcorg_json_check_post_read_permission', 10, 2 ); 27 28 // Query the public post statuses when querying WordCamps via the JSON API. 29 add_action( 'pre_get_posts', 'wcorg_json_pre_get_posts' ); 27 30 28 31 /** … … 328 331 $json_collection_pattern = '^[\[].*[\]]$'; 329 332 333 /* disabling until can set correct header 330 334 $eof_pattern = str_replace( 331 335 '<\?xml', … … 333 337 $eof_pattern 334 338 ); 339 */ 335 340 336 341 // Don't append HTML comments to the JSON output, because that would invalidate it … … 388 393 return in_array( $post['post_status'], WordCamp_Loader::get_public_post_statuses() ); 389 394 } 395 396 /** 397 * Query the public post statuses when querying WordCamps via the JSON API. 398 */ 399 function wcorg_json_pre_get_posts( $query ) { 400 if ( ! defined( 'JSON_REQUEST' ) || ! JSON_REQUEST ) 401 return; 402 403 $post_types = $query->get( 'post_type' ); 404 $post_statuses = $query->get( 'post_status' ); 405 406 if ( $post_types == 'wordcamp' || in_array( 'wordcamp', (array) $post_types ) ) { 407 if ( empty( $post_statuses ) ) { 408 $query->set( 'post_status', WordCamp_Loader::get_public_post_statuses() ); 409 } 410 } 411 }
Note: See TracChangeset
for help on using the changeset viewer.