Skip to content

Migrate WordPress settings requests to apiFetch #3768

Open

Description

@Arukuen
No description provided.

Activity

  1. self-assigned this
    on Oct 19, 2026
  2. bfintal commented on Oct 21, 2026

    @bfintal
    Contributor

    Changes requested for #3769 and premium #412.

    What is already in good shape

    • The old wp.api / models.Settings calls are gone in both pull requests.
    • A successful save still posts the same data to /wp/v2/settings.
    • The editor and welcome scripts now depend on wp-api-fetch.

    What to fix

    1. The v2 migration popup can open for an Editor, then get stuck.

    src/plugins/v2-migration-popup/index.js used to read /wp/v2/settings. Only an administrator (manage_options) can read that, so an Editor never saw the popup.

    It now calls fetchSettings(), which reads /stackable/v3/settings/. Anyone who can edit posts can read that, so the popup can open.

    Save still posts to /wp/v2/settings. An Editor gets 403 (not allowed).

    In src/plugins/v2-migration-popup/migration-popover.js the spinner turns off only when the save succeeds. On 403 the popup stays busy and the page does not reload.

    Use the same permission for the read and the save. If this person cannot save WordPress settings, do not open the popup. Turn the spinner off when the save fails.

    1. Use one save function.

    fetchSettings in src/util/admin.js is the one place that reads settings. Saving is copied in about twenty files as apiFetch({ path: '/wp/v2/settings', method: 'POST', data }), plus four copies in the premium pull request (color-schemes, preset-controls, and welcome/icons.js).

    Add saveSettings next to fetchSettings and call that from each place.

    1. When a save fails, handle it.

    Global colors, typography, block styles, and the premium preset and icon saves do not handle a failed post. The console gets an unhandled error, and a busy indicator that only clears after success stays on. Clear that busy state when the save fails too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions