<?php 
namespace Softech_Addons_for_Elementor\Includes\Dynamic_Tags\Tags\Image_Tags;

use Elementor\Core\DynamicTags\Data_Tag;
use Elementor\Modules\DynamicTags\Module;
use Softech_Addons_for_Elementor\Includes\Dynamic_Tags\Groups\Softech_Image_Group;

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

class Softech_Site_Logo extends Data_Tag {

    public function get_name() {
        return 'softech-site-logo';
    }

    public function get_title() {
        return esc_html__( 'Site Logo', 'softech-addons-for-elementor' );
    }

    public function get_group() {
        return Softech_Image_Group::get_name();
    }

    public function get_categories() {
        return [ Module::IMAGE_CATEGORY ];
    }

   public function get_value( array $options = [] ) {
        $custom_logo_id = get_theme_mod( 'custom_logo' );
        
        if ( $custom_logo_id ) {
            $logo_url = wp_get_attachment_image_url( $custom_logo_id, 'full' );
            
            return [
                'id' => $custom_logo_id,
                'url' => $logo_url,
            ];
        }
        
        // Fallback
        $fallback = $this->get_settings( 'fallback' );
        
        if ( ! empty( $fallback['id'] ) ) {
            return [
                'id' => $fallback['id'],
                'url' => $fallback['url'],
            ];
        }
        
        return [
            'id' => '',
            'url' => '',
        ];
    }
}