Add 'General' category for registration forms#1822
Add 'General' category for registration forms#1822arifulhoque7 wants to merge 2 commits intoweDevsOfficial:developfrom
Conversation
Introduce a new 'general' category to the profile/registration form categories in modal-v4.2.php. The category includes the label 'General' (text domain 'wp-user-frontend') and keywords ['simple', 'signup', 'blog author'] to help surface simple/signup/blog-author templates in the modal.
WalkthroughAdded a new "general" category and re-enabled the "community" category in the registration/profile form categories within the modal configuration, updating labels and keywords and affecting the conditional set of categories used for registration/profile forms. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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: 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/template-parts/modal-v4.2.php`:
- Around line 41-44: The default category slug was added as 'general' but
fallback/category assignments still use 'registration', causing mismatched
counts/filters; update all places that assign a default/fallback category (where
$categories is used and where fallback variables or assignments reference
'registration') to use 'general' instead, or implement a conditional that if the
chosen slug is not in $categories it falls back to 'general' (adjust the
fallback logic around the category assignment code that currently references
'registration' so it consistently uses the 'general' slug).
| 'general' => [ | ||
| 'label' => __( 'General', 'wp-user-frontend' ), | ||
| 'keywords' => [ 'simple', 'signup', 'blog author' ], | ||
| ], |
There was a problem hiding this comment.
Wire general as the actual default registration/profile category.
After introducing general (Line 41), fallback/category assignment still uses registration (Line 93, Line 196, Line 212). That slug is not in $categories, so counts and filters become inconsistent for uncategorized/blank/AI templates.
🔧 Proposed fix
--- a/includes/Admin/template-parts/modal-v4.2.php
+++ b/includes/Admin/template-parts/modal-v4.2.php
@@
- if ( strpos( strtolower( $form_type ), 'registration' ) !== false || strpos( strtolower( $form_type ), 'profile' ) !== false ) {
- return 'registration';
+ if ( strpos( strtolower( $form_type ), 'registration' ) !== false || strpos( strtolower( $form_type ), 'profile' ) !== false ) {
+ return 'general';
} else {
return 'post';
}
@@
-$blank_form_category = strpos( strtolower( $form_type ), 'registration' ) !== false || strpos( strtolower( $form_type ), 'profile' ) !== false ? 'registration' : 'post';
+$blank_form_category = strpos( strtolower( $form_type ), 'registration' ) !== false || strpos( strtolower( $form_type ), 'profile' ) !== false ? 'general' : 'post';
@@
-$ai_form_category = $is_post_form ? 'post' : 'registration';
+$ai_form_category = $is_post_form ? 'post' : 'general';🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@includes/Admin/template-parts/modal-v4.2.php` around lines 41 - 44, The
default category slug was added as 'general' but fallback/category assignments
still use 'registration', causing mismatched counts/filters; update all places
that assign a default/fallback category (where $categories is used and where
fallback variables or assignments reference 'registration') to use 'general'
instead, or implement a conditional that if the chosen slug is not in
$categories it falls back to 'general' (adjust the fallback logic around the
category assignment code that currently references 'registration' so it
consistently uses the 'general' slug).
Uncommented the 'community' entry in modal-v4.2.php and set its keywords to ['community member'] to improve discoverability in the admin modal's block selector. Previously this block was commented out with no keywords.
There was a problem hiding this comment.
♻️ Duplicate comments (1)
includes/Admin/template-parts/modal-v4.2.php (1)
41-44:⚠️ Potential issue | 🟠 MajorDefault category wiring is still inconsistent with the new
generalslug.Line 41 introduces
general, but fallback assignments still useregistration(Line 93, Line 196, Line 212). That slug is absent from$categories, so default/blank/AI templates can bypass expected counts and filters.🔧 Proposed fix
- if ( strpos( strtolower( $form_type ), 'registration' ) !== false || strpos( strtolower( $form_type ), 'profile' ) !== false ) { - return 'registration'; + if ( strpos( strtolower( $form_type ), 'registration' ) !== false || strpos( strtolower( $form_type ), 'profile' ) !== false ) { + return 'general'; } else { return 'post'; } -$blank_form_category = strpos( strtolower( $form_type ), 'registration' ) !== false || strpos( strtolower( $form_type ), 'profile' ) !== false ? 'registration' : 'post'; +$blank_form_category = strpos( strtolower( $form_type ), 'registration' ) !== false || strpos( strtolower( $form_type ), 'profile' ) !== false ? 'general' : 'post'; -$ai_form_category = $is_post_form ? 'post' : 'registration'; +$ai_form_category = $is_post_form ? 'post' : 'general';🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@includes/Admin/template-parts/modal-v4.2.php` around lines 41 - 44, The code introduces a new category slug 'general' in the $categories array but other parts still fall back to 'registration', causing mismatches; update all fallback/default assignments that reference 'registration' (e.g., the default/blank/AI template assignment logic and any variables or functions that choose a category) to use 'general' instead so the category lookups and counts use the newly declared 'general' slug consistently (search for occurrences of 'registration' in the modal-v4.2.php template logic and replace them with 'general' where they serve as defaults/fallbacks).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@includes/Admin/template-parts/modal-v4.2.php`:
- Around line 41-44: The code introduces a new category slug 'general' in the
$categories array but other parts still fall back to 'registration', causing
mismatches; update all fallback/default assignments that reference
'registration' (e.g., the default/blank/AI template assignment logic and any
variables or functions that choose a category) to use 'general' instead so the
category lookups and counts use the newly declared 'general' slug consistently
(search for occurrences of 'registration' in the modal-v4.2.php template logic
and replace them with 'general' where they serve as defaults/fallbacks).
Introduce a new 'general' category to the profile/registration form categories in modal-v4.2.php. The category includes the label 'General' (text domain 'wp-user-frontend') and keywords ['simple', 'signup', 'blog author'] to help surface simple/signup/blog-author templates in the modal.
Related PRO PR
Summary by CodeRabbit