Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Pass WP_JSON_Server instance to json_serve_request #139

Merged
merged 2 commits into from

2 participants

@rmccue
Owner

As noted in #61.

@rmccue rmccue added this to the 1.0 milestone
@rmccue rmccue added the Enhancement label
@rmccue rmccue self-assigned this
@rmccue
Owner

@rachelbaker #reviewmerge

@rmccue rmccue removed their assignment
@rachelbaker rachelbaker was assigned by rmccue
@rachelbaker rachelbaker merged commit 8ff9301 into master
@rmccue rmccue deleted the add-serve-request-arg branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 15, 2014
  1. @rmccue
  2. @rmccue

    Add hook documentation

    rmccue authored
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 3 deletions.
  1. +15 −3 lib/class-wp-json-server.php
View
18 lib/class-wp-json-server.php
@@ -255,9 +255,21 @@ public function serve_request( $path = null ) {
$this->set_status( $code );
}
- // This is a filter rather than an action, since this is designed to be
- // re-entrant if needed
- $served = apply_filters( 'json_serve_request', false, $result, $path, $this->method );
+ /**
+ * Allow sending the request manually
+ *
+ * If `$served` is true, the result will not be sent to the client.
+ *
+ * This is a filter rather than an action, since this is designed to be
+ * re-entrant if needed.
+ *
+ * @param bool $served Whether the request has already been served
+ * @param mixed $result Result to send to the client. JsonSerializable, or other value to pass to `json_encode`
+ * @param string $path Route requested
+ * @param string $method HTTP request method (HEAD/GET/POST/PUT/PATCH/DELETE)
+ * @param WP_JSON_ResponseHandler $this ResponseHandler instance (usually WP_JSON_Server)
+ */
+ $served = apply_filters( 'json_serve_request', false, $result, $path, $this->method, $this );
if ( ! $served ) {
if ( 'HEAD' === $this->method )
Something went wrong with that request. Please try again.