Skip to content

Abilities API: Read and write manual UTC offsets as the settings timezone - #16385

Draft
jorgefilipecosta wants to merge 3 commits into
WordPress:trunkfrom
jorgefilipecosta:add/settings-utc-offset-timezone
Draft

jorgefilipecosta wants to merge 3 commits into
WordPress:trunkfrom
jorgefilipecosta:add/settings-utc-offset-timezone

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #10892.

Currently, sites using a manual offset like UTC+2 have an empty timezone_string, so core/settings-get returns an empty timezone and core/settings-update cannot set an offset.

This PR implements the following changes:

  • timezone also accepts and returns 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.
  • Settings > General now selects UTC+0.5 or UTC-0.5 for sites on those offsets, where it selected UTC+0 before.
  • Shape change: core/settings-get returns the offset, e.g: UTC+2, on sites without a timezone string.

Trac ticket: https://core.trac.wordpress.org/ticket/66902

Testing

Verify unit tests are passing:

vendor/bin/phpunit --group abilities-api,option,date
vendor/bin/phpunit -c tests/phpunit/multisite.xml --group abilities-api,option,date

AI disclosure: the change and tests were drafted with AI assistance (Claude Code).

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

…ist.

Adds `wp_get_timezone_offset_choices()`, `wp_get_timezone_offset_choice()` and `wp_parse_timezone_offset_choice()`, which hold the manual UTC offsets that `wp_timezone_choice()` offers, such as `UTC+2`, and the conversions between those values and the `gmt_offset` option that Settings > General did inline.

`wp_timezone_choice()`, `wp-admin/options.php` and `wp-admin/options-general.php` now use them. The timezone list is unchanged. Settings > General now selects `UTC+0.5` and `UTC-0.5` for a site on those offsets, instead of `UTC+0`.

See #64616.
…tting.

A site on a manual UTC offset keeps its `timezone_string` option empty and stores the offset in `gmt_offset`, so `core/settings-get` returned an empty timezone and `core/settings-update` could not set an offset.

The `timezone` setting of both abilities now accepts and returns the manual offsets that the timezone list offers, such as `UTC+2`, next to timezone identifiers. A site without a timezone string reads as its offset. Writing an offset stores it in `gmt_offset` and empties `timezone_string`, as Settings > General does; an offset the timezone list does not offer is refused, and a refused call writes neither option.

See #64616.
@jorgefilipecosta
jorgefilipecosta force-pushed the add/settings-utc-offset-timezone branch from 162fa8a to 7ad2c23 Compare December 2, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant