array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), 'br' => array(), 'ol' => array(), 'ul' => array(), 'li' => array(), // 'a' => array( // 'href' => array(), // 'title' => array(), // ), 'p' => array(), 'div' => array(), 'b' => array(), 'strong' => array(), 'i' => array(), 'em' => array(), ); // Allow custom tags. $allowed_tags = apply_filters( 'sp_eap_schema_allowed_tags', $allowed_tags ); $string = strip_shortcodes( $string ); $string = wp_kses( $string, $allowed_tags ); // Remove commented codes. $string = preg_replace( '//', '', $string ); $string = preg_replace( '/\s+/', ' ', $string ); $string = trim( $string ); $string = str_replace( '"', "'", $string ); return $string; } } if ( ! function_exists( 'schema_markup' ) ) { /** * Schema_markup * * @param mixed $title title of the accordion. * @param mixed $content accordion content. * @return statement */ function schema_markup( $title = null, $content = null ) { $title = $title ? esc_html( $title ) : '-'; $content = $content ? sp_clean_schema( $content ) : ''; $content = $content ? $content : '-'; $markup = '{ "@type": "Question", "name": "' . $title . '", "acceptedAnswer": { "@type": "Answer", "text": "' . $content . '" } }'; return $markup; } } if ( ! function_exists( 'minify_markup' ) ) { /** * Minify the provided HTML markup by removing unnecessary whitespace. * * @param string $markup The HTML markup to minify. * @return string The minified HTML markup. */ function minify_markup( $markup ) { $markup = preg_replace( array( '/\>[^\S ]+/s', '/[^\S ]+\]+>)\s*/' ), array( '>', '<', ' ', '$1' ), $markup ); return trim( $markup ); } } if ( $eap_schema_markup ) { $unique_id = 'sp-ea-schema-' . $post_id . '-' . uniqid(); $markup = ''; // Output the minified markup, ensuring only one instance is printed. if ( ! isset( $GLOBALS['sp_ea_faq_schema_outputted'] ) ) { echo minify_markup( $markup ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is safe, as $markup is fully escaped in schema_markup(). $GLOBALS['sp_ea_faq_schema_outputted'] = true; } }