Skip to content

Commit 61ecec1

Browse files
authored
Merge b4100fe into 40da397
2 parents 40da397 + b4100fe commit 61ecec1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

classes/models/FrmEntryValidate.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ private static function option_is_valid( $field, $value, $options ) {
265265
break;
266266
}
267267

268+
$match = self::is_filtered_match( $current_value, $option_value );
269+
if ( $match ) {
270+
break;
271+
}
272+
268273
if ( is_numeric( $current_value ) ) {
269274
$match = (int) $current_value === (int) $option_value;
270275
if ( $match ) {
@@ -281,6 +286,30 @@ private static function option_is_valid( $field, $value, $options ) {
281286
return true;
282287
}
283288

289+
/**
290+
* Make an extra check after passing $option_value through the_content filter.
291+
* This is to help catch cases where the option's formatting has been modified using
292+
* the_content filter.
293+
*
294+
* @since x.x
295+
*
296+
* @param string $value
297+
* @param string $option_value
298+
* @return bool
299+
*/
300+
private static function is_filtered_match( $value, $option_value ) {
301+
// First remove the wpautop filter so it doesn't add extra tags to $option_value.
302+
$filter_priority = has_filter( 'the_content', 'wpautop' );
303+
if ( is_numeric( $filter_priority ) ) {
304+
remove_filter( 'the_content', 'wpautop', $filter_priority );
305+
}
306+
$filtered_option = apply_filters( 'the_content', $option_value );
307+
if ( is_numeric( $filter_priority ) ) {
308+
add_filter( 'the_content', 'wpautop', $filter_priority );
309+
}
310+
return $value === trim( $filtered_option );
311+
}
312+
284313
/**
285314
* Do not validate options if they have been modified with a hook.
286315
* This is to help avoid issues where the options could be based on a URL param for example.

0 commit comments

Comments
 (0)