<?php
/**
 * End-Content Theme 4 — Carousel.
 *
 * @package     Relatedly\Theming\EndContent
 * @since       2.0.0
 * @fs_premium_only
 */

namespace Relatedly\Theming\EndContent;

use Relatedly\Theming\AbstractTheme;

defined( 'ABSPATH' ) || exit;

/**
 * Renders the premium carousel end-content theme.
 *
 * @since 2.0.0
 */
class Theme4Carousel extends AbstractTheme {
	/**
	 * Template file name.
	 *
	 * @var string
	 */
	protected string $template_file = 'end-content/carousel.php';

	/**
	 * Get the tracking display type.
	 *
	 * @return string
	 */
	protected function display_type(): string {
		return 'end_content'; }

	/**
	 * Get the end-content label.
	 *
	 * @return string
	 */
	protected function get_label(): string {
		return $this->labels->random_end_content(); }

	/**
	 * Build template variables.
	 *
	 * @param \WP_Post $post      Post object.
	 * @param int|null $source_id Source post ID.
	 * @return array<string,mixed>
	 */
	protected function template_vars( \WP_Post $post, ?int $source_id ): array {
		$vars                   = parent::template_vars( $post, $source_id );
		$vars['css_vars']       = $this->css_vars(
			array(
				'--relatedly-bg'            => 'end_theme4_bg',
				'--relatedly-border'        => 'end_theme4_border_color',
				'--relatedly-title-color'   => 'end_theme4_title_color',
				'--relatedly-title-size'    => 'end_theme4_title_size',
				'--relatedly-label-color'   => 'end_theme4_label_color',
				'--relatedly-label-size'    => 'end_theme4_label_size',
				'--relatedly-excerpt-color' => 'end_theme4_excerpt_color',
				'--relatedly-excerpt-size'  => 'end_theme4_excerpt_size',
			)
		);
		$vars['show_excerpt']   = (bool) $this->options->get( 'end_theme4_show_excerpt', true );
		$vars['thumbnail_size'] = (string) $this->options->get( 'end_theme4_thumbnail_size', 'medium' );
		return $vars;
	}
}
