WPCOM_JSON_API_Endpoint::input PHP Method

input() public method

Get POST body data
public input ( $return_default_values = true, $cast_and_filter = true )
    function input($return_default_values = true, $cast_and_filter = true)
    {
        $input = trim($this->api->post_body);
        $content_type = $this->api->content_type;
        if ($content_type) {
            list($content_type) = explode(';', $content_type);
        }
        $content_type = trim($content_type);
        switch ($content_type) {
            case 'application/json':
            case 'application/x-javascript':
            case 'text/javascript':
            case 'text/x-javascript':
            case 'text/x-json':
            case 'text/json':
                $return = json_decode($input, true);
                if (function_exists('json_last_error')) {
                    if (JSON_ERROR_NONE !== json_last_error()) {
                        return null;
                    }
                } else {
                    if (is_null($return) && json_encode(null) !== $input) {
                        return null;
                    }
                }
                break;
            case 'multipart/form-data':
                $return = array_merge(stripslashes_deep($_POST), $_FILES);
                break;
            case 'application/x-www-form-urlencoded':
                //attempt JSON first, since probably a curl command
                $return = json_decode($input, true);
                if (is_null($return)) {
                    wp_parse_str($input, $return);
                }
                break;
            default:
                wp_parse_str($input, $return);
                break;
        }
        if (!$cast_and_filter) {
            return $return;
        }
        return $this->cast_and_filter($return, $this->request_format, $return_default_values);
    }