Make WordPress Core

Changeset 53906


Ignore:
Timestamp:
08/18/2022 11:43:34 AM (22 months ago)
Author:
audrasjb
Message:

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.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/theme.js

    r52819 r53906  
    16951695        // Create a new collection with the proper theme data
    16961696        // for each section.
    1697         this.collection.query( { browse: section } );
     1697        if ( 'blockthemes' === section ) {
     1698
     1699            var request = { tag: 'full-site-editing' };
     1700
     1701            // Get the themes by sending Ajax POST request to api.wordpress.org/themes
     1702            // or searching the local cache.
     1703            this.collection.query( request );
     1704            return;
     1705
     1706        } else {
     1707            this.collection.query( { browse: section } );
     1708        }
    16981709    },
    16991710
  • trunk/src/wp-admin/theme-install.php

    r53191 r53906  
    9797     *  - `install_themes_pre_updated`
    9898     *  - `install_themes_pre_upload`
     99     *  - `install_themes_pre_blockthemes`
    99100     *
    100101     * @since 2.8.0
     102     * @since 6.1.0 Added `install_themes_pre_blockthemes`.
    101103     */
    102104    do_action( "install_themes_pre_{$tab}" );
     
    186188            <li><a href="#" data-sort="popular"><?php _ex( 'Popular', 'themes' ); ?></a></li>
    187189            <li><a href="#" data-sort="new"><?php _ex( 'Latest', 'themes' ); ?></a></li>
     190            <li><a href="#" data-sort="blockthemes"><?php _ex( 'Block Themes', 'themes' ); ?></a></li>
    188191            <li><a href="#" data-sort="favorites"><?php _ex( 'Favorites', 'themes' ); ?></a></li>
    189192        </ul>
     
    270273     *  - `install_themes_updated`
    271274     *  - `install_themes_upload`
     275     *  - `install_themes_blockthemes`
    272276     *
    273277     * @since 2.8.0
     278     * @since 6.1.0 Added `install_themes_blockthemes`.
    274279     *
    275280     * @param int $paged Number of the current page of results being viewed.
Note: See TracChangeset for help on using the changeset viewer.