<?php
// Select docs page
$args = array(
	'post_type' => 'topic',
	'posts_per_page' => 1,
	'orderby' => 'menu_order',
	'order' => 'desc'
);

$topic_permalink = '';
foreach (get_posts($args) as $post) {
	$topic_permalink = get_permalink($post->ID);
}

$forum_url = admin_url('customize.php?url=') . site_url('/') . get_option('_bbp_root_slug') . '?autofocus[panel]=forumax-settings&autofocus[section]=forum-archive-page';
$topic_url = admin_url('customize.php?url=') . $topic_permalink . '?autofocus[panel]=forumax-settings&autofocus[section]=topics_fields';

// Create a section.
CSF::createSection(
	$prefix,
	[
		'title' => __('General', 'forumax'),
		'icon' => 'dashicons dashicons-admin-generic',
		'fields' => [
			[
				'id' => 'bbpc_brand_color',
				'type' => 'color',
				'title' => esc_html__('Frontend Brand Color', 'forumax'),
				'subtitle' => esc_html__('Choose a primary color to style the frontend appearance of your forum.', 'forumax'),
				'output' => ':root',
				'output_mode' => '--bbpc_brand_color_opt',
			],

			[
				'id' => 'sidebar_position',
				'type' => 'button_set',
				'title' => esc_html__('Sidebar Position', 'forumax'),
				'subtitle' => esc_html__('Set the default position for the forum sidebar on topic and archive pages.', 'forumax'),
				'options' => [
					'left' => esc_html__('Left', 'forumax'),
					'right' => esc_html__('Right', 'forumax'),
				],
				'default' => 'left',
			],

			[
				'id' => 'customizer_visibility',
				'type' => 'switcher',
				'title' => esc_html__('Options Visibility on Customizer', 'forumax'),
				'subtitle' => esc_html__('Enable this to configure and preview forum styling options inside the WordPress Customizer.', 'forumax'),
				'text_on' => esc_html__('Enabled', 'forumax'),
				'text_off' => esc_html__('Disabled', 'forumax'),
				'text_width' => 100
			],

			[
				'type' => 'content',
				'title' => esc_html__('Customizer Options', 'forumax'),
				'subtitle' => esc_html__('Access the real-time customizer to configure specific layout and styling options for your forum.', 'forumax'),
				'content' => '<a href="' . esc_url($forum_url) . '" target="_blank" id="bbpc_forum_option_link">' . esc_html__('Forum', 'forumax')
					. '</a> ' . '<a href="' . esc_url($topic_url) . '" target="_blank" id="bbpc_topic_option_link">' . esc_html__(
					'Topic',
					'forumax'
				) . '</a>',
				'dependency' => [
					['customizer_visibility', '==', true],
				],
			]
		]
	]
);
