Skip to content

Donations Block: admin defaults (frequency/amounts/toggles) - #48799

Merged
angelablake merged 1 commit into
trunkfrom
update/donations-frequency-amount-defaults
May 13, 2026
Merged

angelablake merged 1 commit into
trunkfrom
update/donations-frequency-amount-defaults

Conversation

@angelablake

Copy link
Copy Markdown
Contributor

Stacked on top of #48415. Reviews can wait until that lands; this PR can be tested on Jetpack Beta in parallel.

Proposed changes

Adds admin-configurable frequency visibility controls and donation defaults to the Donations Form block.

Frequency visibility toggles

  • New "Show one-time donations" toggle in the Settings panel, joining the existing monthly and annual toggles, so authors can hide any combination of intervals.
  • Last-enabled guard: the final visible toggle is disabled and shows help text ("At least one frequency must be enabled."), preventing an empty/broken form.
  • Auto-shift: hiding the interval that is currently set as the default silently shifts defaultInterval to the next visible interval in the same setAttributes call — no stale or invisible default can persist.
  • Side-effect bug fix: previously, hiding One-Time while keeping Monthly broke the frontend — view.js was hardcoded to this.interval = 'one-time'. The fix reads the initial interval from data-default-interval on the wrapper instead.

Frequency and amount defaults

  • New "Defaults" sub-section in the Settings panel with a Frequency selector (filtered to currently-shown intervals) and per-frequency default amount selects (None + the three configured dollar values).
  • Default amount is stored by index, not value, so it survives admin edits to the amount values (e.g. changing $15 → $20 keeps the same slot pre-selected).
  • Suggested custom amount: a number input for the placeholder value shown in the custom amount tile; currency-aware minimum enforced.
  • On load and on each tab switch, the configured default amount tile is highlighted and the Donate button is pre-enabled. Clears and resets correctly when switching tabs.
  • Currency change resets customAmountPlaceholder along with the existing per-interval amount reset.

Related product discussion/links

  • Part of the same internal RSM project as #48415.

Does this pull request change what data or activity we track or use?

No tracking or data changes.

Testing instructions

Frequency toggles

  1. Add a Donations Form block. In the Settings panel, toggle "Show one-time donations" off.
    • The One-Time tab should disappear in the editor; the active tab should fall back to Monthly (or Yearly if Monthly is also off).
    • Save and view on the frontend — the One-Time tab should be gone.
  2. Toggle off Monthly as well — only Annual remains. Confirm all three toggle buttons show the last-enabled help text and are disabled, preventing an empty form.
  3. Toggle One-Time back on — the tab reappears and the block is functional again.
  4. Open a legacy Donations block (created before this branch, where oneTimeDonation.show was never set) — the One-Time toggle should show as on and the block should behave normally.

Defaults section [screenshot]
5. Expand the Settings panel and locate the Defaults sub-section below the Show/hide toggles.

  • Set Frequency to Monthly and Monthly default amount to the $15 slot.
  • Save and view on the frontend — the Monthly tab should be active on load, with the $15 tile pre-selected and the Donate button enabled without any user interaction. [demo]
  1. Set a suggested custom amount (e.g. 50) — the custom amount tile placeholder on the frontend should reflect this value.
  2. Change currency — the suggested custom amount should reset.
  3. Hide the frequency that is set as the default — the default should automatically shift to the next visible interval without requiring a separate action.

Recreated as a successor to #48464, which auto-closed when its base branch was deleted on merge of #48415. Same content; rebased onto trunk as a single squashable commit.

Adds configurable defaults that authors set in the Inspector:

- Default frequency (One-Time / Monthly / Yearly) used on first render
- Default amount per frequency (with "None" fallback)
- Configurable suggested custom amount placeholder
- Admin toggle to hide the One-Time interval
- Keep at least one interval enabled (disables last toggle, shows hint)
- New Defaults panel section with consistent Flex layout
- "View donation earnings" link moved into Defaults section

Includes Phan baseline update.
@github-actions

github-actions Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the update/donations-frequency-amount-defaults branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/donations-frequency-amount-defaults

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Block] Donations [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels May 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label May 13, 2026
@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 5 files.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/extensions/blocks/donations/controls.js 0/58 (0.00%) 0.00% 30 💔
projects/plugins/jetpack/extensions/blocks/donations/donations.php 117/355 (32.96%) -2.39% 24 💔
projects/plugins/jetpack/extensions/blocks/donations/view.js 0/123 (0.00%) 0.00% 19 💔
projects/plugins/jetpack/extensions/blocks/donations/tabs.js 0/28 (0.00%) 0.00% 9 💔
projects/plugins/jetpack/extensions/blocks/donations/utils.js 0/10 (0.00%) 0.00% 4 💔

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

@angelablake
angelablake merged commit 26b8159 into trunk May 13, 2026
71 of 72 checks passed
@angelablake
angelablake deleted the update/donations-frequency-amount-defaults branch May 13, 2026 18:42
@github-actions github-actions Bot removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label May 13, 2026
@github-actions github-actions Bot added this to the jetpack/15.9 milestone May 13, 2026
@github-actions github-actions Bot added the [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. label May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Donations [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] UI Changes Add this to PRs that change the UI so documentation can be updated.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant