<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

use Gigneo\Theme_Option;
use Carbon_Fields\Field\Field;
use Gigneo\Theme_Option\Serialized;

//Tab Main Heading
$gigneo_employer_main_heading = Theme_Option::render_heading_markup(
	gigneo_employer_singular(),
	sprintf(
	// translators: %s is a freelancer singular.
		esc_html__( 'Manage %s options and profile settings.', 'gigneo' ),
		strtolower( gigneo_employer_singular() )
	)
);

$gigneo_employer_fields[] =
	Field::make( 'html', 'gigneo_employer_main_heading' )
		->set_html( $gigneo_employer_main_heading )
		->set_classes( 'gn-ts-main-heading' );

//Basic - Sections
$gigneo_employer_general_heading = Theme_Option::render_heading_markup(
	esc_html__( 'General', 'gigneo' ),
	esc_html__( 'Customize and manage the general core features.', 'gigneo' )
);

$gigneo_employer_general_fields[] =
	Field::make( 'html', 'gigneo_ts_heading_employer_general' )
		->set_html( $gigneo_employer_general_heading )
		->set_classes( 'gn-ts-field-heading' );

$gigneo_employer_general_fields[] = Field::make( 'image', 'gigneo_ts_employer_default_profile_image', esc_html__( 'Default profile image', 'gigneo' ) );

$gigneo_employer_general_fields[] =
	Field::make( 'text', 'gigneo_ts_post_type_employer_singular', esc_html__( 'Singular', 'gigneo' ) )
		->set_default_value( esc_html__( 'Employer', 'gigneo' ) )
		->set_attribute( 'data-regex', '^[A-Z][a-z]*$' );

$gigneo_employer_general_fields[] =
	Field::make( 'text', 'gigneo_ts_post_type_employer_plural', esc_html__( 'Plural', 'gigneo' ) )
		->set_default_value( esc_html__( 'Employers', 'gigneo' ) )
		->set_attribute( 'data-regex', '^[A-Z][a-z]*$' );

$gigneo_employer_general_fields[] =
	Field::make( 'select', 'gigneo_ts_employer_profile_access', esc_html__( 'Profile detail', 'gigneo' ) )
		->set_options(
			apply_filters(
				'gigneo_ts_employer_profile_access',
				array(
					'public'  => esc_html__( 'Public', 'gigneo' ),
					'private' => esc_html__( 'Private', 'gigneo' ),
				)
			)
		)
		->set_classes( 'gn-select2' )
		->set_default_value( 'public' )
		->set_help_text( esc_html__( 'Allow or restrict access to employer profile details.', 'gigneo' ) );

//Social Profiles
if ( in_array( 'social_profiles', gigneo_active_modules(), true ) ) {

	$gigneo_employer_general_fields[] =
		Field::make( 'multiselect', 'gigneo_ts_employer_social_profiles', esc_html__( 'Social profiles', 'gigneo' ) )
			->set_datastore( new Serialized() )
			->set_options( gigneo_social_profiles() )
			->set_default_value( array( 'facebook', 'twitter', 'instagram', 'linkedin' ) );
}

$gigneo_employer_general_fields = apply_filters( 'gigneo_ts_tab_employer_section_general_fields', $gigneo_employer_general_fields );
$gigneo_employer_fields         = array_merge( $gigneo_employer_fields, $gigneo_employer_general_fields );

//Archive - Sections
$gigneo_employer_archive_heading = Theme_Option::render_heading_markup(
	esc_html__( 'Archive', 'gigneo' ),
	esc_html__( 'Customize and manage archive display and functionality.', 'gigneo' )
);

$gigneo_employer_archive_fields[] =
	Field::make( 'html', 'gigneo_ts_separator_employer_archive' )
		->set_html( '<hr>' )
		->set_classes( 'gn-separator' );

$gigneo_employer_archive_fields[] =
	Field::make( 'html', 'gigneo_ts_heading_employer_archive' )
		->set_html( $gigneo_employer_archive_heading )
		->set_classes( 'gn-ts-field-heading' );

$gigneo_employer_archive_fields[] =
	Field::make( 'select', 'gigneo_ts_employer_archive_layout', esc_html__( 'Layout', 'gigneo' ) )
		->set_options(
			apply_filters(
				'gigneo_ts_employer_archive_layout_options',
				array(
					'1' => esc_html__( 'Style 1', 'gigneo' ),
					'2' => esc_html__( 'Style 2', 'gigneo' ),
				)
			)
		)
		->set_classes( 'gn-select2' )
		->set_default_value( '1' );

$gigneo_employer_archive_visibility_conditions = array(
	'profile_image' => esc_html__( 'Profile image', 'gigneo' ),
);

if ( in_array( 'email_verification', gigneo_active_modules(), true ) ) {
	$gigneo_employer_archive_visibility_conditions['email_verified'] = esc_html__( 'Email verified', 'gigneo' );
}

$gigneo_employer_archive_visibility_conditions = apply_filters( 'gigneo_employer_archive_visibility_conditions', $gigneo_employer_archive_visibility_conditions );

$gigneo_employer_archive_fields[] =
	Field::make( 'multiselect', 'gigneo_ts_employer_visibility_conditions', esc_html__( 'Visibility conditions', 'gigneo' ) )
		->set_datastore( new Serialized() )
		->set_options( $gigneo_employer_archive_visibility_conditions )
		->set_default_value( array( 'profile_image' ) )
		->set_help_text( esc_html__( 'Set visibility conditions to show on listing page.', 'gigneo' ) );

$gigneo_employer_archive_fields[] =
	Field::make( 'text', 'gigneo_ts_jobs_published', esc_html__( 'Published jobs', 'gigneo' ) )
		->set_attribute( 'type', 'number' )
		->set_attribute( 'data-regex', '^[0-9]+$' )
		->set_default_value( 1 )
		->set_help_text( esc_html__( 'Set minimum published jobs to show on listing page.', 'gigneo' ) )
		->set_conditional_logic(
			array(
				array(
					'field'   => 'gigneo_ts_employer_visibility_conditions',
					'value'   => 'publish_jobs',
					'compare' => 'INCLUDES',
				),
			)
		);

$gigneo_employer_archive_fields[] =
	Field::make( 'text', 'gigneo_ts_employers_per_page', esc_html__( 'Show per page', 'gigneo' ) )
		->set_attribute( 'type', 'number' )
		->set_attribute( 'data-regex', '^[0-9]+$' )
		->set_default_value( 9 );


$gigneo_employer_archive_fields = apply_filters( 'gigneo_ts_tab_employer_section_archive_fields', $gigneo_employer_archive_fields );
$gigneo_employer_fields         = array_merge( $gigneo_employer_fields, $gigneo_employer_archive_fields );
