Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#45799 closed enhancement (invalid)

Add an optional default parameter for WP_REST_Request::get_param method

Reported by: ediamin's profile ediamin Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: REST API Keywords: has-patch close
Focuses: rest-api Cc:


This patch adds a default parameter for WP_REST_Request::get_param method, just like we have a default param for get_option function.

Attachments (1)

45799.diff (845 bytes) - added by ediamin 5 years ago.
Proposed changes for WP_REST_Request::get_param method

Download all attachments as: .zip

Change History (8)

5 years ago

Proposed changes for WP_REST_Request::get_param method

#1 @ediamin
5 years ago

  • Type changed from defect (bug) to enhancement

#2 follow-up: @TimothyBlynJacobs
5 years ago

What is the use case for a default value that you wouldn't want to provide by using the JSON Schema default syntax which will automatically fill in a missing value with the default.

#3 in reply to: ↑ 2 @ediamin
5 years ago

The default property in JSON Schema is not a required property and anyone could skip it.

#4 @TimothyBlynJacobs
5 years ago

Skip it in what sense? The server/request will apply the default automatically.

In what instances do you know the proper default value for a param, but not in the position to notate that default in the schema.

#5 @pento
5 years ago

  • Version trunk deleted

#6 @TimothyBlynJacobs
4 years ago

  • Keywords close added

Conditionally adding the close keyword. @ediamin if you could illustrate the scenario you had in mind that'd be great!

#7 @TimothyBlynJacobs
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.