From 0d199d5b19cd6f295a11d3489b769aebd7baa821 Mon Sep 17 00:00:00 2001 From: Champ Camba Date: Thu, 6 Aug 2020 17:58:08 +0800 Subject: [PATCH] Stop displaying error & notice when the text is empty + esc_attr $text --- includes/core/class-fields.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 826e3cf2..dd36975a 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -378,20 +378,23 @@ if ( ! class_exists( 'um\core\Fields' ) ) { * @return string */ function field_error( $text, $force_show = false ) { + + if( empty( $text ) ) return; + if ( $force_show ) { - $output = '
' . $text . '
'; + $output = '
' . esc_attr( $text ) . '
'; return $output; } if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) { - $output = '
' . $text . '
'; + $output = '
' . esc_attr( $text ) . '
'; } else { $output = ''; } if ( ! UM()->form()->processing ) { - $output = '
' . $text . '
'; + $output = '
' . esc_attr( $text ) . '
'; } return $output; @@ -407,20 +410,23 @@ if ( ! class_exists( 'um\core\Fields' ) ) { * @return string */ function field_notice( $text, $force_show = false ) { + + if( empty( $text ) ) return; + if ( $force_show ) { - $output = '
' . $text . '
'; + $output = '
' . esc_attr( $text ) . '
'; return $output; } if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) { - $output = '
' . $text . '
'; + $output = '
' . esc_attr( $text ) . '
'; } else { $output = ''; } if ( ! UM()->form()->processing ) { - $output = '
' . $text . '
'; + $output = '
' . esc_attr( $text ) . '
'; } return $output;