Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions admin/form-builder/views/post-form-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,20 @@ class="datepicker"
<?php
}

// Handle submit-button-conditional-logics Vue component
if ( 'submit-button-conditional-logics' === $field['type'] ) {
$submit_button_settings = isset( $form_settings['submit_button_cond'] ) ? $form_settings['submit_button_cond'] : array(
'condition_status' => 'no',
'cond_logic' => 'any',
'conditions' => array()
);
?>
<submit-button-conditional-logics
:current-settings="<?php echo esc_attr( json_encode( $submit_button_settings ) ); ?>">
</submit-button-conditional-logics>
<?php
}

if ( ! empty( $field['notice'] ) ) {
?>
<div class="wpuf-bg-yellow-50 wpuf-border-l-4 wpuf-border-yellow-500 wpuf-text-yellow-700 wpuf-p-4">
Expand Down
13 changes: 11 additions & 2 deletions assets/css/admin/form-builder.css
Original file line number Diff line number Diff line change
Expand Up @@ -3723,10 +3723,9 @@ input.wpuf-tab:checked + .wpuf-tab-content,
background-color: rgb(255 255 255 / var(--tw-bg-opacity)) !important;
}


.wpuf-bg-amber-500 {
--tw-bg-opacity: 1;
background-color: rgb(255 144 0 / var(--tw-bg-opacity));
background-color: rgb(245 158 11 / var(--tw-bg-opacity));
}

.wpuf-bg-amber-600 {
Expand Down Expand Up @@ -5318,6 +5317,11 @@ button.swal2-cancel.swal2-styled.swal2-default-outline {
background-color: rgb(240 253 244 / var(--tw-bg-opacity)) !important;
}

.hover\:wpuf-bg-amber-600:hover {
--tw-bg-opacity: 1;
background-color: rgb(217 119 6 / var(--tw-bg-opacity));
}

.hover\:wpuf-bg-blue-700:hover {
--tw-bg-opacity: 1;
background-color: rgb(29 78 216 / var(--tw-bg-opacity));
Expand Down Expand Up @@ -5488,6 +5492,11 @@ button.swal2-cancel.swal2-styled.swal2-default-outline {
border-color: transparent !important;
}

.focus\:wpuf-bg-amber-600:focus {
--tw-bg-opacity: 1;
background-color: rgb(217 119 6 / var(--tw-bg-opacity));
}

.focus\:wpuf-bg-indigo-500:focus {
--tw-bg-opacity: 1;
background-color: rgb(99 102 241 / var(--tw-bg-opacity));
Expand Down
1 change: 1 addition & 0 deletions assets/js-templates/form-components.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ class="wpuf-option-field-title wpuf-font-sm wpuf-text-gray-700 wpuf-font-medium"
<input
type="text"
v-model="value"
:readonly="option_field.is_read_only"
:class="builder_class_names('text')">
</div>
</div>
Expand Down
44 changes: 26 additions & 18 deletions includes/Admin/Forms/Admin_Form_Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
'form_settings_key' => '',
'post_id' => 0,
'shortcodes' => [],
// [ [ 'name' => 'wpuf_form', 'type' => 'profile' ], [ 'name' => 'wpuf_form', 'type' => 'registration' ] ]

Check warning on line 46 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

This comment is 56% valid code; is this commented out code?
];
$this->settings = wp_parse_args( $settings, $defaults );
// set post data to global $post
$post = get_post( $this->settings['post_id'] );

Check failure on line 50 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Overriding WordPress globals is prohibited. Found assignment to $post
// if we have an existing post, then let's start
if ( ! empty( $post->ID ) ) {
add_action( 'in_admin_header', 'wpuf_remove_admin_notices' );
Expand Down Expand Up @@ -118,24 +118,32 @@
wp_enqueue_script( 'zxcvbn' );
wp_enqueue_script( 'password-strength-meter' );
wp_enqueue_script( 'wpuf-form-builder-wpuf-forms' );
$single_objects = [
'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[] = 'profile_photo';

$single_objects = apply_filters(
'wpuf_single_form_field',
[

Check failure on line 128 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Multi-line function call not indented correctly; expected 12 spaces but found 16
'post_title',

Check failure on line 129 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Array item not aligned correctly; expected 20 spaces but found 16
'post_content',

Check failure on line 130 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Array item not aligned correctly; expected 20 spaces but found 16
'post_excerpt',

Check failure on line 131 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Array item not aligned correctly; expected 20 spaces but found 16
'featured_image',

Check failure on line 132 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Array item not aligned correctly; expected 20 spaces but found 16
'user_login',

Check failure on line 133 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Array item not aligned correctly; expected 20 spaces but found 16
'first_name',

Check failure on line 134 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Array item not aligned correctly; expected 20 spaces but found 16
'last_name',

Check failure on line 135 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Array item not aligned correctly; expected 20 spaces but found 16
'nickname',

Check failure on line 136 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Array item not aligned correctly; expected 20 spaces but found 16
'user_email',
'user_url',
'user_bio',
'password',
'user_avatar',
'taxonomy',
'cloudflare_turnstile',
'recaptcha',
]
);
$taxonomy_terms = array_keys( get_taxonomies() );
$single_objects = array_merge( $single_objects, $taxonomy_terms );
Comment on lines +124 to 148
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

wp_enqueue_script( 'wpuf-form-builder-mixins' );
Expand Down Expand Up @@ -317,7 +325,7 @@
'last_column_warn_msg' => __( 'This field must contain at least one column', 'wp-user-frontend' ),
'is_a_pro_feature' => __( 'is a pro feature', 'wp-user-frontend' ),
'pro_feature_msg' => __(
'<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>',

Check warning on line 328 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Translatable string should not be wrapped in HTML. Found: '<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>'
'wp-user-frontend'
),
'upgrade_to_pro' => __( 'Upgrade to PRO', 'wp-user-frontend' ),
Expand All @@ -341,15 +349,15 @@
*/
public static function save_form( $data ) {
$saved_wpuf_inputs = [];
wp_update_post( [ 'ID' => $data['form_id'], 'post_status' => 'publish', 'post_title' => $data['post_title'] ] );

Check warning on line 352 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

When a multi-item array uses associative keys, each value should start on a new line.
$existing_wpuf_input_ids = get_children( [
'post_parent' => $data['form_id'],

Check warning on line 354 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
'post_status' => 'publish',

Check warning on line 355 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
'post_type' => 'wpuf_input',

Check warning on line 356 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
'numberposts' => '-1',

Check warning on line 357 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
'orderby' => 'menu_order',

Check warning on line 358 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
'order' => 'ASC',

Check warning on line 359 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
'fields' => 'ids',

Check warning on line 360 in includes/Admin/Forms/Admin_Form_Builder.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
] );
$new_wpuf_input_ids = [];
if ( ! empty( $data['form_fields'] ) ) {
Expand Down
Loading
Loading