Opened 28 hours ago
Last modified 28 hours ago
#66902 new enhancement
Abilities API: Read and write manual UTC offsets as the timezone setting
| Reported by: | jorgefilipecosta | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.3 |
| Component: | Abilities API | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description (last modified by )
The settings abilities expose timezone_string as timezone. Sites using a manual offset like UTC+2 have an empty timezone_string and store the offset in gmt_offset, so core/settings-get returns an empty timezone and core/settings-update cannot set an offset. Exposing gmt_offset directly is not an option because core computes it from timezone_string, and only the Settings > General form keeps both in sync.
This ticket makes timezone also accept and return the offsets offered on Settings > General, e.g: UTC+2 or UTC-5.5. Writing an offset stores gmt_offset and empties timezone_string, the same way the form does. The conversion logic moves from wp-admin into functions shared by the screen and the abilities, which also fixes Settings > General selecting UTC+0 for sites on UTC+0.5 or UTC-0.5.
Follow-up to #64616.
PR at: https://github.com/WordPress/wordpress-develop/pull/16385
Stacked on https://github.com/WordPress/wordpress-develop/pull/10892. Only the last two commits belong to this PR.
Follow-up to https://github.com/WordPress/wordpress-develop/pull/10892.
A site on a manual UTC offset, such as UTC+2, keeps
timezone_stringempty and stores the offset ingmt_offset. Socore/settings-getreturned an emptytimezone, andcore/settings-updatecould not set an offset. This PR implements the following changes:wp_get_timezone_offset_choices(),wp_get_timezone_offset_choice()andwp_parse_timezone_offset_choice(): the manual offsets thatwp_timezone_choice()offers, and the two conversions Settings > General did inline.wp_timezone_choice(),wp-admin/options.phpandwp-admin/options-general.phpuse them.timezoneaccepts and returns those offsets (UTC+2,UTC-5.5,UTC+0) next to timezone identifiers.gmt_offset.gmt_offsetand emptiestimezone_string. An identifier,UTCincluded, storestimezone_stringas before.UTC+2.0,UTC+15,UTC-0) is refused withsettings_invalid_value. A refused call writes neither option. The offset is written first, so a call stopped between the two writes leaves the site on its timezone string.UTC+0.5andUTC-0.5for a site on those offsets. It selectedUTC+0before.core/settings-get(7.2) now returnsUTC+2, not"", for a site on a manual offset. After anullreset,timezonereads as the stored offset instead of being left out. Thetimezonedescription names the offsets.Testing
Verify unit tests are passing:
AI disclosure: the change and tests were drafted with AI assistance (Claude Code).