feat: Add My Account button block#4409
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new "My Account Button" block to Newspack Plugin, allowing sites with Reader Activation enabled to display a dynamic button that links readers to their account page or opens the sign-in modal. The block adapts its label and behavior based on authentication state.
Changes:
- Added a new My Account Button block with dynamic labels for signed-in and signed-out states
- Moved CSS styles from reader-activation-auth to allow reuse by the new block
- Added account icon to the icons package
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/blocks/my-account-button/class-my-account-button-block.php | Server-side block rendering with authentication state handling and WooCommerce account URL detection |
| src/blocks/my-account-button/edit.js | Block editor component with toolbar toggle for previewing signed-in/out states |
| src/blocks/my-account-button/block.json | Block metadata with support for color, typography, spacing, and border customization |
| src/blocks/my-account-button/style.scss | Block styles including disabled state and icon sizing |
| src/blocks/my-account-button/index.js | Block registration with icon configuration |
| src/blocks/my-account-button/README.md | Documentation describing block behavior and settings |
| src/blocks/index.js | Registration logic preventing block from appearing in classic themes |
| packages/icons/src/account.js | New account SVG icon |
| packages/icons/index.js | Export for new account icon |
| includes/class-blocks.php | Include block PHP class and pass block theme flag to editor |
| src/reader-activation-auth/style.scss | Removed account link styles (moved to block-specific styles) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks @thomasguillot!
The logic in the RAS code only switches the button to the signed in state when you're a registered reader and not when you're logged in. I can do this differently in the block and just have it show the signed in label for anyone who's logged in, but I didn't know the history of that choice re: making it reader specific. Do you? |
|
Thanks @thomasguillot! I've made the following changes:
One last thing from me: what do you think we should do for mobile? I was thinking either make the button only show the icon on small screens, or have an icon-only style as an option that can be added to the mobile header. Or maybe a third option - do you have any preferences? |
rbcorrales
left a comment
There was a problem hiding this comment.
Thanks for addressing all the comments. The button is looking great!
|
Thanks for the review, @rbcorrales! 🙌 |
|
Hey @laurelfulford, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
|
Hey @laurelfulford, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
* feat(my-account): custom subscription details page for Newspack sites * feat: show status badge * feat: start "renew subscription" button for inactive subs * style: unbold grand total if not showing subtotals * feat: custom order again buttons * fix: show order-again button in subscription header only for expired/cancelled status * fix: restore p.order-again element * fix: improper placement of conditional * fix: remove duplicate button class name * Update includes/plugins/woocommerce/my-account/templates/v1/subscription-header.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: esc_html_e instead of _e * fix: esc_html_e instead of _e * Update includes/plugins/woocommerce/my-account/class-my-account-ui-v1.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: global namespace WCS_Staging class * fix: add missing template file * fix: remove unneeded template file * fix: remove no-longer-used variable * Update includes/plugins/woocommerce/my-account/templates/v1/related-orders.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: only show order-again button in expired subscription headers * fix: remove .button class from order-again button * feat(newspack-ui): update demo * feat(newspack-ui): update notice * feat(my-account): reorganise subscription header * feat(newspack-ui): adjust margin for text + icon buttons * fix: full-width header buttons instead of dropdown at mobile viewports * fix: better targeting for header dropdown * fix: show "renew subscription" for cancelled subs sans resubscribe action * fix: set header badge class based on status * feat: replace My Account notices w/ Newspack UI snackbars * style: remove top margin from switch button in header * feat(subscriptions): update table padding * feat(newspack-ui): partially update snackbar * feat: update table * fix: snackbar autohide behavior * fix: snackbar notices behavior * feat(newspack-ui): small tweaks to snackbar * fix(memberships): allow free trial members to comment (#4428) This PR addresses an issue where we were incorrectly filtering memberships with an "active" status, omitting free trial memberships. The Memberships::$active_statuses array uses a hyphen rather than an underscore for `free_trial`, which the wc_memberships_get_user_memberships methods requires. * chore(release): 6.29.4 [skip ci] ## [6.29.4](v6.29.3...v6.29.4) (2026-01-28) ### Bug Fixes * **memberships:** allow free trial members to comment ([#4428](#4428)) ([32d455e](32d455e)) * fix(subscriptions): skip free trial tweak during switches (#4432) * chore(release): 6.29.5 [skip ci] ## [6.29.5](v6.29.4...v6.29.5) (2026-01-29) ### Bug Fixes * **subscriptions:** skip free trial tweak during switches ([#4432](#4432)) ([4277a3c](4277a3c)) * feat: Add My Account button block (#4409) * chore: update translation files [skip ci] * feat(content-gate): support new metering schema (#4419) * chore: update translation files [skip ci] * chore: deprecate circle ci (#4413) * chore(github-actions): fix reusable workflow reference * fix(collections): hide indicator for unpublished collections (#4434) * fix: snackbar slide in-out position * Update src/newspack-ui/js/notices.js Co-authored-by: Miguel Peixe <miguel.peixe@automattic.com> * refactor: newspackUI public API via modules * feat: add newspack_ui_notice_is_urgent to make notices dismissmible --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Thomas Guillot <thomas@automattic.com> Co-authored-by: Rasmy Nguyen <raz@automattic.com> Co-authored-by: matticbot <semantic-release-bot@martynus.net> Co-authored-by: Miguel Peixe <miguel.peixe@automattic.com> Co-authored-by: Laurel <laurel.fulford@automattic.com> Co-authored-by: matticbot <sysops+ghmatticbot@automattic.com> Co-authored-by: Ramon Corrales <rbcorrales@users.noreply.github.com>
# [6.31.0-alpha.1](v6.30.1...v6.31.0-alpha.1) (2026-02-05) ### Bug Fixes * **collections:** hide indicator for unpublished collections ([#4434](#4434)) ([3eda622](3eda622)) * **content-gate:** persist restricted content ([#4420](#4420)) ([856695d](856695d)) * decrease image size for Collections in certain cases ([#4395](#4395)) ([de3c001](de3c001)) * **my-account:** "order again" checkout redirect ([#4427](#4427)) ([3a9e7fb](3a9e7fb)) * remove alignments from the My Account Block button ([#4438](#4438)) ([8de3526](8de3526)) ### Features * Add My Account button block ([#4409](#4409)) ([b0c414f](b0c414f)) * **avatar:** add custom byline support ([#4424](#4424)) ([152b1af](152b1af)) * **content-gate:** grouped access rules evaluation and normalization ([#4435](#4435)) ([aa182c9](aa182c9)) * **content-gate:** layout deletion and default content handling ([#4436](#4436)) ([f0b3b18](f0b3b18)) * **content-gate:** support group subscriptions access rule ([#4442](#4442)) ([416cd13](416cd13)) * **content-gate:** support new metering schema ([#4419](#4419)) ([e3f2f56](e3f2f56)) * **my-account:** new layout for single subscription pages ([#4425](#4425)) ([6425dbf](6425dbf)), closes [#4428](#4428) [#4432](#4432) [#4409](#4409) [#4419](#4419) [#4413](#4413) [#4434](#4434)
|
🎉 This PR is included in version 6.31.0-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
# [6.32.0-alpha.1](v6.31.0...v6.32.0-alpha.1) (2026-02-10) ### Bug Fixes * **collections:** hide indicator for unpublished collections ([#4434](#4434)) ([3eda622](3eda622)) * **content-gate:** persist restricted content ([#4420](#4420)) ([856695d](856695d)) * decrease image size for Collections in certain cases ([#4395](#4395)) ([de3c001](de3c001)) * **my-account:** "order again" checkout redirect ([#4427](#4427)) ([3a9e7fb](3a9e7fb)) * remove alignments from the My Account Block button ([#4438](#4438)) ([8de3526](8de3526)) ### Features * Add My Account button block ([#4409](#4409)) ([b0c414f](b0c414f)) * **avatar:** add custom byline support ([#4424](#4424)) ([152b1af](152b1af)) * **content-gate:** grouped access rules evaluation and normalization ([#4435](#4435)) ([aa182c9](aa182c9)) * **content-gate:** layout deletion and default content handling ([#4436](#4436)) ([f0b3b18](f0b3b18)) * **content-gate:** support group subscriptions access rule ([#4442](#4442)) ([416cd13](416cd13)) * **content-gate:** support new metering schema ([#4419](#4419)) ([e3f2f56](e3f2f56)) * **my-account:** new layout for single subscription pages ([#4425](#4425)) ([6425dbf](6425dbf)), closes [#4428](#4428) [#4432](#4432) [#4409](#4409) [#4419](#4419) [#4413](#4413) [#4434](#4434)
|
🎉 This PR is included in version 6.32.0-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
# [6.32.0](v6.31.1...v6.32.0) (2026-02-16) ### Bug Fixes * add check for my account before switching error notice ([#4484](#4484)) ([9e13eca](9e13eca)) * **collections:** hide indicator for unpublished collections ([#4434](#4434)) ([3eda622](3eda622)) * **content-gate:** persist restricted content ([#4420](#4420)) ([856695d](856695d)) * decrease image size for Collections in certain cases ([#4395](#4395)) ([de3c001](de3c001)) * **my-account:** "order again" checkout redirect ([#4427](#4427)) ([3a9e7fb](3a9e7fb)) * remove alignments from the My Account Block button ([#4438](#4438)) ([8de3526](8de3526)) ### Features * Add My Account button block ([#4409](#4409)) ([b0c414f](b0c414f)) * **avatar:** add custom byline support ([#4424](#4424)) ([152b1af](152b1af)) * **content-gate:** grouped access rules evaluation and normalization ([#4435](#4435)) ([aa182c9](aa182c9)) * **content-gate:** layout deletion and default content handling ([#4436](#4436)) ([f0b3b18](f0b3b18)) * **content-gate:** support group subscriptions access rule ([#4442](#4442)) ([416cd13](416cd13)) * **content-gate:** support new metering schema ([#4419](#4419)) ([e3f2f56](e3f2f56)) * **my-account:** new layout for single subscription pages ([#4425](#4425)) ([6425dbf](6425dbf)), closes [#4428](#4428) [#4432](#4432) [#4409](#4409) [#4419](#4419) [#4413](#4413) [#4434](#4434)
|
🎉 This PR is included in version 6.32.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |

All Submissions:
Changes proposed in this Pull Request:
This PR, along with Automattic/newspack-block-theme#400 and Automattic/newspack-theme#2618 adds a My Account button block to the Newspack Plugin, adds the button to just one pattern (for now) in the Block Theme (for testing), and moves some CSS from the Newspack Plugin to the classic theme to avoid clashing.
I have some open questions/possible weird cruft to still deal with:
Some of these (like the mobile state, and maybe adding an 'Outline' style) can also be handled in a separate PR if there isn't a for-sure direction to follow.
See NPPD-1123.
How to test the changes in this Pull Request:
Other information: