Make WordPress Core

Changeset 41372


Ignore:
Timestamp:
09/11/2017 05:49:58 PM (9 years ago)
Author:
westonruter
Message:

Customize: Align behavior of WP_Customize_Manager::save_changeset_post() with wp_insert_post() by setting status to future if supplied status is publish but date is future.

Props dlh.
Fixes #41336.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r41364 r41372  
    22712271                                return new WP_Error( 'not_future_date' );
    22722272                        }
     2273                }
     2274
     2275                if ( ! empty( $is_future_dated ) && 'publish' === $args['status'] ) {
     2276                        $args['status'] = 'future';
    22732277                }
    22742278
  • trunk/tests/phpunit/tests/customize/manager.php

    r41321 r41372  
    14141414
    14151415        /**
     1416         * Ensure that saving a changeset with a publish status but future date will change the status to future, to align with behavior in wp_insert_post().
     1417         *
     1418         * @ticket 41336
     1419         * @covers WP_Customize_Manager::save_changeset_post
     1420         */
     1421        function test_publish_changeset_with_future_status_when_future_date() {
     1422                $wp_customize = $this->create_test_manager( wp_generate_uuid4() );
     1423
     1424                $wp_customize->save_changeset_post( array(
     1425                        'date_gmt' => gmdate( 'Y-m-d H:i:s', strtotime( '+1 day' ) ),
     1426                        'status' => 'publish',
     1427                        'title' => 'Foo',
     1428                ) );
     1429
     1430                $this->assertSame( 'future', get_post_status( $wp_customize->changeset_post_id() ) );
     1431        }
     1432
     1433        /**
    14161434         * Ensure that save_changeset_post method bails updating an underlying changeset which is invalid.
    14171435         *
Note: See TracChangeset for help on using the changeset viewer.