Make WordPress Core

Changeset 61195


Ignore:
Timestamp:
11/10/2025 09:04:46 PM (2 months ago)
Author:
westonruter
Message:

Themes: Restore 'Live Preview' button for block themes.

Note that the return query parameter is not yet functional in the Site Editor. See Gutenberg#47934.

Follow-up to [52341], [52346], [52353], [52802].

Props ninomiho, mcsf, dhruval04, praful2111, mlaetitia1986.
See #54578.
Fixes #64159.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-theme-installer-skin.php

    r59513 r61195  
    122122        $install_actions = array();
    123123
    124         if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) && ! $theme_info->is_block_theme() ) {
    125             $customize_url = add_query_arg(
    126                 array(
    127                     'theme'  => urlencode( $stylesheet ),
    128                     'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ),
    129                 ),
    130                 admin_url( 'customize.php' )
    131             );
     124        if ( current_user_can( 'edit_theme_options' ) && ( $theme_info->is_block_theme() || current_user_can( 'customize' ) ) ) {
     125            if ( $theme_info->is_block_theme() ) {
     126                $customize_url = add_query_arg(
     127                    array(
     128                        'wp_theme_preview' => urlencode( $stylesheet ),
     129                        'return'           => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ),
     130                    ),
     131                    admin_url( 'site-editor.php' )
     132                );
     133            } else {
     134                $customize_url = add_query_arg(
     135                    array(
     136                        'theme'  => urlencode( $stylesheet ),
     137                        'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ),
     138                    ),
     139                    admin_url( 'customize.php' )
     140                );
     141            }
    132142
    133143            $install_actions['preview'] = sprintf(
  • trunk/src/wp-admin/themes.php

    r59960 r61195  
    646646
    647647            <?php
    648             if ( ! $theme['blockTheme'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
     648            if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
    649649                /* translators: %s: Theme name. */
    650650                $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
     
    10351035                    ><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
    10361036
    1037                     <# if ( ! data.blockTheme ) { #>
    1038                         <?php
    1039                         /* translators: %s: Theme name. */
    1040                         $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
    1041                         ?>
    1042                         <a class="button button-primary hide-if-no-customize disabled"
    1043                             aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
    1044                         ><?php _e( 'Live Preview' ); ?></a>
    1045                     <# } #>
     1037                    <?php
     1038                    /* translators: %s: Theme name. */
     1039                    $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
     1040                    ?>
     1041                    <a class="button button-primary hide-if-no-customize disabled"
     1042                        aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
     1043                    ><?php _e( 'Live Preview' ); ?></a>
    10461044                <# } #>
    10471045            <# } #>
     
    12621260            <div class="inactive-theme">
    12631261                <# if ( data.compatibleWP && data.compatiblePHP ) { #>
    1264                     <# if ( ! data.blockTheme ) { #>
    1265                         <?php
    1266                         /* translators: %s: Theme name. */
    1267                         $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
    1268                         ?>
    1269                         <a class="button button-primary load-customize hide-if-no-customize"
    1270                             href="{{{ data.actions.customize }}}"
    1271                             aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
    1272                         ><?php _e( 'Live Preview' ); ?></a>
    1273                     <# } #>
     1262                    <?php
     1263                    /* translators: %s: Theme name. */
     1264                    $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
     1265                    ?>
     1266                    <a class="button button-primary load-customize hide-if-no-customize"
     1267                        href="{{{ data.actions.customize }}}"
     1268                        aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
     1269                    ><?php _e( 'Live Preview' ); ?></a>
    12741270
    12751271                    <# if ( data.actions.activate ) { #>
     
    12841280                    <# } #>
    12851281                <# } else { #>
    1286                     <# if ( ! data.blockTheme ) { #>
    1287                         <?php
    1288                         /* translators: %s: Theme name. */
    1289                         $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
    1290                         ?>
    1291                         <a class="button button-primary hide-if-no-customize disabled"
    1292                             aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
    1293                         ><?php _e( 'Live Preview' ); ?></a>
    1294                     <# } #>
     1282                    <?php
     1283                    /* translators: %s: Theme name. */
     1284                    $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
     1285                    ?>
     1286                    <a class="button button-primary hide-if-no-customize disabled"
     1287                        aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
     1288                    ><?php _e( 'Live Preview' ); ?></a>
    12951289
    12961290                    <# if ( data.actions.activate ) { #>
Note: See TracChangeset for help on using the changeset viewer.