@@ -265,6 +265,11 @@ private static function option_is_valid( $field, $value, $options ) {
265
265
break ;
266
266
}
267
267
268
+ $ match = self ::is_filtered_match ( $ current_value , $ option_value );
269
+ if ( $ match ) {
270
+ break ;
271
+ }
272
+
268
273
if ( is_numeric ( $ current_value ) ) {
269
274
$ match = (int ) $ current_value === (int ) $ option_value ;
270
275
if ( $ match ) {
@@ -281,6 +286,30 @@ private static function option_is_valid( $field, $value, $options ) {
281
286
return true ;
282
287
}
283
288
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
+
284
313
/**
285
314
* Do not validate options if they have been modified with a hook.
286
315
* This is to help avoid issues where the options could be based on a URL param for example.
0 commit comments