<?php
/**
 * Class Custom_Fields_Person
 *
 * @package dvcrs-core
 */

namespace DVCRS\Core;

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

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

/**
 * Custom_Fields_Person Class
 */
class Custom_Fields_Person {

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

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

	}

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

		Container::make( 'post_meta', __( 'Details', 'dvcrs-core' ) )
				->where( 'post_type', '=', 'person' )
				->add_fields(
					[
						Field::make( 'text', 'job_title', __( 'Job Title' ) )
							->set_default_value( 'Independent Travel Advisor' ),
					]
				);

		Container::make( 'post_meta', __( 'Headshot', 'dvcrs-core' ) )
				->where( 'post_type', '=', 'person' )
				->set_context( 'side' )
				->add_fields(
					[
						Field::make( 'image', 'headshot', __( 'Headshot' ) )->set_type( [ 'image' ] ),
					]
				);

	}
}

new Custom_Fields_Person();
