Opened 12 years ago
Closed 12 years ago
#27578 closed defect (bug) (duplicate)
Editing a draft does not set `post_date_gmt`, but quick editing a draft does
| Reported by: | Denis-de-Bernardy | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Posts, Post Types | Version: | 3.9 |
| Severity: | normal | Keywords: | has-patch needs-unit-tests |
| Cc: | Focuses: | administration |
Description
(It's all in the title…)
Attachments (1)
Change History (7)
#2
@
12 years ago
Trashing a draft sets its post_date_gmt field as well:
- Create a draft.
- Trash it.
- Restore it.
- The date no longer offers to publish immediately
#3
@
12 years ago
A fix to all of these (bar clearing the date, but it works around the problem) is to change the following in wp_insert_post():
if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) {
if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
$post_date_gmt = get_gmt_from_date($post_date);
else
$post_date_gmt = '0000-00-00 00:00:00';
}
To:
if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) {
if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
$post_date_gmt = get_gmt_from_date($post_date);
else
$post_date_gmt = '0000-00-00 00:00:00';
}
elseif ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
$post_date_gmt = '0000-00-00 00:00:00';
}
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
As a bonus, too, you cannot clear the date of the draft to make it so that it gets published immediately: you need to manually set the date to whenever.