base_url = $base_url; $renderer = new WP_Experimental_HTML_Renderer( $html, $options ); $markdown = (string) $renderer->to_markdown(); } catch ( \Throwable $e ) { $markdown = ''; } if ( '' === trim( $markdown ) ) { return trim( wp_strip_all_tags( $html, true ) ); } return trim( $markdown ); } /** * Decodes HTML entities in a plain-text string. * * @since 1.4.0 * * @param string $text Text that may contain HTML entities. * @return string Text with the entities decoded to their characters. */ public function decode_entities( string $text ): string { return html_entity_decode( $text, ENT_QUOTES | ENT_HTML5, get_bloginfo( 'charset' ) ); } }