Repository navigation
Conversation
…emes_tabs`. Re-enables the `install_themes_tabs` filter on `wp-admin/theme-install.php` to allow registering and filtering browse tabs in the Backbone-based theme installer, matching parity with `install_plugins_tabs`. Passes the default active tab to `_wpThemeSettings` for seamless Backbone routing, escapes the tab selector attribute, and adds support for legacy `?tab=:sort` URLs. Props therssoftware, pbiron, audrasjb. See #65979.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
…est capabilities. - Add missing <?php opening tag before upload button condition in src/wp-admin/theme-install.php, preventing plain-text code leak and fixing E2E theme upload tests. - Grant super admin capabilities to the test admin user in multisite environments in tests/phpunit/tests/theme/installThemesTabs.php, resolving multisite test failures. See #65979.
Trac ticket: https://core.trac.wordpress.org/ticket/65979
Description
Restores the
install_themes_tabsfilter inwp-admin/theme-install.phpto allow registering, reordering, and filtering tabs in the Backbone-based theme installer, matching parity withinstall_plugins_tabson the Add Plugins screen.Background & Architecture
WP_Theme_Install_List_Table, which used theinstall_themes_tabsfilter (introduced in 2.8.0).theme-install.phptransitioned to a Backbone.js single-page application, the filter links (<ul class="filter-links">) were hardcoded to'popular','new','block-themes', and'favorites'. The DocBlock forinstall_themes_tabswas demoted to "for backward compatibility only, for the suppression of the upload tab".jQuery('.filter-links').append(...)) to add custom tabs.wp-admin/includes/ajax-actions.php(wp_ajax_query_themes()) is already fully dynamic: anybrowsekey automatically appliesinstall_themes_table_api_args_{$browse}and passes$argsdirectly tothemes_api( 'query_themes', $args ).Changes Made
wp-admin/theme-install.php:popular,new,block-themes,favorites, and conditionallyuploadwhen the user hasupload_themescapability) and runsapply_filters( 'install_themes_tabs', $tabs )beforewp_localize_script().$browse_tabs = array_diff_key( $tabs, array( 'upload' => true ) );and derives$default_tab = ! empty( $browse_tabs ) ? (string) array_key_first( $browse_tabs ) : 'popular';.$default_tabto_wpThemeSettings.settings.defaultTab.<ul class="filter-links">list dynamically from$browse_tabs.! empty( $tabs['upload'] ) && current_user_can( 'upload_themes' ).$_REQUEST['browse']and$_REQUEST['tab']for$tab.src/js/_enqueues/wp/theme.js:InstallerRouterandRunInstaller.init()to route to_wpThemeSettings.settings.defaultTab || 'popular'when visiting the base URL without query parameters.'theme-install.php?tab=:sort': 'sort'to support legacy?tab=URLs alongside?browse=.$.escapeSelector( sort )to safely handle custom tab keys with special characters.tests/phpunit/tests/theme/installThemesTabs.php:upload_themescapability.upload_themescapability.install_themes_tabs.unset( $tabs['upload'] ).Testing Instructions
functions.php, add a custom tab:wp-admin/theme-install.php.?browse=featuredwithout errors.install_themes_table_api_args_featuredorthemes_apiand verify themes render correctly.