| Server IP : 121.121.20.254 / Your IP : 216.73.216.202 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/KnowledgeBase/wp-content/plugins/wp-seopress-pro/src/JsonSchemas/ |
Upload File : |
<?php
namespace SEOPressPro\JsonSchemas;
if ( ! defined('ABSPATH')) {
exit;
}
use SEOPress\Helpers\RichSnippetType;
use SEOPress\Models\GetJsonData;
use SEOPressPro\Models\JsonSchemaValue;
class Faq extends JsonSchemaValue implements GetJsonData {
const NAME = 'faq';
protected function getName() {
return self::NAME;
}
/**
* @since 4.6.0
*
* @param array $context
*
* @return array
*/
public function getJsonData($context = null) {
$data = $this->getArrayJson();
$typeSchema = isset($context['type']) ? $context['type'] : RichSnippetType::MANUAL;
$questions = [];
switch ($typeSchema) {
case RichSnippetType::MANUAL:
$schemaManual = $this->getCurrentSchemaManual($context);
if (null === $schemaManual) {
return $data;
}
if (isset($schemaManual['_seopress_pro_rich_snippets_faq'])) {
$questions = $schemaManual['_seopress_pro_rich_snippets_faq'];
}
break;
}
if ( ! empty($questions)) {
foreach ($questions as $key => $question) {
$variables = [
'name' => $question['question'],
'text' => $question['answer'],
'answerCount' => 1,
];
$schema = seopress_get_service('JsonSchemaGenerator')->getJsonFromSchema(MainEntity::NAME, ['variables' => $variables], ['remove_empty'=> true]);
if (count($schema) > 1 && isset($schema['name']) && ! empty($schema['name'])) {
$data['mainEntity'][] = $schema;
}
}
}
return apply_filters('seopress_pro_get_json_data_faq', $data, $context);
}
}