-
Notifications
You must be signed in to change notification settings - Fork 154
enhance: revamp registration template 1 #1723
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
Changes from all commits
0ca610b
3ba195a
9df56a2
fe5c351
1569809
d237e3c
ff9d6ad
2b356ba
aed3391
dc9465a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -24,7 +24,10 @@ | |||||
| * @return void | ||||||
| */ | ||||||
| public function render( $field_settings, $form_id, $type = 'post', $post_id = null ) { | ||||||
| // Enqueue custom multi-select assets | ||||||
| $this->enqueue_multiselect_assets(); | ||||||
|
|
||||||
| if ( isset( $post_id ) && $post_id != '0' ) { | ||||||
| $selected = $this->get_meta( $post_id, $field_settings['name'], $type ); | ||||||
|
|
||||||
| if ( is_serialized( $selected ) ) { | ||||||
|
|
@@ -40,33 +43,33 @@ | |||||
| $selected = is_array( $selected ) ? $selected : (array) $selected; | ||||||
| } | ||||||
|
|
||||||
| $name = $field_settings['name'] . '[]'; | ||||||
|
|
||||||
| $this->field_print_label( $field_settings, $form_id ); ?> | ||||||
|
|
||||||
| <?php do_action( 'WPUF_multidropdown_field_after_label', $field_settings ); ?> | ||||||
|
|
||||||
| <div class="wpuf-fields"> | ||||||
| <select multiple="multiple" class="multiselect <?php echo 'wpuf_' . esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>" id="<?php echo esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>" name="<?php echo esc_attr( $name ); ?>" mulitple="multiple" data-required="<?php echo esc_attr( $field_settings['required'] ); ?>" data-type="multiselect"> | ||||||
| <select multiple="multiple" class="multiselect wpuf-multiselect-field <?php echo 'wpuf_' . esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>" id="<?php echo esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>" name="<?php echo esc_attr( $name ); ?>" multiple="multiple" data-required="<?php echo esc_attr( $field_settings['required'] ); ?>" data-type="multiselect" data-placeholder="<?php echo esc_attr( $field_settings['first'] ); ?>"> | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate multiple="multiple" attribute The select includes multiple="multiple" twice. Keep one. - <select multiple="multiple" class="multiselect wpuf-multiselect-field <?php echo 'wpuf_' . esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>" id="<?php echo esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>" name="<?php echo esc_attr( $name ); ?>" multiple="multiple" data-required="<?php echo esc_attr( $field_settings['required'] ); ?>" data-type="multiselect" data-placeholder="<?php echo esc_attr( $field_settings['first'] ); ?>">
+ <select multiple="multiple" class="multiselect wpuf-multiselect-field <?php echo 'wpuf_' . esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>" id="<?php echo esc_attr( $field_settings['name'] ) . '_' . esc_attr( $form_id ); ?>" name="<?php echo esc_attr( $name ); ?>" data-required="<?php echo esc_attr( $field_settings['required'] ); ?>" data-type="multiselect" data-placeholder="<?php echo esc_attr( $field_settings['first'] ); ?>">📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| <?php if ( !empty( $field_settings['first'] ) ) { ?> | ||||||
| <option value="-1"><?php echo esc_attr( $field_settings['first'] ); ?></option> | ||||||
| <?php } ?> | ||||||
|
|
||||||
| <?php | ||||||
| if ( $field_settings['options'] && count( $field_settings['options'] ) > 0 ) { | ||||||
| foreach ( $field_settings['options'] as $value => $option ) { | ||||||
| $current_select = selected( in_array( $value, $selected ), true, false ); ?> | ||||||
|
Check failure on line 62 in includes/Fields/Form_Field_MultiDropdown.php
|
||||||
| <option value="<?php echo esc_attr( $value ); ?>"<?php echo esc_attr( $current_select ); ?>><?php echo esc_html( $option ); ?></option> | ||||||
| <?php | ||||||
| } | ||||||
| } ?> | ||||||
| </select> | ||||||
| <?php $this->help_text( $field_settings ); ?> | ||||||
| </div> | ||||||
|
|
||||||
|
|
||||||
| <?php $this->after_field_print_label(); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -102,7 +105,7 @@ | |||||
| public function prepare_entry( $field ) { | ||||||
| check_ajax_referer( 'wpuf_form_add' ); | ||||||
|
|
||||||
| $field_name = isset( $_POST[$field['name']] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST[$field['name']] ) ) : []; | ||||||
|
Check failure on line 108 in includes/Fields/Form_Field_MultiDropdown.php
|
||||||
| $field_name = array_map( 'strip_shortcodes', $field_name ); | ||||||
| $entry_value = ( is_array( $field_name ) && $field_name ) ? $field_name : []; | ||||||
|
|
||||||
|
|
@@ -110,7 +113,7 @@ | |||||
| $new_val = []; | ||||||
|
|
||||||
| foreach ( $entry_value as $option_key ) { | ||||||
| $new_val[] = isset( $field['options'][$option_key] ) ? $field['options'][$option_key] : ''; | ||||||
|
Check failure on line 116 in includes/Fields/Form_Field_MultiDropdown.php
|
||||||
| } | ||||||
| $entry_value = implode( wpuf()->get_field_seperator(), $new_val ); | ||||||
| } else { | ||||||
|
|
@@ -170,4 +173,18 @@ | |||||
| <?php | ||||||
| return ob_get_clean(); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Enqueue custom multi-select assets | ||||||
| * | ||||||
| * @since WPUF_SINCE | ||||||
| * | ||||||
| * @return void | ||||||
| */ | ||||||
| private function enqueue_multiselect_assets() { | ||||||
| // Check if we're in the frontend | ||||||
| if ( ! is_admin() ) { | ||||||
| wp_enqueue_script( 'wpuf-custom-multiselect' ); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,10 +2,11 @@ | |
|
|
||
| namespace WeDevs\Wpuf; | ||
|
|
||
| use WeDevs\Wpuf\Admin\Forms\Form; | ||
| use WeDevs\Wpuf\Admin\Subscription; | ||
|
|
||
| class Frontend_Render_Form { | ||
| private static $_instance; | ||
|
|
||
| public static $meta_key = 'wpuf_form'; | ||
|
|
||
|
|
@@ -123,7 +124,7 @@ | |
| wp_send_json_error( __( 'Unauthorized operation', 'wp-user-frontend' ) ); | ||
| } | ||
|
|
||
| $form_id = isset( $_GET['form_id'] ) ? intval( wp_unslash( $_GET['form_id'] ) ) : 0; | ||
|
Check warning on line 127 in includes/Frontend_Render_Form.php
|
||
|
|
||
| if ( $form_id ) { | ||
| wp_enqueue_script( 'jquery' ); | ||
|
|
@@ -197,15 +198,50 @@ | |
|
|
||
| $label_position = isset( $this->form_settings['label_position'] ) ? $this->form_settings['label_position'] : 'left'; | ||
|
|
||
| $layout = isset( $this->form_settings['form_layout'] ) ? $this->form_settings['form_layout'] : 'layout1'; | ||
| $layout = 'layout1'; | ||
|
|
||
| $theme_css = isset( $this->form_settings['use_theme_css'] ) ? $this->form_settings['use_theme_css'] : 'wpuf-style'; | ||
|
Comment on lines
+201
to
203
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. “Use Theme CSS” emits raw setting as a CSS class and is layout-inconsistent. Currently the class attribute may become “on/off” (or similar), and esc_html is used in a class attribute. Compute a boolean and derive the skin class; use esc_attr. Apply a minimal fix by computing the class at render-time: <?php
$skin_class = ( 'layout1' === $layout )
? ( isset( $this->form_settings['use_theme_css'] ) && wpuf_is_checkbox_or_toggle_on( $this->form_settings['use_theme_css'] ) ? '' : 'wpuf-style' )
: 'wpuf-style';
?>
<form class="wpuf-form-add wpuf-form-<?php echo esc_attr( $layout ); ?> <?php echo esc_attr( $skin_class ); ?>" action="" method="post">Optional cleanup: remove the now-unused $theme_css variable. Also applies to: 261-263 |
||
|
|
||
| do_action( 'wpuf_before_form_render', $form_id ); | ||
|
|
||
| if ( ! empty( $layout ) ) { | ||
| wp_enqueue_style( 'wpuf-' . $layout ); | ||
| $form = new Form($form_id); | ||
|
|
||
| // Check if Use Theme CSS is enabled - if so, don't enqueue plugin styles | ||
| $use_theme_css = isset( $this->form_settings['use_theme_css'] ) ? $this->form_settings['use_theme_css'] : ''; | ||
|
|
||
| if ( 'wpuf_profile' === $form->data->post_type && 'on' !== $use_theme_css ) { | ||
| $layout = isset( $this->form_settings['profile_form_layout'] ) ? $this->form_settings['profile_form_layout'] : 'layout1'; | ||
| switch ( $layout ) { | ||
| case 'layout2': | ||
| wp_enqueue_style( 'wpuf-reg-template-2' ); | ||
| break; | ||
|
|
||
| case 'layout3': | ||
| wp_enqueue_style( 'wpuf-reg-template-3' ); | ||
| break; | ||
|
|
||
| case 'layout4': | ||
| wp_enqueue_style( 'wpuf-reg-template-4' ); | ||
| break; | ||
|
|
||
| case 'layout5': | ||
| wp_enqueue_style( 'wpuf-reg-template-5' ); | ||
| break; | ||
|
|
||
| default: | ||
| wp_enqueue_style( 'wpuf-reg-template-1' ); | ||
| break; | ||
| } | ||
| } else { | ||
| $layout = isset( $this->form_settings['form_layout'] ) ? $this->form_settings['form_layout'] : 'layout1'; | ||
|
|
||
| if ( ! empty( $layout ) && 'on' !== $use_theme_css ) { | ||
| // Always enqueue the base template style | ||
| wp_enqueue_style( 'wpuf-reg-template-base' ); | ||
| wp_enqueue_style( 'wpuf-' . $layout ); | ||
| } | ||
| } | ||
|
|
||
| if ( ! is_user_logged_in() && ( ! empty( $this->form_settings['post_permission'] ) && 'guest_post' !== $this->form_settings['post_permission'] ) ) { | ||
| $login = wpuf()->frontend->simple_login->get_login_url(); | ||
| $register = wpuf()->frontend->simple_login->get_registration_url(); | ||
|
|
@@ -328,8 +364,8 @@ | |
| </div> | ||
| <div > | ||
| <label > | ||
| <input type="checkbox" class="wpuf_is_featured" name="is_featured_item" value="1" <?php echo $is_featured ? 'checked' : ''; ?> > | ||
| <span class="wpuf-items-table-containermessage-box" id="remaining-feature-item"> <?php echo sprintf( | ||
| // translators: %1$s is Post type and %2$d is item | ||
| wp_kses_post( __( 'Mark the %1$s as featured (remaining %2$d)', 'wp-user-frontend' ) ), esc_html( $post_type ), esc_html( $featured_item ) ); ?></span> | ||
| </label> | ||
|
|
@@ -365,7 +401,7 @@ | |
|
|
||
| foreach ( $form_vars as $key => $value ) { | ||
| // get column field input fields | ||
| if ( $value['input_type'] == 'column_field' ) { | ||
| $inner_fields = $value['inner_fields']; | ||
|
|
||
| foreach ( $inner_fields as $column_key => $column_fields ) { | ||
|
|
@@ -377,12 +413,12 @@ | |
| } | ||
|
|
||
| //separate the post and custom fields | ||
| if ( isset( $column_field['is_meta'] ) && $column_field['is_meta'] == 'yes' ) { | ||
| $meta_vars[] = $column_field; | ||
| continue; | ||
| } | ||
|
|
||
| if ( $column_field['input_type'] == 'taxonomy' ) { | ||
|
|
||
| // don't add "category" | ||
| // if ( $column_field['name'] == 'category' ) { | ||
|
|
||
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.
🧩 Analysis chain
Asset enqueue is good; ensure handle exists and admin preview needs
Looks good for frontend. Verify the 'wpuf-custom-multiselect' handle is registered and consider enqueueing on form preview pages in admin if the builder preview relies on it.
🏁 Script executed:
Length of output: 544
🏁 Script executed:
Length of output: 670
🏁 Script executed:
Length of output: 1545
🏁 Script executed:
Length of output: 3573
🏁 Script executed:
Length of output: 13540
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 108
Register 'wpuf-custom-multiselect' handle before enqueueing
The script handle 'wpuf-custom-multiselect' is being enqueued at includes/Fields/Form_Field_MultiDropdown.php:187 but is not registered anywhere in the codebase. Register it in Assets.php via the
get_scripts()method with the appropriate source file and dependencies, or the asset will fail to load.Additionally, consider whether this script needs to be enqueued on admin form preview/builder pages if the preview relies on it (currently only enqueued on frontend via
if ( ! is_admin() )).🤖 Prompt for AI Agents