Conversation
|
🎉 This PR is included in version 6.35.2-hotfix-missing-memberships-gate.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
adekbadek
left a comment
There was a problem hiding this comment.
Tested locally against WC Memberships 1.28.1. Confirmed the bug on release (content truncated, no gate) and verified the fix on this branch (gate renders correctly).
The approach is sound – the three guard clauses (empty message only, content restriction codes only, Newspack gate present) keep the scope tight. The placeholder is fully replaced by Newspack's gate HTML in wc_memberships_notice_html(), so it never leaks to the frontend.
One minor note: on product pages, the is_product() check in wc_memberships_notice_html would return the notice unchanged, but the str_contains($message_code, 'content_') guard effectively prevents this since product restriction codes don't contain content_.
|
Hey @dkoo, 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! ❤️ |
|
🎉 This PR is included in version 6.35.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
Closes NPPM-2707.
When all WC Memberships message templates are set to empty strings (which is the case when Newspack content gates replace them), the
get_message_html()method in WC Memberships skipsget_notice_html()entirely. This means thewc_memberships_notice_htmlfilter never fires, so Newspack's content gate is never rendered. The result is that restricted content is truncated but no gate is shown to the reader.This fix adds a
wc_memberships_restricted_messagefilter that returns a non-breaking space ( ) when the message is empty and a Newspack gate is configured. This ensuresget_notice_html()is called, which fireswc_memberships_notice_html, and the gate renders correctly. The placeholder is fully replaced by Newspack's gate HTML inwc_memberships_notice_html().The filter has three guard clauses to limit its scope:
content_message codes (not product discounts etc.)How to test the changes in this Pull Request:
update_option('wc_memberships_messages', ['content_restricted_message' => '', ...]))Expected on
release(bug): Content is truncated but no gate appears below it.Expected on this branch (fix): Content is truncated and the memberships gate is rendered below.
Other information: