From d83e14e86cdb3b658a8fb9cefe05350e4e14c904 Mon Sep 17 00:00:00 2001 From: scruffian Date: Thu, 7 Sep 2023 11:58:02 +0100 Subject: [PATCH 1/4] Theme Previews: Make the back button customizable --- lib/compat/wordpress-6.4/theme-previews.php | 23 +++++++++++++++++++ lib/load.php | 1 + .../sidebar-navigation-screen/index.js | 6 +---- 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 lib/compat/wordpress-6.4/theme-previews.php diff --git a/lib/compat/wordpress-6.4/theme-previews.php b/lib/compat/wordpress-6.4/theme-previews.php new file mode 100644 index 00000000000000..fd633d6bb139a0 --- /dev/null +++ b/lib/compat/wordpress-6.4/theme-previews.php @@ -0,0 +1,23 @@ + ) } Date: Tue, 12 Sep 2023 14:43:51 +0900 Subject: [PATCH 2/4] Add a comment about a filter --- lib/compat/wordpress-6.4/theme-previews.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/compat/wordpress-6.4/theme-previews.php b/lib/compat/wordpress-6.4/theme-previews.php index fd633d6bb139a0..d120c57567a94a 100644 --- a/lib/compat/wordpress-6.4/theme-previews.php +++ b/lib/compat/wordpress-6.4/theme-previews.php @@ -11,13 +11,16 @@ * @param array $settings The editor settings. * @return array The editor settings. */ - function gutenberg_theme_preview_block_editor_settings_all( $settings ) { $settings['__experimentalDashboardLink'] = 'themes.php'; return $settings; } -// Attaches filters to enable theme previews in the Site Editor. +/** + * Attaches filters to enable theme previews in the Site Editor. + * This would go inside of `initialize_theme_preview_hooks` + * to avoid the global scope when we port this to the core. + */ if ( ! empty( $_GET['wp_theme_preview'] ) ) { add_filter( 'block_editor_settings_all', 'gutenberg_theme_preview_block_editor_settings_all' ); } From 04e476771be2eb50c470b0b830c9d5a0a05f6469 Mon Sep 17 00:00:00 2001 From: okmttdhr Date: Tue, 12 Sep 2023 14:47:29 +0900 Subject: [PATCH 3/4] Theme Previews: Make the backlink text customizable --- lib/compat/wordpress-6.4/theme-previews.php | 1 + .../src/components/sidebar-navigation-screen/index.js | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/compat/wordpress-6.4/theme-previews.php b/lib/compat/wordpress-6.4/theme-previews.php index d120c57567a94a..78becbb2f75bab 100644 --- a/lib/compat/wordpress-6.4/theme-previews.php +++ b/lib/compat/wordpress-6.4/theme-previews.php @@ -13,6 +13,7 @@ */ function gutenberg_theme_preview_block_editor_settings_all( $settings ) { $settings['__experimentalDashboardLink'] = 'themes.php'; + $settings['__experimentalDashboardLinkText'] = __( 'Go back to the theme showcase' ); return $settings; } diff --git a/packages/edit-site/src/components/sidebar-navigation-screen/index.js b/packages/edit-site/src/components/sidebar-navigation-screen/index.js index d395da4f83abb4..9ab6f58c81b212 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen/index.js @@ -41,10 +41,11 @@ export default function SidebarNavigationScreen( { description, backPath: backPathProp, } ) { - const { dashboardLink } = useSelect( ( select ) => { + const { dashboardLink, dashboardLinkText } = useSelect( ( select ) => { const { getSettings } = unlock( select( editSiteStore ) ); return { dashboardLink: getSettings().__experimentalDashboardLink, + dashboardLinkText: getSettings().__experimentalDashboardLinkText, }; }, [] ); const { getTheme } = useSelect( coreStore ); @@ -92,9 +93,7 @@ export default function SidebarNavigationScreen( { From 14c75accb4e3f701f364ef9e774b11bbbc7041cc Mon Sep 17 00:00:00 2001 From: okmttdhr Date: Tue, 12 Sep 2023 14:49:58 +0900 Subject: [PATCH 4/4] Fix PHPCS errors --- lib/compat/wordpress-6.4/theme-previews.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compat/wordpress-6.4/theme-previews.php b/lib/compat/wordpress-6.4/theme-previews.php index 78becbb2f75bab..5755fc992921d4 100644 --- a/lib/compat/wordpress-6.4/theme-previews.php +++ b/lib/compat/wordpress-6.4/theme-previews.php @@ -12,7 +12,7 @@ * @return array The editor settings. */ function gutenberg_theme_preview_block_editor_settings_all( $settings ) { - $settings['__experimentalDashboardLink'] = 'themes.php'; + $settings['__experimentalDashboardLink'] = 'themes.php'; $settings['__experimentalDashboardLinkText'] = __( 'Go back to the theme showcase' ); return $settings; }