tag with specific attributes. $allowed_html = array( 'img' => array( 'src' => array(), 'alt' => array(), 'class' => array(), ), ); // Construct the tag. $img_tag = ''; // Return sanitized HTML. return wp_kses( $img_tag, $allowed_html ); } /** * Convert OpenAI Markdown to HTML. * * @param string $content The OpenAI Markdown content. * @param string $title The title of the content. * * @since 1.0.0 * @package AIContentWriter * @return array The HTML content and title. */ function aicw_convert_openai_markdown_to_html( $content, $title = '' ) { // Replace headers. $content = preg_replace( '/###### (.+)/', '
$1
', $content ); $content = preg_replace( '/##### (.+)/', '
$1
', $content ); $content = preg_replace( '/#### (.+)/', '

$1

', $content ); $content = preg_replace( '/### (.+)/', '

$1

', $content ); $content = preg_replace( '/## (.+)/', '

$1

', $content ); // Replace bold text. $content = preg_replace( '/\*\*(.+?)\*\*/', '$1', $content ); // Extract title if present. preg_match( '/^# (.+)/m', $content, $matches ); $title = $matches[1] ?? $title; // Remove title from content. $content = preg_replace( '/^# .+\n*/', '', $content ); return array( 'title' => $title, 'content' => $content, ); }