Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions lib/endpoints/class-wp-rest-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function register_routes() {
}

/**
* Get a collection of items
* Get a collection of items.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
Expand All @@ -21,7 +21,7 @@ public function get_items( $request ) {
}

/**
* Get one item from the collection
* Get one item from the collection.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
Expand All @@ -31,7 +31,7 @@ public function get_item( $request ) {
}

/**
* Create one item from the collection
* Create one item from the collection.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
Expand All @@ -41,7 +41,7 @@ public function create_item( $request ) {
}

/**
* Update one item from the collection
* Update one item from the collection.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
Expand All @@ -51,7 +51,7 @@ public function update_item( $request ) {
}

/**
* Delete one item from the collection
* Delete one item from the collection.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
Expand All @@ -61,7 +61,7 @@ public function delete_item( $request ) {
}

/**
* Check if a given request has access to get items
* Check if a given request has access to get items.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
Expand All @@ -71,7 +71,7 @@ public function get_items_permissions_check( $request ) {
}

/**
* Check if a given request has access to get a specific item
* Check if a given request has access to get a specific item.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
Expand All @@ -81,7 +81,7 @@ public function get_item_permissions_check( $request ) {
}

/**
* Check if a given request has access to create items
* Check if a given request has access to create items.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
Expand All @@ -91,7 +91,7 @@ public function create_item_permissions_check( $request ) {
}

/**
* Check if a given request has access to update a specific item
* Check if a given request has access to update a specific item.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
Expand All @@ -101,7 +101,7 @@ public function update_item_permissions_check( $request ) {
}

/**
* Check if a given request has access to delete a specific item
* Check if a given request has access to delete a specific item.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
Expand All @@ -111,17 +111,17 @@ public function delete_item_permissions_check( $request ) {
}

/**
* Prepare the item for create or update operation
* Prepare the item for create or update operation.
*
* @param WP_REST_Request $request Request object
* @param WP_REST_Request $request Request object.
* @return WP_Error|object $prepared_item
*/
protected function prepare_item_for_database( $request ) {
return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be over-ridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) );
}

/**
* Prepare the item for the REST response
* Prepare the item for the REST response.
*
* @param mixed $item WordPress representation of the item.
* @param WP_REST_Request $request Request object.
Expand Down Expand Up @@ -152,7 +152,7 @@ public function prepare_response_for_collection( $response ) {
}

/**
* Filter a response based on the context defined in the schema
* Filter a response based on the context defined in the schema.
*
* @param array $data
* @param string $context
Expand Down Expand Up @@ -186,7 +186,7 @@ public function filter_response_by_context( $data, $context ) {
}

/**
* Get the item's schema, conforming to JSON Schema
* Get the item's schema, conforming to JSON Schema.
*
* @return array
*/
Expand All @@ -213,7 +213,7 @@ public function get_public_item_schema() {
}

/**
* Get the query params for collections
* Get the query params for collections.
*
* @return array
*/
Expand All @@ -240,11 +240,11 @@ public function get_collection_params() {
}

/**
* Add the values from additional fields to a data object
* Add the values from additional fields to a data object.
*
* @param array $object
* @param WP_REST_Request $request
* @return array modified object with additional fields
* @return array modified object with additional fields.
*/
protected function add_additional_fields_to_object( $object, $request ) {

Expand Down Expand Up @@ -278,7 +278,7 @@ protected function update_additional_fields_for_object( $object, $request ) {
continue;
}

// Don't run the update callbacks if the data wasn't passed in the request
// Don't run the update callbacks if the data wasn't passed in the request.
if ( ! isset( $request[ $field_name ] ) ) {
continue;
}
Expand All @@ -288,19 +288,19 @@ protected function update_additional_fields_for_object( $object, $request ) {
}

/**
* Add the schema from additional fields to an schema array
* Add the schema from additional fields to an schema array.
*
* The type of object is inferred from the passed schema.
*
* @param array $schema Schema array
* @param array $schema Schema array.
*/
protected function add_additional_fields_schema( $schema ) {
if ( ! $schema || ! isset( $schema['title'] ) ) {
return $schema;
}

/**
* Can't use $this->get_object_type otherwise we cause an inf loop
* Can't use $this->get_object_type otherwise we cause an inf loop.
*/
$object_type = $schema['title'];

Expand All @@ -318,7 +318,7 @@ protected function add_additional_fields_schema( $schema ) {
}

/**
* Get all the registered additional fields for a given object-type
* Get all the registered additional fields for a given object-type.
*
* @param string $object_type
* @return array
Expand Down Expand Up @@ -497,7 +497,7 @@ public function sanitize_schema_property( $value, $request, $parameter ) {

case 'email' :
// as sanitize_email is very lossy, we just want to
// make sure the string is safe
// make sure the string is safe.
if ( sanitize_email( $value ) ) {
return sanitize_email( $value );
}
Expand Down