Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme Previews: Make the back button customizable #54242

Merged
merged 4 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions lib/compat/wordpress-6.4/theme-previews.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* Enable theme previews in the Site Editor for block themes.
*
* @package gutenberg
*/

/**
* Allow developers to customize the back to dashboard link in the Site Editor
*
* @param array $settings The editor settings.
* @return array The editor settings.
*/

Check failure on line 13 in lib/compat/wordpress-6.4/theme-previews.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

There must be no blank lines after the function comment

function gutenberg_theme_preview_block_editor_settings_all( $settings ) {
$settings['__experimentalDashboardLink'] = 'themes.php';
okmttdhr marked this conversation as resolved.
Show resolved Hide resolved
return $settings;
}

// Attaches filters to enable theme previews in the Site Editor.
okmttdhr marked this conversation as resolved.
Show resolved Hide resolved
if ( ! empty( $_GET['wp_theme_preview'] ) ) {
add_filter( 'block_editor_settings_all', 'gutenberg_theme_preview_block_editor_settings_all' );
}
1 change: 1 addition & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function gutenberg_is_experiment_enabled( $name ) {
// WordPress 6.4 compat.
require_once __DIR__ . '/compat/wordpress-6.4/class-gutenberg-rest-global-styles-revisions-controller-6-4.php';
require_once __DIR__ . '/compat/wordpress-6.4/rest-api.php';
require_once __DIR__ . '/compat/wordpress-6.4/theme-previews.php';

// Plugin specific code.
require_once __DIR__ . '/class-wp-rest-global-styles-controller-gutenberg.php';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@ export default function SidebarNavigationScreen( {
? __( 'Go to the Dashboard' )
: __( 'Go back to the theme showcase' )
}
href={
! isPreviewingTheme()
? dashboardLink || 'index.php'
: 'themes.php'
}
href={ dashboardLink || 'index.php' }
/>
) }
<Heading
Expand Down
Loading