-
Notifications
You must be signed in to change notification settings - Fork 41
Add new align option hooks #2593
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
8036909
fefdecc
41fa639
252e94a
3ace44c
46dcd15
220661b
a0154e3
62f5639
5ae0983
fa86fd5
d0c6146
2146d17
7bf6de9
ec2b30d
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 |
|---|---|---|
|
|
@@ -64,15 +64,25 @@ class="frm-style-item-heading"><?php esc_html_e( 'Check Box', 'formidable' ); ?> | |
| </div> | ||
| <div class="frm7 frm_form_field"> | ||
| <?php | ||
| $align_options = array( | ||
| 'block' => __( 'One Column', 'formidable' ), | ||
| 'inline' => __( 'Inline Options', 'formidable' ), | ||
| ); | ||
|
|
||
| /** | ||
| * @since x.x | ||
| * | ||
| * @param array $align_options | ||
| * @param array $atts | ||
| */ | ||
| $checkbox_align_options = apply_filters( 'frm_checkbox_align_options', $align_options, $atts ); | ||
|
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.
|
||
|
|
||
| new FrmDropdownStyleComponent( | ||
| $frm_style->get_field_name( 'check_align' ), | ||
|
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.
|
||
| $style->post_content['check_align'], | ||
|
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.
|
||
| array( | ||
| 'id' => 'frm_check_align', | ||
| 'options' => array( | ||
| 'block' => esc_html__( 'Multiple Rows', 'formidable' ), | ||
| 'inline' => esc_html__( 'Single Row', 'formidable' ), | ||
| ), | ||
| 'options' => $checkbox_align_options, | ||
| ) | ||
| ); | ||
| ?> | ||
|
|
@@ -85,15 +95,20 @@ class="frm-style-item-heading"><?php esc_html_e( 'Radio', 'formidable' ); ?></la | |
| </div> | ||
| <div class="frm7 frm_form_field"> | ||
| <?php | ||
| /** | ||
| * @since x.x | ||
| * | ||
| * @param array $align_options | ||
| * @param array $atts | ||
| */ | ||
| $radio_align_options = apply_filters( 'frm_radio_align_options', $align_options, $atts ); | ||
|
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.
|
||
|
|
||
| new FrmDropdownStyleComponent( | ||
| $frm_style->get_field_name( 'radio_align' ), | ||
|
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.
|
||
| $style->post_content['radio_align'], | ||
|
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.
|
||
| array( | ||
| 'id' => 'frm_radio_align', | ||
| 'options' => array( | ||
| 'block' => esc_html__( 'Multiple Rows', 'formidable' ), | ||
| 'inline' => esc_html__( 'Single Row', 'formidable' ), | ||
| ), | ||
| 'options' => $radio_align_options, | ||
| ) | ||
| ); | ||
| ?> | ||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6963,6 +6963,9 @@ window.frmAdminBuildJS = function() { | |||||||||||||||||||||||
| let replaceWith = ` ${ setting.value }`; | ||||||||||||||||||||||||
| const fieldId = field.getAttribute( 'data-fid' ); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if ( '' === replaceWith.trim() ) { | ||||||||||||||||||||||||
| replaceWith = ' ' + setting.querySelector( 'option[data-align]' ).getAttribute( 'data-align' ); | ||||||||||||||||||||||||
|
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.
|
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+6966
to
+6968
Contributor
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. Guard The new fallback assumes:
This can cause issues:
Recommend tightening the logic to:
For example: - if ( '' === replaceWith.trim() ) {
- replaceWith = ' ' + setting.querySelector( 'option[data-align]' ).getAttribute( 'data-align' );
- }
+ if ( '' === replaceWith.trim() && setting.classList.contains( 'field_options_align' ) ) {
+ const selectedOption = setting.options[ setting.selectedIndex ];
+ const dataAlign = selectedOption ? selectedOption.getAttribute( 'data-align' ) : '';
+
+ if ( dataAlign ) {
+ replaceWith = ' ' + dataAlign;
+ }
+ }This keeps existing behavior for non‑align inputs, avoids exceptions when no 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| // Include classes from multiple settings. | ||||||||||||||||||||||||
| if ( fieldId !== undefined ) { | ||||||||||||||||||||||||
| if ( setting.classList.contains( 'field_options_align' ) ) { | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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.
A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.