Making WordPress.org

Changeset 2848


Ignore:
Timestamp:
03/30/2016 12:09:58 PM (11 years ago)
Author:
kovshenin
Message:

WordCamp Post Type: Allow the old JSON API endpoint to read our custom statuses.

File:
1 edited

Legend:

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

    r2358 r2848  
    11<?php
    2 
    32/*
    43 * Customizations to the JSON REST API
    … …  
    2322// Allow some routes to skip the JSON REST API v1 plugin.
    2423add_action( 'parse_request', 'wcorg_json_v2_compat', 9 );
     24
     25// Allow users to read new post statuses.
     26add_filter( 'json_check_post_read_permission', 'wcorg_json_check_post_read_permission', 10, 2 );
    2527
    2628/**
    … …  
    372374        return;
    373375}
     376
     377function wcorg_json_check_post_read_permission( $permission, $post ) {
     378        if ( $permission || ! defined( 'WCPT_POST_TYPE_ID' ) ) {
     379                return $permission;
     380        }
     381
     382        if ( $post['post_type'] != WCPT_POST_TYPE_ID ) {
     383                return $permission;
     384        }
     385
     386        return in_array( $post['post_status'], WordCamp_Loader::get_public_post_statuses() );
     387}
Note: See TracChangeset for help on using the changeset viewer.