<?php
/**
 * End-content Theme 1 - List.
 *
 * @package Relatedly\Theming\EndContent
 * @since   2.0.0
 */

namespace Relatedly\Theming\EndContent;

use Relatedly\Theming\AbstractTheme;
defined( 'ABSPATH' ) || exit;

/**
 * Renders the list end-content theme.
 *
 * @since 2.0.0
 */
class Theme1List extends AbstractTheme {
	/**
	 * Template file name.
	 *
	 * @var string
	 */
	protected string $template_file = 'end-content/list.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(
			[
				'--relatedly-bg'            => 'end_theme1_bg',
				'--relatedly-border'        => 'end_theme1_border_color',
				'--relatedly-title-color'   => 'end_theme1_title_color',
				'--relatedly-title-size'    => 'end_theme1_title_size',
				'--relatedly-title-weight'  => 'end_theme1_title_weight',
				'--relatedly-label-color'   => 'end_theme1_label_color',
				'--relatedly-label-size'    => 'end_theme1_label_size',
				'--relatedly-label-weight'  => 'end_theme1_label_weight',
				'--relatedly-excerpt-color' => 'end_theme1_excerpt_color',
				'--relatedly-excerpt-size'  => 'end_theme1_excerpt_size',
			]
		);
		$vars['show_excerpt'] = (bool) $this->options->get( 'end_theme1_show_excerpt', true );
		return $vars;
	}
}
