<?php
/**
 * FAQ Schema Type
 *
 * @package SEOvaultSEO\Schema\Types
 */

namespace SEOvaultSEO\Schema\Types;

use SEOvaultSEO\Schema\SchemaBase;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class FAQ extends SchemaBase {

	public function schema_data() {
		return array(
			'title'   => 'FAQ',
			'type'    => 'FAQPage',
			'show_on' => array(
				'rules'        => array( 'post|post' ),
				'specific'     => array(),
				'specificText' => array(),
			),
			'fields'  => $this->parse_fields( $this->get() ),
		);
	}

	public function get() {
		return apply_filters(
			'seovaultseo_schema_type_faq',
			array(
				array(
					'id'      => 'schema_name',
					'label'   => __( 'Schema Title', 'seovault-ai' ),
					'show'    => true,
					'default' => true,
					'type'    => 'Title',
					'std'     => 'FAQ',
				),
				array(
					'id'       => '@id',
					'type'     => 'Hidden',
					'std'      => '%current.url%#faq',
					'required' => true,
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'       => 'name',
					'label'    => __( 'Page Name', 'seovault-ai' ),
					'required' => true,
					'std'      => '%post.title%',
					'type'     => 'Text',
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'      => 'mainEntity',
					'label'   => __( 'FAQ Entries', 'seovault-ai' ),
					'type'    => 'Group',
					'default' => true,
					'show'    => true,
					'fields'  => array(
						array(
							'id'      => '@type',
							'type'    => 'Hidden',
							'std'     => 'Question',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'name',
							'label'   => __( 'Question', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Text',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'acceptedAnswer',
							'label'   => __( 'Answer', 'seovault-ai' ),
							'type'    => 'Group',
							'default' => true,
							'show'    => true,
							'fields'  => array(
								array(
									'id'      => '@type',
									'type'    => 'Hidden',
									'std'     => 'Answer',
									'default' => true,
									'show'    => true,
								),
								array(
									'id'      => 'text',
									'label'   => __( 'Answer Text', 'seovault-ai' ),
									'std'     => '',
									'type'    => 'Text',
									'default' => true,
									'show'    => true,
								),
							),
						),
					),
				),
			)
		);
	}
}
