<?php
/**
 * Template Tags
 *
 * Procedural wrappers for use in templates.
 *
 * @package Kutby
 * @since   1.0.0
 */

declare(strict_types=1);

namespace Kutby\TemplateTags;

use Kutby\Helpers\Utils;
use Kutby\ThemeOptions\Manager;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class Tags
 */
final class Tags {

	/**
	 * Print site logo (desktop/mobile aware foundation).
	 *
	 * @return void
	 */
	public static function logo(): void {
		$desktop = (int) Manager::get( 'general.logo_desktop', 0 );
		$mobile  = (int) Manager::get( 'general.logo_mobile', 0 );

		if ( $desktop ) {
			echo wp_get_attachment_image( $desktop, 'medium', false, array( 'class' => 'kutby-logo kutby-logo--desktop' ) );
		} elseif ( has_custom_logo() ) {
			the_custom_logo();
		} else {
			printf(
				'<a class="kutby-logo-text" href="%1$s">%2$s</a>',
				esc_url( home_url( '/' ) ),
				esc_html( get_bloginfo( 'name' ) )
			);
		}

		if ( $mobile && $mobile !== $desktop ) {
			echo wp_get_attachment_image( $mobile, 'full', false, array( 'class' => 'kutby-logo kutby-logo--mobile' ) );
		}
	}

	/**
	 * Whether a homepage section should render.
	 *
	 * @param string $section Section key.
	 * @return bool
	 */
	public static function show_section( string $section ): bool {
		return Utils::section_enabled( $section );
	}
}
