Skip to content

Commit 62735e4

Browse files
committed
Use wp_is_valid_utf8 if available
1 parent e5c8555 commit 62735e4

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎src/WP_Export_Oxymel.php‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@ public function optional_cdata( $tag_name, $contents ) {
1616
}
1717

1818
public function cdata( $text ) {
19-
if ( is_string( $text ) && ! seems_utf8( $text ) ) {
20-
$text = mb_convert_encoding( $text, 'UTF-8' );
19+
if ( is_string( $text ) ) {
20+
if ( function_exists( 'wp_is_valid_utf8' ) ) {
21+
if ( ! wp_is_valid_utf8( $text ) ) {
22+
$text = mb_convert_encoding( $text, 'UTF-8' );
23+
}
24+
} elseif ( ! seems_utf8( $text ) ) { // phpcs:ignore WordPress.WP.DeprecatedFunctions.seems_utf8Found
25+
$text = mb_convert_encoding( $text, 'UTF-8' );
26+
27+
}
2128
}
2229
return parent::cdata( $text );
2330
}

0 commit comments

Comments
 (0)