Make WordPress Core


Ignore:
Timestamp:
10/18/2016 08:04:36 PM (8 years ago)
Author:
westonruter
Message:

Customize: Implement customized state persistence with changesets.

Includes infrastructure developed in the Customize Snapshots feature plugin.

See https://make.wordpress.org/core/2016/10/12/customize-changesets-technical-design-decisions/

Props westonruter, valendesigns, utkarshpatel, stubgo, lgedeon, ocean90, ryankienstra, mihai2u, dlh, aaroncampbell, jonathanbardo, jorbin.
See #28721.
See #31089.
Fixes #30937.
Fixes #31517.
Fixes #30028.
Fixes #23225.
Fixes #34142.
Fixes #36485.

File:
1 edited

Legend:

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

    r38672 r38810  
    2121}
    2222
     23/**
     24 * @global WP_Scripts           $wp_scripts
     25 * @global WP_Customize_Manager $wp_customize
     26 */
     27global $wp_scripts, $wp_customize;
     28
     29if ( $wp_customize->changeset_post_id() ) {
     30    if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $wp_customize->changeset_post_id() ) ) {
     31        wp_die(
     32            '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     33            '<p>' . __( 'Sorry, you are not allowed to edit this changeset.' ) . '</p>',
     34            403
     35        );
     36    }
     37    if ( in_array( get_post_status( $wp_customize->changeset_post_id() ), array( 'publish', 'trash' ), true ) ) {
     38        wp_die(
     39            '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
     40            '<p>' . __( 'This changeset has already been published and cannot be further modified.' ) . '</p>' .
     41            '<p><a href="' . esc_url( remove_query_arg( 'changeset_uuid' ) ) . '">' . __( 'Customize New Changes' ) . '</a></p>',
     42            403
     43        );
     44    }
     45}
     46
     47
    2348wp_reset_vars( array( 'url', 'return', 'autofocus' ) );
    2449if ( ! empty( $url ) ) {
     
    3156    $wp_customize->set_autofocus( wp_unslash( $autofocus ) );
    3257}
    33 
    34 /**
    35  * @global WP_Scripts           $wp_scripts
    36  * @global WP_Customize_Manager $wp_customize
    37  */
    38 global $wp_scripts, $wp_customize;
    3958
    4059$registered = $wp_scripts->registered;
     
    116135            <?php
    117136            $save_text = $wp_customize->is_theme_active() ? __( 'Save &amp; Publish' ) : __( 'Save &amp; Activate' );
    118             submit_button( $save_text, 'primary save', 'save', false );
     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 );
    119142            ?>
    120143            <span class="spinner"></span>
Note: See TracChangeset for help on using the changeset viewer.