<?php

namespace Hecate\Components\Logo;

use Hecate\Components\ComponentBase;



class LogoComponent extends ComponentBase {

	public static $type         = 'logo';
	protected static $rootClass = 'hecate-logo';
	protected static $template  = 'components/logo';



    public function getSections() {
        return array(
            array(
                'id'              => $this->getSectionId(),
                'title'           => __( 'Logo', 'hecate' ),
                'hiddenSection'   => true,
                'panel'           => $this->getCurrentPanel(),
                'type'            => 'hecate-tab-section',
                'priority'        => 1,
            ),
        );
    }

	public function logoIsImage() {
		return ! $this->logoIsText();
	}

	public function renderTextLogo() {

		echo sprintf(
			'<a class="hecate-text-logo" data-type="group" data-dynamic-mod="true" href="%1$s">%2$s</a>',
			esc_attr( $this->getHomeurl() ),
			esc_html( get_bloginfo( 'name' ) )
		);

	}

	public function renderLogo() {
		if ( $this->logoIsImage() ) {
            // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
			echo get_custom_logo();
		}
		if ( $this->logoIsText() ) {
			$this->renderTextLogo();
		}

	}

	public function getHomeUrl() {
		return esc_url( home_url( '/' ) );
	}

	public function logoIsText() {
		return ! has_custom_logo();
	}

	public function getLogoTitle() {
		return get_bloginfo( 'name' );
	}

}

