feat(content-gate): layout deletion and default content handling#4436
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the content gate feature by adding automatic layout deletion when gates are removed and implementing default content fallback handling when gate layouts don't exist.
Changes:
- Adds automatic deletion of associated gate layouts when a gate is permanently deleted
- Implements default content fallback when gate layout posts are deleted or don't exist
- Creates default layouts automatically for registration and custom_access modes when creating new gates
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| includes/content-gate/trait-content-gate-layout.php | Adds get_default_gate_content() method and updates get_inline_gate_content_for_post() and get_restricted_post_excerpt_for_gate() to handle missing gate layouts with default content fallback |
| includes/content-gate/class-content-gate.php | Adds delete_gate_layouts() hook to clean up layouts on gate deletion, enhances create_gate() to automatically create default layouts, adds get_block_pattern_content() helper method, and updates create_gate_layout() to accept optional content parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ve fallback handling
dkoo
left a comment
There was a problem hiding this comment.
Working well! The only issue I found is that if creating a Registration gate layout for a gate that already exists (such as after deleting all gate layouts), it should be created with the same default Registration block pattern. I think we'd need to add that here.
|
Hey @miguelpeixe, 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! ❤️ |
# [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:
Introduces default content handling and fallback strategies when retrieving the gate layout. For clarity, the gate content methods now receive a
$gate_layout_id, even though it could be anp_gate_layoutor anp_memberships_gate.When creating a gate, layouts should now be created automatically. For the registration mode, it adds the contents of the "Registration Card" pattern:
For the custom access mode, it adds the generic paragraph:
Deleting a gate permanently should also delete its layouts.
Several new unit tests were added for:
How to test the changes in this Pull Request:
define( 'NEWSPACK_CONTENT_GATES', true );) and create a new gate with Registration Accesswp post delete $(wp post list --post_type='np_gate_layout' --format=ids) --forceOther information: