[wp-trac] [WordPress Trac] #64830: Introduce a helper function to extract the major.minor "branch" version
WordPress Trac
noreply at wordpress.org
Tue Mar 10 07:31:50 UTC 2026
#64830: Introduce a helper function to extract the major.minor "branch" version
-------------------------------------------------+-------------------------
Reporter: apermo | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: General | Version: 3.2
Severity: normal | Resolution:
Keywords: has-patch needs-refresh needs- | Focuses:
testing |
-------------------------------------------------+-------------------------
Changes (by suhan2411):
* keywords: has-patch => has-patch needs-refresh needs-testing
Comment:
Thanks everyone for the feedback.
I've updated the PR and pushed the changes addressing the points raised
above.
1. Terminology (@jorbin, @apermo)
Docblocks now follow the version numbering handbook: `x.y` represents the
major version and `x.y.z` the minor version. The helper returns the major
version (e.g. `7.0`).
2. Extending wp_get_wp_version() (@peterwilsoncc, @westonruter)
Instead of introducing a new public API, `wp_get_wp_version()` now accepts
an optional `$part` parameter:
- wp_get_wp_version( 'major' ) → `x.y` (e.g. `7.0`)
- wp_get_wp_version( 'minor' ) → `x.y.z` (e.g. `7.0.1`)
- wp_get_wp_version() / wp_get_wp_version( 'full' ) → full version string
(unchanged)
`wp_get_branch_version()` remains available for parsing arbitrary version
strings, and `wp_get_wp_version( 'major' )` delegates to it for the
current version.
3. Admin header classes (@apermo, @westonruter)
For versions like `7.0.x`, the admin now outputs both:
- `branch-7-0`
- `branch-7` (for back-compat with existing selectors)
4. Test coverage (@jorbin)
Added PHPUnit tests in
`tests/phpunit/tests/functions/wpGetBranchVersion.php` using a data
provider to cover cases such as:
- `7.0`, `7.0.0`, `7.0.1`, `7.0.10`
- `10.0.0`, `100.1.0`
- alpha/beta/RC suffixes
Additional tests were added for `wp_get_wp_version( 'major' )`,
`wp_get_wp_version( 'minor' )`, and `wp_get_wp_version( 'full' )`.
5. Site Health edge case (@siliconforks)
The previous-version calculation for dev builds now uses
`wp_get_branch_version()` and correctly resolves `7.0 → 6.9`.
PR: https://github.com/WordPress/wordpress-develop/pull/11211
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64830#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list