Repository navigation
refactor: resolve the version switcher source and installer through filters - #568
Merged
Merged
Conversation
… at the top of the screen
…-switcher-seams/core # Conflicts: # src/php/Core/Uninstaller.php # src/php/Settings/Version_Switch.php
lightbulbman
marked this pull request as ready for review
October 19, 2026 14:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the two parts of the version switcher that an implementation may need to vary — where the list of available versions comes from, and how a package is written to disk — behind interfaces resolved through filters. Caching, the in-progress marker, capability and nonce checks, validation and rendering remain in
Version_Switch.Changes
Version_SourceandPackage_Installerinterfaces, withWordPress_Org_Version_SourceandUpgrader_Package_Installeras the defaults. No registration is required; the defaults apply unless thecode_snippets_version_sourceorcode_snippets_package_installerfilters supply a replacement.Version_Switchto resolve both services through those filters each time they are used, cache the catalogue under the source's ownget_cache_key(), record the reason a catalogue request failed, and render the available, unavailable and in-progress states.initVersionSwitch()when the switcher configuration is absent, so the unavailable state renders as a notice with no controls.get_last_error_message().code_snippets_settings_tab_contentsfilter.Version_Source::get_switch_warning(), for a source to attach a warning to an individual version. The warning is rendered as adata-warningattribute on the version's option and shown inside the switch warning when that version is selected.WordPress_Org_Version_Sourcereturns no warning.inlineclass so WordPress does not move it to the top of the screen. Removes the separateversion_warningsettings field and the tab-change handler that hid the relocated notice.--cs-color-surface-warningtheme token, with body-coloured text for contrast.code-snippets-noticeclass on them so the admin notice filter does not hide them.core-beta. The changelog is taken fromcore-betaunchanged, as the 4.0.0 section it previously extended has been released; entries for this change belong in the next release section.Verification
tests/unit/Settings/Version_Switch_Test.phpadds 35 tests covering the cache key, uncached source errors, target validation, the install and cleanup paths on both success and failure, logging of a failed install, the filters replacing and restoring both services, a source registered after the first lookup, clearing the WordPress.org catalogue, the Reset Caches notices, and the markup rendered for a failed request, an empty catalogue, a populated catalogue, the floor notice, per-version warnings, the placement of the switch warning, and the refresh button while the source is unavailable.tests/unit/Settings/Version_Switch_Ajax_Test.phpcovers the refresh request's success and error responses.tests/unit/Core/Uninstaller_Test.phpcovers the transient removal.tests/e2e/version-switch.spec.tscovers a switch response containing markup being shown as text.