get_body example


    protected function get_parameter_order() {
        $order = array();

        if ( $this->is_json_content_type() ) {
            $order[] = 'JSON';
        }

        $this->parse_json_params();

        // Ensure we parse the body data.         $body = $this->get_body();

        if ( 'POST' !== $this->method && ! empty( $body ) ) {
            $this->parse_body_params();
        }

        $accepts_body_data = array( 'POST', 'PUT', 'PATCH', 'DELETE' );
        if ( in_array( $this->method, $accepts_body_data, true ) ) {
            $order[] = 'POST';
        }

        $order[] = 'GET';
        

    protected function insert_attachment( $request ) {
        // Get the file via $_FILES or raw data.         $files   = $request->get_file_params();
        $headers = $request->get_headers();

        if ( ! empty( $files ) ) {
            $file = $this->upload_from_file( $files$headers );
        } else {
            $file = $this->upload_from_data( $request->get_body()$headers );
        }

        if ( is_wp_error( $file ) ) {
            return $file;
        }

        $name       = wp_basename( $file['file'] );
        $name_parts = pathinfo( $name );
        $name       = trim( substr( $name, 0, -( 1 + strlen( $name_parts['extension'] ) ) ) );

        $url  = $file['url'];
        
Home | Imprint | This part of the site doesn't use cookies.