Make WordPress Core


Ignore:
Timestamp:
09/27/2017 10:24:37 PM (7 years ago)
Author:
westonruter
Message:

Customize: Introduce drafting and scheduling for Customizer changesets.

  • Incorporates code from the Customize Snapshots and Customize Posts feature plugins.
  • Adds a new Publish Settings section for managing the changeset status, scheduled date, and frontend preview link.
  • Updates Publish button to reflect the status selected in the Publish Settings (including Save Draft and Schedule).
  • Deactivates the Themes section when a non-publish status selected, and deactivates the Publish Settings section when previewing a theme switch.
  • Introduces an outer section type (wp.customize.OuterSection in JS) for the Publish Settings section to use and for available widgets and available nav menu panels to use in the future. These sections can be expanded while other sections are expanded.
  • Introduces WP_Customize_Date_Time_Control in PHP and wp.customize.DateTimeControl in JS for managing a date/time value.
  • Keeps track of scheduled time and proactively publish from the client when the time arrives, as opposed to waiting for WP Cron.
  • Auto-publishes a scheduled changeset when attempting to access one that missed its schedule.
  • Starts a new changeset if attempting to save a changeset that was previously publish.
  • Adds force arg to requestChangesetUpdate() to force an update request even when there are no pending changes.
  • Adds utils methods for getCurrentTimestamp and getRemainingTime.
  • Adds new state values for selectedChangesetStatus, changesetDate, selectedChangesetDate.
  • Fixes logic for when to short-circuit check to close Customizer when there are unsaved changes.
  • Adds getter methods for autosaved and branching parameters, with the latter applying the customize_changeset_branching filter.
  • Call to establish_loaded_changeset on the fly when changeset_uuid() is called if no changeset UUID was specififed.
  • De-duplicates logic for dismissing auto-draft changesets.
  • Includes unit tests.

Builds on [41597].
Props sayedwp, westonruter, melchoyce, JoshuaWold, folletto, stubgo, karmatosed, dlh, paaljoachim, afercia, johnregan3, utkarshpatel, valendesigns.
See #30937.
Fixes #39896, #28721, #39275.

File:
1 edited

Legend:

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

    r41374 r41626  
    2828
    2929if ( $wp_customize->changeset_post_id() ) {
    30     if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $wp_customize->changeset_post_id() ) ) {
     30    $changeset_post = get_post( $wp_customize->changeset_post_id() );
     31
     32    if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post->ID ) ) {
    3133        wp_die(
    3234            '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     
    3537        );
    3638    }
    37     if ( in_array( get_post_status( $wp_customize->changeset_post_id() ), array( 'publish', 'trash' ), true ) ) {
     39
     40    $missed_schedule = (
     41        'future' === $changeset_post->post_status &&
     42        get_post_time( 'G', true, $changeset_post ) < time()
     43    );
     44    if ( $missed_schedule ) {
     45        wp_publish_post( $changeset_post->ID );
     46        wp_die(
     47            '<h1>' . __( 'Your scheduled changes just published' ) . '</h1>' .
     48            '<p><a href="' . esc_url( remove_query_arg( 'changeset_uuid' ) ) . '">' . __( 'Customize New Changes' ) . '</a></p>',
     49            200
     50        );
     51    }
     52
     53    if ( in_array( get_post_status( $changeset_post->ID ), array( 'publish', 'trash' ), true ) ) {
    3854        wp_die(
    3955            '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     
    133149    <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
    134150        <div id="customize-header-actions" class="wp-full-overlay-header">
    135             <?php
    136             $save_text = $wp_customize->is_theme_active() ? __( 'Save &amp; Publish' ) : __( 'Save &amp; Activate' );
    137             $save_attrs = array();
    138             if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->publish_posts ) ) {
    139                 $save_attrs['style'] = 'display: none';
    140             }
    141             submit_button( $save_text, 'primary save', 'save', false, $save_attrs );
    142             ?>
     151            <?php $save_text = $wp_customize->is_theme_active() ? __( 'Publish' ) : __( 'Activate &amp; Publish' ); ?>
     152            <div id="customize-save-button-wrapper" class="customize-save-button-wrapper" >
     153                <?php submit_button( $save_text, 'primary save', 'save', false ); ?>
     154                <button id="publish-settings" class="publish-settings button-primary button dashicons dashicons-admin-generic" aria-label="<?php esc_attr_e( 'Publish Settings' ); ?>" aria-expanded="false" disabled></button>
     155            </div>
    143156            <span class="spinner"></span>
    144157            <button type="button" class="customize-controls-preview-toggle">
     
    204217    </form>
    205218    <div id="customize-preview" class="wp-full-overlay-main"></div>
     219    <div id="customize-sidebar-outer-content">
     220        <div id="customize-outer-theme-controls-wrapper">
     221            <div id="customize-outer-theme-controls">
     222                <ul class="customize-outer-pane-parent"><?php // Outer panel and sections are not implemented, but its here as a placeholder to avoid any side-effect in api.Section. ?></ul>
     223            </div>
     224        </div>
     225    </div>
    206226    <?php
    207227
Note: See TracChangeset for help on using the changeset viewer.