<?php
/**
 * Class Custom_Fields_Page
 *
 * @package dvcrs
 */

namespace DVCRS\Core;

use \Carbon_Fields\Container;
use \Carbon_Fields\Field;

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

/**
 * Custom_Fields_Page Class
 */
class Custom_Fields_Page {

	/**
	 * Custom_Fields_Page constructor
	 */
	public function __construct() {

		\add_action( 'carbon_fields_register_fields', [ $this, 'register_fields' ] );

	}

	/**
	 * Register custom fields
	 */
	public function register_fields() {

		Container::make( 'post_meta', __( 'Page Hero', 'dvcrs-core' ) )
		         ->where( 'post_type', '=', 'page' )
			     ->set_context( 'side' )
			     ->set_priority( 'high' )
		         ->add_fields(
			         [
				         Field::make( 'text', 'subtitle', __( 'Subtitle', 'dvcrs-core' ) ),
			         ]
		         );



	
		Container::make( 'post_meta', __( 'Content', 'dvcrs-core' ) )
			->where( 'post_type', '=', 'page' )
			->add_fields(
				[
					Field::make( 'html', 'diff_section_title', __( 'The DVCRS Difference', 'dvcrs-core' ) )
							->set_html( sprintf( '<h1>%s</h1>', __( 'The DVCRS Difference', 'dvcrs-core' ) ) ),
					Field::make( 'text', 'diff_title', __( 'Title', 'dvcrs-core' ) ),
					Field::make( 'complex', 'diff_cards', __( 'Cards', 'dvcrs-core' ) )
						->add_fields(
							[
								Field::make( 'image', 'icon', __( 'Icon', 'dvcrs-core' ) ),
								Field::make( 'text', 'title', __( 'Title', 'dvcrs-core' ) ),
								Field::make( 'text', 'text', __( 'Text', 'dvcrs-core' ) ),
								Field::make( 'text', 'url', __( 'Link', 'dvcrs-core' ) )
										->set_attribute( 'type', 'url' ),
							]
						),
					Field::make( 'html', 'test_section_title', __( 'Client Testimonials', 'dvcrs-core' ) )
							->set_html( sprintf( '<h1>%s</h1>', __( 'Client Testimonials', 'dvcrs-core' ) ) ),
					Field::make( 'text', 'test_title', __( 'Title', 'dvcrs-core' ) ),
					Field::make( 'text', 'test_intro', __( 'Intro', 'dvcrs-core' ) ),
					Field::make( 'complex', 'testimonials', __( 'Testimonials', 'dvcrs-core' ) )
						->add_fields(
							[
								Field::make( 'image', 'avatar', __( 'Avatar', 'dvcrs-core' ) ),
								Field::make( 'text', 'quote', __( 'Quote', 'dvcrs-core' ) ),
								Field::make( 'text', 'name', __( 'Name', 'dvcrs-core' ) ),
							]
						),
				]
			);
	}
}

new Custom_Fields_Page();
