mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
REST API: Pass "null" as the post date property to reset post to initial "floating" date value.
Props TimothyBlynJacobs, adamsilverstein, jnylen0, mnelson4. Fixes #44975. git-svn-id: https://develop.svn.wordpress.org/trunk@46249 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1036,6 +1036,16 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
// Sending a null date or date_gmt value resets date and date_gmt to their
|
||||
// default values (`0000-00-00 00:00:00`).
|
||||
if (
|
||||
( ! empty( $schema['properties']['date_gmt'] ) && $request->has_param( 'date_gmt' ) && null === $request['date_gmt'] ) ||
|
||||
( ! empty( $schema['properties']['date'] ) && $request->has_param( 'date' ) && null === $request['date'] )
|
||||
) {
|
||||
$prepared_post->post_date_gmt = null;
|
||||
$prepared_post->post_date = null;
|
||||
}
|
||||
|
||||
// Post slug.
|
||||
if ( ! empty( $schema['properties']['slug'] ) && isset( $request['slug'] ) ) {
|
||||
$prepared_post->post_name = $request['slug'];
|
||||
@@ -1891,13 +1901,13 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
'properties' => array(
|
||||
'date' => array(
|
||||
'description' => __( "The date the object was published, in the site's timezone." ),
|
||||
'type' => 'string',
|
||||
'type' => array( 'string', 'null' ),
|
||||
'format' => 'date-time',
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
),
|
||||
'date_gmt' => array(
|
||||
'description' => __( 'The date the object was published, as GMT.' ),
|
||||
'type' => 'string',
|
||||
'type' => array( 'string', 'null' ),
|
||||
'format' => 'date-time',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user