<?php
/**
 * End-Content Theme 5 — Timeline.
 *
 * @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 timeline end-content theme.
 *
 * @since 2.0.0
 */
class Theme5Timeline extends AbstractTheme {
	/**
	 * Template file name.
	 *
	 * @var string
	 */
	protected string $template_file = 'end-content/timeline.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_theme5_bg',
				'--relatedly-line-color'    => 'end_theme5_line_color',
				'--relatedly-title-color'   => 'end_theme5_title_color',
				'--relatedly-title-size'    => 'end_theme5_title_size',
				'--relatedly-label-color'   => 'end_theme5_label_color',
				'--relatedly-label-size'    => 'end_theme5_label_size',
				'--relatedly-date-color'    => 'end_theme5_date_color',
				'--relatedly-excerpt-color' => 'end_theme5_excerpt_color',
				'--relatedly-excerpt-size'  => 'end_theme5_excerpt_size',
			)
		);
		$vars['show_excerpt'] = (bool) $this->options->get( 'end_theme5_show_excerpt', true );
		$vars['date_type']    = (string) $this->options->get( 'end_theme5_date_type', 'modified' );
		return $vars;
	}
}
