PluginProbe
Elementor Website Builder – more than just a page builder / 4.1.0-beta1
Elementor Website Builder – more than just a page builder v4.1.0-beta1
4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 All 456 releases
← All changes | includes/utils.php +13 -0 4.0.9 → 4.1.0-beta1 View file →
@@ -972,5 +972,18 @@
972 972
973 973 public static function encode_string( string $decoded_string ): string {
974 974 return base64_encode( $decoded_string );
975 975 }
976 +
977 + public static function html_to_plain_text( string $html ): string {
978 + if ( empty( $html ) ) {
979 + return '';
980 + }
981 +
982 + $text = preg_replace( '#<br\s*/?\s*>#i', ' ', $html );
983 + $text = preg_replace( '#</?[a-z][^>]*>#i', ' ', $text );
984 + $text = html_entity_decode( $text, ENT_QUOTES, 'UTF-8' );
985 + $text = str_replace( "\xE2\x80\x8B", '', $text );
986 +
987 + return trim( preg_replace( '/\s+/', ' ', $text ) );
988 + }
976 989 }