Make WordPress Core


Ignore:
Timestamp:
06/27/2023 09:34:34 AM (3 years ago)
Author:
isabel_brison
Message:

General: add block theme previews.

Adds a preview link to block themes in the themes screen, opening the previews in the site editor.

Props onemaggie, andraganescu, audrasjb, flixos90, peterwilsoncc, spacedmonkey, scruffian.
Fixes #58561.

File:
1 edited

Legend:

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

    r55276 r56059  
    712712
    713713                if ( $is_block_theme && $can_edit_theme_options ) {
    714                         $customize_action = esc_url( admin_url( 'site-editor.php' ) );
     714                        $customize_action = admin_url( 'site-editor.php' );
     715                        if ( $current_theme !== $slug ) {
     716                                $customize_action = add_query_arg( 'wp_theme_preview', $slug, $customize_action );
     717                        }
    715718                } elseif ( ! $is_block_theme && $can_customize && $can_edit_theme_options ) {
    716                         $customize_action = esc_url(
    717                                 add_query_arg(
    718                                         array(
    719                                                 'return' => urlencode( sanitize_url( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ),
    720                                         ),
    721                                         wp_customize_url( $slug )
    722                                 )
     719                        $customize_action = wp_customize_url( $slug );
     720                }
     721                if ( null !== $customize_action ) {
     722                        $customize_action = add_query_arg(
     723                                array(
     724                                        'return' => urlencode( sanitize_url( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ),
     725                                ),
     726                                $customize_action
    723727                        );
     728                        $customize_action = esc_url( $customize_action );
    724729                }
    725730
Note: See TracChangeset for help on using the changeset viewer.