Add guest & paid guest post templates and assets#1818
Add guest & paid guest post templates and assets#1818arifulhoque7 wants to merge 3 commits intoweDevsOfficial:developfrom
Conversation
Introduce two new post form templates: Paid Guest Post (one-time payment) and Guest Post (Recurring Subscription) along with their SVG preview images. Add a Pro preview class for a Testimonial template and its SVG, and register the testimonial preview in Free_Loader. Register the new post templates in wpuf_get_post_form_templates and add corresponding entries to the form builder menu. Templates collect title, content, excerpt, featured image, category and tags and configure payment/notification settings.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughAdds two new guest post form templates (paid and recurring subscription) and a testimonial pro preview template; registers the preview in the loader and exposes the new templates in the post form template registry and builder menu. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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: 2
🧹 Nitpick comments (1)
includes/Admin/Forms/Post/Templates/Post_Form_Template_Guest_Post_Recurring.php (1)
14-211: Consider extracting shared field/settings definitions to avoid near-total duplication withPost_Form_Template_Paid_Guest_Post.The entire
$this->form_fieldsarray (all six fields) and roughly 90 % of$this->form_settingsare copied verbatim between the two new templates. Only five keys differ (comment_status,form_description,fallback_ppp_enable,form_template, andnotification.new_subject). Maintaining these in sync will be fragile.A lightweight fix is a shared base class:
♻️ Suggested refactor
// New file: Post_Form_Template_Guest_Post_Base.php abstract class Post_Form_Template_Guest_Post_Base extends Form_Template { public function __construct() { parent::__construct(); $this->enabled = true; $this->form_fields = [ // ... the six shared fields ... ]; } protected function base_form_settings(): array { return [ 'post_type' => 'post', 'post_status' => 'draft', 'default_cat' => '-1', 'post_permission' => 'guest_post', 'guest_post' => 'true', 'guest_details' => 'on', 'name_label' => 'Name', 'email_label' => 'E-Mail', 'guest_email_verify' => 'on', // ... all shared keys ... ]; } } // Post_Form_Template_Guest_Post_Recurring class Post_Form_Template_Guest_Post_Recurring extends Post_Form_Template_Guest_Post_Base { public function __construct() { parent::__construct(); $this->title = __( 'Guest Post (Recurring Subscription)', 'wp-user-frontend' ); $this->description = __( '...', 'wp-user-frontend' ); $this->image = WPUF_ASSET_URI . '/images/templates/guest-post-recurring.svg'; $this->form_settings = array_merge( $this->base_form_settings(), [ 'comment_status' => 'open', 'fallback_ppp_enable' => 'on', 'form_template' => 'post_form_template_guest_post_recurring', 'form_description' => __( '...recurring...', 'wp-user-frontend' ), 'notification' => [ /* recurring notification */ ], ] ); } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@includes/Admin/Forms/Post/Templates/Post_Form_Template_Guest_Post_Recurring.php` around lines 14 - 211, The two templates (Post_Form_Template_Guest_Post_Recurring and Post_Form_Template_Paid_Guest_Post) duplicate the same $this->form_fields and most of $this->form_settings; extract the shared data into a new base class (e.g., Post_Form_Template_Guest_Post_Base) by moving the six shared field definitions into the base constructor as $this->form_fields and exposing a protected base_form_settings() that returns the shared settings array, then in each child (Post_Form_Template_Guest_Post_Recurring) call parent::__construct() and set title/description/image and set $this->form_settings = array_merge($this->base_form_settings(), [/* only the five differing keys: comment_status, form_description, fallback_ppp_enable, form_template, notification.new_subject */]); ensure symbol names match the existing classes and preserve gettext calls and notification structure.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@includes/Admin/Forms/Post/Templates/Post_Form_Template_Paid_Guest_Post.php`:
- Line 155: Update the Paid Guest Post template's 'form_description' to mention
the excerpt field so it matches the fields declared in 'form_fields'
(specifically the 'post_excerpt' field); locate the 'form_description' entry in
Post_Form_Template_Paid_Guest_Post.php and edit the string to include "excerpt"
(e.g., add "excerpt" or "post excerpt" alongside title, content, tags, and
featured image) so submitters see the same fields that are actually submitted.
In `@wpuf-functions.php`:
- Around line 5206-5207: The labels for the paid guest-post template are
inconsistent: update the $template_options entry keyed by
'post_form_template_paid_guest_post' in wpuf-functions.php so its translation
string matches Post_Form_Template_Paid_Guest_Post::$title (use "Paid Guest
Post"), ensuring both the Add New Form modal and the form-builder dropdown show
the same label; edit the __('Paid Guest Post Form', 'wp-user-frontend') call to
__('Paid Guest Post', 'wp-user-frontend') so the strings align.
---
Nitpick comments:
In
`@includes/Admin/Forms/Post/Templates/Post_Form_Template_Guest_Post_Recurring.php`:
- Around line 14-211: The two templates (Post_Form_Template_Guest_Post_Recurring
and Post_Form_Template_Paid_Guest_Post) duplicate the same $this->form_fields
and most of $this->form_settings; extract the shared data into a new base class
(e.g., Post_Form_Template_Guest_Post_Base) by moving the six shared field
definitions into the base constructor as $this->form_fields and exposing a
protected base_form_settings() that returns the shared settings array, then in
each child (Post_Form_Template_Guest_Post_Recurring) call parent::__construct()
and set title/description/image and set $this->form_settings =
array_merge($this->base_form_settings(), [/* only the five differing keys:
comment_status, form_description, fallback_ppp_enable, form_template,
notification.new_subject */]); ensure symbol names match the existing classes
and preserve gettext calls and notification structure.
includes/Admin/Forms/Post/Templates/Post_Form_Template_Paid_Guest_Post.php
Outdated
Show resolved
Hide resolved
Include 'excerpt' in the Paid Guest Post form description, enable pay-per-post by default with a default cost of 5, and switch default payment option flags (disable forced pack purchase). Update the admin menu label to 'Paid Guest Post' (remove 'Form' suffix). Also apply minor formatting/spacing fixes in Free_Loader (HTML/pro-badge strings and long string concatenation) and a small code formatting tweak for the post form template instantiation.
Summary
Post_Form_Template_Paid_Guest_Post— free template for one-time paid guest submissions (mandatory subscription, fallback PPP disabled, guest post permission with name/email/email-verify, post status: draft)Post_Form_Template_Guest_Post_Recurring— free template for recurring subscription guest submissions (mandatory subscription, fallback pay-per-post ON when limit exceeds, comment status open)wpuf_get_post_form_templates()and$template_optionsPro_Form_Preview_Testimonialstub + register inFree_Loaderfor Pro badge previewFields (both templates)
Post Title → Post Content → Post Excerpt → Featured Image → Category → Tags
Test plan
Close 882
Close 884
Summary by CodeRabbit
New Features
Enhancements