diff --git src/wp-admin/theme-install.php src/wp-admin/theme-install.php
index 43f105f377..63a73d0f07 100644
|
|
get_current_screen()->set_help_sidebar( |
123 | 123 | |
124 | 124 | include(ABSPATH . 'wp-admin/admin-header.php'); |
125 | 125 | |
| 126 | $is_customize_preview_available = true; |
| 127 | |
| 128 | /** This filter is documented in wp-includes/class-wp-customize-manager.php */ |
| 129 | if ( ! apply_filters( 'customize_changeset_branching', false ) ) { |
| 130 | $is_customize_preview_available = count( get_posts( array( |
| 131 | 'post_status' => array_diff( get_post_stati(), array( 'auto-draft', 'publish', 'trash', 'inherit', 'private' ) ), |
| 132 | 'author' => 'any', |
| 133 | 'posts_per_page' => 1, |
| 134 | 'order' => 'DESC', |
| 135 | 'orderby' => 'date', |
| 136 | 'post_type' => 'customize_changeset', |
| 137 | 'no_found_rows' => true, |
| 138 | 'cache_results' => true, |
| 139 | 'update_post_meta_cache' => false, |
| 140 | 'update_post_term_cache' => false, |
| 141 | 'lazy_load_term_meta' => false, |
| 142 | ) ) ) === 0; |
| 143 | } |
| 144 | |
126 | 145 | ?> |
127 | 146 | <div class="wrap"> |
128 | 147 | <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1> |
… |
… |
include(ABSPATH . 'wp-admin/admin-header.php'); |
150 | 169 | <p><?php _e( 'The Theme Installer screen requires JavaScript.' ); ?></p> |
151 | 170 | </div> |
152 | 171 | |
| 172 | <?php if ( ! $is_customize_preview_available ) : ?> |
| 173 | <div class="notice notice-info"> |
| 174 | <p><?php _e( 'Live preview for inactive themes is not currently available because there are drafted or scheduled changes for the active theme.' ); ?></p> |
| 175 | </div> |
| 176 | <?php endif; ?> |
| 177 | |
153 | 178 | <div class="upload-theme"> |
154 | 179 | <?php install_themes_upload(); ?> |
155 | 180 | </div> |
… |
… |
if ( $tab ) { |
277 | 302 | <# if ( data.activate_url ) { #> |
278 | 303 | <a class="button button-primary activate" href="{{ data.activate_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a> |
279 | 304 | <# } #> |
280 | | <# if ( data.customize_url ) { #> |
| 305 | <# if ( data.customize_url && <?php echo wp_json_encode( $is_customize_preview_available ); ?> ) { #> |
281 | 306 | <a class="button load-customize" href="{{ data.customize_url }}"><?php _e( 'Live Preview' ); ?></a> |
282 | 307 | <# } else { #> |
283 | 308 | <button class="button preview install-theme-preview"><?php _e( 'Preview' ); ?></button> |
diff --git src/wp-admin/themes.php src/wp-admin/themes.php
index 9218983239..c5a8a2deb8 100644
|
|
wp_enqueue_script( 'theme' ); |
148 | 148 | wp_enqueue_script( 'updates' ); |
149 | 149 | |
150 | 150 | require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
| 151 | |
| 152 | $is_customize_preview_available = true; |
| 153 | |
| 154 | /** This filter is documented in wp-includes/class-wp-customize-manager.php */ |
| 155 | if ( ! apply_filters( 'customize_changeset_branching', false ) ) { |
| 156 | $is_customize_preview_available = count( get_posts( array( |
| 157 | 'post_status' => array_diff( get_post_stati(), array( 'auto-draft', 'publish', 'trash', 'inherit', 'private' ) ), |
| 158 | 'author' => 'any', |
| 159 | 'posts_per_page' => 1, |
| 160 | 'order' => 'DESC', |
| 161 | 'orderby' => 'date', |
| 162 | 'post_type' => 'customize_changeset', |
| 163 | 'no_found_rows' => true, |
| 164 | 'cache_results' => true, |
| 165 | 'update_post_meta_cache' => false, |
| 166 | 'update_post_term_cache' => false, |
| 167 | 'lazy_load_term_meta' => false, |
| 168 | ) ) ) === 0; |
| 169 | } |
| 170 | |
151 | 171 | ?> |
152 | 172 | |
153 | 173 | <div class="wrap"> |
… |
… |
if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) : ?> |
178 | 198 | <?php |
179 | 199 | endif; |
180 | 200 | |
| 201 | if ( ! $is_customize_preview_available ) : |
| 202 | ?> |
| 203 | <div class="notice notice-info"> |
| 204 | <p><?php _e( 'Live preview for inactive themes is not currently available because there are drafted or scheduled changes for the active theme.' ); ?></p> |
| 205 | </div> |
| 206 | <?php |
| 207 | endif; |
| 208 | |
181 | 209 | $ct = wp_get_theme(); |
182 | 210 | |
183 | 211 | if ( $ct->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) { |
… |
… |
foreach ( $themes as $theme ) : |
296 | 324 | $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' ); |
297 | 325 | ?> |
298 | 326 | <a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a> |
299 | | <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?> |
| 327 | <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) && $is_customize_preview_available ) { ?> |
300 | 328 | <a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a> |
301 | 329 | <?php } ?> |
302 | 330 | <?php } ?> |
… |
… |
$can_install = current_user_can( 'install_themes' ); |
431 | 459 | $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' ); |
432 | 460 | ?> |
433 | 461 | <a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a> |
434 | | <a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a> |
| 462 | <?php if ( $is_customize_preview_available ) : ?> |
| 463 | <a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a> |
| 464 | <?php endif; ?> |
435 | 465 | <# } #> |
436 | 466 | </div> |
437 | 467 | </div> |
… |
… |
$can_install = current_user_can( 'install_themes' ); |
492 | 522 | <# if ( data.actions.activate ) { #> |
493 | 523 | <a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a> |
494 | 524 | <# } #> |
495 | | <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a> |
| 525 | <?php if ( $is_customize_preview_available ) : ?> |
| 526 | <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a> |
| 527 | <?php endif; ?> |
496 | 528 | </div> |
497 | 529 | |
498 | 530 | <# if ( ! data.active && data.actions['delete'] ) { #> |
diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
index 12256d2173..a063e3e148 100644
|
|
final class WP_Customize_Manager { |
782 | 782 | * |
783 | 783 | * @since 4.9.0 |
784 | 784 | * |
785 | | * @param bool $allow_branching Whether branching is allowed. If `false`, the default, |
786 | | * then only one saved changeset exists at a time. |
787 | | * @param WP_Customize_Manager $wp_customize Manager instance. |
| 785 | * @param bool $allow_branching Whether branching is allowed. If `false`, the default, |
| 786 | * then only one saved changeset exists at a time. |
788 | 787 | */ |
789 | | $this->branching = apply_filters( 'customize_changeset_branching', $this->branching, $this ); |
| 788 | $this->branching = apply_filters( 'customize_changeset_branching', $this->branching ); |
790 | 789 | |
791 | 790 | return $this->branching; |
792 | 791 | } |