Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion classes/controllers/FrmEntriesAJAXSubmitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ public static function ajax_create() {
}

$response['errors'] = $obj;
$invalid_msg = FrmFormsHelper::get_invalid_error_message( array( 'form' => $form ) );
$invalid_msg = FrmFormsHelper::get_invalid_error_message(
array(
'form' => $form,
'errors' => $errors,
)
);
$response['error_message'] = FrmFormsHelper::get_success_message(
array(
'message' => $invalid_msg,
Expand Down
69 changes: 68 additions & 1 deletion classes/helpers/FrmFormsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,77 @@
}

$frm_settings = FrmAppHelper::get_settings( $settings_args );
$invalid_msg = do_shortcode( $frm_settings->invalid_msg );

$field_error_messages = self::get_clickable_field_error_messages( $args );

$invalid_msg = '<span>' . do_shortcode( $frm_settings->invalid_msg ) . '</span>';

if ( $field_error_messages ) {
$invalid_msg .= "<ul>$field_error_messages</ul>";
}
return apply_filters( 'frm_invalid_error_message', $invalid_msg, $args );
}

/**
* Get clickable field error messages.
*
* @since x.x
*
* @param array $args
*
* @return string
*/
private static function get_clickable_field_error_messages( $args ) {
$field_error_messages = '';

if ( empty( $args['errors'] ) ) {
return $field_error_messages;
}

$field_ids = array_map(
function ( $field_plus_id ) {
$field_id = str_replace( 'field', '', $field_plus_id );

if ( strpos( $field_id, '-' ) !== false ) {

Check warning on line 323 in classes/helpers/FrmFormsHelper.php

View workflow job for this annotation

GitHub Actions / Mago

str-contains

Consider replacing `strpos` with `str_contains` for improved readability and intent clarity. >This comparison can be simplified. Using `str_contains` makes the code easier to understand and more expressive. Help: `strpos($a, $b) !== false` can be simplified to `str_contains($a, $b)`.
$field_id = explode( '-', $field_id )[0];
}
return $field_id;
},
array_keys( $args['errors'] )
);
$field_keys = FrmDb::get_results( 'frm_fields', array( 'id' => $field_ids ), 'id,field_key,type' );

foreach ( $args['errors'] as $field_plus_id => $error ) {
$field_id = str_replace( 'field', '', $field_plus_id );
$row = '';

if ( strpos( $field_id, '-' ) !== false ) {

Check warning on line 336 in classes/helpers/FrmFormsHelper.php

View workflow job for this annotation

GitHub Actions / Mago

str-contains

Consider replacing `strpos` with `str_contains` for improved readability and intent clarity. >This comparison can be simplified. Using `str_contains` makes the code easier to understand and more expressive. Help: `strpos($a, $b) !== false` can be simplified to `str_contains($a, $b)`.
$field_id_parts = explode( '-', $field_id );

if ( count( $field_id_parts ) === 3 ) {
$field_id = $field_id_parts[0];
$row = '-' . $field_id_parts[2];
}
}

$index = array_search( $field_id, array_column( $field_keys, 'id' ), true );

if ( false === $index ) {
continue;
}

$html_id = 'field_' . $field_keys[ $index ]->field_key . $row;

if ( in_array( $field_keys[ $index ]->type, array( 'checkbox', 'radio' ), true ) ) {
// Needed to focus on the first option when error link is clicked.
$html_id .= '-0';
}

$field_error_messages .= '<li><a href="#' . $html_id . '">' . $error . '</a></li>';
}//end foreach
return $field_error_messages;
}

/**
* @param array $atts {
* The success message details.
Expand Down
17 changes: 17 additions & 0 deletions css/_single_theme.css.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,23 @@
margin-bottom:var(--field-margin);
}

.<?php echo esc_html( $style_class ); ?> .frm_error_style span{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style_class might not be defined


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.

font-weight: bold<?php echo esc_html( $important ); ?>;;
}

.<?php echo esc_html( $style_class ); ?> .frm_error_style ul{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style_class might not be defined


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.

list-style: inside<?php echo esc_html( $important ); ?>;;
color: <?php echo esc_html( $error_text . $important ); ?>;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $error_text might not be defined


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.

}

.<?php echo esc_html( $style_class ); ?> .frm_error_style ul li a{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style_class might not be defined


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.

color: <?php echo esc_html( $error_text . $important ); ?>;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $error_text might not be defined


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.

}

.<?php echo esc_html( $style_class ); ?> .frm_error_style ul li a:hover{
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style_class might not be defined


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.

text-decoration: underline<?php echo esc_html( $important ); ?>;;
}
Comment on lines +419 to +434
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix CSS syntax errors – double semicolons.

Lines 384, 388, and 397 each have a double semicolon (;;) that will cause CSS syntax errors. The semicolon should appear only once at the end of each declaration.

Apply this diff to fix the syntax errors:

 .<?php echo esc_html( $style_class ); ?> .frm_error_style span{
-	font-weight: bold<?php echo esc_html( $important ); ?>;;
+	font-weight: bold<?php echo esc_html( $important ); ?>;
 }
 
 .<?php echo esc_html( $style_class ); ?> .frm_error_style ul{
-	list-style: inside<?php echo esc_html( $important ); ?>;;
+	list-style: inside<?php echo esc_html( $important ); ?>;
 	color: <?php echo esc_html( $error_text . $important ); ?>;
 }
 
 .<?php echo esc_html( $style_class ); ?> .frm_error_style ul li a{
 	color: <?php echo esc_html( $error_text . $important ); ?>;
 }
 
 .<?php echo esc_html( $style_class ); ?> .frm_error_style ul li a:hover{
-	text-decoration: underline<?php echo esc_html( $important ); ?>;;
+	text-decoration: underline<?php echo esc_html( $important ); ?>;
 }
📝 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.

Suggested change
.<?php echo esc_html( $style_class ); ?> .frm_error_style span{
font-weight: bold<?php echo esc_html( $important ); ?>;;
}
.<?php echo esc_html( $style_class ); ?> .frm_error_style ul{
list-style: inside<?php echo esc_html( $important ); ?>;;
color: <?php echo esc_html( $error_text . $important ); ?>;
}
.<?php echo esc_html( $style_class ); ?> .frm_error_style ul li a{
color: <?php echo esc_html( $error_text . $important ); ?>;
}
.<?php echo esc_html( $style_class ); ?> .frm_error_style ul li a:hover{
text-decoration: underline<?php echo esc_html( $important ); ?>;;
}
.<?php echo esc_html( $style_class ); ?> .frm_error_style span{
font-weight: bold<?php echo esc_html( $important ); ?>;
}
.<?php echo esc_html( $style_class ); ?> .frm_error_style ul{
list-style: inside<?php echo esc_html( $important ); ?>;
color: <?php echo esc_html( $error_text . $important ); ?>;
}
.<?php echo esc_html( $style_class ); ?> .frm_error_style ul li a{
color: <?php echo esc_html( $error_text . $important ); ?>;
}
.<?php echo esc_html( $style_class ); ?> .frm_error_style ul li a:hover{
text-decoration: underline<?php echo esc_html( $important ); ?>;
}
🤖 Prompt for AI Agents
In css/_single_theme.css.php around lines 383 to 398, several CSS declarations
end with double semicolons (lines ~384, ~388, ~397) which is invalid; remove the
extra semicolons so each CSS property ends with a single semicolon, making sure
you only append one semicolon after the PHP-echoed value (i.e., replace
instances of ";;" with ";" and verify concatenation of esc_html(...) and the
trailing ";" remains correct).


<?php if ( $pro_is_installed ) { ?>
.<?php echo esc_html( $style_class ); ?> #frm_loading .progress-striped .progress-bar{
background-image:linear-gradient(45deg, <?php echo esc_html( $border_color ); ?> 25%, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 0) 50%, <?php echo esc_html( $border_color ); ?> 50%, <?php echo esc_html( $border_color ); ?> 75%, rgba(0, 0, 0, 0) 75%, rgba(0, 0, 0, 0));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $border_color might not be defined


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.

Expand Down
Loading