<?php

namespace ThemeAtelier\DomainForSale\Admin\Views;

use ThemeAtelier\DomainForSale\Admin\Framework\Classes\DOMAIN_FOR_SALE;
use ThemeAtelier\DomainForSale\Admin\Views\Metabox\DomainDisplayOption;
use ThemeAtelier\DomainForSale\Admin\Views\Metabox\FilterDomain;
use ThemeAtelier\DomainForSale\Admin\Views\Metabox\ListingLayout;

if (!defined('ABSPATH')) {
	die;
} // Cannot access directly.

class ListingMetabox
{
	/**
	 * Layout Metabox function.
	 *
	 * @param string $prefix The meta-key for this metabox.
	 * @return void
	 */
	public static function layout_metabox($prefix)
	{
		/**
		 * Preview metabox.
		 *
		 * @param string $prefix The metabox main Key.
		 * @return void
		 */
		DOMAIN_FOR_SALE::createMetabox(
			'listing_live_preview',
			array(
				'title'             => __('Live Preview', 'domain-for-sale'),
				'post_type'         => 'domain_listing',
				'show_restore'      => false,
				'sp_tpro_shortcode' => false,
				'context'           => 'normal',
			)
		);
		DOMAIN_FOR_SALE::createSection(
			'listing_live_preview',
			array(
				'fields' => array(
					array(
						'type' => 'preview',
					),
				),
			)
		);

		DOMAIN_FOR_SALE::createMetabox(
			$prefix,
			array(
				'title'        => esc_html__('Domain For Sale', 'domain-for-sale'),
				'post_type'    => 'domain_listing',
				'show_restore' => false,
				'context'      => 'normal',
			)
		);
		ListingLayout::section($prefix);
	}

	/**
	 * Option Metabox function
	 *
	 * @param string $prefix The metabox key.
	 * @return void
	 */
	public static function option_metabox($prefix)
	{
		DOMAIN_FOR_SALE::createMetabox(
			$prefix,
			array(
				'title'        	=> esc_html__('View Options', 'domain-for-sale'),
				'post_type'    	=> 'domain_listing',
				'show_restore' 	=> false,
				'nav'        	=> 'inline',
				'theme'        	=> 'light',
				'context'      => 'normal',
			)
		);

		FilterDomain::options($prefix);
		DomainDisplayOption::options($prefix);
	}

	/**
	 * Shortcode Metabox function
	 *
	 * @param string $prefix The metabox key.
	 * @return void
	 */
	public static function shortcode_metabox($prefix)
	{
		DOMAIN_FOR_SALE::createMetabox(
			$prefix,
			array(
				'title'        => esc_html__('Domain For Sale', 'domain-for-sale'),
				'post_type'    => 'domain_listing',
				'context'      => 'side',
				'show_restore' => false,
			)
		);

		DOMAIN_FOR_SALE::createSection(
			$prefix,
			array(
				'fields' => array(
					array(
						'type'  => 'listing_shortcode',
						'class' => 'domain-for-sale-pro-admin-sidebar',
					),
				),
			)
		);
	}
}
