Add guest & paid guest post templates and assets#1818
Add guest & paid guest post templates and assets#1818arifulhoque7 wants to merge 5 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.
WalkthroughAdds two new post form templates (paid guest post and guest post with recurring subscription), a pro testimonial preview template, and registers the new preview and templates in the loader and post-form template registry/menu. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
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)
📝 Coding Plan
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.
sapayth
left a comment
There was a problem hiding this comment.
- Duplicate Pro_Form_Preview_Artwork registration (Free_Loader.php)
The diff adds a new aligned line for Artwork but doesn't remove the old one, resulting in Artwork being registered twice:
// Line added by this PR:
$integrations['WPUF_Pro_Form_Preview_Artwork'] = new Pro_Form_Preview_Artwork();
$integrations['WPUF_Pro_Form_Preview_Testimonial'] = new Pro_Form_Preview_Testimonial();
// Original line still present:
$integrations['WPUF_Pro_Form_Preview_Artwork'] = new Pro_Form_Preview_Artwork();
This instantiates Pro_Form_Preview_Artwork twice. The second overwrites the first so it won't break at runtime, but it's clearly a merge/rebase mistake and should be cleaned up.
- Hardcoded @SInCE 4.2.2 instead of WPUF_SINCE placeholder
Both new template classes use @SInCE 4.2.2 in docblocks. Per project convention, this should be @SInCE WPUF_SINCE so it gets replaced with the actual version at release time.
Medium Issues
- Non-translatable labels in form_settings
Both templates have hardcoded strings that should be wrapped in __():
'name_label' => 'Name', // Should be __( 'Name', 'wp-user-frontend' )
'email_label' => 'E-Mail', // Should be __( 'E-Mail', 'wp-user-frontend' )
- Pro_Form_Preview_Testimonial missing @SInCE docblock
The class-level docblock has no @SInCE tag. The other two new classes have @SInCE — this one should too (as WPUF_SINCE). Also, individual method docblocks are missing @SInCE tags.
- Inconsistent alignment in wpuf-functions.php
The new entries use different column alignment from surrounding lines:
$integrations['post_form_template_post'] = new ... // spaces to col ~52
$integrations['post_form_template_video'] = new ... // spaces to col ~52
$integrations['post_form_template_paid_guest_post'] = new ... // spaces to col ~57
$integrations['post_form_template_guest_post_recurring'] = new ... // spaces to col ~57
Same issue in wpuf_get_post_form_builder_setting_menu_contents(). The alignment should be consistent within each block.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
includes/Free/Free_Loader.php (1)
1029-1035: Remove duplicateWPUF_Pro_Form_Preview_Artworkregistration.Line 1034 reassigns the same key already set on Line 1032. It currently has no runtime effect, but it’s noisy and error-prone for future edits.
Proposed cleanup
$integrations['WPUF_Pro_Form_Preview_EDD'] = new Pro_Form_Preview_EDD(); $integrations['WPUF_Pro_Form_Preview_Press_Release'] = new Pro_Form_Preview_Press_Release(); $integrations['WPUF_Pro_Form_Preview_Professional_Video'] = new Pro_Form_Preview_Professional_Video(); $integrations['WPUF_Pro_Form_Preview_Artwork'] = new Pro_Form_Preview_Artwork(); $integrations['WPUF_Pro_Form_Preview_Testimonial'] = new Pro_Form_Preview_Testimonial(); - $integrations['WPUF_Pro_Form_Preview_Artwork'] = new Pro_Form_Preview_Artwork(); $integrations['WPUF_Pro_Form_Preview_Portfolio'] = new Pro_Form_Preview_Portfolio(); $integrations['WPUF_Pro_Form_Preview_Volunteer'] = new Pro_Form_Preview_Volunteer();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@includes/Free/Free_Loader.php` around lines 1029 - 1035, The integrations array is registering WPUF_Pro_Form_Preview_Artwork twice (the key/class WPUF_Pro_Form_Preview_Artwork appears on both the Pro_Form_Preview_Artwork lines); remove the duplicate assignment so the integrations array only instantiates new Pro_Form_Preview_Artwork() once (leave the other registrations like WPUF_Pro_Form_Preview_Portfolio intact) to eliminate the redundant noisy re-assignment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@includes/Free/Free_Loader.php`:
- Around line 1029-1035: The integrations array is registering
WPUF_Pro_Form_Preview_Artwork twice (the key/class WPUF_Pro_Form_Preview_Artwork
appears on both the Pro_Form_Preview_Artwork lines); remove the duplicate
assignment so the integrations array only instantiates new
Pro_Form_Preview_Artwork() once (leave the other registrations like
WPUF_Pro_Form_Preview_Portfolio intact) to eliminate the redundant noisy
re-assignment.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e3dd814f-51fd-4dfc-af73-41d913ca2cde
📒 Files selected for processing (3)
includes/Admin/Forms/Post/Templates/Post_Form_Template_Paid_Guest_Post.phpincludes/Free/Free_Loader.phpwpuf-functions.php
🚧 Files skipped from review as they are similar to previous changes (2)
- includes/Admin/Forms/Post/Templates/Post_Form_Template_Paid_Guest_Post.php
- wpuf-functions.php
Wrap guest name/email labels in translation calls and replace hardcoded @SInCE values with WPUF_SINCE in several post form templates. Add @SInCE annotations to Pro_Form_Preview_Testimonial class/methods. Remove a duplicate Pro form preview integration in Free_Loader and apply minor spacing/formatting cleanups in wpuf-functions.php.
|
All 5 issues fixed @sapayth vai. Here's a summary:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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_Guest_Post_Recurring.php`:
- Around line 174-179: The 'fallback_ppp_enable' value in the template is using
the string 'on' which breaks style consistency; change the array entry for
'fallback_ppp_enable' to use the string 'true' (match the sibling
Post_Form_Template_Paid_Guest_Post.php and the form UI expectations) so the
configuration keys (e.g., 'payment_options', 'force_pack_purchase',
'fallback_ppp_enable') all use the same 'true'/'false' string format.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3fad4953-7a75-4525-808c-ba03104f9f97
📒 Files selected for processing (5)
includes/Admin/Forms/Post/Templates/Post_Form_Template_Guest_Post_Recurring.phpincludes/Admin/Forms/Post/Templates/Post_Form_Template_Paid_Guest_Post.phpincludes/Admin/Forms/Post/Templates/Pro_Form_Preview_Testimonial.phpincludes/Free/Free_Loader.phpwpuf-functions.php
🚧 Files skipped from review as they are similar to previous changes (2)
- wpuf-functions.php
- includes/Admin/Forms/Post/Templates/Pro_Form_Preview_Testimonial.php
| 'payment_options' => 'true', | ||
| 'choose_payment_option' => 'force_pack_purchase', | ||
| 'force_pack_purchase' => 'true', | ||
| 'enable_pay_per_post' => 'false', | ||
| 'fallback_ppp_enable' => 'on', | ||
| 'use_theme_css' => 'wpuf-style', |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check how fallback_ppp_enable is evaluated in the codebase to verify which format is expected
# Search for fallback_ppp_enable usage patterns
rg -nC3 'fallback_ppp_enable' --type=php
# Check if wpuf_is_checkbox_or_toggle_on is used for this setting
rg -nP 'fallback_ppp_enable.*wpuf_is_checkbox|wpuf_is_checkbox.*fallback_ppp' --type=phpRepository: weDevsOfficial/wp-user-frontend
Length of output: 8946
🏁 Script executed:
# Find the definition of wpuf_is_checkbox_or_toggle_on function
rg -n 'function\s+wpuf_is_checkbox_or_toggle_on' --type=php -A 10Repository: weDevsOfficial/wp-user-frontend
Length of output: 625
Remove the claim about potential evaluation issues; this is a style consistency fix only.
The fallback_ppp_enable setting in this template uses 'on' while the sibling template (Post_Form_Template_Paid_Guest_Post.php) and the HTML form UI (which expects 'true') use the 'true'/'false' string format. While wpuf_is_checkbox_or_toggle_on() does handle 'on' correctly, aligning this to 'true' ensures consistent formatting across templates.
🔧 Suggested fix for consistency
'payment_options' => 'true',
'choose_payment_option' => 'force_pack_purchase',
'force_pack_purchase' => 'true',
'enable_pay_per_post' => 'false',
- 'fallback_ppp_enable' => 'on',
+ 'fallback_ppp_enable' => 'true',📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| 'payment_options' => 'true', | |
| 'choose_payment_option' => 'force_pack_purchase', | |
| 'force_pack_purchase' => 'true', | |
| 'enable_pay_per_post' => 'false', | |
| 'fallback_ppp_enable' => 'on', | |
| 'use_theme_css' => 'wpuf-style', | |
| 'payment_options' => 'true', | |
| 'choose_payment_option' => 'force_pack_purchase', | |
| 'force_pack_purchase' => 'true', | |
| 'enable_pay_per_post' => 'false', | |
| 'fallback_ppp_enable' => 'true', | |
| 'use_theme_css' => 'wpuf-style', |
🤖 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 174 - 179, The 'fallback_ppp_enable' value in the template is using
the string 'on' which breaks style consistency; change the array entry for
'fallback_ppp_enable' to use the string 'true' (match the sibling
Post_Form_Template_Paid_Guest_Post.php and the form UI expectations) so the
configuration keys (e.g., 'payment_options', 'force_pack_purchase',
'fallback_ppp_enable') all use the same 'true'/'false' string format.
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