-
Notifications
You must be signed in to change notification settings - Fork 151
Add profile photo support and improve form builder UI #1606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add profile photo support and improve form builder UI #1606
Conversation
Introduces fallback functions for profile photo allowed extensions and MIME types for non-Pro users. Updates the form builder to support a new 'submit-button-conditional-logics' Vue component, improves field read-only handling, and refines unique field logic to include 'profile_photo'. Also updates admin CSS for new color classes and enhances translation strings and line references in the POT file.
WalkthroughThis update introduces new conditional logic rendering for submit button settings in the admin form builder, adds Vue template improvements for read-only fields, updates translation entries and references, revises how single form fields are initialized, sets a default for conditional logic toggles, and implements fallback functions for profile photo file validation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Possibly related PRs
Suggested labels
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (5)
assets/css/admin/form-builder.css (2)
5320-5323: New hover utility adds value but consider parity withactive/focus-visiblestates
The explicit rule for.hover\:wpuf-bg-amber-600:hoveris fine, yet we now have hover & focus utilities only for amber-600. For UX consistency (and to avoid one-off declarations in the future) you may want to:
- Add an
active:variant (.active\:wpuf-bg-amber-600:active).- Or, if this CSS is generated from Tailwind, rely on Tailwind’s variant system instead of hard-coding each state here—this keeps the file from ballooning further.
No functional bug, just a maintainability nit.
5495-5498: Focus utility duplicates hover rule – can be DRYed
The focus rule duplicates the hover rule’s colour value and could be merged into a single selector:-.hover\:wpuf-bg-amber-600:hover { +.hover\:wpuf-bg-amber-600:hover, +.focus\:wpuf-bg-amber-600:focus { --tw-bg-opacity: 1; background-color: rgb(217 119 6 / var(--tw-bg-opacity)); }Reduces repetition and keeps the build lighter.
includes/Admin/Forms/Admin_Form_Builder.php (1)
128-136: Fix PHPCS array alignment issues.The array items are not properly aligned according to the project's coding standards.
Apply this diff to fix the array alignment:
$single_objects = apply_filters( 'wpuf_single_form_field', - [ - 'post_title', - 'post_content', - 'post_excerpt', - 'featured_image', - 'user_login', - 'first_name', - 'last_name', - 'nickname', - 'user_email', + [ + 'post_title', + 'post_content', + 'post_excerpt', + 'featured_image', + 'user_login', + 'first_name', + 'last_name', + 'nickname', + 'user_email',wpuf-functions.php (2)
5518-5524: Replace placeholderWPUF_SINCEwith a concrete version.
@since WPUF_SINCEwill end up in the generated docs verbatim; the constant is not defined anywhere in the code-base, so tooling will treat it as noise.- * @since WPUF_SINCE + * @since 4.1.0
5558-5564: Redundant / invalid MIME entry and potential duplication.
image/jpgis not part of WordPress’ default mime list (get_allowed_mime_types()maps all JPG extensions toimage/jpeg).
It will therefore be stripped by thearray_intersect, making the element pointless and leaving a duplicateimage/jpeg.Consider trimming the list to the canonical set:
- $allowed_mimes = [ - 'image/jpeg', - 'image/jpg', - 'image/png', - 'image/gif', - ]; + $allowed_mimes = [ + 'image/jpeg', + 'image/png', + 'image/gif', + ];
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
admin/form-builder/views/post-form-settings.php(1 hunks)assets/css/admin/form-builder.css(3 hunks)assets/js-templates/form-components.php(1 hunks)includes/Admin/Forms/Admin_Form_Builder.php(1 hunks)languages/wp-user-frontend.pot(18 hunks)wpuf-functions.php(1 hunks)
🧰 Additional context used
🪛 GitHub Check: Run PHPCS inspection
includes/Admin/Forms/Admin_Form_Builder.php
[failure] 136-136:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 135-135:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 134-134:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 133-133:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 132-132:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 131-131:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 130-130:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 129-129:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 128-128:
Multi-line function call not indented correctly; expected 12 spaces but found 16
🪛 GitHub Actions: Inspections
admin/form-builder/views/post-form-settings.php
[warning] 1-1: This comment is 56% valid code; is this commented out code?
[error] 1-1: Overriding WordPress globals is prohibited. Found assignment to $post
🔇 Additional comments (5)
assets/css/admin/form-builder.css (1)
3726-3729: Amber-500 colour fix is spot-on
Switching torgb(245 158 11)matches Tailwind’s canonicalamber-500(#f59e0b). No issues.assets/js-templates/form-components.php (1)
625-625: LGTM! Clean implementation of conditional readonly functionality.The Vue.js attribute binding is correctly implemented and enhances the form builder's capabilities by allowing text meta fields to be conditionally read-only based on the
is_read_onlyproperty.admin/form-builder/views/post-form-settings.php (2)
543-555: Well-implemented conditional logic handler.The new submit button conditional logic field type is properly implemented with:
- Appropriate default fallback values
- Secure JSON encoding with
esc_attr()- Clean Vue component integration
102-102: ```shell
#!/bin/bashConfirm no assignment to $post in the specific view file
rg -n '$post\s*=' admin/form-builder/views/post-form-settings.php
</details> <details> <summary>languages/wp-user-frontend.pot (1)</summary> `1-8657`: **Verify POT file integrity after resolving merge conflicts.** After fixing the merge conflicts, ensure the POT file is valid by: 1. Running `msgfmt --check-format` to validate syntax 2. Checking for any remaining duplicate msgid entries 3. Verifying the file can be properly loaded by translation tools Run this script to validate the POT file after fixes: ```shell #!/bin/bash # Description: Validate POT file integrity and check for duplicates # Check for remaining merge conflict markers echo "Checking for remaining merge conflict markers..." if grep -n "<<<<<<\|>>>>>>\|=======" languages/wp-user-frontend.pot; then echo "ERROR: Merge conflict markers still present" exit 1 else echo "✓ No merge conflict markers found" fi # Check for duplicate msgid entries echo "Checking for duplicate msgid entries..." grep "^msgid " languages/wp-user-frontend.pot | sort | uniq -d | head -10 # Validate POT file format if msgfmt is available if command -v msgfmt >/dev/null 2>&1; then echo "Validating POT file format..." msgfmt --check-format languages/wp-user-frontend.pot echo "✓ POT file format is valid" else echo "msgfmt not available, skipping format validation" fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix logical bug: 'profile_photo' field gets overwritten and lost.
The current implementation has a logical flaw where 'profile_photo' is added to $single_objects on line 124, but then immediately overwritten by the apply_filters() call on lines 126-146, making the addition ineffective.
Apply this diff to fix the logic and ensure 'profile_photo' is included in the final unique fields list:
- /**
- * Unique fields list. Only 1 field can be added in a form.
- */
- $single_objects[] = 'profile_photo';
-
- $single_objects = apply_filters(
- 'wpuf_single_form_field',
- [
- 'post_title',
- 'post_content',
- 'post_excerpt',
- 'featured_image',
- 'user_login',
- 'first_name',
- 'last_name',
- 'nickname',
- 'user_email',
- 'user_url',
- 'user_bio',
- 'password',
- 'user_avatar',
- 'taxonomy',
- 'cloudflare_turnstile',
- 'recaptcha',
- ]
- );
+ /**
+ * Unique fields list. Only 1 field can be added in a form.
+ */
+ $single_objects = apply_filters(
+ 'wpuf_single_form_field',
+ [
+ 'post_title',
+ 'post_content',
+ 'post_excerpt',
+ 'featured_image',
+ 'user_login',
+ 'first_name',
+ 'last_name',
+ 'nickname',
+ 'user_email',
+ 'user_url',
+ 'user_bio',
+ 'password',
+ 'user_avatar',
+ 'taxonomy',
+ 'cloudflare_turnstile',
+ 'recaptcha',
+ 'profile_photo',
+ ]
+ );🧰 Tools
🪛 GitHub Check: Run PHPCS inspection
[failure] 136-136:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 135-135:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 134-134:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 133-133:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 132-132:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 131-131:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 130-130:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 129-129:
Array item not aligned correctly; expected 20 spaces but found 16
[failure] 128-128:
Multi-line function call not indented correctly; expected 12 spaces but found 16
🤖 Prompt for AI Agents
In includes/Admin/Forms/Admin_Form_Builder.php around lines 124 to 148, the
'profile_photo' field is initially added to $single_objects but then overwritten
by the apply_filters() call, causing it to be lost. To fix this, assign the
filtered array to a temporary variable first, then merge 'profile_photo' and the
taxonomy terms into $single_objects, ensuring 'profile_photo' is included in the
final list without being overwritten.
| 'jpg' => __( 'JPG', 'wpuf-pro' ), | ||
| 'jpeg' => __( 'JPEG', 'wpuf-pro' ), | ||
| 'png' => __( 'PNG', 'wpuf-pro' ), | ||
| 'gif' => __( 'GIF', 'wpuf-pro' ), | ||
| ]; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Wrong text-domain used in newly added strings.
The fallback lives in the free package, but the domain is set to wpuf-pro.
Unless wpuf-pro is explicitly loaded, these strings will never be translated.
- 'jpg' => __( 'JPG', 'wpuf-pro' ),
- 'jpeg' => __( 'JPEG', 'wpuf-pro' ),
- 'png' => __( 'PNG', 'wpuf-pro' ),
- 'gif' => __( 'GIF', 'wpuf-pro' ),
+ 'jpg' => __( 'JPG', 'wp-user-frontend' ),
+ 'jpeg' => __( 'JPEG', 'wp-user-frontend' ),
+ 'png' => __( 'PNG', 'wp-user-frontend' ),
+ 'gif' => __( 'GIF', 'wp-user-frontend' ),📝 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.
| 'jpg' => __( 'JPG', 'wpuf-pro' ), | |
| 'jpeg' => __( 'JPEG', 'wpuf-pro' ), | |
| 'png' => __( 'PNG', 'wpuf-pro' ), | |
| 'gif' => __( 'GIF', 'wpuf-pro' ), | |
| ]; | |
| 'jpg' => __( 'JPG', 'wp-user-frontend' ), | |
| 'jpeg' => __( 'JPEG', 'wp-user-frontend' ), | |
| 'png' => __( 'PNG', 'wp-user-frontend' ), | |
| 'gif' => __( 'GIF', 'wp-user-frontend' ), | |
| ]; |
🤖 Prompt for AI Agents
In wpuf-functions.php around lines 5528 to 5533, the text domain used in the
translation functions is incorrectly set to 'wpuf-pro' for the newly added
strings. Change the text domain from 'wpuf-pro' to the correct free package
domain, likely 'wpuf', to ensure these strings are properly translated when the
free package is used.
| <<<<<<< Updated upstream | ||
| ======= | ||
| #: includes/Admin/Forms/Admin_Form_Builder.php:302 | ||
| msgid "Advanced Options" | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Builder.php:303 | ||
| msgid "Delete Field Confirmation" | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Builder.php:304 | ||
| msgid "Are you sure you want to delete this field? This action cannot be undone." | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Builder.php:309 | ||
| msgid "Okay" | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Builder.php:311 | ||
| #: includes/Admin/views/shortcode-builder.php:70 | ||
| msgid "Close" | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Builder.php:312 | ||
| msgid "This field must contain at least one choice" | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Builder.php:313 | ||
| #: includes/Fields/Form_Field_Checkbox.php:110 | ||
| #: includes/Fields/Form_Field_Dropdown.php:109 | ||
| #: includes/Fields/Form_Field_MultiDropdown.php:84 | ||
| #: includes/Fields/Form_Field_Radio.php:114 | ||
| msgid "Option" | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Builder.php:314 | ||
| msgid "Column" | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Builder.php:315 | ||
| msgid "This field must contain at least one column" | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Builder.php:316 | ||
| msgid "is a pro feature" | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Builder.php:317 | ||
| msgid "" | ||
| "<p class=\"wpuf-text-gray-500 wpuf-font-medium wpuf-text-xl\">Please " | ||
| "upgrade to the Pro version to unlock all these awesome features</p>" | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Builder.php:322 | ||
| #: includes/Fields/Field_Contract.php:449 | ||
| msgid "Select" | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Builder.php:323 | ||
| msgid "Saved form data" | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Builder.php:324 | ||
| msgid "You have unsaved changes." | ||
| msgstr "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Handler.php:350 | ||
| #: includes/Admin/Forms/Admin_Form_Handler.php:391 | ||
| #. translators: %d is the number of forms | ||
| #. translators: %s is the form url | ||
| msgid "%d form moved to the trash." | ||
| msgid_plural "%d forms moved to the trash." | ||
| msgstr[0] "" | ||
| msgstr[1] "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Handler.php:359 | ||
| #: includes/Admin/Forms/Admin_Form_Handler.php:400 | ||
| #. translators: %d is the number of forms | ||
| msgid "%d form restored from the trash." | ||
| msgid_plural "%d forms restored from the trash." | ||
| msgstr[0] "" | ||
| msgstr[1] "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Handler.php:368 | ||
| #: includes/Admin/Forms/Admin_Form_Handler.php:409 | ||
| #. translators: %d is the number of forms | ||
| #. translators: %d is the number of form | ||
| msgid "%d form permanently deleted." | ||
| msgid_plural "%d forms permanently deleted." | ||
| msgstr[0] "" | ||
| msgstr[1] "" | ||
|
|
||
| #: includes/Admin/Forms/Admin_Form_Handler.php:378 | ||
| #: includes/Admin/Forms/Admin_Form_Handler.php:419 | ||
| #. translators: %s is the form url | ||
| msgid "Form duplicated successfully. <a href=\"%s\">View form.</a>" | ||
| msgstr "" | ||
|
|
||
| >>>>>>> Stashed changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Large unresolved merge conflict with duplicated translation entries.
There's a massive unresolved merge conflict containing duplicated translation entries for form builder components. This creates invalid POT file syntax and duplicate msgid entries.
Remove the merge conflict markers and deduplicate the entries. The conflict contains duplicate entries for:
- Admin_Form_Builder.php strings (lines 2603-2697)
- Form builder UI strings like "Advanced Options", "Delete Field Confirmation", etc.
You'll need to:
- Remove the conflict markers (
<<<<<<< Updated upstream,=======,>>>>>>> Stashed changes) - Keep only one set of the duplicated translation entries
- Ensure all msgid entries are unique within the file
🤖 Prompt for AI Agents
In languages/wp-user-frontend.pot between lines 2600 and 2698, there is a large
unresolved merge conflict with duplicated translation entries and conflict
markers present. Remove all conflict markers (<<<<<<<, =======, >>>>>>>), then
deduplicate the translation entries by keeping only one copy of each msgid
string related to Admin_Form_Builder.php and form builder UI strings. Ensure
that all msgid entries are unique and the POT file syntax is valid after
cleanup.
| <<<<<<< Updated upstream | ||
| "POT-Creation-Date: 2025-06-25 11:26:12+00:00\n" | ||
| ======= | ||
| "POT-Creation-Date: 2025-06-23 05:19:57+00:00\n" | ||
| >>>>>>> Stashed changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Unresolved merge conflict in POT file header.
There's an unresolved Git merge conflict in the POT-Creation-Date header that needs to be fixed immediately. This will prevent the translation file from working properly.
Resolve the merge conflict by choosing the appropriate creation date:
-<<<<<<< Updated upstream
-"POT-Creation-Date: 2025-06-25 11:26:12+00:00\n"
-=======
-"POT-Creation-Date: 2025-06-23 05:19:57+00:00\n"
->>>>>>> Stashed changes
+"POT-Creation-Date: 2025-06-25 11:26:12+00:00\n"📝 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.
| <<<<<<< Updated upstream | |
| "POT-Creation-Date: 2025-06-25 11:26:12+00:00\n" | |
| ======= | |
| "POT-Creation-Date: 2025-06-23 05:19:57+00:00\n" | |
| >>>>>>> Stashed changes | |
| "POT-Creation-Date: 2025-06-25 11:26:12+00:00\n" |
🤖 Prompt for AI Agents
In languages/wp-user-frontend.pot around lines 7 to 11, there is an unresolved
Git merge conflict in the POT-Creation-Date header. Remove the conflict markers
(<<<<<<<, =======, >>>>>>>) and select the correct creation date to keep,
ensuring the header contains only a single valid date line without any conflict
artifacts.
…ofile_photo_field
helper for PR #868
Introduces fallback functions for profile photo allowed extensions and MIME types for non-Pro users. Updates the form builder to support a new 'submit-button-conditional-logics' Vue component, improves field read-only handling, and refines unique field logic to include 'profile_photo'. Also updates admin CSS for new color classes and enhances translation strings and line references in the POT file.
Summary by CodeRabbit
New Features
Improvements
Translations