MR-10: Allow setting paragraph count before paywall#23
Conversation
📝 WalkthroughWalkthroughAdds a configurable ChangesConfigurable Paragraph Count
Sequence Diagram(s)sequenceDiagram
participant Admin
participant memberful_wp_global_marketing
participant WordPressOptions
participant global_marketing_filter as memberful_apply_global_snippets_content_filter
Admin->>memberful_wp_global_marketing: submit save_global_marketing
memberful_wp_global_marketing->>memberful_wp_global_marketing: sanitize & clamp paragraph count (1-10)
memberful_wp_global_marketing->>WordPressOptions: update_option memberful_paragraph_count
Admin->>memberful_wp_global_marketing: view global_marketing page
memberful_wp_global_marketing->>WordPressOptions: get_option memberful_paragraph_count (default 2)
memberful_wp_global_marketing->>Admin: render form with paragraph_count field
global_marketing_filter->>WordPressOptions: get_option memberful_paragraph_count (default MEMBERFUL_PARAGRAPH_COUNT)
global_marketing_filter->>global_marketing_filter: clamp value (1-10) and build teaser loop
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@wordpress/wp-content/plugins/memberful-wp/views/global_marketing.php`:
- Around line 56-61: The displayed value in global_marketing.php is only clamped
with the lower bound in the paragraph count input, so it can render above the
field’s max when the stored option is too large. Update the value handling in
the paragraph count input to clamp both bounds before echoing it, matching the
existing save-time and filter-time behavior in the memberful paragraph count
logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: TheCodeCompany/coderabbit/.coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8d1ce49a-09ef-41fa-b834-5f5491f6011b
📒 Files selected for processing (5)
wordpress/wp-content/plugins/memberful-wp/src/admin.phpwordpress/wp-content/plugins/memberful-wp/src/global_marketing.phpwordpress/wp-content/plugins/memberful-wp/src/options.phpwordpress/wp-content/plugins/memberful-wp/stylesheets/admin.csswordpress/wp-content/plugins/memberful-wp/views/global_marketing.php
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Summary
Customise how many paragraphs before paywall with global marketing content.
What's included
Test plan
paragraphs and no Paywall Divider block as a logged-out visitor, and confirm exactly N paragraphs appear before the paywall; posts using a Paywall Divider block are unaffected.
Note
Low Risk
Marketing/teaser display only; values are sanitized and clamped, with no auth or payment impact.
Overview
Adds a configurable paragraph count (1–10, default 2) for the “automatically pull an excerpt” global marketing flow, replacing the fixed
MEMBERFUL_PARAGRAPH_COUNTloop limit at runtime.Site admins get a “Paragraphs before paywall” number field on Global marketing content, visible only when the excerpt checkbox is on; saves clamp the value to 1–10 via
memberful_paragraph_count. Copy and admin CSS were updated to match existing paywall builder field styling.Reviewed by Cursor Bugbot for commit 0761b85. Bugbot is set up for automated code reviews on this repo. Configure here.