Files
medicalalert-web-reloaded/wp/wp-content/plugins/wp-schema-pro/classes/schema/class-bsf-aiosrs-pro-schema-faq.php
Tony Volpe b721d2fd4a Merged in feature/102-dev-dev01 (pull request #6)
auto-patch  102-dev-dev01-2023-12-11T19_15_32

* auto-patch  102-dev-dev01-2023-12-11T19_15_32
2023-12-11 19:17:10 +00:00

48 lines
1.3 KiB
PHP

<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.0.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_FAQ' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.0.0
*/
class BSF_AIOSRS_Pro_Schema_FAQ {
/**
* Render Schema.
*
* @param array $data Meta Data.
* @param array $post Current Post Array.
* @return array
*/
public static function render( $data, $post ) {
global $post;
$schema = array();
if ( isset( $data['question-answer'][0]['question'] ) && ! empty( $data['question-answer'][0]['question'] ) ) {
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'FAQPage';
foreach ( $data['question-answer'] as $key => $value ) {
if ( isset( $value['question'] ) && ! empty( $value['question'] ) ) {
$schema['mainEntity'][ $key ]['@type'] = 'Question';
$schema['mainEntity'][ $key ]['name'] = $value['question'];
}
if ( isset( $value['answer'] ) && ! empty( $value['answer'] ) ) {
$schema['mainEntity'][ $key ]['acceptedAnswer']['@type'] = 'Answer';
$schema['mainEntity'][ $key ]['acceptedAnswer']['text'] = $value['answer'];
}
}
}
return apply_filters( 'wp_schema_pro_schema_faq', $schema, $data, $post );
}
}
}