From 9341d6980f18564e8fe3bc6cc8c29f27337abb55 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Thu, 18 Aug 2022 11:43:34 +0000 Subject: [PATCH] Themes: Add a Block Themes filter in Theme Install Screen. The Theme Directory on wordpress.org recently got updated to show a shortcut for filtering block themes. This changeset adds a "Block Themes" filter when adding a new theme from WordPress administration. It also introduces two new action hooks: `install_themes_pre_blockthemes` (fires before the tab is rendered) and `install_themes_blockthemes` (fires at the top the tab). Follow-up to [meta11963]. Props luminuu, audrasjb, SergeyBiryukov, rafiahmedd. Fixes #56283. See #meta6330. git-svn-id: https://develop.svn.wordpress.org/trunk@53906 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/wp/theme.js | 13 ++++++++++++- src/wp-admin/theme-install.php | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/js/_enqueues/wp/theme.js b/src/js/_enqueues/wp/theme.js index b3821246d9..4faa6db1b5 100644 --- a/src/js/_enqueues/wp/theme.js +++ b/src/js/_enqueues/wp/theme.js @@ -1694,7 +1694,18 @@ themes.view.Installer = themes.view.Appearance.extend({ browse: function( section ) { // Create a new collection with the proper theme data // for each section. - this.collection.query( { browse: section } ); + if ( 'blockthemes' === section ) { + + var request = { tag: 'full-site-editing' }; + + // Get the themes by sending Ajax POST request to api.wordpress.org/themes + // or searching the local cache. + this.collection.query( request ); + return; + + } else { + this.collection.query( { browse: section } ); + } }, // Sorting navigation. diff --git a/src/wp-admin/theme-install.php b/src/wp-admin/theme-install.php index 07a76ede7f..1fd5a6739b 100644 --- a/src/wp-admin/theme-install.php +++ b/src/wp-admin/theme-install.php @@ -96,8 +96,10 @@ if ( $tab ) { * - `install_themes_pre_search` * - `install_themes_pre_updated` * - `install_themes_pre_upload` + * - `install_themes_pre_blockthemes` * * @since 2.8.0 + * @since 6.1.0 Added `install_themes_pre_blockthemes`. */ do_action( "install_themes_pre_{$tab}" ); } @@ -185,6 +187,7 @@ require_once ABSPATH . 'wp-admin/admin-header.php'; @@ -269,8 +272,10 @@ if ( $tab ) { * - `install_themes_search` * - `install_themes_updated` * - `install_themes_upload` + * - `install_themes_blockthemes` * * @since 2.8.0 + * @since 6.1.0 Added `install_themes_blockthemes`. * * @param int $paged Number of the current page of results being viewed. */