Make WordPress Core


Ignore:
Timestamp:
07/02/2023 08:02:45 AM (12 months ago)
Author:
audrasjb
Message:

Quick/Bulk Edit: Ensure scheduled posts are published when using Bulk Edit.

This changeset ensures scheduled posts are actually published when changing their status to "Published" using bulk edit. Also adds related unit tests.

Props siobhan, Clorith, webcommsat, cadic, oglekler, audrasjb, pavanpatil1.
Fixes #31635.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r56091 r56123  
    668668        // Prevent wp_insert_post() from overwriting post format with the old data.
    669669        unset( $post_data['tax_input']['post_format'] );
     670
     671        // Reset post date of scheduled post to be published.
     672        if (
     673            in_array( $post->post_status, array( 'future', 'draft' ), true ) &&
     674            'publish' === $post_data['post_status']
     675        ) {
     676            $post_data['post_date']     = current_time( 'mysql' );
     677            $post_data['post_date_gmt'] = '';
     678        }
    670679
    671680        $post_id = wp_update_post( $post_data );
Note: See TracChangeset for help on using the changeset viewer.